Showing the changes to Source/Libraries/TimeSeriesPlatformLibrary/Common/Convert.h (1 of 28 files). Show all
Unified · Split
| @@ -32,18 +32,18 @@ namespace GSF · 31 unmodified lines | |||
| 32 | void ToUnixTime(int64_t ticks, time_t& unixSOC, uint16_t& milliseconds); | 32 | void ToUnixTime(int64_t ticks, time_t& unixSOC, uint16_t& milliseconds); |
| 33 | 33 | ||
| 34 | // Convert Unix second of century and milliseconds to DateTime | 34 | // Convert Unix second of century and milliseconds to DateTime |
| 35 | DateTime FromUnixTime(time_t unixSOC, uint16_t milliseconds); | 35 | datetime_t FromUnixTime(time_t unixSOC, uint16_t milliseconds); |
| 36 | 36 | ||
| 37 | // Converts a timestamp, in Ticks, to DateTime | 37 | // Converts a timestamp, in Ticks, to DateTime |
| 38 | DateTime FromTicks(int64_t ticks); | 38 | datetime_t FromTicks(int64_t ticks); |
| 39 | 39 | ||
| 40 | // Converts a DateTime to Ticks | 40 | // Converts a DateTime to Ticks |
| 41 | int64_t ToTicks(const DateTime& time); | 41 | int64_t ToTicks(const datetime_t& time); |
| 42 | 42 | ||
| 43 | // Thin wrapper around strftime to provide formats for milliseconds (%f) and full-resolution ticks (%t) | 43 | // Thin wrapper around strftime to provide formats for milliseconds (%f) and full-resolution ticks (%t) |
| 44 | uint32_t TicksToString(char* ptr, uint32_t maxsize, std::string format, int64_t ticks); | 44 | uint32_t TicksToString(char* ptr, uint32_t maxsize, std::string format, int64_t ticks); |
| 45 | 45 | ||
| 46 | DateTime LocalFromUtc(const DateTime& timestamp); | 46 | datetime_t LocalFromUtc(const datetime_t& timestamp); |
| 47 | 47 | ||
| 48 | // Converts an object to a string | 48 | // Converts an object to a string |
| 49 | template<class T> | 49 | template<class T> |
| @@ -56,7 +56,7 @@ namespace GSF · 6 unmodified lines | |||
| 56 | 56 | ||
| 57 | std::string ToString(const Guid& value); | 57 | std::string ToString(const Guid& value); |
| 58 | 58 | ||
| 59 | std::string ToString(const DateTime& value, const char* format = "%Y-%m-%d %H:%M:%S%F"); | 59 | std::string ToString(const datetime_t& value, const char* format = "%Y-%m-%d %H:%M:%S%F"); |
| 60 | 60 | ||
| 61 | std::string ToString(const TimeSpan& value); | 61 | std::string ToString(const TimeSpan& value); |
| 62 | 62 | ||
| @@ -74,7 +74,11 @@ namespace GSF · 11 unmodified lines | |||
| 74 | 74 | ||
| 75 | bool ParseBoolean(const std::string& value); | 75 | bool ParseBoolean(const std::string& value); |
| 76 | 76 | ||
| 77 | bool TryParseDouble(const std::string& value, float64_t& result); | 77 | bool TryParseInt32(const std::string& value, int32_t& result, int32_t defaultValue = 0); |
| 78 | |||
| 79 | bool TryParseInt64(const std::string& value, int64_t& result, int64_t defaultValue = 0L); | ||
| 80 | |||
| 81 | bool TryParseDouble(const std::string& value, float64_t& result, float64_t defaultValue = 0.0); | ||
| 78 | 82 | ||
| 79 | // Encodes a character value into an escaped RegEx value | 83 | // Encodes a character value into an escaped RegEx value |
| 80 | std::string RegExEncode(char value); | 84 | std::string RegExEncode(char value); |
| @@ -88,10 +92,10 @@ namespace GSF · 7 unmodified lines | |||
| 88 | const char* Coalesce(const char* data, const char* nonEmptyValue); | 92 | const char* Coalesce(const char* data, const char* nonEmptyValue); |
| 89 | 93 | ||
| 90 | // Attempts to parse an time string in several common formats | 94 | // Attempts to parse an time string in several common formats |
| 91 | bool TryParseTimestamp(const char* time, DateTime& timestamp, bool parseAsUTC = true); | 95 | bool TryParseTimestamp(const char* time, datetime_t& timestamp, const datetime_t& defaultValue = DateTime::MinValue, bool parseAsUTC = true); |
| 92 | 96 | ||
| 93 | // Converts a string to a date-time that may be in several common formats | 97 | // Converts a string to a date-time that may be in several common formats |
| 94 | DateTime ParseTimestamp(const char* time, bool parseAsUTC = true); | 98 | datetime_t ParseTimestamp(const char* time, bool parseAsUTC = true); |
| 95 | 99 | ||
| 96 | // Parses a string of key/value pairs into a case-insensitive string dictionary | 100 | // Parses a string of key/value pairs into a case-insensitive string dictionary |
| 97 | StringMap<std::string> ParseKeyValuePairs(const std::string& value, char parameterDelimiter = ';', char keyValueDelimiter = '=', char startValueDelimiter = '{', char endValueDelimiter = '}'); | 101 | StringMap<std::string> ParseKeyValuePairs(const std::string& value, char parameterDelimiter = ';', char keyValueDelimiter = '=', char startValueDelimiter = '{', char endValueDelimiter = '}'); |