| Kea 3.0.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
25 class MessageReader {
26 public:
27
36 typedef enum {
37 ADD,
38 REPLACE
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
69 MessageDictionary* getDictionary() const {
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
isc::log::MessageDictionary
Message Dictionary.
Definition message_dictionary.h:47
isc::log::MessageReader::MessageIDCollection
std::vector< std::string > MessageIDCollection
Visible collection types.
Definition message_reader.h:42
isc::log::MessageReader::processLine
virtual void processLine(const std::string &line, Mode mode=ADD)
Process Line.
Definition message_reader.cc:72
isc::log::MessageReader::MessageReader
MessageReader(MessageDictionary *dictionary=NULL)
Constructor.
Definition message_reader.h:55
isc::log::MessageReader::~MessageReader
virtual ~MessageReader()
Virtual Destructor.
Definition message_reader.h:60
isc::log::MessageReader::clearNamespace
virtual void clearNamespace()
Clear Namespace.
Definition message_reader.h:118
isc::log::MessageReader::getNotAdded
MessageIDCollection getNotAdded() const
Get Not-Added List.
Definition message_reader.h:145
isc::log::MessageReader::setDictionary
void setDictionary(MessageDictionary *dictionary)
Set Dictionary.
Definition message_reader.h:81
isc::log::MessageReader::getDictionary
MessageDictionary * getDictionary() const
Get Dictionary.
Definition message_reader.h:69
isc::log::MessageReader::getPrefix
virtual std::string getPrefix() const
Get Prefix.
Definition message_reader.h:126
isc::log::MessageReader::clearPrefix
virtual void clearPrefix()
Clear Prefix.
Definition message_reader.h:134
isc::log::MessageReader::Mode
Mode
Read Mode.
Definition message_reader.h:36
isc::log::MessageReader::ADD
@ ADD
Definition message_reader.h:37
isc::log::MessageReader::REPLACE
@ REPLACE
Definition message_reader.h:38
isc::log::MessageReader::getNamespace
virtual std::string getNamespace() const
Get Namespace.
Definition message_reader.h:110
isc::log::MessageReader::readFile
virtual void readFile(const std::string &file, Mode mode=ADD)
Read File.
Definition message_reader.cc:36
message_dictionary.h
message_types.h
isc::log
Definition buffer_appender_impl.cc:17
isc
Defines the logger used by the top-level component of kea-lfc.
Definition agent_parser.cc:148