Kea 2.7.1
message_dictionary.h
Go to the documentation of this file.
1// Copyright (C) 2011-2016 Internet Systems Consortium, Inc. ("ISC")
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7#ifndef MESSAGE_DICTIONARY_H
8#define MESSAGE_DICTIONARY_H
9
10#include <cstddef>
11#include <string>
12#include <map>
13#include <vector>
14
15#include <boost/lexical_cast.hpp>
16#include <boost/shared_ptr.hpp>
17
18#include <log/message_types.h>
19
20namespace isc {
21namespace log {
22
24class MessageDictionary;
25
27typedef boost::shared_ptr<MessageDictionary> MessageDictionaryPtr;
28
46
48public:
49
50 typedef std::map<std::string, std::string> Dictionary;
51 typedef Dictionary::const_iterator const_iterator;
52
55
57 virtual ~MessageDictionary();
58
69 virtual bool add(const MessageID& ident, const std::string& text) {
70 return (add(boost::lexical_cast<std::string>(ident), text));
71 }
72
82 virtual bool add (const std::string& ident, const std::string& text);
83
84
95 virtual bool replace(const MessageID& ident, const std::string& text) {
96 return (replace(boost::lexical_cast<std::string>(ident), text));
97 }
98
108 virtual bool replace(const std::string& ident, const std::string& text);
109
110
128 virtual bool erase(const std::string& ident, const std::string& text);
129
145 virtual std::vector<std::string> load(const char* elements[]);
146
156 virtual const std::string& getText(const MessageID& ident) const {
157 return(getText(boost::lexical_cast<std::string>(ident)));
158 }
159
160
170 virtual const std::string& getText(const std::string& ident) const;
171
172
176 virtual size_t size() const {
177 return (dictionary_.size());
178 }
179
180
183 return (dictionary_.begin());
184 }
185
186
189 return (dictionary_.end());
190 }
191
192
199
200private:
201 Dictionary dictionary_;
202 const std::string empty_;
203};
204
205} // namespace log
206} // namespace isc
207
208#endif // MESSAGE_DICTIONARY_H
virtual bool replace(const MessageID &ident, const std::string &text)
Replace Message.
static const MessageDictionaryPtr & globalDictionary()
Return Global Dictionary.
virtual const std::string & getText(const MessageID &ident) const
Get Message Text.
virtual std::vector< std::string > load(const char *elements[])
Load Dictionary.
const_iterator end() const
Return end() iterator of internal map.
virtual size_t size() const
Number of Items in Dictionary.
std::map< std::string, std::string > Dictionary
virtual bool erase(const std::string &ident, const std::string &text)
Removes the specified message from the dictionary.
const_iterator begin() const
Return begin() iterator of internal map.
Dictionary::const_iterator const_iterator
virtual ~MessageDictionary()
Virtual Destructor.
virtual bool add(const MessageID &ident, const std::string &text)
Add Message.
boost::shared_ptr< MessageDictionary > MessageDictionaryPtr
Shared pointer to the MessageDictionary.
const char * MessageID
Defines the logger used by the top-level component of kea-lfc.