[#BloombergLP-balber-BerUtil] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/balber.adoc[balber]::BerUtil :relfileprefix: ../../ :mrdocs: This utility contains functions to encode and decode primitive BER constructs and simple value semantic types. By convention, all functions return 0 on success, and a non‐zero value otherwise. Also by convention, all the "get" functions take an `accumNumBytesConsumed`; each of the functions will add to this variable the number of bytes consumed within the scope of the function. == Synopsis Declared in `<balber_berutil.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- struct BerUtil; ---- == Enums [cols="1,4"] |=== | Name| Description | xref:BloombergLP/balber/BerUtil/_04enum.adoc[`Unnamed enum`] | Length sentinel indicating an indefinite BER element length. |=== == Static Member Functions [cols="1,4"] |=== | Name| Description | xref:BloombergLP/balber/BerUtil/getEndOfContentOctets.adoc[`getEndOfContentOctets`] | Decode the "end‐of‐content" octets (two consecutive zero‐octets) from the specified `streamBuf` and add the number of bytes consumed (which is always 2) to the specified `accumNumBytesConsumed`. Return 0 on success, and a non‐zero value otherwise. | xref:BloombergLP/balber/BerUtil/getIdentifierOctets.adoc[`getIdentifierOctets`] | Decode the identifier octets from the specified `streamBuf` and load the tag class, tag type, and tag number to the specified `tagClass`, `tagType`, and `tagNumber` respectively. Add the number of bytes consumed to the specified `accumNumBytesConsumed`. Return 0 on success, and a non‐zero value otherwise. | xref:BloombergLP/balber/BerUtil/getLength.adoc[`getLength`] | Decode the length octets from the specified `streamBuf` and load the result to the specified `result`. If the length is indefinite (i.e., contents will be terminated by "end‐of‐content" octets) then `result` will be set to `k_INDEFINITE_LENGTH`. Add the number of bytes consumed to the specified `accumNumBytesConsumed`. Return 0 on success, and a non‐zero value otherwise. | xref:BloombergLP/balber/BerUtil/getValue-0b.adoc[`getValue`] | `getValue` overloads | xref:BloombergLP/balber/BerUtil/putEndOfContentOctets.adoc[`putEndOfContentOctets`] | Encode the "end‐of‐content" octets (two consecutive zero‐octets) to the specified `streamBuf`. The "end‐of‐content" octets act as the termination bytes for objects that have indefinite length. Return 0 on success, and a non‐zero value otherwise. | xref:BloombergLP/balber/BerUtil/putIdentifierOctets.adoc[`putIdentifierOctets`] | Encode the identifier octets for the specified `tagClass`, `tagType` and `tagNumber` to the specified `streamBuf`. Return 0 on success, and a non‐zero value otherwise. | xref:BloombergLP/balber/BerUtil/putIndefiniteLengthOctet.adoc[`putIndefiniteLengthOctet`] | Encode the "indefinite‐length" octet onto the specified `streamBuf`. This octet signifies that the length of the contents is indefinite (i.e., contents will be terminated by end of content octets). Return 0 on success, and a non‐zero value otherwise. | xref:BloombergLP/balber/BerUtil/putLength.adoc[`putLength`] | Encode the specified `length` to the specified `streamBuf`. Return 0 on success, and a non‐zero value otherwise. The behavior is undefined unless `0 <= length`. | xref:BloombergLP/balber/BerUtil/putValue.adoc[`putValue`] | Encode the specified `value` to the specified `streamBuf`. Return 0 on success, and a non‐zero value otherwise. Note that the value consists of the length and contents primitives. Also note that only fundamental C++ types, `bsl::string`, `bsl::string_view`, `bslstl::StringRef`, and BDE date/time types are supported. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#