/src/jsoncons/include/jsoncons_ext/ubjson/ubjson_options.hpp
Line | Count | Source |
1 | | // Copyright 2013-2026 Daniel Parker |
2 | | // Distributed under the Boost license, Version 1.0. |
3 | | // (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
4 | | |
5 | | // See https://github.com/danielaparker/jsoncons for latest version |
6 | | |
7 | | #ifndef JSONCONS_EXT_UBJSON_UBJSON_OPTIONS_HPP |
8 | | #define JSONCONS_EXT_UBJSON_UBJSON_OPTIONS_HPP |
9 | | |
10 | | #include <cwchar> |
11 | | |
12 | | namespace jsoncons { |
13 | | namespace ubjson { |
14 | | |
15 | | class ubjson_options; |
16 | | |
17 | | class ubjson_options_common |
18 | | { |
19 | | friend class ubjson_options; |
20 | | |
21 | | int max_nesting_depth_{1024}; |
22 | | protected: |
23 | 1.00k | ubjson_options_common() = default; |
24 | | ubjson_options_common(const ubjson_options_common&) = default; |
25 | 1.00k | virtual ~ubjson_options_common() = default; |
26 | | public: |
27 | | int max_nesting_depth() const |
28 | 1.00k | { |
29 | 1.00k | return max_nesting_depth_; |
30 | 1.00k | } |
31 | | }; |
32 | | |
33 | | class ubjson_decode_options : public virtual ubjson_options_common |
34 | | { |
35 | | friend class ubjson_options; |
36 | | std::size_t max_items_{1 << 24}; |
37 | | public: |
38 | 746 | ubjson_decode_options() = default; |
39 | | ubjson_decode_options(const ubjson_decode_options& other) = default; |
40 | | protected: |
41 | | ubjson_decode_options& operator=(const ubjson_decode_options& other) = default; |
42 | | public: |
43 | | std::size_t max_items() const |
44 | 746 | { |
45 | 746 | return max_items_; |
46 | 746 | } |
47 | | }; |
48 | | |
49 | | class ubjson_encode_options : public virtual ubjson_options_common |
50 | | { |
51 | | friend class ubjson_options; |
52 | | public: |
53 | 256 | ubjson_encode_options() = default; |
54 | | ubjson_encode_options(const ubjson_encode_options& other) = default; |
55 | | protected: |
56 | | ubjson_encode_options& operator=(const ubjson_encode_options& other) = default; |
57 | | }; |
58 | | |
59 | | class ubjson_options final : public ubjson_decode_options, public ubjson_encode_options |
60 | | { |
61 | | public: |
62 | | using ubjson_options_common::max_nesting_depth; |
63 | | using ubjson_decode_options::max_items; |
64 | | |
65 | | ubjson_options() = default; |
66 | | ubjson_options(const ubjson_options& other) = default; |
67 | | |
68 | | ubjson_options& operator=(const ubjson_options& other) = default; |
69 | | |
70 | | ubjson_options& max_nesting_depth(int value) |
71 | 0 | { |
72 | 0 | this->max_nesting_depth_ = value; |
73 | 0 | return *this; |
74 | 0 | } |
75 | | |
76 | | ubjson_options& max_items(std::size_t value) |
77 | 0 | { |
78 | 0 | this->max_items_ = value; |
79 | 0 | return *this; |
80 | 0 | } |
81 | | }; |
82 | | |
83 | | } // namespace ubjson |
84 | | } // namespace jsoncons |
85 | | |
86 | | #endif // JSONCONS_EXT_UBJSON_UBJSON_OPTIONS_HPP |