MongoDB C++ Driver mongocxx-4.0.0
Loading...
Searching...
No Matches
validate.hpp
Go to the documentation of this file.
1// Copyright 2009-present MongoDB, Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#pragma once
16
17#include <cstdint>
18#include <memory>
19
21
24
26
27namespace bsoncxx {
28namespace v_noabi {
29
44BSONCXX_ABI_EXPORT_CDECL(stdx::optional<document::view>)
45validate(const std::uint8_t* data, std::size_t length);
46
67BSONCXX_ABI_EXPORT_CDECL(stdx::optional<document::view>)
68validate(const std::uint8_t* data,
69 std::size_t length,
70 const validator& validator,
71 std::size_t* invalid_offset = nullptr);
72
77class validator {
78 public:
83
88
95 BSONCXX_ABI_EXPORT_CDECL(void) check_utf8(bool check_utf8);
96
102 BSONCXX_ABI_EXPORT_CDECL(bool) check_utf8() const;
103
112 BSONCXX_ABI_EXPORT_CDECL(void) check_utf8_allow_null(bool check_utf8_allow_null);
113
121 BSONCXX_ABI_EXPORT_CDECL(bool) check_utf8_allow_null() const;
122
129 BSONCXX_ABI_EXPORT_CDECL(void) check_dollar_keys(bool check_dollar_keys);
130
137 BSONCXX_ABI_EXPORT_CDECL(bool) check_dollar_keys() const;
138
145 BSONCXX_ABI_EXPORT_CDECL(void) check_dot_keys(bool check_dot_keys);
146
153 BSONCXX_ABI_EXPORT_CDECL(bool) check_dot_keys() const;
154
155 private:
156 struct impl;
157 std::unique_ptr<impl> _impl;
158};
159
160} // namespace v_noabi
161} // namespace bsoncxx
162
163namespace bsoncxx {
164
165using ::bsoncxx::v_noabi::validate;
166
167} // namespace bsoncxx
168
170
175
176#if defined(BSONCXX_PRIVATE_DOXYGEN_PREPROCESSOR)
177
178namespace bsoncxx {
179
182 std::size_t length);
183
186 std::size_t length,
188 std::size_t* invalid_offset = nullptr);
189
190} // namespace bsoncxx
191
192#endif // defined(BSONCXX_PRIVATE_DOXYGEN_PREPROCESSOR)
The bsoncxx macro guard postlude header.
The bsoncxx macro guard prelude header.
A polyfill for std::optional<T>.
Definition optional.hpp:826
A validator is used to enable or disable specific checks that can be performed during BSON validation...
Definition validate.hpp:77
bsoncxx::v_noabi::validator
Definition validate-fwd.hpp:45
Provides bsoncxx::v_noabi::document::view.
#define BSONCXX_ABI_EXPORT_CDECL(...)
Equivalent to BSONCXX_ABI_EXPORT with BSONCXX_ABI_CDECL.
Definition fwd.hpp:177
stdx::optional< document::view > validate(const std::uint8_t *data, std::size_t length)
Validates a BSON document. This is a simplified overload that will only do the bare minimum validatio...
The top-level namespace within which all bsoncxx library entities are declared.
v_noabi::stdx::optional< v_noabi::document::view > validate(const std::uint8_t *data, std::size_t length)
bsoncxx::v_noabi::validate(const std::uint8_t* data, std::size_t length)
The top-level namespace reserved for the C++ standard library.
Provides std::optional-related polyfills for library API usage.
Declares bsoncxx::v_noabi::validator.