BDE 4.39.x Production Release
Loading...
Searching...
No Matches
balxml::Encoder Class Reference

#include <balxml_encoder.h>

Detailed Description

This class contains the parameterized encode functions that encode bdlat types in XML format.

See balxml_encoder

Public Member Functions

 BSLMF_NESTED_TRAIT_DECLARATION (Encoder, bslma::UsesBslmaAllocator)
 
 Encoder (const EncoderOptions *options, bslma::Allocator *basicAllocator)
 
 Encoder (const EncoderOptions *options, bsl::ostream *errorStream=0, bsl::ostream *warningStream=0, bslma::Allocator *basicAllocator=0)
 
 ~Encoder ()
 
template<class TYPE >
int encode (bsl::streambuf *buffer, const TYPE &object)
 
template<class TYPE >
int encodeToStream (bsl::ostream &stream, const TYPE &object)
 
template<class TYPE >
bsl::ostream & encode (bsl::ostream &stream, const TYPE &object)
 
template<class TYPE >
int encode (Formatter &formatter, const TYPE &object)
 
template<class TYPE >
int encodeAny (bsl::streambuf *buffer, const TYPE &object)
 
int encodeAny (bsl::streambuf *buffer, const bdlar::AnyConstRef &object)
 
template<class TYPE >
int encodeAnyToStream (bsl::ostream &stream, const TYPE &object)
 
int encodeAnyToStream (bsl::ostream &stream, const bdlar::AnyConstRef &object)
 
template<class TYPE >
bsl::ostream & encodeAny (bsl::ostream &stream, const TYPE &object)
 
bsl::ostream & encodeAny (bsl::ostream &stream, const bdlar::AnyConstRef &object)
 
template<class TYPE >
int encodeAny (Formatter &formatter, const TYPE &object)
 
int encodeAny (Formatter &formatter, const bdlar::AnyConstRef &object)
 
const EncoderOptionsoptions () const
 
bool isCompact () const
 
bsl::ostream * errorStream () const
 
bsl::ostream * warningStream () const
 
ErrorInfo::Severity errorSeverity () const
 
bslstl::StringRef loggedMessages () const
 

Friends

class Encoder_Context
 

Constructor & Destructor Documentation

◆ Encoder() [1/2]

balxml::Encoder::Encoder ( const EncoderOptions options,
bslma::Allocator basicAllocator 
)

◆ Encoder() [2/2]

balxml::Encoder::Encoder ( const EncoderOptions options,
bsl::ostream *  errorStream = 0,
bsl::ostream *  warningStream = 0,
bslma::Allocator basicAllocator = 0 
)

Construct a encoder object using the specified options. Errors and warnings will be rendered to the optionally specified errorStream and warningStream respectively.

◆ ~Encoder()

balxml::Encoder::~Encoder ( )

Destroy this object. This destruction has no effect on objects pointed-to by the pointers provided at construction.

Member Function Documentation

◆ BSLMF_NESTED_TRAIT_DECLARATION()

balxml::Encoder::BSLMF_NESTED_TRAIT_DECLARATION ( Encoder  ,
bslma::UsesBslmaAllocator   
)

◆ encode() [1/3]

template<class TYPE >
bsl::ostream & balxml::Encoder::encode ( bsl::ostream &  stream,
const TYPE &  object 
)
inline

Encode the specified non-modifiable object to the specified stream. Return a reference to stream. If an encoding error is detected, stream.fail() will be true on return.

Note
Note that the encoder will use encoder options, error and warning streams specified at the construction time. IMPORTANT: The use of stream.fail() to communicate errors to the caller has two consequences: 1) if stream is the same as the errorStream passed to the constructor, then the error message may be suppressed (because of the output/error stream becoming invalidated) and 2) it is important to call stream.clear() after testing the stream state. To avoid these issues, we recommend that you use use encodeToStream, above, instead of this version of encode.

◆ encode() [2/3]

template<class TYPE >
int balxml::Encoder::encode ( bsl::streambuf *  buffer,
const TYPE &  object 
)
inline

Encode the specified non-modifiable object to the specified buffer. Return 0 on success, and a non-zero value otherwise.

Note
Note that the encoder will use encoder options, error and warning streams specified at the construction time.

◆ encode() [3/3]

template<class TYPE >
int balxml::Encoder::encode ( Formatter formatter,
const TYPE &  object 
)

