mongo-cxx-driver icon indicating copy to clipboard operation
mongo-cxx-driver copied to clipboard

v1: uri (CXX-3237, CXX-3238)

Open eramongodb opened this issue 1 week ago • 0 comments

Resolves CXX-3237 and CXX-3238 for the v1::uri component.

To continue to support implicit conversion from e.g. char const* -> string::view_or_value without ambiguity with the v1 ctor (because v1::uri also has a non-explicit string_view ctor), a constrained non-explicit constructor template is added to have higher priority for convertible-to-string::view_or_value arguments than the non-explicit v1 ctor.

This PR also adds /Zc:strictStrings (part of /permissive-, which we do not yet enable) to avoid non-conforming behavior with MSVC which interacts poorly with our void* ctor (even when private or explicit). This flag is applied to mongocxx library (and test) builds only and is not inherited by users. We can consider adding a char const* ctor instead, but I'd prefer depending on and encouraging standard conformance instead.

Additional notes:

  • Fix missing const qualifiers for getters overlooked by https://github.com/mongodb/mongo-cxx-driver/pull/1482.
  • Try to use new mongoc URI API when able.
  • Try to use v1 bsoncxx API instead of bson when able; however, cannot use bsoncxx for URI field lookup due to backward compatibility with case (in)sensitivity lookups. Not all options may support canonicalization into lowercase form.
  • v_noabi::uri remains non-copyable for backward compatibility despite v1::uri being copyable.

eramongodb avatar Dec 12 '25 17:12 eramongodb