-
Notifications
You must be signed in to change notification settings - Fork 543
CXX-2745 add v1 forward headers and component files (bsoncxx) #1336
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
/// | ||
/// @attention This feature is experimental! It is not ready for use! | ||
/// | ||
enum class binary_subtype : std::uint8_t {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider moving binary_subtype
into the types
namespace to colocate with b_binary
. I expect it is mainly used to create a b_binary
.
/// @param X the user-defined macro to be expanded. | ||
/// | ||
// clang-format off | ||
#define BSONCXX_V1_BINARY_SUBTYPES_XMACRO(X) \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest making the X-macros private. I expect the binary subtype macro will expand in the future (e.g. CXX-3077 adds subtype 9). I expect adding a value could be considered an API break.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe there is still value to providing these X-macros as part of the public API.
Added documentation clarifying the compatibility guidelines for using X-macros with the following admonition:
Important
The addition of new expansions to this X-macro ARE NOT considered an API breaking change.
The modification or removal of existing expansions to this X-macro ARE considered an API breaking change.
This X-macro MUST be used in a manner that is compatible with these API compatibility guidelines!
In short, users are expected to use these X-macros in a manner that accounts for the possibility of extension.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I interpret "element" to mean "key/value pair" from https://bsonspec.org/spec.html. But the b_*
structs only represent the "value" part of the pair.
Consider renaming element.hpp
to types.hpp
.
Closing due to significant refactors required to accomodate proposed refactors for |
Summary
An intermediate PR related to CXX-2745 following #1318 and #1323.
This PR is focused on adding (non-internal) component files, implementing forward declarations, and adding API documentation stubs for bsoncxx v1 interfaces to be implemented in upcoming PRs. This PR is a "lightweight" preview of the bsoncxx v1 interface, file structure, and corresponding API documentation. The v1 interfaces themselves (data members, member functions, and non-member functions) will be implemented in a followup PR.
Relative Changelog (v1 <- v_noabi)
Additional Features
BSONCXX_V1_TYPES_XMACRO
andBSONCXX_V1_BINARY_SUBTYPES_XMACRO
.#include
pattern.binary_sub_type
tobinary_subtype
for terminology consistency (e.g. Drivers Specifications, MongoDB Manual, and BSON Spec).bsoncxx::v1::error
for user-facing error conditions. (CXX-834)mongoc_error_domain_t
.mongoc_error_domain_t
,bsoncxx::v_noabi::error_code
, etc.).Changed Features
types/bson_value/
(v_noabi) are moved up intotypes/
(v1).types/value.hpp
(v_noabi) was removed in CXX-3158.types/view.hpp
(v1) <-types/bson_value/view.hpp
(v_noabi)types/value.hpp
(v1) <-types/bson_value/value.hpp
(v_noabi)bson_value
is removed to avoid confusion with highly overloaded "value" terminology.types/element.hpp
.types.hpp
.array/
anddocument/
components.types.hpp
(v_noabi) andtypes/*.hpp
(v_noabi) headers.exception/exception.hpp
(v_noabi) andexception/error_code.hpp
(v_noabi) into a singleexception.hpp
(v1) header.Removed Features
enums/*.hpp
.types-fwd.hpp
.view_or_value.hpp
. (CXX-1827)std::string
andstd::string_view
.string/to_string.hpp
.stdx::string_view
emulatingexplicit std::string::string(std::string_view)
.Skipped/Deferred Features
to_v1()
(to be explored in further detail in upcoming PRs; see this comment for a preview of the expected pattern).Absolute Changelog (v_noabi)
API Documentation
Stubs
Deliberately kept minimal at the moment.
All forward-declared v1 interfaces are currently labeled with the following message:
This message will be updated as their interfaces are filled and implemented going forward.
Embedded API Examples
\par "Example"
and Markdown codeblocks when a dedicated API Examples page is not necessary.Component File Structure
A component's headers are always included before any other header to mitigate against dependency resolution via transitive inclusion.
foo-fwd.hpp
) is at the top of the component header hierarchy.foo.hpp
) includes the forward header first.foo.hh
) includes the normal header first.foo.cpp
) includes the internal or normal header first.This is enforced by inserting a blank
//
comment between the component header and other dependency headers, including macro guard headers.The source file contains out-of-line definitions for interfaces provided by both the normal and internal header. Non-trivial function definitions or those which introduce additional header dependencies should preferably be moved into implementation files to minimize cost of (re)compilation when such headers are updated (keep the include dependency graph "wide" rather than "tall").