BDE 4.14.0 Production release
|
#include <baljsn_encoderoptions.h>
Public Member Functions | |
EncoderOptions () | |
Create an object of type EncoderOptions having the default value. | |
EncoderOptions (const EncoderOptions &original) | |
~EncoderOptions () | |
Destroy this object. | |
EncoderOptions & | operator= (const EncoderOptions &rhs) |
Assign to this object the value of the specified rhs object. | |
void | reset () |
template<class MANIPULATOR > | |
int | manipulateAttributes (MANIPULATOR &manipulator) |
template<class MANIPULATOR > | |
int | manipulateAttribute (MANIPULATOR &manipulator, int id) |
template<class MANIPULATOR > | |
int | manipulateAttribute (MANIPULATOR &manipulator, const char *name, int nameLength) |
void | setInitialIndentLevel (int value) |
void | setSpacesPerLevel (int value) |
void | setEncodingStyle (baljsn::EncodingStyle::Value value) |
void | setEncodingStyle (baljsn::EncoderOptions::EncodingStyle value) |
void | setEncodeEmptyArrays (bool value) |
void | setEncodeNullElements (bool value) |
void | setEncodeInfAndNaNAsStrings (bool value) |
void | setDatetimeFractionalSecondPrecision (int value) |
void | setMaxFloatPrecision (int value) |
void | setMaxDoublePrecision (int value) |
void | setEncodeQuotedDecimal64 (bool value) |
bsl::ostream & | print (bsl::ostream &stream, int level=0, int spacesPerLevel=4) const |
template<class ACCESSOR > | |
int | accessAttributes (ACCESSOR &accessor) const |
template<class ACCESSOR > | |
int | accessAttribute (ACCESSOR &accessor, int id) const |
template<class ACCESSOR > | |
int | accessAttribute (ACCESSOR &accessor, const char *name, int nameLength) const |
int | initialIndentLevel () const |
int | spacesPerLevel () const |
baljsn::EncoderOptions::EncodingStyle | encodingStyle () const |
bool | encodeEmptyArrays () const |
bool | encodeNullElements () const |
bool | encodeInfAndNaNAsStrings () const |
int | datetimeFractionalSecondPrecision () const |
int | maxFloatPrecision () const |
int | maxDoublePrecision () const |
bool | encodeQuotedDecimal64 () const |
Static Public Member Functions | |
static const bdlat_AttributeInfo * | lookupAttributeInfo (int id) |
static const bdlat_AttributeInfo * | lookupAttributeInfo (const char *name, int nameLength) |
Static Public Attributes | |
static const char | CLASS_NAME [] |
static const int | DEFAULT_INITIALIZER_INITIAL_INDENT_LEVEL |
static const int | DEFAULT_INITIALIZER_SPACES_PER_LEVEL |
static const baljsn::EncodingStyle::Value | DEFAULT_INITIALIZER_ENCODING_STYLE |
static const bool | DEFAULT_INITIALIZER_ENCODE_EMPTY_ARRAYS |
static const bool | DEFAULT_INITIALIZER_ENCODE_NULL_ELEMENTS |
static const bool | DEFAULT_INITIALIZER_ENCODE_INF_AND_NA_N_AS_STRINGS |
static const int | DEFAULT_INITIALIZER_DATETIME_FRACTIONAL_SECOND_PRECISION |
static const int | DEFAULT_INITIALIZER_MAX_FLOAT_PRECISION |
static const int | DEFAULT_INITIALIZER_MAX_DOUBLE_PRECISION |
static const bool | DEFAULT_INITIALIZER_ENCODE_QUOTED_DECIMAL64 |
static const bdlat_AttributeInfo | ATTRIBUTE_INFO_ARRAY [] |
Options for performing JSON encoding. EncodingStyle
is either COMPACT
or PRETTY
. If EncodingStyle
is COMPACT
, no whitespace will be added between elements. If encoding style is PRETTY
, then the InitialIndentLevel
and SpacesPerLevel
parameters are used to specify the formatting of the output. Note that InitialIndentLevel
and SpacesPerLevel
are ignored when EncodingStyle
is COMPACT
(this is the default). The EncodeEmptyArrays
and EncodeNullElements
encode empty array and null elements respectively. By default empty array and null elements are not encoded. The EncodeInfAndNaNAsStrings
attribute provides users the option to encode Infinity
and NaN
floating point values as strings. These values do not have a valid JSON representation and by default such value will result in an encoding error. The DatetimeFractionalSecondPrecision
specifies the precision of milliseconds printed with date time values. By default a precision of 3
decimal places is used. The MaxFloatPrecision
and MaxDoublePrecision
attributes allow specifying the maximum precision for float
and double
values. When not specified, or 0 is specified, the precision is determined automatically to use enough digits to ensure restoring the original binary floating point value by a reader. We recommend against setting these options: they were provided prior to the current default behavior (of choosing the shortest presentation that can be restored to the original value) being available.
anonymous enum |
anonymous enum |
baljsn::EncoderOptions::EncoderOptions | ( | ) |
baljsn::EncoderOptions::EncoderOptions | ( | const EncoderOptions & | original | ) |
Create an object of type EncoderOptions
having the value of the specified original
object.
baljsn::EncoderOptions::~EncoderOptions | ( | ) |
int baljsn::EncoderOptions::accessAttribute | ( | ACCESSOR & | accessor, |
const char * | name, | ||
int | nameLength | ||
) | const |
Invoke the specified accessor
on the (non-modifiable) attribute of this object indicated by the specified name
of the specified nameLength
, supplying accessor
with the corresponding attribute information structure. Return the value returned from the invocation of accessor
if name
identifies an attribute of this class, and -1 otherwise.
int baljsn::EncoderOptions::accessAttribute | ( | ACCESSOR & | accessor, |
int | id | ||
) | const |
Invoke the specified accessor
on the (non-modifiable) attribute of this object indicated by the specified id
, supplying accessor
with the corresponding attribute information structure. Return the value returned from the invocation of accessor
if id
identifies an attribute of this class, and -1 otherwise.
int baljsn::EncoderOptions::accessAttributes | ( | ACCESSOR & | accessor | ) | const |
Invoke the specified accessor
sequentially on each (non-modifiable) attribute of this object, supplying accessor
with the corresponding attribute information structure until such invocation returns a non-zero value. Return the value from the last invocation of accessor
(i.e., the invocation that terminated the sequence).
|
inline |
Return a reference to the non-modifiable "DatetimeFractionalSecondPrecision" attribute of this object.
|
inline |
Return a reference to the non-modifiable "EncodeEmptyArrays" attribute of this object. Note that empty arrays occurring as selections of choices are always encoded regardless of the setting of this option.
|
inline |
Return a reference to the non-modifiable "EncodeInfAndNaNAsStrings" attribute of this object.
|
inline |
Return a reference to the non-modifiable "EncodeNullElements" attribute of this object.
|
inline |
Return the value of the "EncodeQuotedDecimal64" attribute of this object.
|
inline |
Return a reference to the non-modifiable "EncodingStyle" attribute of this object.
|
inline |
Return a reference to the non-modifiable "InitialIndentLevel" attribute of this object.
|
static |
Return attribute information for the attribute indicated by the specified name
of the specified nameLength
if the attribute exists, and 0 otherwise.
|
static |
Return attribute information for the attribute indicated by the specified id
if the attribute exists, and 0 otherwise.
int baljsn::EncoderOptions::manipulateAttribute | ( | MANIPULATOR & | manipulator, |
const char * | name, | ||
int | nameLength | ||
) |
Invoke the specified manipulator
on the address of the (modifiable) attribute indicated by the specified name
of the specified nameLength
, supplying manipulator
with the corresponding attribute information structure. Return the value returned from the invocation of manipulator
if name
identifies an attribute of this class, and -1 otherwise.
int baljsn::EncoderOptions::manipulateAttribute | ( | MANIPULATOR & | manipulator, |
int | id | ||
) |
Invoke the specified manipulator
on the address of the (modifiable) attribute indicated by the specified id
, supplying manipulator
with the corresponding attribute information structure. Return the value returned from the invocation of manipulator
if id
identifies an attribute of this class, and -1 otherwise.
int baljsn::EncoderOptions::manipulateAttributes | ( | MANIPULATOR & | manipulator | ) |
Invoke the specified manipulator
sequentially on the address of each (modifiable) attribute of this object, supplying manipulator
with the corresponding attribute information structure until such invocation returns a non-zero value. Return the value from the last invocation of manipulator
(i.e., the invocation that terminated the sequence).
|
inline |
Return a reference to the non-modifiable "MaxDoublePrecision" attribute of this object.
|
inline |
Return a reference to the non-modifiable "MaxFloatPrecision" attribute of this object.
EncoderOptions & baljsn::EncoderOptions::operator= | ( | const EncoderOptions & | rhs | ) |
bsl::ostream & baljsn::EncoderOptions::print | ( | bsl::ostream & | stream, |
int | level = 0 , |
||
int | spacesPerLevel = 4 |
||
) | const |
Format this object to the specified output stream
at the optionally specified indentation level
and return a reference to the modifiable stream
. If level
is specified, optionally specify spacesPerLevel
, the number of spaces per indentation level for this and all of its nested objects. Each line is indented by the absolute value of level * spacesPerLevel
. If level
is negative, suppress indentation of the first line. If spacesPerLevel
is negative, suppress line breaks and format the entire output on one line. If stream
is initially invalid, this operation has no effect. Note that a trailing newline is provided in multiline mode only.
void baljsn::EncoderOptions::reset | ( | ) |
Reset this object to the default value (i.e., its value upon default construction).
|
inline |
Set the "DatetimeFractionalSecondPrecision" attribute of this object to the specified value
.
|
inline |
Set the "EncodeEmptyArrays" attribute of this object to the specified value
.
|
inline |
Set the "EncodeInfAndNaNAsStrings" attribute of this object to the specified value
.
|
inline |
Set the "EncodeNullElements" attribute of this object to the specified value
.
|
inline |
Set the "EncodeQuotedDecimal64" attribute of this object to the specified value
.
|
inline |
Set the "EncodingStyle" attribute of this object to the specified value
.
|
inline |
|
inline |
Set the "InitialIndentLevel" attribute of this object to the specified value
.
|
inline |
Set the "MaxDoublePrecision" attribute of this object to the specified value
.
|
inline |
Set the "MaxFloatPrecision" attribute of this object to the specified value
.
|
inline |
Set the "SpacesPerLevel" attribute of this object to the specified value
.
|
inline |
Return a reference to the non-modifiable "SpacesPerLevel" attribute of this object.
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |