CXX-3231 add v1 forward headers and component files #1401
Merged
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_XMACROandBSONCXX_V1_BINARY_SUBTYPES_XMACRO.bsoncxx::v1::errorfor 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_typeare nowtypes::id(v1) andtypes::binary_subtype(v1). A type alias for both will be provided in thev_noabinamespace 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_noabinamespace to assist with incremental upgrades.exceptionis 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::valueis left open as an owning equivalent toelement::viewand a possible successor tobuilder::basic::kvp(v_noabi) as part of the potential redesign of BSON builders.types::viewandtypes::value:documentandarrayclass types.types(v1) namespace (avoiding thetypevs.typesconfusion):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.errorandexception:errornamespace will contain declarations for error code enumerations and corresponding error categories which describe component-specific errors which may be thrown by thev1interface.sourceandtypeerror 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_noabiandv1namespaces by catchingstd::system_errorinstead of ABI-specific exception types. Thev_noabiAPI will continue to throwv_noabi::exceptioneven if the underlying implementation is refactored to usev1API for backward compatibility.