Kea 2.7.6
|
Message Dictionary. More...
#include <message_dictionary.h>
Public Types | |
typedef Dictionary::const_iterator | const_iterator |
typedef std::map< std::string, std::string > | Dictionary |
Public Member Functions | |
MessageDictionary () | |
Constructor. | |
virtual | ~MessageDictionary () |
Virtual Destructor. | |
virtual bool | add (const MessageID &ident, const std::string &text) |
Add Message. | |
virtual bool | add (const std::string &ident, const std::string &text) |
Add Message. | |
const_iterator | begin () const |
Return begin() iterator of internal map. | |
const_iterator | end () const |
Return end() iterator of internal map. | |
virtual bool | erase (const std::string &ident, const std::string &text) |
Removes the specified message from the dictionary. | |
virtual const std::string & | getText (const MessageID &ident) const |
Get Message Text. | |
virtual const std::string & | getText (const std::string &ident) const |
Get Message Text. | |
virtual std::vector< std::string > | load (const char *elements[]) |
Load Dictionary. | |
virtual bool | replace (const MessageID &ident, const std::string &text) |
Replace Message. | |
virtual bool | replace (const std::string &ident, const std::string &text) |
Replace Message. | |
virtual size_t | size () const |
Number of Items in Dictionary. | |
Static Public Member Functions | |
static const MessageDictionaryPtr & | globalDictionary () |
Return Global Dictionary. | |
Message Dictionary.
The message dictionary is a wrapper around a std::map object, and allows message text to be retrieved given the string identification.
Adding text occurs in two modes:
Through the "Add" method, ID/text mappings are added to the dictionary unless the ID already exists. This is designed for use during program initialization, where a local message may supplant a compiled-in message.
Through the "Replace" method, ID/text mappings are added to the dictionary only if the ID already exists. This is for use when a message file is supplied to replace messages provided with the program.
Although the class can be used stand-alone, it does supply a static method to return a particular instance - the "global" dictionary.
Definition at line 47 of file message_dictionary.h.
Dictionary::const_iterator isc::log::MessageDictionary::const_iterator |
Definition at line 51 of file message_dictionary.h.
std::map<std::string, std::string> isc::log::MessageDictionary::Dictionary |
Definition at line 50 of file message_dictionary.h.
isc::log::MessageDictionary::MessageDictionary | ( | ) |
|
virtual |
Virtual Destructor.
Definition at line 25 of file message_dictionary.cc.
|
inlinevirtual |
Add Message.
Adds a message to the dictionary. If the ID already exists, the ID is added to the overflow vector.
ident | Identification of the message to add |
text | Message text |
Definition at line 69 of file message_dictionary.h.
References add().
Referenced by add(), and load().
|
virtual |
Add Message.
Alternate signature.
ident | Identification of the message to add |
text | Message text |
Definition at line 31 of file message_dictionary.cc.
|
inline |
Return begin() iterator of internal map.
Definition at line 182 of file message_dictionary.h.
|
inline |
Return end() iterator of internal map.
Definition at line 188 of file message_dictionary.h.
|
virtual |
Removes the specified message from the dictionary.
Checks if both the message identifier and the text match the message in the dictionary before removal. If the text doesn't match it is an indication that the message which removal is requested is a duplicate of another message. This may occur when two Kea modules register messages with the same identifier. When one of the modules is unloaded and the relevant messages are unregistered, there is a need to make sure that the message registered by the other module is not accidentally removed. Hence, the additional check for the text match is needed.
ident | Identification of the message to remove. |
text | Message text |
Definition at line 59 of file message_dictionary.cc.
|
inlinevirtual |
Get Message Text.
Given an ID, retrieve associated message text.
ident | Message identification |
Definition at line 156 of file message_dictionary.h.
References getText().
Referenced by getText(), and writeProgramFile().
|
virtual |
Get Message Text.
Alternate signature.
ident | Message identification |
Definition at line 100 of file message_dictionary.cc.
|
static |
Return Global Dictionary.
Returns a pointer to the singleton global dictionary.
Definition at line 112 of file message_dictionary.cc.
References MessageDictionary().
Referenced by isc::log::MessageInitializer::loadDictionary(), isc::log::LoggerImpl::lookupMessage(), main(), and isc::log::LoggerManager::readLocalMessageFile().
|
virtual |
Load Dictionary.
Designed to be used during the initialization of programs, this accepts a set of (ID, text) pairs as a one-dimensional array of const char* and adds them to the dictionary. The messages are added using "Add".
elements | null-terminated array of const char* alternating ID and message text. This should be an odd number of elements long, the last element being NULL. If it is an even number of elements long, the last ID is ignored. |
Definition at line 72 of file message_dictionary.cc.
References add().
|
inlinevirtual |
Replace Message.
Replaces a message in the dictionary. If the ID does not exist, it is added to the overflow vector.
ident | Identification of the message to replace |
text | Message text |
Definition at line 95 of file message_dictionary.h.
References replace().
Referenced by replace().
|
virtual |
Replace Message.
Alternate signature.
ident | Identification of the message to replace |
text | Message text |
Definition at line 46 of file message_dictionary.cc.
|
inlinevirtual |
Number of Items in Dictionary.
Definition at line 176 of file message_dictionary.h.