Kea  1.9.9-git
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 
20 namespace isc {
21 namespace log {
22 
25 
27 typedef boost::shared_ptr<MessageDictionary> MessageDictionaryPtr;
28 
46 
48 public:
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 
182  const_iterator begin() const {
183  return (dictionary_.begin());
184  }
185 
186 
188  const_iterator end() const {
189  return (dictionary_.end());
190  }
191 
192 
198  static const MessageDictionaryPtr& globalDictionary();
199 
200 private:
201  Dictionary dictionary_;
202  const std::string empty_;
203 };
204 
205 } // namespace log
206 } // namespace isc
207 
208 #endif // MESSAGE_DICTIONARY_H
static const MessageDictionaryPtr & globalDictionary()
Return Global Dictionary.
virtual bool erase(const std::string &ident, const std::string &text)
Removes the specified message from the dictionary.
Dictionary::const_iterator const_iterator
virtual const std::string & getText(const MessageID &ident) const
Get Message Text.
const_iterator begin() const
Return begin() iterator of internal map.
virtual ~MessageDictionary()
Virtual Destructor.
virtual bool replace(const MessageID &ident, const std::string &text)
Replace Message.
Defines the logger used by the top-level component of kea-dhcp-ddns.
virtual size_t size() const
Number of Items in Dictionary.
boost::shared_ptr< MessageDictionary > MessageDictionaryPtr
Shared pointer to the MessageDictionary.
virtual bool add(const MessageID &ident, const std::string &text)
Add Message.
const_iterator end() const
Return end() iterator of internal map.
virtual std::vector< std::string > load(const char *elements[])
Load Dictionary.
std::map< std::string, std::string > Dictionary
const char * MessageID
Definition: message_types.h:15