template<class FORMATTER>
struct baljsn::EncodeImplUtil< FORMATTER >
This component-private utility struct provides a suite of functions that encode bdlat types in the JSON format.
See baljsn_encodeimplutil
|
| 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) |
| |
template<class FORMATTER >
template<class TYPE >
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.
- Precondition
- 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.
template<class FORMATTER >
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.
- Precondition
- 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.
template<class FORMATTER >
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.
template<class FORMATTER >
template<class TYPE >
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.