summaryrefslogtreecommitdiff
path: root/modules/core/c++/abstract
diff options
context:
space:
mode:
Diffstat (limited to 'modules/core/c++/abstract')
-rw-r--r--modules/core/c++/abstract/data.hpp89
-rw-r--r--modules/core/c++/abstract/error.hpp2
2 files changed, 90 insertions, 1 deletions
diff --git a/modules/core/c++/abstract/data.hpp b/modules/core/c++/abstract/data.hpp
index f1ae5a7..327fb63 100644
--- a/modules/core/c++/abstract/data.hpp
+++ b/modules/core/c++/abstract/data.hpp
@@ -10,8 +10,97 @@ class data final {};
template<typename T, uint64_t N>
class data<sch::Primitive<T,N>,Encode> final {
+public:
+ using Schema = sch::Primitive<T,N>;
+ using Encode = Encode;
private:
+ native_data_type<Schema>::type value_;
public:
+ data():
+ value_{}
+ {}
+
+ data(native_data_type<Schema>::type value__):
+ value_{value__}
+ {}
+
+ constexpr auto get() const {
+ return value_;
+ }
+
+ void set(native_data_type value__){
+ value_ = value__;
+ }
+
+ constexpr bool operator==(const data<Schema,Encode>& rhs) const {
+ return value_ == rhs.value_;
+ }
+
+ constexpr bool operator!=(const data<Schema,Encode>& rhs) const {
+ return value_ != rhs.value_;
+ }
+
+ constexpr bool operator>(const data<Schema,Encode>& rhs) const {
+ return value_ > rhs.value_;
+ }
+
+ constexpr bool operator<(const data<Schema,Encode>& rhs) const {
+ return value_ < rhs.value_;
+ }
+
+ constexpr bool operator>=(const data<Schema,Encode>& rhs) const {
+ return value_ >= rhs.value_;
+ }
+
+ constexpr bool operator<=(const data<Schema,Encode>& rhs) const {
+ return value_ >= rhs.value_;
+ }
+
+ constexpr bool equals(const data<Schema,Encode>& rhs) const {
+ return (*this) == rhs;
+ }
+
+ data<Schema,Encode> operator+(const data<Schema,Encode>& rhs) const {
+ return {value_ + rhs.value_};
+ }
+
+ data<Schema,Encode> operator-(const data<Schema,Encode>& rhs) const {
+ return {value_ - rhs.value_};
+ }
+
+ data<Schema,Encode> operator*(const data<Schema,Encode>& rhs) const {
+ return {value_ * rhs.value_};
+ }
+
+ data<Schema,Encode> operator/(const data<Schema,Encode>& rhs) const {
+ return {value_ / rhs.value_};
+ }
+
+ data<Schema,Encode>& operator+=(const data<Schema,Encode>& rhs) {
+ value_ += rhs.value_;
+ return *this
+ }
+
+ data<Schema,Encode>& operator-=(const data<Schema,Encode>& rhs) {
+ value_ -= rhs.value_;
+ return *this
+ }
+
+ data<Schema,Encode>& operator*=(const data<Schema,Encode>& rhs) {
+ value_ *= rhs.value_;
+ return *this
+ }
+
+ data<Schema,Encode>& operator/=(const data<Schema,Encode>& rhs) {
+ value_ /= rhs.value_;
+ return *this
+ }
+
+ template<typename T>
+ data<T,Encode> cast_to() const {
+ data<T,Encode> val{static_cast<typename native_data_type<T>::type>(value_)};
+ return val;
+ }
};
diff --git a/modules/core/c++/abstract/error.hpp b/modules/core/c++/abstract/error.hpp
index 19917de..94a2c35 100644
--- a/modules/core/c++/abstract/error.hpp
+++ b/modules/core/c++/abstract/error.hpp
@@ -305,7 +305,7 @@ public:
/**
* This tries to catch cases where error starts including itself as a type which can happen in more complicated cases.
- * So this acts as a type safe guard.
+ * So this acts as a type safe guard in case internal handling fails to treat conversion correctly.
*/
template <typename T> class error_or<error_or<T>> {
private: