CXX-3231 add v1 forward headers and component files #1401
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves CXX-3231. Followup to #1336.
As initially attempted in #1336, this PR is a "lightweight" preview of the bsoncxx v1 interface, file structure, and corresponding API documentation. Relevant details from #1336 are copied here for locality and updated with latest changes.
BSONCXX_V1_TYPES_XMACRO
andBSONCXX_V1_BINARY_SUBTYPES_XMACRO
.bsoncxx::v1::error
for user-facing error conditions. This will be elaborated in greater detail in the followup "interfaces" PR.types::bson_value::view
(v_noabi) andtypes::bson_value::value
(v_noabi) are nowtypes::view
(v1) andtypes::value
(v1).type
(v_noabi) andbinary_sub_type
are nowtypes::id
(v1) andtypes::binary_subtype
(v1). A type alias for both will be provided in thev_noabi
namespace to assist with incremental upgrades.document::element
(v_noabi) andarray::element
(v_noabi) are now represented by a single classelement::view
. Type aliases for all three will be provided in thev_noabi
namespace to assist with incremental upgrades.exception
is now provided byexception.hpp
(v1) rather thanexception/exception.hpp
(v_noabi) to be consistent with its namespace scope.enums/*.hpp
: replaced by new X macros.exception/error_code.hpp
: folded intoexception.hpp
(v1) and replaced by component-specific error codes.string::to_string
: supported by the explicit conversion operator instdx::string_view
.view_or_value
: see CXX-1827.Details and rationale:
element::view
(andelement::value
)array
:view
+value
.document
:view
+value
.element
:view
(+value
).types
:view
+value
.element::value
is left open as an owning equivalent toelement::view
and a possible successor tobuilder::basic::kvp
(v_noabi) as part of the potential redesign of BSON builders.types::view
andtypes::value
:document
andarray
class types.types
(v1) namespace (avoiding thetype
vs.types
confusion):id
: a "BSON type" or "BSON type id", formerlytype
.binary_subtype
: a "BSON binary subtype", formerlybinary_sub_type
.b_*
: "BSON type values" (the value of a BSON element without a key).view
: a non-owning, read-only union of BSON type values.value
: an owning union of BSON type values.error
andexception
:error
namespace will contain declarations for error code enumerations and corresponding error categories which describe component-specific errors which may be thrown by thev1
interface.source
andtype
error conditions are expected to be the primary means by which users programmatically inspect the cause of thrown errors. This will be elaborated in greater detail in the upcoming "interfaces" PR.v_noabi
andv1
namespaces by catchingstd::system_error
instead of ABI-specific exception types. Thev_noabi
API will continue to throwv_noabi::exception
even if the underlying implementation is refactored to usev1
API for backward compatibility.