Kea 2.2.0
master_loader.h
Go to the documentation of this file.
1// Copyright (C) 2012-2017 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 MASTER_LOADER_H
8#define MASTER_LOADER_H
9
11
12#include <boost/noncopyable.hpp>
13
14namespace isc {
15namespace dns {
16
17class Name;
18class RRClass;
19
23public:
24 MasterLoaderError(const char* file, size_t line, const char* what) :
25 Exception(file, line, what)
26 {}
27};
28
36class MasterLoader : boost::noncopyable {
37public:
39 enum Options {
40 DEFAULT = 0,
41 MANY_ERRORS = 1
43 };
44
73 MasterLoader(const char* master_file,
74 const Name& zone_origin,
75 const RRClass& zone_class,
76 const MasterLoaderCallbacks& callbacks,
77 const AddRRCallback& add_callback,
78 Options options = DEFAULT);
79
87 MasterLoader(std::istream& input,
88 const Name& zone_origin,
89 const RRClass& zone_class,
90 const MasterLoaderCallbacks& callbacks,
91 const AddRRCallback& add_callback,
92 Options options = DEFAULT);
93
96
111 bool loadIncremental(size_t count_limit);
112
121 void load() {
122 while (!loadIncremental(1000)) { // 1000 = arbitrary largish number
123 // Body intentionally left blank
124 }
125 }
126
135 bool loadedSuccessfully() const;
136
161 size_t getSize() const;
162
173 size_t getPosition() const;
174
175private:
176 class MasterLoaderImpl;
177 MasterLoaderImpl* impl_;
178};
179
180} // end namespace dns
181} // end namespace isc
182
183#endif // MASTER_LOADER_H
184
185// Local Variables:
186// mode: c++
187// End:
This is a base class for exceptions thrown from the DNS library module.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
Set of issue callbacks for a loader.
Error while loading by MasterLoader without specifying the MANY_ERRORS option.
Definition: master_loader.h:22
MasterLoaderError(const char *file, size_t line, const char *what)
Definition: master_loader.h:24
A class able to load DNS master files.
Definition: master_loader.h:36
size_t getPosition() const
Return the position of the loader in zone.
void load()
Load everything.
MasterLoader(const char *master_file, const Name &zone_origin, const RRClass &zone_class, const MasterLoaderCallbacks &callbacks, const AddRRCallback &add_callback, Options options=DEFAULT)
Constructor.
bool loadedSuccessfully() const
Was the loading successful?
Options
Options how the parsing should work.
Definition: master_loader.h:39
@ MANY_ERRORS
Lenient mode (see documentation of MasterLoader constructor).
Definition: master_loader.h:41
@ DEFAULT
Nothing special.
Definition: master_loader.h:40
size_t getSize() const
Return the total size of the zone files and streams.
bool loadIncremental(size_t count_limit)
Load some RRs.
The Name class encapsulates DNS names.
Definition: name.h:223
The RRClass class encapsulates DNS resource record classes.
Definition: rrclass.h:98
std::function< void(const Name &name, const RRClass &rrclass, const RRType &rrtype, const RRTTL &rrttl, const rdata::RdataPtr &rdata)> AddRRCallback
Type of callback to add a RR.
Defines the logger used by the top-level component of kea-lfc.