mongo-cxx-driver
mongo-cxx-driver copied to clipboard
CXX-3232 add bsoncxx v1 declarations
Resolves CXX-3232. Followup to https://github.com/mongodb/mongo-cxx-driver/pull/1318, https://github.com/mongodb/mongo-cxx-driver/pull/1401, and https://github.com/mongodb/mongo-cxx-driver/pull/1402.
This is 2 out of an estimated 7 major PRs which in total are expected to resolve CXX-2745.
- [x] Top-Level Dependencies (CXX-3239)
- [ ] bsoncxx v1 Interfaces (CXX-3232) (<-- you are here)
- [ ] bsoncxx v1 Implementations (CXX-3233)
- [ ] bsoncxx v_noabi Refactor (CXX-3234)
- [ ] mongocxx v1 Interfaces (CXX-3236)
- [ ] mongocxx v1 Implementations (CXX-3237)
- [ ] mongocxx v_noabi Refactor (CXX-3238)
This PR introduces the very first set of v1 ABI exported symbols. 🎉
... only because MSVC complains otherwise. The rest will come as planned in CXX-3233 (impls).
Due to the volume of changes relative to the equivalent v_noabi interfaces, the bulk of relative changelog (v_noabi -> v1) and rationale for design decisions are documented inline as GitHub comments (coincidentally, exactly 100 comments in total).
In summary, notable changes include:
- General Notes
- Nearly all preconditions are now documented and well-defined to instead throw an exception or yield an "invalid" state.
- Narrowing casts and discarded return values are now thoroughly accounted for as new error codes.
- All potentially-thrown exceptions are now documented and include the list of error codes which may be thrown.
v1::error- All exceptions thrown by library components have a corresponding error code enumeration declared in
v1::errorwith corresponding error category declared inv1::error::category. - Error conditions
sourceandtypeare provided as the primary user-facing error code query mechanism when component-specific error codes are not necessary.
- All exceptions thrown by library components have a corresponding error code enumeration declared in
v1::types::b_*- All types are now consistently non-aggregate for list-initialization consistency.
- All "single underlying value" types now consistently support implicit conversion to said value.
- Multi-argument constructors are no longer explicit (always favored over
value).
v1::types::view- This type is now semitrivial (no user-provided non-default special member functions).
- Conversion to this type is now favored over conversion to
valuewhen applicable.
v1::types::value- All (non-default) constructors are now explicit (
b_*is always favored) so eitherb_*orview(cheap) is always preferred tovalue(expensive) when applicable. v1::types::idconstructors are removed in favor ofb_*and converting constructors.- "Inline PIMPL" avoids redundant allocation while preserving encapsulation.
- All (non-default) constructors are now explicit (
v1::element::view- The "invalid" state is now clarified and thoroughly documented.
- "Inline PIMPL" leaves room for an alternative
bool-based approach to "missing field" diagnostics (CXX-2120). - Although not semitrivial, the class is still nothrow copyable.
- Equality comparison is defined as "same field in same BSON binary data". Relational comparison is also possible but deferred for now.
v1::document::view- Now supports an "invalid" state without underlying BSON binary data.
v1::array::view- Now (nearly) completely defined in terms of
v1::document::view. - API is extended for better parity with
v1::document::view(CXX-2118).
- Now (nearly) completely defined in terms of
v1::document::value- Now default-constructible (CXX-939), equivalent to an "invalid"
v1::document::view. deleter_typeis now astd::function<T>instead of a function pointer.- Customization points for
to_bsonandfrom_bsonare now properly constrained.
- Now default-constructible (CXX-939), equivalent to an "invalid"
v1::array::value- Now (nearly) completely defined in terms of
v1::document::value. - API is extended for better parity with
v1::document::value(CXX-2118).
- Now (nearly) completely defined in terms of