Kea 3.3.3
message_reader.h
Go to the documentation of this file.
1// Copyright (C) 2011-2026 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
11#include <log/message_types.h>
12
13#include <cstdint>
14#include <map>
15#include <string>
16#include <vector>
17
18namespace isc {
19namespace log {
20
25
27public:
28
37 enum Mode : uint16_t {
40 };
41
43 typedef std::vector<std::string> MessageIDCollection;
44
56 MessageReader(MessageDictionary* dictionary = NULL) :
57 dictionary_(dictionary), lineno_(0)
58 {}
59
62 {}
63
71 return (dictionary_);
72 }
73
74
82 void setDictionary(MessageDictionary* dictionary) {
83 dictionary_ = dictionary;
84 }
85
86
94 virtual void readFile(const std::string& file, Mode mode = ADD);
95
96
105 virtual void processLine(const std::string& line, Mode mode = ADD);
106
107
111 virtual std::string getNamespace() const {
112 return (ns_);
113 }
114
115
119 virtual void clearNamespace() {
120 ns_ = "";
121 }
122
123
127 virtual std::string getPrefix() const {
128 return (prefix_);
129 }
130
131
135 virtual void clearPrefix() {
136 prefix_ = "";
137 }
138
139
147 return (not_added_);
148 }
149
150private:
151
160 void parseMessage(const std::string& line, Mode mode);
161
162
169 void parseDirective(const std::string& line);
170
171
175 void parsePrefix(const std::vector<std::string>& tokens);
176
177
181 void parseNamespace(const std::vector<std::string>& tokens);
182
193 bool invalidSymbol(const std::string& symbol);
194
195
196
198 MessageDictionary* dictionary_;
199 MessageIDCollection not_added_;
200 int lineno_;
201 std::string prefix_;
202 std::string ns_;
203};
204
205} // namespace log
206} // namespace isc
207
208#endif // MESSAGE_READER_H
std::vector< std::string > MessageIDCollection
Visible collection types.
virtual void processLine(const std::string &line, Mode mode=ADD)
Process Line.
MessageReader(MessageDictionary *dictionary=NULL)
Constructor.
virtual ~MessageReader()
Virtual Destructor.
virtual void clearNamespace()
Clear Namespace.
MessageIDCollection getNotAdded() const
Get Not-Added List.
void setDictionary(MessageDictionary *dictionary)
Set Dictionary.
MessageDictionary * getDictionary() const
Get Dictionary.
virtual std::string getPrefix() const
Get Prefix.
virtual void clearPrefix()
Clear Prefix.
virtual std::string getNamespace() const
Get Namespace.
virtual void readFile(const std::string &file, Mode mode=ADD)
Read File.
Defines the logger used by the top-level component of kea-lfc.