Quick Links:

bal | bbl | bdl | bsl

Public Types | Static Public Member Functions

baljsn::Encoder_EncodeImplUtil Struct Reference

#include <baljsn_encoder.h>

List of all members.

Public Types

typedef Encoder_EncodeImplUtil ThisUtil
typedef int FormattingMode

Static Public Member Functions

static void openDocument (bsl::ostream *outputStream, const EncoderOptions &options)
static void closeDocument (bsl::ostream *outputStream, const EncoderOptions &options)
template<class TYPE >
static int encode (bsl::ostream *jsonStream, const TYPE &value, const EncoderOptions &options=EncoderOptions())
template<class TYPE >
static int encode (bsl::ostream *logStream, bsl::ostream *jsonStream, const TYPE &value, const EncoderOptions &options=EncoderOptions())
template<class TYPE >
static int encode (bool *isValueEmpty, Formatter *formatter, bsl::ostream *logStream, const TYPE &value, FormattingMode formattingMode, const EncoderOptions &options, bool isFirstMember)
template<class TYPE >
static int validate (bsl::ostream *logStream, const TYPE &value, bdlat_TypeCategory::Choice category)
template<class TYPE , class CATEGORY >
static int validate (bsl::ostream *logStream, const TYPE &value, CATEGORY category)
template<class TYPE >
static int validateChoice (bsl::ostream *logStream, const TYPE &value)
static int encodeCharArray (Formatter *formatter, const bsl::vector< char > &value, const EncoderOptions &options)
template<class TYPE >
static int encodeSimpleValue (Formatter *formatter, const TYPE &value, const EncoderOptions &options)
static void encodeObjectPrefix (bool *isPrefixEmpty, Formatter *formatter, FormattingMode formattingMode)
static void encodeObjectSuffix (bool *isSuffixEmpty, Formatter *formatter, FormattingMode formattingMode)
static void encodeEmptyArray (Formatter *formatter)
template<class TYPE >
static int encodeNonEmptyArray (Formatter *formatter, bsl::ostream *logStream, const TYPE &value, const EncoderOptions &options)
static int encodeMember (bool *isMemberEmpty, Formatter *formatter, bsl::ostream *logStream, const bsl::string_view &memberName, const bsl::vector< char > &member, FormattingMode formattingMode, const EncoderOptions &options, bool isFirstMember, bdlat_TypeCategory::Array category)
template<class TYPE >
static int encodeMember (bool *isMemberEmpty, Formatter *formatter, bsl::ostream *logStream, const bsl::string_view &memberName, const TYPE &member, FormattingMode formattingMode, const EncoderOptions &options, bool isFirstMember, bdlat_TypeCategory::Array category)
template<class TYPE , class OTHER_CATEGORY >
static int encodeMember (bool *isMemberEmpty, Formatter *formatter, bsl::ostream *logStream, const bsl::string_view &memberName, const TYPE &member, FormattingMode formattingMode, const EncoderOptions &options, bool isFirstMember, OTHER_CATEGORY category)
static int encodeMemberPrefix (Formatter *formatter, bsl::ostream *logStream, const bsl::string_view &memberName, bool isFirstMember)
static int encodeMemberPrefix (Formatter *formatter, bsl::ostream *logStream, const bsl::string_view &memberName, FormattingMode formattingMode, bool isFirstMember)
static int encodeMemberPrefix (bool *isPrefixEmpty, Formatter *formatter, bsl::ostream *logStream, const bsl::string_view &memberName, FormattingMode formattingMode, bool isFirstMember)

Detailed Description

This component-private utility struct provides a suite of functions that encode bdlat types in the JSON format.

See Component baljsn_encoder


Member Typedef Documentation


Member Function Documentation

static void baljsn::Encoder_EncodeImplUtil::openDocument ( bsl::ostream *  outputStream,
const EncoderOptions options 
) [static]

Print the sequence of characters that designate the start of a JSON document to the specified outputStream according to the specified encoding options. See the component-level documentation of baljsn_encoderoptions for a description of the effects, if any, of each option in the options on the start of a JSON document.

static void baljsn::Encoder_EncodeImplUtil::closeDocument ( bsl::ostream *  outputStream,
const EncoderOptions options 
) [static]

Print the sequence of characters that designate the end of a JSON document to the specified outputStream according to the specified encoding options. See the component-level documentation of baljsn_encoderoptions for a description of the effects, if any, of each option in the options on the end of a JSON document.

template<class TYPE >
static int baljsn::Encoder_EncodeImplUtil::encode ( bsl::ostream *  jsonStream,
const TYPE &  value,
const EncoderOptions options = EncoderOptions() 
) [static]

Encode the JSON representation of the specified value to the specified jsonStream. Optionally specify options to configure aspects of the JSON representation of the value. If options is not specified, the default EncoderOptions value is used. Return 0 on success, and a non-zero value otherwise. The behavior is undefined unless the specified TYPE satisfies both the static and dynamic requirements of one bdlat type-category concept. See the component-level documentation of baljsn_encoderoptions for a description of the effects, if any, of each option in the options on the JSON representation of the value. See the package-level documentation of bdlat for a description of the available type-category concepts.

