/src/jsoncons/include/jsoncons_ext/bson/bson_options.hpp
Line | Count | Source |
1 | | // Copyright 2013-2025 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_BSON_BSON_OPTIONS_HPP |
8 | | #define JSONCONS_EXT_BSON_BSON_OPTIONS_HPP |
9 | | |
10 | | #include <cwchar> |
11 | | |
12 | | namespace jsoncons { |
13 | | namespace bson { |
14 | | |
15 | | class bson_options; |
16 | | |
17 | | class bson_options_common |
18 | | { |
19 | | friend class bson_options; |
20 | | |
21 | | int max_nesting_depth_{1024}; |
22 | | protected: |
23 | 12.0k | bson_options_common() = default; |
24 | | bson_options_common(const bson_options_common&) = default; |
25 | 12.0k | virtual ~bson_options_common() = default; |
26 | | |
27 | | bson_options_common& operator=(const bson_options_common&) = default; |
28 | | |
29 | | public: |
30 | | int max_nesting_depth() const |
31 | 12.0k | { |
32 | 12.0k | return max_nesting_depth_; |
33 | 12.0k | } |
34 | | }; |
35 | | |
36 | | class bson_decode_options : public virtual bson_options_common |
37 | | { |
38 | | friend class bson_options; |
39 | | public: |
40 | 9.21k | bson_decode_options() = default; |
41 | | bson_decode_options(const bson_decode_options& other) = default; |
42 | | protected: |
43 | | bson_decode_options& operator=(const bson_decode_options& other) = default; |
44 | | }; |
45 | | |
46 | | class bson_encode_options : public virtual bson_options_common |
47 | | { |
48 | | friend class bson_options; |
49 | | public: |
50 | 2.85k | bson_encode_options() = default; |
51 | | bson_encode_options(const bson_encode_options& other) = default; |
52 | | protected: |
53 | | bson_encode_options& operator=(const bson_encode_options& other) = default; |
54 | | }; |
55 | | |
56 | | class bson_options final : public bson_decode_options, public bson_encode_options |
57 | | { |
58 | | public: |
59 | | using bson_options_common::max_nesting_depth; |
60 | | |
61 | | bson_options() = default; |
62 | | bson_options(const bson_options& other) = default; |
63 | | bson_options& operator=(const bson_options& other) = default; |
64 | | |
65 | | bson_options& max_nesting_depth(int value) |
66 | 0 | { |
67 | 0 | this->max_nesting_depth_ = value; |
68 | 0 | return *this; |
69 | 0 | } |
70 | | }; |
71 | | |
72 | | } // namespace bson |
73 | | } // namespace jsoncons |
74 | | |
75 | | #endif // JSONCONS_EXT_BSON_BSON_OPTIONS_HPP |