|
BDE 4.14.0 Production release
|
#include <baljsn_encoder.h>
Public Types | |
| typedef Encoder_EncodeImplUtil | ThisUtil |
ThisUtil is a convenience alias for this utility struct. | |
| 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) |
This component-private utility struct provides a suite of functions that encode bdlat types in the JSON format.
| typedef int baljsn::Encoder_EncodeImplUtil::FormattingMode |
FormattingMode is an alias to the type of an int-valued bdlat_FormattingMode bit-field. A FormattingMode value is not valid unless it is equal to an enumerator of bdlat_FormattingMode or a valid bitwise-or of two or more such enumerators. See bdlat_formattingmode for a description of the set of valid formatting-mode values.
|
inlinestatic |
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 baljsn_encoderoptions for a description of the effects, if any, of each option in the options on the end of a JSON document.
|
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 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.
|
inlinestatic |
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 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.
|
inlinestatic |
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 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 |
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.
|
inlinestatic |
Encode the representation of the empty-array JSON value to the specified formatter.
|
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 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 |
This function purposefully ignores the EncodeEmptyArrays option in the specified options and always encodes the value of the specified member array. The caller is responsible for checking the value of this option and deciding whether to obey the option or not. Callers that encode array-valued attributes of sequences must always obey the option. Callers that encode array-valued selections of choices must never obey the option, and must always encode the array value.
|
static |
|
inlinestatic |
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.
|
inlinestatic |
|
inlinestatic |
|
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 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.
|
inlinestatic |
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.
|
inlinestatic |
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.
|
inlinestatic |
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 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.
|
inlinestatic |
Print the sequence of characters that designate the start of a JSON document to the specified outputStream according to the specified encoding options. See baljsn_encoderoptions for a description of the effects, if any, of each option in the options on the start of a JSON document.
|
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.
|
inlinestatic |
|
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.