PropertyConverter Module¶
Module Contents¶
-
class PropertyConverter¶
PropertyConverter - PropertyValueT to/from string.
We need to be able to convert strings to PropertyValueT instances and the reverse while using custom settings for decimal precision and time format. There are enough differences in the way locales are implemented across platforms that I insist on encapsulating it in this class. We will use this in readers and writers.
Public Functions
-
PropertyConverter()¶
Instantiate an default PropertyConverter.
-
PropertyConverter(PropertyConverter const &other)¶
Copy contructor, create a PropertyConverter with a copy of another.
- Parameters:
other – [in] PropertyConverter to copy from
-
virtual ~PropertyConverter()¶
Destructor.
-
PropertyConverter &operator=(PropertyConverter const &other)¶
Assign a PropertyConverter to the value of another.
- Parameters:
other – [in] PropertyConverter to assign value of
- Returns:
PropertyConverter with the new assigned value
-
bool operator==(PropertyConverter const &other) const¶
Check whether one PropertyConverter is equal to another by comparing the properties.
Two items are equal if all of their properties are equal.
- Parameters:
other – [in] PropertyConverter for comparison
- Returns:
Boolean indicating equivalency
-
bool operator!=(PropertyConverter const &other) const¶
Check whether two PropertyConverter are unequal.
- Parameters:
other – [in] PropertyConverter for comparison
- Returns:
Boolean indicating equivalency
-
void set_timestamp_input_format(string_type const &format)¶
Set format string for parsing timestamps.
This format string must adhere to the guidelines in the documentation for Boost’s date/time input format. See the following page:
http://www.boost.org/doc/libs/master/doc/html/date_time/date_time_io.html
- Parameters:
format – [in] Format string for timestamp parsing
-
string_type timestamp_input_format() const¶
Return the current input format.
- Returns:
Format string for timestamp parsing
-
void set_timestamp_output_format(string_type const &format)¶
Set format string for writing timestamps to strings.
This format string must adhere to the guidelines in the documentation for Boost’s date/time input format. See the following page:
http://www.boost.org/doc/libs/master/doc/html/date_time/date_time_io.html
- Parameters:
format – [in] Format string for timestamp output
-
string_type timestamp_output_format() const¶
Return the current output format.
- Returns:
Format string for timestamp output
-
void set_null_value(string_type const &null_value)¶
Set string that represents null values.
- Parameters:
null_value – [in] String to stand in for nulls
-
string_type null_value() const¶
Get string that represents null values.
- Returns:
String representing null
-
void set_decimal_precision(std::size_t digits)¶
Set number of digits of precision for writing real numbers.
- Parameters:
digits – [in] Number of digits to use
-
std::size_t decimal_precision() const¶
Get number of digits of precision for writing real numbers.
- Returns:
Number of digits in use
-
string_type property_to_string(PropertyValueT const &property)¶
Convert a property to a string.
Convert a property to a string according to the current output format.
- Parameters:
property – [in] Value to write
- Returns:
String representation of timestamp
-
PropertyValueT property_from_string(string_type const &prop_string, PropertyUnderlyingType prop_type)¶
Convert a string and type ID to a property.
Parse a string to create a property value according to the current input formats and the requested output type.
- Parameters:
prop_string – [in] Property represented as string
prop_type – [in] Property type (see tracktable::PropertyUnderlyingType)
- Returns:
Property parsed from string
-
TimestampConverter *timestamp_converter()¶
Convert a timestamp to read/write.
-
PropertyConverter()¶