template<class TYPE >
static int baljsn::Encoder_EncodeImplUtil::encode ( bsl::ostream *  logStream,
bsl::ostream *  jsonStream,
const TYPE &  value,
const EncoderOptions options = EncoderOptions() 
) [static]

Encode the JSON representation of the specified value to the specified jsonStream. If this operation is not successful, load an unspecified, human-readable description of the error condition to the specified logStream. Optionally specify options to configure aspects of the JSON representation of the value. If options is not specified, the default EncoderOptions value is used. Return 0 on success, and a non-zero value otherwise. The behavior is undefined unless the specified TYPE satisfies both the static and dynamic requirements of one bdlat type-category concept. See the component-level documentation of baljsn_encoderoptions for a description of the effects, if any, of each option in the options on the JSON representation of the value. See the package-level documentation of bdlat for an introduction to the requirements of bdlat type-category concepts.

template<class TYPE >
static int baljsn::Encoder_EncodeImplUtil::encode ( bool *  isValueEmpty,
Formatter formatter,
bsl::ostream *  logStream,
const TYPE &  value,
FormattingMode  formattingMode,
const EncoderOptions options,
bool  isFirstMember 
) [static]

Encode the JSON representation of the specified value to the specified JSON formatter, according to the specified formattingMode. If the representation contains no text, load the value true into isValueEmpty and the value false otherwise. If the specified isFirstMember option is true, then the representation of the value contains no leading sequence delimiter, and does contain such a delimiter if the remaining representation is non-empty otherwise. Use the specified options to configure aspects of the JSON representation of the value. If this operation is not successful, load an unspecified, human-readable description of the error condition to the specified logStream. Return 0 on success, and a non-zero value otherwise. The behavior is undefined unless the specified TYPE satisfies both the static and dynamic requirements of one of the bdlat type-category concepts. See the component-level documentation of baljsn_encoderoptions for a description of the effects, if any, of each option in the options on the JSON representation of the value. See the package-level documentation of bdlat for an introduction to the requirements of bdlat type-category concepts.

template<class TYPE >
static int baljsn::Encoder_EncodeImplUtil::validate ( bsl::ostream *  logStream,
const TYPE &  value,
bdlat_TypeCategory::Choice  category 
) [static]
template<class TYPE , class CATEGORY >
static int baljsn::Encoder_EncodeImplUtil::validate ( bsl::ostream *  logStream,
const TYPE &  value,
CATEGORY  category 
) [static]

Determine if the specified value having the specified bdlat category satisfies the requirements for encoding using this component. If the value meets the encoding requirements, return 0, otherwise load an unspecified, human-readable description of the requirements that are not satisfied by the value and return a non-zero value. For values satisfying the bdlat Choice type-category concept, the value of the selectionId attribute must not be undefined. For values satisfying the requirements of other bdlat type-category concepts, there are no further requirements for encoding using this component. See the package-level documentation of bdlat for an introduction to the requirements of bdlat type-category concepts.

template<class TYPE >
static int baljsn::Encoder_EncodeImplUtil::validateChoice ( bsl::ostream *  logStream,
const TYPE &  value 
) [static]

Determine if the specified value satisfies the requirements for encoding using this component. If the value meets the encoding requirements, return 0, otherwise load an unspecified, human-readable description of the requirements that are not satisfied by the value to the specified logStream and return a non-zero value. The value is required to not have an undefined selectionId.

static int baljsn::Encoder_EncodeImplUtil::encodeCharArray ( Formatter formatter,
const bsl::vector< char > &  value,
const EncoderOptions options 
) [static]

Encode the JSON representation of the specified value to the specified JSON formatter. Use the specified options to configure aspects of the JSON representation of the value. Return 0 on success, and a non-zero value otherwise.

template<class TYPE >
static int baljsn::Encoder_EncodeImplUtil::encodeSimpleValue ( Formatter formatter,
const TYPE &  value,
const EncoderOptions options 
) [static]

Encode the JSON representation of the specified value to the specified JSON formatter. Use the specified options to configure aspects of the JSON representation of the value. Return 0 on success, and a non-zero value otherwise. The behavior is undefined unless the specified TYPE satisfies both the static and dynamic requirements of the Simple bdlat type-category concept. See the component-level documentation of baljsn_encoderoptions for a description of the effects, if any, of each option in the options on the JSON representation of the value. See the package-level documentation of bdlat for an introduction to the requirements of bdlat type-category concepts.

static void baljsn::Encoder_EncodeImplUtil::encodeObjectPrefix ( bool *  isPrefixEmpty,
Formatter formatter,
FormattingMode  formattingMode 
) [static]

If the specified formattingMode does not have the bdlat_FormattingMode::e_UNTAGGED bit set, encode a "left brace" JSON token to the specified formatter, and encoding nothing to the formatter otherwise. If this operation encodes a token to the formatter, load the value false to the specified isPrefixEmpty, and the value true otherwise.

