Kea 2.7.6
master_loader.h
Go to the documentation of this file.
1// Copyright (C) 2012-2024 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
10#include <dns/exceptions.h>
12
13#include <boost/noncopyable.hpp>
14
15#include <memory>
16
17namespace isc {
18namespace dns {
19
20class Name;
21class RRClass;
22
26public:
27 MasterLoaderError(const char* file, size_t line, const char* what) :
28 Exception(file, line, what)
29 {}
30};
31
39class MasterLoader : boost::noncopyable {
40public:
42 enum Options {
43 DEFAULT = 0,
44 MANY_ERRORS = 1
46 };
47
76 MasterLoader(const char* master_file,
77 const Name& zone_origin,
78 const RRClass& zone_class,
79 const MasterLoaderCallbacks& callbacks,
80 const AddRRCallback& add_callback,
81 Options options = DEFAULT);
82
90 MasterLoader(std::istream& input,
91 const Name& zone_origin,
92 const RRClass& zone_class,
93 const MasterLoaderCallbacks& callbacks,
94 const AddRRCallback& add_callback,
95 Options options = DEFAULT);
96
99
114 bool loadIncremental(size_t count_limit);
115
124 void load() {
125 while (!loadIncremental(1000)) { // 1000 = arbitrary largish number
126 // Body intentionally left blank
127 }
128 }
129
138 bool loadedSuccessfully() const;
139
164 size_t getSize() const;
165
176 size_t getPosition() const;
177
178private:
179 class MasterLoaderImpl;
180 std::unique_ptr<MasterLoaderImpl> impl_;
181};
182
183} // end namespace dns
184} // end namespace isc
185
186#endif // MASTER_LOADER_H
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.
MasterLoaderError(const char *file, size_t line, const char *what)
A class able to load DNS master files.
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.
@ MANY_ERRORS
Lenient mode (see documentation of MasterLoader constructor).
@ DEFAULT
Nothing special.
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:219
The RRClass class encapsulates DNS resource record classes.
Definition rrclass.h:89
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.