aboutsummaryrefslogtreecommitdiff
path: root/core/src/Model/Workflow/Values/BasicValues.cpp
diff options
context:
space:
mode:
authorrtk0c <[email protected]>2021-06-03 10:06:55 -0700
committerrtk0c <[email protected]>2021-06-03 10:06:55 -0700
commit7a325e1b3be04bc54941431458903022da1643ac (patch)
treeaa76ab5b243fb351693645bfe2d2841019a45c5a /core/src/Model/Workflow/Values/BasicValues.cpp
parent016d58996db755630f8b41ddbef67516fe0c13b2 (diff)
Create template inheritance hierarchy, object value RTTI system
Diffstat (limited to 'core/src/Model/Workflow/Values/BasicValues.cpp')
-rw-r--r--core/src/Model/Workflow/Values/BasicValues.cpp117
1 files changed, 0 insertions, 117 deletions
diff --git a/core/src/Model/Workflow/Values/BasicValues.cpp b/core/src/Model/Workflow/Values/BasicValues.cpp
deleted file mode 100644
index 748c652..0000000
--- a/core/src/Model/Workflow/Values/BasicValues.cpp
+++ /dev/null
@@ -1,117 +0,0 @@
-#include "BasicValues.hpp"
-
-#include <charconv>
-#include <cmath>
-#include <limits>
-
-bool NumericValue::IsInstance(const BaseValue* value)
-{
- return value->GetKind() == KD_Numeric;
-}
-
-NumericValue::NumericValue()
- : BaseValue(BaseValue::KD_Numeric)
-{
-}
-
-template <class T, int kMaxSize>
-static std::string NumberToString(T value)
-{
- char buf[kMaxSize];
-
-#if PLATFORM_WIN32
- auto res = std::to_chars(buf, buf + kMaxSize, value);
- if (res.ec == std::errc()) {
- return std::string(buf, res.ptr);
- } else {
- return "<err>";
- }
-#else
- // TODO libstdc++ doesn't have floating point charconv yet
- return std::to_string(value);
-#endif
-}
-
-std::string NumericValue::GetTruncatedString() const
-{
- constexpr auto kMaxSize = std::numeric_limits<int64_t>::digits10;
- return ::NumberToString<int64_t, kMaxSize>((int64_t)mValue);
-}
-
-std::string NumericValue::GetRoundedString() const
-{
- constexpr auto kMaxSize = std::numeric_limits<int64_t>::digits10;
- return ::NumberToString<int64_t, kMaxSize>((int64_t)std::round(mValue));
-}
-
-std::string NumericValue::GetString() const
-{
- constexpr auto kMaxSize = std::numeric_limits<double>::max_digits10;
- return ::NumberToString<double, kMaxSize>(mValue);
-}
-
-int64_t NumericValue::GetInt() const
-{
- return static_cast<int64_t>(mValue);
-}
-
-double NumericValue::GetValue() const
-{
- return mValue;
-}
-
-void NumericValue::SetValue(double value)
-{
- mValue = value;
-}
-
-bool TextValue::IsInstance(const BaseValue* value)
-{
- return value->GetKind() == KD_Text;
-}
-
-TextValue::TextValue()
- : BaseValue(BaseValue::KD_Text)
-{
-}
-
-const std::string& TextValue::GetValue() const
-{
- return mValue;
-}
-
-void TextValue::SetValue(const std::string& value)
-{
- mValue = value;
-}
-
-bool DateTimeValue::IsInstance(const BaseValue* value)
-{
- return value->GetKind() == KD_DateTime;
-}
-
-DateTimeValue::DateTimeValue()
- : BaseValue(BaseValue::KD_DateTime)
-{
-}
-
-std::string DateTimeValue::GetString() const
-{
- namespace chrono = std::chrono;
- auto t = chrono::system_clock::to_time_t(mValue);
-
- char data[32];
- std::strftime(data, sizeof(data), "%Y-%m-%d %H:%M:%S", std::localtime(&t));
-
- return std::string(data);
-}
-
-const std::chrono::time_point<std::chrono::system_clock>& DateTimeValue::GetValue() const
-{
- return mValue;
-}
-
-void DateTimeValue::SetValue(const std::chrono::time_point<std::chrono::system_clock>& value)
-{
- mValue = value;
-}