Kea  2.3.2-git
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 
14 namespace isc {
15 namespace dns {
16 
17 class Name;
18 class RRClass;
19 
23 public:
24  MasterLoaderError(const char* file, size_t line, const char* what) :
25  Exception(file, line, what)
26  {}
27 };
28 
36 class MasterLoader : boost::noncopyable {
37 public:
39  enum Options {
40  DEFAULT = 0,
41  MANY_ERRORS = 1
42  };
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 
95  ~MasterLoader();
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 
175 private:
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:
The Name class encapsulates DNS names.
Definition: name.h:223
A class able to load DNS master files.
Definition: master_loader.h:36
MasterLoaderError(const char *file, size_t line, const char *what)
Definition: master_loader.h:24
Private implementation class for the MasterLoader.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
The RRClass class encapsulates DNS resource record classes.
Definition: rrclass.h:98
Options
Options how the parsing should work.
Definition: master_loader.h:39
This is a base class for exceptions thrown from the DNS library module.
Defines the logger used by the top-level component of kea-lfc.
Error while loading by MasterLoader without specifying the MANY_ERRORS option.
Definition: master_loader.h:22
void load()
Load everything.
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.
Set of issue callbacks for a loader.