| Kea 3.0.2-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
24 class MessageDictionary;
25
27 typedef boost::shared_ptr<MessageDictionary> MessageDictionaryPtr;
28
46
47 class MessageDictionary {
48 public:
49
50 typedef std::map<std::string, std::string> Dictionary;
51 typedef Dictionary::const_iterator const_iterator;
52
54 MessageDictionary();
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
isc::log::MessageDictionary
Message Dictionary.
Definition message_dictionary.h:47
isc::log::MessageDictionary::MessageDictionary
MessageDictionary()
Constructor.
Definition message_dictionary.cc:20
isc::log::MessageDictionary::replace
virtual bool replace(const MessageID &ident, const std::string &text)
Replace Message.
Definition message_dictionary.h:95
isc::log::MessageDictionary::globalDictionary
static const MessageDictionaryPtr & globalDictionary()
Return Global Dictionary.
Definition message_dictionary.cc:112
isc::log::MessageDictionary::getText
virtual const std::string & getText(const MessageID &ident) const
Get Message Text.
Definition message_dictionary.h:156
isc::log::MessageDictionary::load
virtual std::vector< std::string > load(const char *elements[])
Load Dictionary.
Definition message_dictionary.cc:72
isc::log::MessageDictionary::end
const_iterator end() const
Return end() iterator of internal map.
Definition message_dictionary.h:188
isc::log::MessageDictionary::size
virtual size_t size() const
Number of Items in Dictionary.
Definition message_dictionary.h:176
isc::log::MessageDictionary::Dictionary
std::map< std::string, std::string > Dictionary
Definition message_dictionary.h:50
isc::log::MessageDictionary::erase
virtual bool erase(const std::string &ident, const std::string &text)
Removes the specified message from the dictionary.
Definition message_dictionary.cc:59
isc::log::MessageDictionary::begin
const_iterator begin() const
Return begin() iterator of internal map.
Definition message_dictionary.h:182
isc::log::MessageDictionary::const_iterator
Dictionary::const_iterator const_iterator
Definition message_dictionary.h:51
isc::log::MessageDictionary::~MessageDictionary
virtual ~MessageDictionary()
Virtual Destructor.
Definition message_dictionary.cc:25
isc::log::MessageDictionary::add
virtual bool add(const MessageID &ident, const std::string &text)
Add Message.
Definition message_dictionary.h:69
message_types.h
isc::log
Definition buffer_appender_impl.cc:17
isc::log::MessageDictionaryPtr
boost::shared_ptr< MessageDictionary > MessageDictionaryPtr
Shared pointer to the MessageDictionary.
Definition message_dictionary.h:27
isc::log::MessageID
const char * MessageID
Definition message_types.h:15
isc
Defines the logger used by the top-level component of kea-lfc.
Definition agent_parser.cc:148