BDE 4.14.0 Production release
Loading...
Searching...
No Matches
balber::BerUtil Struct Reference

#include <balber_berutil.h>

Public Types

enum  { k_INDEFINITE_LENGTH = -1 , BDEM_INDEFINITE_LENGTH = k_INDEFINITE_LENGTH , INDEFINITE_LENGTH = k_INDEFINITE_LENGTH }
 

Static Public Member Functions

static int getEndOfContentOctets (bsl::streambuf *streamBuf, int *accumNumBytesConsumed)
 
static int getIdentifierOctets (bsl::streambuf *streamBuf, BerConstants::TagClass *tagClass, BerConstants::TagType *tagType, int *tagNumber, int *accumNumBytesConsumed)
 
static int getLength (bsl::streambuf *streamBuf, int *result, int *accumNumBytesConsumed)
 
template<typename TYPE >
static int getValue (bsl::streambuf *streamBuf, TYPE *value, int length, const BerDecoderOptions &options=BerDecoderOptions())
 
template<typename TYPE >
static int getValue (bsl::streambuf *streamBuf, TYPE *value, int *accumNumBytesConsumed, const BerDecoderOptions &options=BerDecoderOptions())
 
static int putEndOfContentOctets (bsl::streambuf *streamBuf)
 
static int putIdentifierOctets (bsl::streambuf *streamBuf, BerConstants::TagClass tagClass, BerConstants::TagType tagType, int tagNumber)
 
static int putIndefiniteLengthOctet (bsl::streambuf *streamBuf)
 
static int putLength (bsl::streambuf *streamBuf, int length)
 
template<typename TYPE >
static int putValue (bsl::streambuf *streamBuf, const TYPE &value, const BerEncoderOptions *options=0)
 

Detailed Description

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.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
k_INDEFINITE_LENGTH 
BDEM_INDEFINITE_LENGTH 
INDEFINITE_LENGTH 

Member Function Documentation

◆ getEndOfContentOctets()

int balber::BerUtil::getEndOfContentOctets ( bsl::streambuf *  streamBuf,
int *  accumNumBytesConsumed 
)
inlinestatic

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.

◆ getIdentifierOctets()

static int balber::BerUtil::getIdentifierOctets ( bsl::streambuf *  streamBuf,
BerConstants::TagClass tagClass,
BerConstants::TagType tagType,
int *  tagNumber,
int *  accumNumBytesConsumed 
)
static

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.

◆ getLength()

int balber::BerUtil::getLength ( bsl::streambuf *  streamBuf,
int *  result,
int *  accumNumBytesConsumed 
)
inlinestatic

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.

◆ getValue() [1/2]

template<typename TYPE >
int balber::BerUtil::getValue ( bsl::streambuf *  streamBuf,
TYPE *  value,
int *  accumNumBytesConsumed,
const BerDecoderOptions options = BerDecoderOptions() 
)
inlinestatic

Decode the specified value from the specified streamBuf and add the number of bytes consumed to the specified accumNumBytesConsumed. Return 0 on success, and a non-zero value otherwise. Optionally specify decoding options to control aspects of the decoding. Note that the value consists of the length and contents primitives. Also note that only fundamental C++ types, bsl::string, and BDE date/time types are supported.

◆ getValue() [2/2]

template<class TYPE >
int balber::BerUtil::getValue ( bsl::streambuf *  streamBuf,
TYPE *  value,
int  length,
const BerDecoderOptions options = BerDecoderOptions() 
)
inlinestatic

Decode the specified value from the specified streamBuf, consuming exactly the specified length bytes. Return 0 on success, and a non-zero value otherwise. Optionally specify decoding options to control aspects of the decoding. Note that the value consists of the contents bytes only (no length prefix). Also note that only fundamental C++ types, bsl::string, and BDE date/time types are supported.

◆ putEndOfContentOctets()

int balber::BerUtil::putEndOfContentOctets ( bsl::streambuf *  streamBuf)
inlinestatic

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.

◆ putIdentifierOctets()

static int balber::BerUtil::putIdentifierOctets ( bsl::streambuf *  streamBuf,
BerConstants::TagClass  tagClass,
BerConstants::TagType  tagType,
int  tagNumber 
)
static

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.

◆ putIndefiniteLengthOctet()

int balber::BerUtil::putIndefiniteLengthOctet ( bsl::streambuf *  streamBuf)
inlinestatic

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.

◆ putLength()

int balber::BerUtil::putLength ( bsl::streambuf *  streamBuf,
int  length 
)
inlinestatic

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.

◆ putValue()

template<typename TYPE >
int balber::BerUtil::putValue ( bsl::streambuf *  streamBuf,
const TYPE &  value,
const BerEncoderOptions options = 0 
)
inlinestatic

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.


The documentation for this struct was generated from the following file: