BDE 4.14.0 Production release
|
Functions | |
balber::BerDecoder::MemOutStream::MemOutStream (bslma::Allocator *basicAllocator=0) | |
void | balber::BerDecoder::MemOutStream::reset () |
Reset the internal streambuf to the empty state. | |
const char * | balber::BerDecoder::MemOutStream::data () const |
int | balber::BerDecoder::MemOutStream::length () const |
Provide a BER decoder class.
This component defines a single class, balber::BerDecoder
, that contains a parameterized decode
function. The decode
function decodes data read from a specified stream and loads the corresponding object to an object of the parameterized type. The decode
method is overloaded for two types of input streams:
bsl::streambuf
bsl::istream
This class decodes objects based on the X.690 BER specification and is restricted to types supported by the bdlat
framework.
This section illustrates intended use of this component.
Suppose that an "employee record" consists of a sequence of attributes – name
, age
, and salary
– that are of types bsl::string
, int
, and float
, respectively. Furthermore, we have a need to BER encode employee records as a sequence of values (for out-of-process consumption).
Assume that we have defined a usage::EmployeeRecord
class to represent employee record values, and assume that we have provided the bdlat
specializations that allow the balber
codec components to represent class values as a sequence of BER primitive values. See {bdlat_sequencefunctions |Usage} for details of creating specializations for a sequence type.
First, we create an employee record object having typical values:
Next, we create a balber::Encoder
object and use it to encode our bob
object. Here, to facilitate the examination of our results, the BER encoding data is delivered to a bslsb::MemOutStreamBuf
object:
Now, we create a bdlsb::FixedMemInStreamBuf
object to manage our access to the data portion of the bdlsb::MemOutStreamBuf
(where our BER encoding resides), decode the values found there, and use them to set the value of an usage::EmployeeRecord
object.
Finally, we confirm that the object defined by the BER encoding has the same value as the original object.
|
inline |
Return a pointer to the memory containing the formatted values formatted to this stream. The data is not null-terminated unless a null character was appended onto this stream.
|
inline |
Return the length of the formatted data, including null characters appended to the stream, if any.
|
inline |
Create a stream object. Optionally specify a basicAllocator
used to supply memory. If basicAllocator
is 0, the currently installed default allocator is used.
|
inline |