summaryrefslogtreecommitdiffstats
path: root/src/lib/cc/cfg_to_element.h
blob: 480dd1fa7485c8e8be067af26bb2224c486cad85 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Copyright (C) 2017 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

#ifndef CFG_TO_ELEMENT_H
#define CFG_TO_ELEMENT_H

#include <exceptions/exceptions.h>
#include <cc/data.h>

namespace isc {

/// @brief Cannot unparse error
///
/// This exception is expected to be thrown when toElement fails
/// and to skip flawed elements is not wanted.
class ToElementError : public isc::Exception {
public:
    ToElementError(const char* file, size_t line, const char* what) :
        isc::Exception(file, line, what) { };
};

namespace data {

/// @brief Abstract class for configuration Cfg_* classes
///
struct CfgToElement {
    /// Destructor
    virtual ~CfgToElement() { }

    /// @brief Unparse a configuration object
    ///
    /// Returns an element which must parse into the same object, i.e.
    /// @code
    /// for all valid config C parse(parse(C)->toElement()) == parse(C)
    /// @endcode
    ///
    /// @return a pointer to a configuration which can be parsed into
    /// the initial configuration object
    virtual isc::data::ElementPtr toElement() const = 0;
};

}; // namespace isc::dhcp
}; // namespace isc

#endif // CFG_TO_ELEMENT_H