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

#include <balber_berutil.h>

Public Types

typedef BerUtil_Constants Constants
 
typedef BerUtil_LengthImpUtil LengthImpUtil
 
typedef BerUtil_RawIntegerImpUtil RawIntegerUtil
 
typedef BerUtil_StreambufUtil StreambufUtil
 

Public Member Functions

template<typename TYPE >
int getNumOctetsToStream (TYPE value)
 
template<typename TYPE >
int getIntegerValue (TYPE *value, bsl::streambuf *streamBuf, int length)
 
template<typename TYPE >
int putIntegerValue (bsl::streambuf *streamBuf, TYPE value)
 
template<typename TYPE >
int putIntegerGivenLength (bsl::streambuf *streamBuf, TYPE value, int length)
 

Static Public Member Functions

static int getNumOctetsToStream (short value)
 
static int getNumOctetsToStream (int value)
 
static int getNumOctetsToStream (long long value)
 
template<class INTEGRAL_TYPE >
static int getNumOctetsToStream (INTEGRAL_TYPE value)
 
static int getIntegerValue (long long *value, bsl::streambuf *streamBuf, int length)
 
template<class INTEGRAL_TYPE >
static int getIntegerValue (INTEGRAL_TYPE *value, bsl::streambuf *streamBuf, int length)
 
static int get40BitIntegerValue (bsls::Types::Int64 *value, bsl::streambuf *streamBuf)
 
template<class INTEGRAL_TYPE >
static int putIntegerValue (bsl::streambuf *streamBuf, INTEGRAL_TYPE value)
 
static int put40BitIntegerValue (bsl::streambuf *streamBuf, bsls::Types::Int64 value)
 
template<class INTEGRAL_TYPE >
static int putIntegerGivenLength (bsl::streambuf *streamBuf, INTEGRAL_TYPE value, int length)
 

Static Public Attributes

static const int k_40_BIT_INTEGER_LENGTH = 5
 Number of octets used to encode a signed integer value in 40 bits.
 

Detailed Description

This component-private utility struct provides a namespace for a suite of functions used by BerUtil to implement BER encoding and decoding operations for integer values. Within the definition of this struct:

: the specification: : Refers to the August 2015 revision of the ITU-T Recommendation X.690.

Member Typedef Documentation

◆ Constants

Constants is an alias to a namespace for a suite of general-purpose constants that occur when encoding or decoding BER data.

◆ LengthImpUtil

LengthUtil is an alias to a namespace for a suite of functions used to implement BER encoding and decoding operations for length quantities.

◆ RawIntegerUtil

RawIntegerUtil is an alias to a namespace for a suite of low-level functions used to implement BER encoding operations for integer values.

◆ StreambufUtil

StreambufUtil is an alias to a namespace for a suite of functions used to implement input and output operations on bsl::streambuf objects.

Member Function Documentation

◆ get40BitIntegerValue()

int balber::BerUtil_IntegerImpUtil::get40BitIntegerValue ( bsls::Types::Int64 value,
bsl::streambuf *  streamBuf 
)
inlinestatic

Read 5 bytes from the input sequence of the specified streamBuf and load to the specified value the interpretation of those bytes as a 40-bit, signed, 2's-complement, big-endian integer. Return 0 if successful, and a non-zero value otherwise. The operation succeeds if all 5 bytes are successfully read from the input sequence of the streamBuf without the read position becoming unavailable, and the bytes read contain a valid representation of a 40-bit, signed, 2's-complement, big-endian integer.

◆ getIntegerValue() [1/3]

template<class INTEGRAL_TYPE >
static int balber::BerUtil_IntegerImpUtil::getIntegerValue ( INTEGRAL_TYPE *  value,
bsl::streambuf *  streamBuf,
int  length 
)
static

Read the specified length number of bytes from the input sequence of the specified streamBuf and load to the specified value the interpretation of those bytes as the contents octets of BER-encoded integer value according to the specification. Return 0 if successful, and a non-zero value otherwise. The operation succeeds if length bytes are successfully read from the input sequence of the streamBuf without the read position becoming unavailable, and the bytes read contain a valid representation of the contents octets of an integer value according to the specification. The program is ill-formed unless the specified INTEGRAL_TYPE is a fundamental integral type.

◆ getIntegerValue() [2/3]

