Kea  2.3.2-git
message_reader.h
Go to the documentation of this file.
1 // Copyright (C) 2011-2015 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_READER_H
8 #define MESSAGE_READER_H
9 
10 #include <map>
11 #include <string>
12 #include <vector>
13 
14 #include <log/message_dictionary.h>
15 #include <log/message_types.h>
16 
17 namespace isc {
18 namespace log {
19 
24 
26 public:
27 
36  typedef enum {
37  ADD,
39  } Mode;
40 
42  typedef std::vector<std::string> MessageIDCollection;
43 
55  MessageReader(MessageDictionary* dictionary = NULL) :
56  dictionary_(dictionary), lineno_(0)
57  {}
58 
60  virtual ~MessageReader()
61  {}
62 
70  return (dictionary_);
71  }
72 
73 
81  void setDictionary(MessageDictionary* dictionary) {
82  dictionary_ = dictionary;
83  }
84 
85 
93  virtual void readFile(const std::string& file, Mode mode = ADD);
94 
95 
104  virtual void processLine(const std::string& line, Mode mode = ADD);
105 
106 
110  virtual std::string getNamespace() const {
111  return (ns_);
112  }
113 
114 
118  virtual void clearNamespace() {
119  ns_ = "";
120  }
121 
122 
126  virtual std::string getPrefix() const {
127  return (prefix_);
128  }
129 
130 
134  virtual void clearPrefix() {
135  prefix_ = "";
136  }
137 
138 
145  MessageIDCollection getNotAdded() const {
146  return (not_added_);
147  }
148 
149 private:
150 
159  void parseMessage(const std::string& line, Mode mode);
160 
161 
168  void parseDirective(const std::string& line);
169 
170 
174  void parsePrefix(const std::vector<std::string>& tokens);
175 
176 
180  void parseNamespace(const std::vector<std::string>& tokens);
181 
192  bool invalidSymbol(const std::string& symbol);
193 
194 
195 
197  MessageDictionary* dictionary_;
198  MessageIDCollection not_added_;
199  int lineno_;
200  std::string prefix_;
201  std::string ns_;
202 };
203 
204 } // namespace log
205 } // namespace isc
206 
207 #endif // MESSAGE_READER_H
virtual void clearPrefix()
Clear Prefix.
virtual void readFile(const std::string &file, Mode mode=ADD)
Read File.
void setDictionary(MessageDictionary *dictionary)
Set Dictionary.
virtual std::string getPrefix() const
Get Prefix.
vector< string > tokens(const std::string &text, const std::string &delim, bool escape)
Split String into Tokens.
Definition: strutil.cc:77
virtual void processLine(const std::string &line, Mode mode=ADD)
Process Line.
virtual void clearNamespace()
Clear Namespace.
Defines the logger used by the top-level component of kea-lfc.
MessageIDCollection getNotAdded() const
Get Not-Added List.
virtual ~MessageReader()
Virtual Destructor.
Read Message File.
MessageReader(MessageDictionary *dictionary=NULL)
Constructor.
MessageDictionary * getDictionary() const
Get Dictionary.
virtual std::string getNamespace() const
Get Namespace.
std::vector< std::string > MessageIDCollection
Visible collection types.