1.1.4. FieldToString¶
-
class
eprosima::is::core::FieldToString¶ Convenience class for converting simple field types into strings. It is useful to discern between the different Dynamic Types that may be requested to be replaced in a certain StringTemplate, and perform the conversion accordingly.
Public Functions
-
FieldToString(const std::string &usage_details)¶ Constructor.
- Parameters
[in] usage_details: Sets the details for how the conversion should be used.
-
FieldToString(const FieldToString &other)¶ Copy Constructor.
- Parameters
[in] other: The instance to be copied.
-
FieldToString(FieldToString &&other)¶ Move Constructor.
- Parameters
[in] other: The instance to be moved.
-
~FieldToString() = default¶ Destructor.
-
const std::string
to_string(eprosima::xtypes::ReadableDynamicDataRef field, const std::string &field_name) const¶ Converts a certain field to a string, given the field name.
- Return
A const string representation of the requested field.
- Parameters
[in] field: Reference to the Dynamic Data instance representing the field’s values.[in] field_name: The specific field whose value should be retrieved.
-
const std::string &
details() const¶ Gets a const reference to the details attribute.
- Return
A const string reference to “details”.
-
std::string &
details()¶ Gets a mutable reference to the details attribute.
- Return
A non-const string reference to “details”.
-
-
class
eprosima::is::core::UnknownFieldToStringCast: public runtime_error¶ Exception that gets thrown by FieldToString when it’s unknown how to convert a given field type into a string.
Public Functions
-
UnknownFieldToStringCast(const std::string &type, const std::string &field_name, const std::string &details)¶ Constructor.
- Parameters
[in] type: The type kind that should have been cast to a string.[in] field_name: The field whose conversion to string was unsuccessfully attempted.[in] details: The details on how the conversion is being done.
-
~UnknownFieldToStringCast() = default¶ Destructor.
-
const std::string &
type() const¶ Getter method for
_typeparameter.- Return
A const reference to the field type string.
-
const std::string &
field_name() const¶ Getter method for the field’s name.
- Return
A const reference to the field’s name string.
-