Kea 2.7.6
|
Read Message File. More...
#include <message_reader.h>
Public Types | |
typedef std::vector< std::string > | MessageIDCollection |
Visible collection types. | |
enum | Mode { ADD , REPLACE } |
Read Mode. More... | |
Public Member Functions | |
MessageReader (MessageDictionary *dictionary=NULL) | |
Constructor. | |
virtual | ~MessageReader () |
Virtual Destructor. | |
virtual void | clearNamespace () |
Clear Namespace. | |
virtual void | clearPrefix () |
Clear Prefix. | |
MessageDictionary * | getDictionary () const |
Get Dictionary. | |
virtual std::string | getNamespace () const |
Get Namespace. | |
MessageIDCollection | getNotAdded () const |
Get Not-Added List. | |
virtual std::string | getPrefix () const |
Get Prefix. | |
virtual void | processLine (const std::string &line, Mode mode=ADD) |
Process Line. | |
virtual void | readFile (const std::string &file, Mode mode=ADD) |
Read File. | |
void | setDictionary (MessageDictionary *dictionary) |
Set Dictionary. | |
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.
std::vector<std::string> isc::log::MessageReader::MessageIDCollection |
Visible collection types.
Definition at line 42 of file message_reader.h.
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.
Enumerator | |
---|---|
ADD | |
REPLACE |
Definition at line 36 of file message_reader.h.
|
inline |
Constructor.
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).
dictionary | Dictionary 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.
|
inlinevirtual |
Virtual Destructor.
Definition at line 60 of file message_reader.h.
|
inlinevirtual |
|
inlinevirtual |
|
inline |
Get Dictionary.
Returns the pointer to the dictionary object. Note that ownership is not transferred - the caller should not delete it.
Definition at line 69 of file message_reader.h.
|
inlinevirtual |
Get Namespace.
Definition at line 110 of file message_reader.h.
Referenced by main().
|
inline |
Get Not-Added List.
Returns the list of IDs that were not added during the last read of the file.
Definition at line 145 of file message_reader.h.
Referenced by errorDuplicates(), and isc::log::LoggerManager::readLocalMessageFile().
|
inlinevirtual |
Get Prefix.
Definition at line 126 of file message_reader.h.
|
virtual |
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.
line | Line of text to process |
mode | If a message line, how to add the message to the dictionary. |
Definition at line 72 of file message_reader.cc.
References isc::util::str::trim().
Referenced by readFile().
|
virtual |
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.
file | Name of the message file. |
mode | Addition mode. See the description of the "Mode" enum. |
Definition at line 36 of file message_reader.cc.
References isc_throw_4, isc::log::LOG_INPUT_OPEN_FAIL, isc::log::LOG_READ_ERROR, and processLine().
Referenced by main(), and isc::log::LoggerManager::readLocalMessageFile().
|
inline |
Set Dictionary.
Sets the current dictionary object.
dictionary | New 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.