/src/valijson/include/valijson/internal/frozen_value.hpp
Line | Count | Source (jump to first uncovered line) |
1 | | #pragma once |
2 | | |
3 | | #include <valijson/internal/adapter.hpp> |
4 | | |
5 | | namespace valijson { |
6 | | namespace adapters { |
7 | | |
8 | | /** |
9 | | * @brief An interface that provides minimal access to a stored JSON value. |
10 | | * |
11 | | * The main reason that this interface exists is to support the 'enum' |
12 | | * constraint. Each Adapter type is expected to provide an implementation of |
13 | | * this interface. That class should be able to maintain its own copy of a |
14 | | * JSON value, independent of the original document. |
15 | | * |
16 | | * This interface currently provides just the clone and equalTo functions, but |
17 | | * could be expanded to include other functions declared in the Adapter |
18 | | * interface. |
19 | | * |
20 | | * @todo it would be nice to better integrate this with the Adapter interface |
21 | | */ |
22 | | class FrozenValue |
23 | | { |
24 | | public: |
25 | | |
26 | | /** |
27 | | * @brief Virtual destructor defined to ensure deletion via base-class |
28 | | * pointers is safe. |
29 | | */ |
30 | 0 | virtual ~FrozenValue() { } |
31 | | |
32 | | /** |
33 | | * @brief Clone the stored value and return a pointer to a new FrozenValue |
34 | | * object containing the value. |
35 | | */ |
36 | | virtual FrozenValue *clone() const = 0; |
37 | | |
38 | | /** |
39 | | * @brief Return true if the stored value is equal to the value contained |
40 | | * by an Adapter instance. |
41 | | * |
42 | | * @param adapter Adapter to compare value against |
43 | | * @param strict Flag to use strict type comparison |
44 | | * |
45 | | * @returns true if values are equal, false otherwise |
46 | | */ |
47 | | virtual bool equalTo(const Adapter &adapter, bool strict) const = 0; |
48 | | |
49 | | }; |
50 | | |
51 | | } // namespace adapters |
52 | | } // namespace valijson |