RTI Connext Modern C++ API  Version 6.0.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
rti::topic::PrintFormatProperty Class Reference

<<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.
 
PrintFormatPropertykind (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.
 
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.
 
bool enum_as_int () const
 Get the value of enum_as_int.
 
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.
 
bool include_root_elements () const
 Get the value of include_root_elements.
 
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.
 

Static Public Member Functions

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

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

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

Get the value of kind.

See Also
kind(PrintFormatKind value)
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
bool rti::topic::PrintFormatProperty::pretty_print ( ) const
inline

Get the value of pretty_print.

See Also
pretty_print(bool value)
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
bool rti::topic::PrintFormatProperty::enum_as_int ( ) const
inline

Get the value of enum_as_int.

See Also
enum_as_int(bool value)
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
bool rti::topic::PrintFormatProperty::include_root_elements ( ) const
inline

Get the value of include_root_elements.

See Also
include_root_elements(bool value)
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
static PrintFormatProperty rti::topic::PrintFormatProperty::Default ( )
inlinestatic

Creates a property with PrintFormatKind::DEFAULT.

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

Creates a property with PrintFormatKind::XML.

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

Creates a property with PrintFormatKind::JSON.


RTI Connext Modern C++ API Version 6.0.1 Copyright © Sat Nov 23 2019 Real-Time Innovations, Inc