RTI Connext Modern C++ API  Version 6.1.0

<<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. More...
 
PrintFormatKind kind () const
 Get the value of kind. More...
 
PrintFormatPropertykind (PrintFormatKind value)
 Set the value for kind, indicating the kind of format to be used when converting a data sample to a string. More...
 
bool pretty_print () const
 Get the value of pretty_print. More...
 
PrintFormatPropertypretty_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. More...
 
bool enum_as_int () const
 Get the value of enum_as_int. More...
 
PrintFormatPropertyenum_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. More...
 
bool include_root_elements () const
 Get the value of include_root_elements. More...
 
PrintFormatPropertyinclude_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. More...
 

Static Public Member Functions

static PrintFormatProperty Default ()
 Creates a property with PrintFormatKind::DEFAULT. More...
 
static PrintFormatProperty Xml ()
 Creates a property with PrintFormatKind::XML. More...
 
static PrintFormatProperty Json ()
 Creates a property with PrintFormatKind::JSON. More...
 

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

◆ PrintFormatProperty()

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

◆ kind() [1/2]

PrintFormatKind rti::topic::PrintFormatProperty::kind ( ) const
inline

Get the value of kind.

See also
kind(PrintFormatKind value)

◆ kind() [2/2]

PrintFormatProperty& rti::topic::PrintFormatProperty::kind ( PrintFormatKind  value)
inline

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
valueThe value to set for kind

◆ pretty_print() [1/2]

bool rti::topic::PrintFormatProperty::pretty_print ( ) const
inline

Get the value of pretty_print.

See also
pretty_print(bool value)

◆ pretty_print() [2/2]

PrintFormatProperty& rti::topic::PrintFormatProperty::pretty_print ( bool  value)
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
valueThe value to set for pretty_print

◆ enum_as_int() [1/2]

bool rti::topic::PrintFormatProperty::enum_as_int ( ) const
inline

Get the value of enum_as_int.

See also
enum_as_int(bool value)

◆ enum_as_int() [2/2]

PrintFormatProperty& rti::topic::PrintFormatProperty::enum_as_int ( bool  value)
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
valueThe value to set for enum_as_int

◆ include_root_elements() [1/2]

bool rti::topic::PrintFormatProperty::include_root_elements ( ) const
inline

Get the value of include_root_elements.

See also
include_root_elements(bool value)

◆ include_root_elements() [2/2]

PrintFormatProperty& rti::topic::PrintFormatProperty::include_root_elements ( bool  value)
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:

{
"myLong":5
}

If the value is false the elements described above will not be included in the output. For example:

<myLong>5</myLong>
"myLong":5

[default] true

Parameters
valueThe value to set for include_root_elements

◆ Default()

static PrintFormatProperty rti::topic::PrintFormatProperty::Default ( )
inlinestatic

Creates a property with PrintFormatKind::DEFAULT.

Referenced by rti::topic::to_string().

◆ Xml()

static PrintFormatProperty rti::topic::PrintFormatProperty::Xml ( )
inlinestatic

Creates a property with PrintFormatKind::XML.

◆ Json()

static PrintFormatProperty rti::topic::PrintFormatProperty::Json ( )
inlinestatic

Creates a property with PrintFormatKind::JSON.