BDE 3.113.1 Release

Schedule

  • The BDE team announces that the BDE 3.113.1 production release was completed on Monday, January 16 2023.

bdljsn Release

The bdljsn package is formally released and available. As previously announced, this package provides a document representation tailored to JSON that integrates with Bloomberg vocabulary types (BSL types, bdldfp::Decimal64).

For more information, please see The package’s release article.

BDE 3.113.1 Highlights

Caseless Comparisons Are Now Transparent

BDE 3.113 updates bdlb_caselessstringviewless bdlb_caselessstringviewequalto and bdlb_caselessstringviewhash to perform transparent comparison. This allows for comparison of container elements (typically bsl::string) with values of closely related types (like bsl::string_view) without performing a conversion, thus providing efficiency and ergonoimics in one API.

void caselessComparisonExample()
{
    bsl::set<bsl::string, bdlb::CaselessStringViewLess> stringSet;
    // Add data to set...
    auto stringLiteralResult = stringSet.find(                 "some string" );
    auto stringResult        = stringSet.find(bsl::string(     "some string"));
    auto stringViewResult    = stringSet.find(bsl::string_view("some string"));
}

Memory-conserving APIs for bdlbb::BlobUtil

The appendWithCapacityBuffer and prependWithCapacityBuffer functions were added to bdlbb::BlobUtil that allow one to respectively append and prepend data to a Blob using a portion of an externally-provided BlobBuffer if the Blob’s capacity is insufficient. These APIs allow the client to store a BlobBuffer and use pieces thereof to add small chunks of data at either end of several Blob’s representing individual messages without every Blob using their BlobBufferFactory to allocate potentially large BlobBuffer buffers whose capacity would be largely wasted.

Relaxed DateTime Parsing

New parseRelaxed functions in bdlt_iso8601util accept “relaxed” ISO 8601 formats that are a superset of the strict ISO 8601 format. Currently this allows a SPACE character to be used in place of T to separate date and time elements, a common format for PostgreSQL.

For example:

1970-01-01T00:00.000 // Strict ISO-8601 string
1970-01-01 00:00.000 // Relaxed format

bdljsn::Json Enhancements

This release brings several enhancements to the recently-introduced bdljsn package. This package provides a document representation tailored to JSON that integrates with Bloomberg vocabulary types (BSL types, bdldfp::Decimal64).

User-Defined Literal Support

The library now provides support for JSON user-defined literals, which allow programmers to write JSON strings that generate bdljsn::Json document objects. This feature pairs especially well with C++ raw string literals:

using namespace bdljsn::JsonLiterals;

bdljsn::Json json = R"({
    "number": 4,
    "array": [1, 2, null],
    "object": {
        "string": "lorem ipsum dolor sit amet."
    }
})"_json;

assert(json["object"]["string"].theString() == "lorem ipsum dolor sit amet.");

Enhanced Error Messages

We’ve improved the library’s error reporting facilities to provide human-readable descriptions of where parsing errors occur in invalid JSON documents. This is provided by the new bdljsn::JsonUtil::printError function:

const bsl::string_view invalidJson = R"({
    "a": 1,
    "b": 2,
    "c": oops,
})";

bdljsn::Json  document;
bdljsn::Error error;

int rc = bdljsn::JsonUtil::read(&document, &error, invalidJson);
assert(rc != 0);

bdljsn::JsonUtil::printError(bsl::cerr, invalidJson, error);

Prints the following to standard error:

Error (line 4, col 14): Invalid JSON Number

Embedded Documents and Multi-Document Streams

We’ve added an option to bdljsn::JsonUtil::read that permits text to follow a complete JSON document, which read will not consume when parsing from a stream. This allows some flexibility for parsing JSON documents that are embedded in larger, possibly non-JSON documents. It also allows having multiple JSON documents in a single stream. See bdljsn::ReadOptions.

Behavioral Change: Three bsl Container Adaptors

The behavior of the three bsl container adaptors has just been revised to better conform to the C++17 Standard. There is a chance that existing code may now experience compilation errors when compiled for C++17 (-std=c++17). Those cases probably require a small fix.

The three container adaptors are stack, queue, and priority_queue:

template<class VALUE, class CONTAINER = deque<VALUE> >
class stack;

template<class VALUE, class CONTAINER = deque<VALUE> >
class queue;

template<class VALUE,
         class CONTAINER = vector<VALUE>,
         class COMPARE   = less<typename CONTAINER::value_type>
> class priority_queue;

each of these adaptors has a VALUE parameter whose only role is to define CONTAINER::value_type of the default CONTAINER. This specification allows users to (accidentally) define types where VALUE and CONTAINER::value_type do not match. For example:

bsl::stack<short,       bsl::vector<int> > someStack1;
//         *****                    ^^^

bsl::stack<bsl::string, bsl::vector<int> > someStack2;
//         ***********              ^^^

Historically, the first parameter was simply ignored when the second was provided and the resulting code either worked (e,g., someStack1) or resulted in a compilation failure at the point of use, depending whether or not VALUE was convertible to CONTAINER::value_type (e.g., someStack2).

The C++17 Standard classified these mismatches as undefined behavior. Accordingly, bsl::stack, bsl::queue, and bsl::priority_queue have now been revised to mirror the behavior of their std counterparts:

  • For C++17 and later, type mismatches cause compile-time errors.

  • For older versions, the historic behavior is preserved.

Fixed requests:

Summary

bsl::optional issue with types containing non-const copy constructor

C++14: Implement equal_to<void>

C++17 work: set (and variations) noexcept specifications

C++17 work: map (and variations) noexcept specifications

C++17 work: stack, queue and priority_queue behavioral fix

C++17 work: span implementation

C++17 work: bsl::string doesn’t work with bsl::quoted

[FUZZ] ‘TimeZoneUtil::convertLocalToUtc’ corner cases

C++17 work: bsl::vector::resize adds copies instead of new default-initialized objects

C++17 work: bsl::deque<bsls::AtomicInt> does not compile

Provide a SmallBlobBufferAllocator

balb_pipecontrolchannel Documentation page corrections

C++17 work: Inconsistent move-insert behavior of ‘bsl::vector’

bslmt_threadutil: facilitate use of ‘createWithAllocator’ with detached threads

bdlde::CharConvertUtf16 doesn’t allow to query a buffer size only

bdlb_caselessstringview* functors are not transparent

Add C support for bsls_deprecatefeature

Avoid hanging in GuidUtil::generateNonSecure when system entropy is exhausted

Add support of RFC 3339 datetime format to ISO-8601 parser

C++17 work: bslstl_span.t build failure on cpp20

Add function to print error location to bdljsn::JsonUtil

bslstl_optional: Investigate use of BSLMF_MOVABLEREF_DEDUCE

Fix C++20 build on MSVC 2022

Please address bdljsn_json and bdljsn_jsonutil warnings

Support for streams with text after a complete JSON document

Add support for JSON user defined literals

Release BDE 3.113.0