BDE 4.14.0 Production release
Loading...
Searching...
No Matches
balxml::Encoder Class Reference

#include <balxml_encoder.h>

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)
 
const EncoderOptionsoptions () const
 Return the encoder options.
 
bool isCompact () const
 
bsl::ostream * errorStream () const
 Return pointer to the error stream.
 
bsl::ostream * warningStream () const
 Return pointer to the warning stream.
 
ErrorInfo::Severity errorSeverity () const
 
bslstl::StringRef loggedMessages () const
 

Friends

class Encoder_Context
 

Detailed Description

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

See balxml_encoder

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 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 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 that encoder will use encoder options, error and warning streams specified at the construction time.

◆ 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 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

◆ 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

◆ warningStream()

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

Friends And Related Symbol Documentation

◆ Encoder_Context

friend class Encoder_Context
friend

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