Kea
1.9.9-git
|
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... | |
MessageDictionary * | getDictionary () 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... | |
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.
typedef 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().
|
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 71 of file message_reader.cc.
References isc::util::str::trim().
|
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 35 of file message_reader.cc.
References isc_throw_4, isc::log::LOG_INPUT_OPEN_FAIL, and isc::log::LOG_READ_ERROR.
Referenced by main().
|
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.