diff options
author | Claudius "keldu" Holeksa <mail@keldu.de> | 2024-05-28 17:23:20 +0200 |
---|---|---|
committer | Claudius "keldu" Holeksa <mail@keldu.de> | 2024-05-28 17:23:20 +0200 |
commit | 7b6e0ca99f8521e034452f0d0243a7f3e33843a9 (patch) | |
tree | 22ee558b32738cb670baa3594bcaa9919eb68908 /modules/codec/c++/data.hpp | |
parent | 8b5c1e6a6cd5536d9414262c42452f8655658728 (diff) |
Docs and Sycl fixes
Diffstat (limited to 'modules/codec/c++/data.hpp')
-rw-r--r-- | modules/codec/c++/data.hpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/modules/codec/c++/data.hpp b/modules/codec/c++/data.hpp index c7af0d4..2a5f082 100644 --- a/modules/codec/c++/data.hpp +++ b/modules/codec/c++/data.hpp @@ -205,15 +205,27 @@ public: } }; +/** + * Data class which represents a struct in the native format. + */ template<typename... T, string_literal... literals> class data<schema::Struct<schema::Member<T, literals>...>, encode::Native<storage::Default>> { private: + /** + * Tuple storing the member values. + */ std::tuple<data<T,encode::Native<storage::Default>>...> value_; public: + /** + * Default constructor. + */ data() = default; SAW_DEFAULT_COPY(data); SAW_DEFAULT_MOVE(data); + /** + * Get the member value based on the string_literal. + */ template<string_literal literal> data< typename parameter_pack_type< @@ -225,6 +237,9 @@ public: return std::get<parameter_key_pack_index<literal, literals...>::value>(value_); } + /** + * Get the member value based on the string_literal. + */ template<string_literal literal> const data< typename parameter_pack_type< @@ -236,6 +251,9 @@ public: return std::get<parameter_key_pack_index<literal, literals...>::value>(value_); } + /** + * Return the amount of members. + */ constexpr size_t size() const { return sizeof...(T); } @@ -469,9 +487,15 @@ private: } }; +/** + * Data type representing string. + */ template<> class data<schema::String, encode::Native<storage::Default>> { private: + /** + * The native way to represent strings. + */ std::string value_; public: data() = default; @@ -483,18 +507,30 @@ public: value_.resize(size_); } + /** + * Return the length of the string. + */ std::size_t size() const { return value_.size(); } + /** + * set the inner string to str. + */ void set(std::string str){ value_ = std::move(str); } + /** + * Get a char reference at position i. + */ char& at(size_t i) { return value_.at(i); } + /** + * Get a char reference at position i. + */ const char& at(size_t i) const { return value_.at(i); } @@ -507,6 +543,9 @@ public: value_.at(i) = val; } + /** + * Check if a string_view is equal to this type. + */ bool operator==(const std::string_view& val)const{ return value_ == val; } |