Loading...
Searching...
No Matches
validate.hpp
Go to the documentation of this file.
// Copyright 2009-present MongoDB, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once
#include <cstdint>
#include <memory>
#include <bsoncxx/validate-fwd.hpp> // IWYU pragma: export
#include <bsoncxx/document/view.hpp>
#include <bsoncxx/stdx/optional.hpp>
#include <bsoncxx/config/prelude.hpp>
namespace bsoncxx {
namespace v_noabi {
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE(stdx::optional<document::view>)
validate(std::uint8_t const* data, std::size_t length);
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE(stdx::optional<document::view>)
validate(
std::uint8_t const* data,
std::size_t length,
validator const& validator,
std::size_t* invalid_offset = nullptr);
class validator {
public:
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE() validator();
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE() ~validator();
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE(void) check_utf8(bool check_utf8);
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE(bool) check_utf8() const;
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE(void) check_utf8_allow_null(bool check_utf8_allow_null);
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE(bool) check_utf8_allow_null() const;
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE(void) check_dollar_keys(bool check_dollar_keys);
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE(bool) check_dollar_keys() const;
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE(void) check_dot_keys(bool check_dot_keys);
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE(bool) check_dot_keys() const;
private:
struct impl;
std::unique_ptr<impl> _impl;
};
} // namespace v_noabi
} // namespace bsoncxx
namespace bsoncxx {
using v_noabi::validate;
} // namespace bsoncxx
#include <bsoncxx/config/postlude.hpp>
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.