<<extension>> <<value-type>> A collection of attributes used to configure how data samples will be formatted when converted to a string.
More...
#include <rti/topic/PrintFormat.hpp>
Public Member Functions |
| PrintFormatProperty (PrintFormatKind the_kind=PrintFormatKind::DEFAULT, bool is_pretty_print=true, bool is_enum_as_int=false, bool is_include_root_elements=true) |
| Initializes the properties.
|
|
PrintFormatKind | kind () const |
| Get the value of kind.
|
|
PrintFormatProperty & | kind (PrintFormatKind value) |
| Set the value for kind, indicating the kind of format to be used when converting a data sample to a string.
|
|
bool | pretty_print () const |
| Get the value of pretty_print.
|
|
PrintFormatProperty & | pretty_print (bool value) |
| Set the value for pretty_print, indicating if the string representation of the data sample should be a more readable format or should be void of all white space.
|
|
bool | enum_as_int () const |
| Get the value of enum_as_int.
|
|
PrintFormatProperty & | enum_as_int (bool value) |
| Set the value for enum_as_int, indicating whether to format enum values as integers or as strings when converting data samples to strings.
|
|
bool | include_root_elements () const |
| Get the value of include_root_elements.
|
|
PrintFormatProperty & | include_root_elements (bool value) |
| Set the value for include_root_elements, indicating whether to include the root elements of the print format in the output string when converting data samples to strings.
|
|
Detailed Description
<<extension>> <<value-type>> A collection of attributes used to configure how data samples will be formatted when converted to a string.
- See Also
- rti::topic::to_string
Constructor & Destructor Documentation
rti::topic::PrintFormatProperty::PrintFormatProperty |
( |
PrintFormatKind |
the_kind = PrintFormatKind::DEFAULT , |
|
|
bool |
is_pretty_print = true , |
|
|
bool |
is_enum_as_int = false , |
|
|
bool |
is_include_root_elements = true |
|
) |
| |
|
inline |
Initializes the properties.
Member Function Documentation
Set the value for kind, indicating the kind of format to be used when converting a data sample to a string.
Data samples can be represented in a default, XML, or JSON format.
- See Also
- PrintFormatKind
[default] PrintFormatKind::DEFAULT_PRINT_FORMAT
- Parameters
-
value | The value to set for kind |
bool rti::topic::PrintFormatProperty::pretty_print |
( |
| ) |
const |
|
inline |
Set the value for pretty_print, indicating if the string representation of the data sample should be a more readable format or should be void of all white space.
A value of true will add indentation and newlines to the string representation of the data sample making it more readable. For example:
<FooType>
<myLong>5</myLong>
</FooType>
A value of false will cause all white space in the string representation of the data sample to be eliminated. For example:
<FooType><myLong>5</myLong></FooType>
[default] true
- Parameters
-
value | The value to set for pretty_print |
bool rti::topic::PrintFormatProperty::enum_as_int |
( |
| ) |
const |
|
inline |
Set the value for enum_as_int, indicating whether to format enum values as integers or as strings when converting data samples to strings.
A value of true will cause enumeration literals to be printed using their integer value. For example:
<FooType>
<myEnum>5</myEnum>
</FooType>
A value of false will cause enumeration literals to be printed as strings using their member names. For example:
<FooType>
<myEnum>RED</myEnum>
</FooType>
[default] false
- Parameters
-
value | The value to set for enum_as_int |
bool rti::topic::PrintFormatProperty::include_root_elements |
( |
| ) |
const |
|
inline |
Set the value for include_root_elements, indicating whether to include the root elements of the print format in the output string when converting data samples to strings.
This field only applies if the PrintFormatProperty::kind is PrintFormatKind::XML_PRINT_FORMAT or PrintFormatKind::JSON_PRINT_FORMAT
If the value is true and the kind is PrintFormatKind::XML_PRINT_FORMAT then a top-level tag with the type's name in it will be included in the output. For example:
<FooType>
<myLong>5</myLong>
</FooType>
If the value is true and the kind is PrintFormatKind::JSON_PRINT_FORMAT then top-level opening and closing braces will be included in the output. For example:
If the value is false the elements described above will not be included in the output. For example:
[default] true
- Parameters
-
value | The value to set for include_root_elements |
Creates a property with PrintFormatKind::DEFAULT.
Creates a property with PrintFormatKind::XML.
Creates a property with PrintFormatKind::JSON.