static void baljsn::Encoder_EncodeImplUtil::encodeObjectSuffix ( bool *  isSuffixEmpty,
Formatter formatter,
FormattingMode  formattingMode 
) [static]

If the specified formattingMode does not have the bdlat_FormattingMode::e_UNTAGGED bit set, encode a "right brace" JSON token to the specified formatter, and encoding nothing to the formatter otherwise. If this operation encodes a token to the formatter, load the value false to the specified isSuffixEmpty, and the value true otherwise.

static void baljsn::Encoder_EncodeImplUtil::encodeEmptyArray ( Formatter formatter  )  [static]

Encode the representation of the empty-array JSON value to the specified formatter.

template<class TYPE >
static int baljsn::Encoder_EncodeImplUtil::encodeNonEmptyArray ( Formatter formatter,
bsl::ostream *  logStream,
const TYPE &  value,
const EncoderOptions options 
) [static]

Encode the JSON representation of the specified value to the specified JSON formatter. Use the specified options to configure aspects of the JSON representation of the value. If this operation is not successful, load an unspecified, human-readable description of the error condition to the specified logStream. Return 0 on success, and a non-zero value otherwise. The behavior is undefined unless the value is non-empty and the specified TYPE satisfies both the static and dynamic requirements of the Array bdlat type-category concept. See the component-level documentation of baljsn_encoderoptions for a description of the effects, if any, of each option in the options on the JSON representation of the selection. See the package-level documentation of bdlat for an introduction to the requirements of bdlat type-category concepts.

static int baljsn::Encoder_EncodeImplUtil::encodeMember ( bool *  isMemberEmpty,
Formatter formatter,
bsl::ostream *  logStream,
const bsl::string_view &  memberName,
const bsl::vector< char > &  member,
FormattingMode  formattingMode,
const EncoderOptions options,
bool  isFirstMember,
bdlat_TypeCategory::Array  category 
) [static]
template<class TYPE >
static int baljsn::Encoder_EncodeImplUtil::encodeMember ( bool *  isMemberEmpty,
Formatter formatter,
bsl::ostream *  logStream,
const bsl::string_view &  memberName,
const TYPE &  member,
FormattingMode  formattingMode,
const EncoderOptions options,
bool  isFirstMember,
bdlat_TypeCategory::Array  category 
) [static]
template<class TYPE , class OTHER_CATEGORY >
static int baljsn::Encoder_EncodeImplUtil::encodeMember ( bool *  isMemberEmpty,
Formatter formatter,
bsl::ostream *  logStream,
const bsl::string_view &  memberName,
const TYPE &  member,
FormattingMode  formattingMode,
const EncoderOptions options,
bool  isFirstMember,
OTHER_CATEGORY  category 
) [static]

Encode the JSON representation of the specified object member having the specified memberName to the specified JSON formatter, according to the specified formattingMode. If the representation contains no text, load the value true to isMemberEmpty and the value false otherwise. If the specified isFirstMember option is true, then the representation of the member contains no leading sequence delimiter, and does contain such a delimiter otherwise. Use the specified options to configure aspects of the JSON representation of the member. If this operation is not successful, load an unspecified, human-readable description of the error condition to the specified logStream. Return 0 on success, and a non-zero value otherwise. The behavior is undefined unless the specified TYPE satisfies both the static and dynamic requirements of the specified category bdlat type-category concept. See the component-level documentation of baljsn_encoderoptions for a description of the effects, if any, of each option in the options on the JSON representation of the selection. See the package-level documentation of bdlat for an introduction to the requirements of bdlat type-category concepts.

static int baljsn::Encoder_EncodeImplUtil::encodeMemberPrefix ( Formatter formatter,
bsl::ostream *  logStream,
const bsl::string_view &  memberName,
bool  isFirstMember 
) [static]
static int baljsn::Encoder_EncodeImplUtil::encodeMemberPrefix ( Formatter formatter,
bsl::ostream *  logStream,
const bsl::string_view &  memberName,
FormattingMode  formattingMode,
bool  isFirstMember 
) [static]
static int baljsn::Encoder_EncodeImplUtil::encodeMemberPrefix ( bool *  isPrefixEmpty,
Formatter formatter,
bsl::ostream *  logStream,
const bsl::string_view &  memberName,
FormattingMode  formattingMode,
bool  isFirstMember 
) [static]

If the specified isFirstMember flag is false, encode a "comma" JSON token to the specified formatter, and do not encode a "comma" JSON token otherwise. If the specified formattingMode does not have the bdlat_FormattingMode::e_UNTAGGED bit set, encode a JSON "string" token having the specified memberName contents, and encode a JSON "colon" token after the string, and do not encode these tokens otherwise. If this operation is not successful, load an unspecified, human-readable description of the error condition to the specified logStream. Optionally specify isPrefixEmpty. If this operation encodes a token to the formatter, load the value false to isPrefixEmpty if specified, and the value true otherwise. Return 0 on success, and a non-zero value otherwise.


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