Kea  2.1.7-git
isc::log::MessageReader Class Reference

Read Message File. More...

#include <message_reader.h>

Public Types

typedef std::vector< std::string > MessageIDCollection
 Visible collection types. More...
enum  Mode { ADD, REPLACE }
 Read Mode. More...

Public Member Functions

 MessageReader (MessageDictionary *dictionary=NULL)
 Constructor. More...
virtual ~MessageReader ()
 Virtual Destructor. More...
virtual void clearNamespace ()
 Clear Namespace. More...
virtual void clearPrefix ()
 Clear Prefix. More...
MessageDictionarygetDictionary () const
 Get Dictionary. More...
virtual std::string getNamespace () const
 Get Namespace. More...
MessageIDCollection getNotAdded () const
 Get Not-Added List. More...
virtual std::string getPrefix () const
 Get Prefix. More...
virtual void processLine (const std::string &line, Mode mode=ADD)
 Process Line. More...
virtual void readFile (const std::string &file, Mode mode=ADD)
 Read File. More...
void setDictionary (MessageDictionary *dictionary)
 Set Dictionary. More...

Detailed Description

Read Message File.

Reads a message file and creates a map of identifier against the text of the message. This map can be retrieved for subsequent processing.

Definition at line 25 of file message_reader.h.

Member Typedef Documentation

◆ MessageIDCollection

typedef std::vector<std::string> isc::log::MessageReader::MessageIDCollection

Visible collection types.

Definition at line 42 of file message_reader.h.

Member Enumeration Documentation

◆ Mode

Read Mode.

If ADD, messages are added to the dictionary if the ID does not exist there. If it does, the ID is added to the dictionary's overflow vector.

If REPLACE, the dictionary is only modified if the message ID already exists in it. New message IDs are added to the overflow vector.


Definition at line 36 of file message_reader.h.

Constructor & Destructor Documentation

◆ MessageReader()

isc::log::MessageReader::MessageReader ( MessageDictionary dictionary = NULL)


Default constructor. All work is done in the main readFile code (so that a status return can be returned instead of needing to throw an exception).

dictionaryDictionary to which messages read read from the file are added. (This should be a local dictionary when the class is used in the message compiler, and the global dictionary when used in a server. The ownership of the dictionary object is not transferred - the caller is responsible for managing the lifetime of the dictionary.

Definition at line 55 of file message_reader.h.

◆ ~MessageReader()

virtual isc::log::MessageReader::~MessageReader ( )

Virtual Destructor.

Definition at line 60 of file message_reader.h.

Member Function Documentation

◆ clearNamespace()

virtual void isc::log::MessageReader::clearNamespace ( )

Clear Namespace.

Clears the current namespace.

Definition at line 118 of file message_reader.h.

◆ clearPrefix()

virtual void isc::log::MessageReader::clearPrefix ( )

Clear Prefix.

Clears the current prefix.

Definition at line 134 of file message_reader.h.

◆ getDictionary()

MessageDictionary* isc::log::MessageReader::getDictionary ( ) const

Get Dictionary.

Returns the pointer to the dictionary object. Note that ownership is not transferred - the caller should not delete it.

Pointer to current dictionary object

Definition at line 69 of file message_reader.h.

◆ getNamespace()

virtual std::string isc::log::MessageReader::getNamespace ( ) const

Get Namespace.

Argument to the $NAMESPACE directive (if present)

Definition at line 110 of file message_reader.h.

Referenced by main().

◆ getNotAdded()

MessageIDCollection isc::log::MessageReader::getNotAdded ( ) const

Get Not-Added List.

Returns the list of IDs that were not added during the last read of the file.

Collection of messages not added

Definition at line 145 of file message_reader.h.

References isc::util::str::tokens().

Referenced by errorDuplicates().

+ Here is the call graph for this function:

◆ getPrefix()

virtual std::string isc::log::MessageReader::getPrefix ( ) const

Get Prefix.

Argument to the $PREFIX directive (if present)

Definition at line 126 of file message_reader.h.

◆ processLine()

void isc::log::MessageReader::processLine ( const std::string &  line,
MessageReader::Mode  mode = ADD 

Process Line.

Parses a text line and adds it to the message map. Although this is for use in readFile, it can also be used to add individual messages to the message map.

lineLine of text to process
modeIf a message line, how to add the message to the dictionary.

Definition at line 71 of file

References isc_throw_2, isc_throw_3, isc_throw_assert, isc::log::LOG_DUPLICATE_NAMESPACE, isc::log::LOG_INVALID_MESSAGE_ID, isc::log::LOG_NAMESPACE_EXTRA_ARGS, isc::log::LOG_NAMESPACE_INVALID_ARG, isc::log::LOG_NAMESPACE_NO_ARGS, isc::log::LOG_NO_MESSAGE_ID, isc::log::LOG_NO_MESSAGE_TEXT, isc::log::LOG_PREFIX_EXTRA_ARGS, isc::log::LOG_PREFIX_INVALID_ARG, isc::log::LOG_UNRECOGNIZED_DIRECTIVE, isc::util::str::tokens(), isc::util::str::trim(), and isc::util::str::uppercase().

Referenced by setDictionary().

+ Here is the call graph for this function:

◆ readFile()

void isc::log::MessageReader::readFile ( const std::string &  file,
MessageReader::Mode  mode = ADD 

Read File.

This is the main method of the class and reads in the file, parses it, and stores the result in the message dictionary.

fileName of the message file.
modeAddition mode. See the description of the "Mode" enum.

Definition at line 35 of file

References isc_throw_4, isc::log::LOG_INPUT_OPEN_FAIL, and isc::log::LOG_READ_ERROR.

Referenced by main(), and setDictionary().

◆ setDictionary()

void isc::log::MessageReader::setDictionary ( MessageDictionary dictionary)

Set Dictionary.

Sets the current dictionary object.

dictionaryNew dictionary object. The ownership of the dictionary object is not transferred - the caller is responsible for managing the lifetime of the dictionary.

Definition at line 81 of file message_reader.h.

References ADD, processLine(), and readFile().

+ Here is the call graph for this function:

The documentation for this class was generated from the following files: