MongoDB C++ Driver
4.4.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
20
#include <
bsoncxx/validate-fwd.hpp
>
// IWYU pragma: export
21
22
#include <
bsoncxx/document/view.hpp
>
23
#include <
bsoncxx/stdx/optional.hpp
>
24
25
#include <
bsoncxx/config/prelude.hpp
>
26
27
namespace
bsoncxx
{
28
namespace
v_noabi
{
29
44
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE
(
stdx::optional<document::view>
)
45
validate
(std::uint8_t const* data, std::
size_t
length);
46
67
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE
(
stdx
::optional<
document
::view>)
68
validate
(
69
std::uint8_t const* data,
70
std::
size_t
length,
71
validator
const&
validator
,
72
std::
size_t
* invalid_offset =
nullptr
);
73
77
class
validator
{
78
public
:
82
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE
()
validator
();
83
87
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE
() ~
validator
();
88
95
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE
(
void
)
check_utf8
(
bool
check_utf8
);
96
102
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE
(
bool
)
check_utf8
() const;
103
112
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE
(
void
)
check_utf8_allow_null
(
bool
check_utf8_allow_null
);
113
121
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE
(
bool
)
check_utf8_allow_null
() const;
122
129
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE
(
void
)
check_dollar_keys
(
bool
check_dollar_keys
);
130
137
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE
(
bool
)
check_dollar_keys
() const;
138
145
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE
(
void
)
check_dot_keys
(
bool
check_dot_keys
);
146
153
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE
(
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
163
namespace
bsoncxx
{
164
165
using
v_noabi::validate
;
166
167
}
// namespace bsoncxx
168
169
#include <
bsoncxx/config/postlude.hpp
>
170
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE
#define BSONCXX_ABI_EXPORT_CDECL_UNSTABLE(...)
Equivalent to BSONCXX_ABI_EXPORT_UNSTABLE with BSONCXX_ABI_CDECL.
Definition
config.hpp:28
postlude.hpp
The bsoncxx v_noabi macro guard postlude header.
prelude.hpp
The bsoncxx v_noabi macro guard prelude header.
bsoncxx::v1::stdx::optional
A polyfill for std::optional<T>.
Definition
optional.hpp:799
bsoncxx::v_noabi::validator
Used to toggle checks which may be performed during BSON validation.
Definition
validate.hpp:77
bsoncxx::v_noabi::validator::validator
validator()
Constructs a validator.
bsoncxx::v_noabi::validator::check_dot_keys
void check_dot_keys(bool check_dot_keys)
Verifies that document keys do not contain any '.' characters.
bsoncxx::v_noabi::validator::check_utf8_allow_null
void check_utf8_allow_null(bool check_utf8_allow_null)
Verify that all keys and string values are valid UTF-8, but allow null bytes. This is generally bad p...
bsoncxx::v_noabi::validator::check_utf8
void check_utf8(bool check_utf8)
Verify that all keys and string values are valid UTF-8.
bsoncxx::v_noabi::validator::check_dollar_keys
void check_dollar_keys(bool check_dollar_keys)
Verifies that document keys are not preceeded with '$'.
bsoncxx::v_noabi::document
Declares entities representing a BSON document.
bsoncxx::v_noabi::stdx
Declares C++17 standard library polyfills.
bsoncxx::v_noabi
Declares entities whose ABI stability is NOT guaranteed.
bsoncxx::v_noabi::validate
stdx::optional< document::view > validate(std::uint8_t const *data, std::size_t length)
Validates a BSON document. This is a simplified overload that will only do the bare minimum validatio...
bsoncxx
The top-level namespace within which all bsoncxx library entities are declared.
view.hpp
Provides bsoncxx::v_noabi::document::view.
optional.hpp
Provides std::optional-related polyfills for library API usage.
validate-fwd.hpp
Declares bsoncxx::v_noabi::validator.
bsoncxx
v_noabi
bsoncxx
validate.hpp
Generated by
1.15.0