Kea 2.7.6
isc::log::MessageReader Class Reference

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.
 
MessageDictionarygetDictionary () 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.
 

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

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.

Enumerator
ADD 
REPLACE 

Definition at line 36 of file message_reader.h.

Constructor & Destructor Documentation

◆ MessageReader()

isc::log::MessageReader::MessageReader ( MessageDictionary * dictionary = NULL)
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).

Parameters
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 ( )
inlinevirtual

Virtual Destructor.

Definition at line 60 of file message_reader.h.

Member Function Documentation

◆ clearNamespace()

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

Clear Namespace.

Clears the current namespace.

Definition at line 118 of file message_reader.h.

◆ clearPrefix()

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

Clear Prefix.

Clears the current prefix.

Definition at line 134 of file message_reader.h.

◆ getDictionary()

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

Get Dictionary.

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

Returns
Pointer to current dictionary object

Definition at line 69 of file message_reader.h.

◆ getNamespace()

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

Get Namespace.

Returns
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
inline

Get Not-Added List.

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

Returns
Collection of messages not added

Definition at line 145 of file message_reader.h.

Referenced by errorDuplicates(), and isc::log::LoggerManager::readLocalMessageFile().

◆ getPrefix()

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

Get Prefix.

Returns
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 )
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.

Parameters
lineLine of text to process
modeIf 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().

+ Here is the call graph for this function:

◆ readFile()

void isc::log::MessageReader::readFile ( const std::string & file,
MessageReader::Mode mode = ADD )
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.

Parameters
fileName of the message file.
modeAddition 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().

+ Here is the call graph for this function:

◆ setDictionary()

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

Set Dictionary.

Sets the current dictionary object.

Parameters
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.


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