Encode the specified non-modifiable object to the specified formatter. Return 0 on success, and a non-zero value otherwise.

Note
Note that encoder will use encoder options, error and warning streams specified at the construction time.

◆ encodeAny() [1/6]

bsl::ostream & balxml::Encoder::encodeAny ( bsl::ostream &  stream,
const bdlar::AnyConstRef object 
)

◆ encodeAny() [2/6]

template<class TYPE >
bsl::ostream & balxml::Encoder::encodeAny ( bsl::ostream &  stream,
const TYPE &  object 
)
inline

Encode the specified non-modifiable object to the specified stream. Return a reference to stream. If an encoding error is detected, stream.fail() will be true on return.

Note
Note that the encoder will use encoder options, error and warning streams specified at the construction time. Also note that this function behaves identically to encode, but does not instantiate any templates at compile time at the expense of being slightly slower at runtime; see the balxml package documentation for more details.

◆ encodeAny() [3/6]

int balxml::Encoder::encodeAny ( bsl::streambuf *  buffer,
const bdlar::AnyConstRef object 
)

◆ encodeAny() [4/6]

template<class TYPE >
int balxml::Encoder::encodeAny ( bsl::streambuf *  buffer,
const TYPE &  object 
)
inline

Encode the specified non-modifiable object to the specified buffer. Return 0 on success, and a non-zero value otherwise.

Note
Note that the encoder will use encoder options, error and warning streams specified at the construction time. Also note that this function behaves identically to encode, but does not instantiate any templates at compile time at the expense of being slightly slower at runtime; see the balxml package documentation for more details.

◆ encodeAny() [5/6]

int balxml::Encoder::encodeAny ( Formatter formatter,
const bdlar::AnyConstRef object 
)

◆ encodeAny() [6/6]

template<class TYPE >
int balxml::Encoder::encodeAny ( Formatter formatter,
const TYPE &  object 
)
inline

Encode the specified non-modifiable object to the specified formatter. Return 0 on success, and a non-zero value otherwise.

Note
Note that encoder will use encoder options, error and warning streams specified at the construction time. Also note that this function behaves identically to encode, but does not instantiate any templates at compile time at the expense of being slightly slower at runtime; see the balxml package documentation for more details.

◆ encodeAnyToStream() [1/2]

int balxml::Encoder::encodeAnyToStream ( bsl::ostream &  stream,
const bdlar::AnyConstRef object 
)
inline

◆ encodeAnyToStream() [2/2]

template<class TYPE >
int balxml::Encoder::encodeAnyToStream ( bsl::ostream &  stream,
const TYPE &  object 
)
inline

Encode the specified non-modifiable object to the specified stream. Return 0 on success, and a non-zero value otherwise.

Note
Note that the encoder will use encoder options, error and warning streams specified at the construction time. Also note that this function behaves identically to encodeToStream, but does not instantiate any templates at compile time at the expense of being slightly slower at runtime; see the balxml package documentation for more details.

◆ encodeToStream()

template<class TYPE >
int balxml::Encoder::encodeToStream ( bsl::ostream &  stream,
const TYPE &  object 
)
inline

Encode the specified non-modifiable object to the specified stream. Return 0 on success, and a non-zero value otherwise.

Note
Note that the encoder will use encoder options, error and warning streams specified at the construction time.

◆ errorSeverity()

ErrorInfo::Severity balxml::Encoder::errorSeverity ( ) const
inline

Return the severity of the most severe warning or error encountered during the last call to the encode method. The severity is reset each time encode is called.

◆ errorStream()

bsl::ostream * balxml::Encoder::errorStream ( ) const
inline

Return pointer to the error stream.

◆ isCompact()

bool balxml::Encoder::isCompact ( ) const
inline

Return true if the encoding style in the encoder options is defined as EncodingStyle::BAEXML_COMPACT, and false otherwise.

◆ loggedMessages()

bslstl::StringRef balxml::Encoder::loggedMessages ( ) const
inline

Return a string containing any error, warning, or trace messages that were logged during the last call to the encode method. The log is reset each time encode is called.

◆ options()

const EncoderOptions * balxml::Encoder::options ( ) const
inline

Return the encoder options.

◆ warningStream()

bsl::ostream * balxml::Encoder::warningStream ( ) const
inline

Return pointer to the warning stream.

Friends And Related Symbol Documentation

◆ Encoder_Context

friend class Encoder_Context
friend

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