static int balber::BerUtil_IntegerImpUtil::getIntegerValue ( long long *  value,
bsl::streambuf *  streamBuf,
int  length 
)
static

Read the specified length number of bytes from the input sequence of the specified streamBuf and load to the specified value the interpretation of those bytes as the contents octets of a BER-encoded integer value according to the specification. Return 0 if successful, and a non-zero value otherwise.

◆ getIntegerValue() [3/3]

template<typename TYPE >
int balber::BerUtil_IntegerImpUtil::getIntegerValue ( TYPE *  value,
bsl::streambuf *  streamBuf,
int  length 
)

◆ getNumOctetsToStream() [1/5]

static int balber::BerUtil_IntegerImpUtil::getNumOctetsToStream ( int  value)
static

◆ getNumOctetsToStream() [2/5]

template<class INTEGRAL_TYPE >
static int balber::BerUtil_IntegerImpUtil::getNumOctetsToStream ( INTEGRAL_TYPE  value)
static

Return the number of octets required to provide a BER encoding of the specified value according to the specification. The program is ill-formed unless the specified INTEGRAL_TYPE is a fundamental integral type.

◆ getNumOctetsToStream() [3/5]

static int balber::BerUtil_IntegerImpUtil::getNumOctetsToStream ( long long  value)
static

Return the number of octets required to provide a BER encoding of the specified value according to the specification.

◆ getNumOctetsToStream() [4/5]

static int balber::BerUtil_IntegerImpUtil::getNumOctetsToStream ( short  value)
static

◆ getNumOctetsToStream() [5/5]

template<typename TYPE >
int balber::BerUtil_IntegerImpUtil::getNumOctetsToStream ( TYPE  value)

◆ put40BitIntegerValue()

int balber::BerUtil_IntegerImpUtil::put40BitIntegerValue ( bsl::streambuf *  streamBuf,
bsls::Types::Int64  value 
)
inlinestatic

Write the 5 octets that comprise the 40-bit, signed, 2's-complement, bit-endian representation of the specified integer value to the specified streamBuf. Return 0 if successful, and a non-zero value otherwise. The operation succeeds if all bytes corresponding to the representation of the value are written to the streamBuf without the write position becoming unavailable. The behavior is undefined unless the value is in the half-open interval [-549755813888, 549755813888).

Implementation Note

This implementation requires the platform use a 2's complement representation for signed integer values.

◆ putIntegerGivenLength() [1/2]

template<class INTEGRAL_TYPE >
static int balber::BerUtil_IntegerImpUtil::putIntegerGivenLength ( bsl::streambuf *  streamBuf,
INTEGRAL_TYPE  value,
int  length 
)
static

Write exactly the specified length number of contents octets of the BER encoding of the specified integer value (as defined in the specification) to the output sequence of the specified streamBuf. Return 0 if successful, and a non-zero value otherwise. The operation succeeds if all bytes corresponding to the contents octets are written to the streamBuf without the write position becoming unavailable. The behavior is undefined unless there are exactly length number of contents octets used to encode the integer value according to the specification. The program is ill-formed unless the specified INTEGRAL_TYPE is a fundamental integral type.

◆ putIntegerGivenLength() [2/2]

template<typename TYPE >
int balber::BerUtil_IntegerImpUtil::putIntegerGivenLength ( bsl::streambuf *  streamBuf,
TYPE  value,
int  length 
)

◆ putIntegerValue() [1/2]

template<class INTEGRAL_TYPE >
static int balber::BerUtil_IntegerImpUtil::putIntegerValue ( bsl::streambuf *  streamBuf,
INTEGRAL_TYPE  value 
)
static

Write the length and contents octets of the BER encoding of the specified integer value (as defined in the specification) to the output sequence of the specified streamBuf. Return 0 if successful, and a non-zero value otherwise. The operation succeeds if all bytes corresponding to the length and contents octets are written to the streamBuf without the write position becoming unavailable. The program is ill-formed unless the specified INTEGRAL_TYPE is a fundamental integral type.

◆ putIntegerValue() [2/2]

template<typename TYPE >
int balber::BerUtil_IntegerImpUtil::putIntegerValue ( bsl::streambuf *  streamBuf,
TYPE  value 
)

Member Data Documentation

◆ k_40_BIT_INTEGER_LENGTH

const int balber::BerUtil_IntegerImpUtil::k_40_BIT_INTEGER_LENGTH = 5
static

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