Kea 3.3.3
master_loader.h
Go to the documentation of this file.
1// Copyright (C) 2012-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 MASTER_LOADER_H
8#define MASTER_LOADER_H
9
10#include <dns/exceptions.h>
12
13#include <cstdint>
14#include <memory>
15
16#include <boost/noncopyable.hpp>
17
18namespace isc {
19namespace dns {
20
21class Name;
22class RRClass;
23
27public:
28 MasterLoaderError(const char* file, size_t line, const char* what) :
29 Exception(file, line, what)
30 {}
31};
32
40class MasterLoader : boost::noncopyable {
41public:
43 enum Options : uint16_t {
44 DEFAULT = 0,
47 };
48
77 MasterLoader(const char* master_file,
78 const Name& zone_origin,
79 const RRClass& zone_class,
80 const MasterLoaderCallbacks& callbacks,
81 const AddRRCallback& add_callback,
82 Options options = DEFAULT);
83
91 MasterLoader(std::istream& input,
92 const Name& zone_origin,
93 const RRClass& zone_class,
94 const MasterLoaderCallbacks& callbacks,
95 const AddRRCallback& add_callback,
96 Options options = DEFAULT);
97
100
115 bool loadIncremental(size_t count_limit);
116
125 void load() {
126 while (!loadIncremental(1000)) { // 1000 = arbitrary largish number
127 // Body intentionally left blank
128 }
129 }
130
139 bool loadedSuccessfully() const;
140
165 size_t getSize() const;
166
177 size_t getPosition() const;
178
179private:
180 class MasterLoaderImpl;
181 std::unique_ptr<MasterLoaderImpl> impl_;
182};
183
184} // end namespace dns
185} // end namespace isc
186
187#endif // MASTER_LOADER_H
This is a base class for exceptions thrown from the DNS library module.
Exception(const char *file, size_t line, const char *what)
Constructor for a given type for exceptions with file name and file line number.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
Set of issue callbacks for a loader.
MasterLoaderError(const char *file, size_t line, const char *what)
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.
Options
Options how the parsing should work.
@ MANY_ERRORS
Lenient mode (see documentation of MasterLoader constructor).
@ DEFAULT
Nothing special.
bool loadedSuccessfully() const
Was the loading successful?
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:217
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.