diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/codec/c++/base64.hpp | 8 | ||||
-rw-r--r-- | modules/codec/c++/csv.hpp | 6 | ||||
-rw-r--r-- | modules/codec/c++/data.hpp | 194 | ||||
-rw-r--r-- | modules/codec/c++/schema_meta.hpp | 6 | ||||
-rw-r--r-- | modules/codec/c++/simple.hpp | 12 | ||||
-rw-r--r-- | modules/codec/examples/arg_parser.cpp | 4 | ||||
-rw-r--r-- | modules/codec/tests/codec.cpp | 42 | ||||
-rw-r--r-- | modules/codec/tests/csv.cpp | 6 | ||||
-rw-r--r-- | modules/codec/tests/data.cpp | 32 | ||||
-rw-r--r-- | modules/codec/tests/transport.cpp | 16 |
10 files changed, 177 insertions, 149 deletions
diff --git a/modules/codec/c++/base64.hpp b/modules/codec/c++/base64.hpp index 141a63d..ce9d4ce 100644 --- a/modules/codec/c++/base64.hpp +++ b/modules/codec/c++/base64.hpp @@ -71,8 +71,8 @@ public: std::string b64_str; try { - uint64_t unpadded_len = (from.size() * 4u + 2u) / 3u; - uint64_t padded_len = ( unpadded_len + 3u ) & ~3u; + uint64_t unpadded_len = (from.size() * 4u + 2u).get() / 3u; + uint64_t padded_len = (unpadded_len + 3u) & ~3u; b64_str.resize(padded_len); }catch(const std::exception&){ return make_error<err::out_of_memory>(); @@ -81,8 +81,8 @@ public: uint64_t j{0u}, k{0u}; std::array<uint8_t,3> s{}; - for(uint64_t i = 0u; i < from.size(); ++i){ - s[j] = from.at(i); + for(data<schema::UInt64> i = 0u; i < from.size(); ++i){ + s[j] = from.at(i.get()); ++j; if(j==3){ b64_str.at(k) = impl::base64_char_map.at((s[0u] & 0xFC) >> 2); diff --git a/modules/codec/c++/csv.hpp b/modules/codec/c++/csv.hpp index 240ed75..0d76372 100644 --- a/modules/codec/c++/csv.hpp +++ b/modules/codec/c++/csv.hpp @@ -50,7 +50,7 @@ struct csv_encode<schema::Array<T,Dim>, FromDecode> { } } - for(std::size_t i = 0; i < from.size(); ++i){ + for(data<schema::UInt64> i = 0; i < from.size(); ++i){ auto eov = csv_encode<T,FromDecode>::encode(from.at(i), to); if(eov.is_error()){ return eov; @@ -166,8 +166,8 @@ struct csv_encode<schema::String, FromDecode> { using Schema = schema::String; static error_or<void> encode(const data<Schema, FromDecode>& from, buffer& to){ - for(size_t i = 0; i < from.size(); ++i){ - auto eov = stream_value<schema::Int8>::encode(from.at(i), to); + for(data<schema::UInt64> i = 0; i < from.size(); ++i){ + auto eov = stream_value<schema::Int8>::encode(from.at(i.get()), to); if(eov.is_error()){ return eov; } diff --git a/modules/codec/c++/data.hpp b/modules/codec/c++/data.hpp index 75c611c..01eddb6 100644 --- a/modules/codec/c++/data.hpp +++ b/modules/codec/c++/data.hpp @@ -167,6 +167,11 @@ public: return {get() - rhs.get()}; } + data<Schema, encode::Native>& operator++() { + set(get() + static_cast<typename native_data_type<Schema>::type>(1)); + return *this; + } + template<typename Enc> bool operator==(const data<Schema, Enc>& rhs)const{ return get() == rhs.get(); @@ -271,6 +276,74 @@ public: } }; +template<typename T, uint64_t... D> +class data<schema::FixedArray<T,D...>, encode::Native> { +public: + using Schema = schema::FixedArray<T,D...>; + using MetaSchema = typename meta_schema<Schema>::MetaSchema; +private: + //using inner_type = std::array<data<T, encode::Native>, multiply_helper<Dims...>::value>; + //std::unique_ptr<inner_type> value_; + using ArrayT = std::array<data<T, encode::Native>, ct_multiply<uint64_t, D...>::value>; + ArrayT value_; + +public: + data() = default; + data(data<MetaSchema, encode::Native>){} + data(const std::array<data<T, encode::Native>, ct_multiply<uint64_t,D...>::value>& value__): + value_{value__} + {} + + data<T, encode::Native>& at(const std::array<uint64_t, sizeof...(D)>& ind){ + return value_.at(this->get_flat_index(ind)); + } + + const data<T, encode::Native>& at(const std::array<uint64_t, sizeof...(D)>& ind) const { + return value_.at(this->get_flat_index(ind)); + } + + data<T, encode::Native>& at(data<schema::UInt64, encode::Native> i) { + return value_.at(this->get_flat_index({i.get()})); + } + + const data<T, encode::Native>& at(data<schema::UInt64, encode::Native> i) const { + return value_.at(this->get_flat_index({i.get()})); + } + + data<T, encode::Native>& at(const data<schema::FixedArray<schema::UInt64, sizeof...(D)>>& i){ + return value_.at(this->get_flat_index(i)); + } + + const data<T, encode::Native>& at(const data<schema::FixedArray<schema::UInt64, sizeof...(D)>>& i)const{ + return value_.at(this->get_flat_index(i)); + } + + template<uint64_t i> + uint64_t get_dim_size() const { + return parameter_pack_value<i, uint64_t, D...>::value; + } + + data<schema::FixedArray<schema::UInt64, sizeof...(D)>> get_dims() const { + return {std::array<uint64_t, sizeof...(D)>{D...}}; + } +private: + uint64_t get_flat_index(const std::array<uint64_t, sizeof...(D)>& i) const { + uint64_t s = 0; + + uint64_t stride = 1; + + constexpr static std::array<uint64_t, sizeof...(D)> dims_{D...}; + + for(uint64_t iter = 0; iter < sizeof...(D); ++iter){ + assert(i.at(iter) < dims_.at(iter)); + s += i.at(iter) * stride; + stride *= dims_.at(iter); + } + + return s; + } +}; + /* template<typename T, typename N> class data<schema::Ref<schema::Primitive<T,N>>, encode::Native { @@ -427,7 +500,7 @@ public: /** * Return the amount of members. */ - constexpr size_t size() const { + constexpr uint64_t size() const { return sizeof...(T); } }; @@ -474,7 +547,7 @@ public: return std::get<i>(value_); } - constexpr size_t size() const { + constexpr uint64_t size() const { return sizeof...(T); } }; @@ -609,15 +682,17 @@ class data<schema::Array<T,Dim>, encode::Native> { const data<T, encode::Native>& at(const std::array<uint64_t, Dim>& ind) const { return value_.at(this->get_flat_index(ind)); } - - template<std::integral... Dims> - data<T, encode::Native>& at(Dims... i){ - return value_.at(this->get_flat_index(std::array<uint64_t, Dim>{static_cast<uint64_t>(i)...})); - } - template<std::integral... Dims> - const data<T, encode::Native>& at(Dims... i) const { - return value_.at(this->get_flat_index(std::array<uint64_t, Dim>{static_cast<uint64_t>(i)...})); + data<T, encode::Native>& at(data<schema::UInt64, encode::Native> i) { + data<schema::FixedArray<schema::UInt64,Dim>, encode::Native> i_arr; + i_arr.at(0u) = i; + return at(i_arr); + } + + const data<T, encode::Native>& at(data<schema::UInt64, encode::Native> i) const { + data<schema::FixedArray<schema::UInt64,Dim>, encode::Native> i_arr; + i_arr.at(0u) = i; + return at(i_arr); } data<T,encode::Native>& at(const data<schema::FixedArray<schema::UInt64,Dim>>& i){ @@ -632,7 +707,7 @@ class data<schema::Array<T,Dim>, encode::Native> { return dims_.at(i); } - size_t size() const { return value_.size();} + data<schema::UInt64,encode::Native> size() const { return {value_.size()};} data<schema::FixedArray<schema::UInt64, Dim>> get_dims() const { return {dims_}; @@ -662,7 +737,7 @@ private: static_assert(always_false<V>, "Cases exhausted"); } }(i.at(iter)); - assert(ind < dims_.at(iter)); + assert(ind < dims_.at({iter})); s += ind * stride; stride *= dims_.at(iter); } @@ -671,85 +746,6 @@ private: } }; -template<typename T, uint64_t... D> -class data<schema::FixedArray<T,D...>, encode::Native> { -public: - using Schema = schema::FixedArray<T,D...>; - using MetaSchema = typename meta_schema<Schema>::MetaSchema; -private: - //using inner_type = std::array<data<T, encode::Native>, multiply_helper<Dims...>::value>; - //std::unique_ptr<inner_type> value_; - using ArrayT = std::array<data<T, encode::Native>, ct_multiply<uint64_t, D...>::value>; - ArrayT value_; - -public: - data() = default; - data(data<MetaSchema, encode::Native>){} - data(const std::array<data<T, encode::Native>, ct_multiply<uint64_t,D...>::value>& value__): - value_{value__} - {} - - data<T, encode::Native>& at(const std::array<uint64_t, sizeof...(D)>& ind){ - return value_.at(this->get_flat_index(ind)); - } - - const data<T, encode::Native>& at(const std::array<uint64_t, sizeof...(D)>& ind) const { - return value_.at(this->get_flat_index(ind)); - } - - template<typename... Sch> - data<T, encode::Native>& at(data<Sch, encode::Native>... i) { - return value_.at(this->get_flat_index({i...})); - } - - template<typename... Sch> - const data<T, encode::Native>& at(data<Sch, encode::Native>... i) const { - return value_.at(this->get_flat_index({i...})); - } - - template<std::integral... Dims> - data<T, encode::Native>& at(Dims... i) { - return value_.at(this->get_flat_index({i...})); - } - - template<std::integral... Dims> - const data<T, encode::Native>& at(Dims... i) const { - return value_.at(this->get_flat_index({i...})); - } - - data<T, encode::Native>& at(const data<schema::FixedArray<schema::UInt64, sizeof...(D)>>& i){ - return value_.at(this->get_flat_index(i)); - } - - const data<T, encode::Native>& at(const data<schema::FixedArray<schema::UInt64, sizeof...(D)>>& i)const{ - return value_.at(this->get_flat_index(i)); - } - - template<uint64_t i> - uint64_t get_dim_size() const { - return parameter_pack_value<i, uint64_t, D...>::value; - } - - data<schema::FixedArray<schema::UInt64, sizeof...(D)>> get_dims() const { - return {std::array<uint64_t, sizeof...(D)>{D...}}; - } -private: - uint64_t get_flat_index(const std::array<uint64_t, sizeof...(D)>& i) const { - uint64_t s = 0; - - uint64_t stride = 1; - - constexpr static std::array<uint64_t, sizeof...(D)> dims_{D...}; - - for(uint64_t iter = 0; iter < sizeof...(D); ++iter){ - assert(i.at(iter) < dims_.at(iter)); - s += i.at(iter) * stride; - stride *= dims_.at(iter); - } - - return s; - } -}; /** * Data type representing string. @@ -781,8 +777,8 @@ public: /** * Return the length of the string. */ - std::size_t size() const { - return value_.size(); + data<schema::UInt64, encode::Native> size() const { + return {value_.size()}; } /** @@ -795,22 +791,22 @@ public: /** * Get a char reference at position i. */ - char& at(size_t i) { + char& at(uint64_t i) { return value_.at(i); } /** * Get a char reference at position i. */ - const char& at(size_t i) const { + const char& at(uint64_t i) const { return value_.at(i); } - char get_at(size_t i) const{ + char get_at(uint64_t i) const{ return value_.at(i); } - void set_at(size_t i, char val){ + void set_at(uint64_t i, char val){ value_.at(i) = val; } @@ -828,8 +824,8 @@ public: return false; } bool eq = true; - for(uint64_t i = 0; i < size(); ++i){ - eq = eq && (get_at(i) == rhs.get_at(i)); + for(data<schema::UInt64, encode::Native> i = 0; i < size(); ++i){ + eq = eq && (get_at(i.get()) == rhs.get_at(i.get())); } return eq; } diff --git a/modules/codec/c++/schema_meta.hpp b/modules/codec/c++/schema_meta.hpp index 80b6686..659250c 100644 --- a/modules/codec/c++/schema_meta.hpp +++ b/modules/codec/c++/schema_meta.hpp @@ -78,9 +78,9 @@ struct meta_schema<schema::Array<T,Dim>> { using Schema = schema::Array<T,Dim>; }; -template<typename T, uint64_t Dim> -struct meta_schema<schema::FixedArray<T,Dim>> { +template<typename T, uint64_t... Dim> +struct meta_schema<schema::FixedArray<T,Dim...>> { using MetaSchema = schema::Void; - using Schema = schema::FixedArray<T,Dim>; + using Schema = schema::FixedArray<T,Dim...>; }; } diff --git a/modules/codec/c++/simple.hpp b/modules/codec/c++/simple.hpp index 33831b6..4990578 100644 --- a/modules/codec/c++/simple.hpp +++ b/modules/codec/c++/simple.hpp @@ -169,7 +169,7 @@ template<typename FromEnc> struct kelsimple_encode<schema::String, FromEnc> { static error_or<void> encode(const data<schema::String, FromEnc>& from, buffer& to){ const auto str_size = from.size(); - typename native_data_type<schema::UInt64>::type str_len = static_cast<uint64_t>(str_size); + typename native_data_type<schema::UInt64>::type str_len = static_cast<uint64_t>(str_size.get()); { auto eov = stream_value<schema::UInt64>::encode(str_len, to); if(eov.is_error()){ @@ -177,8 +177,8 @@ struct kelsimple_encode<schema::String, FromEnc> { } } - for(std::size_t i = 0; i < str_size; ++i){ - auto eov = stream_value<schema::Int8>::encode(from.at(i), to); + for(data<schema::UInt64> i = 0; i < str_size; ++i){ + auto eov = stream_value<schema::Int8>::encode(from.at(i.get()), to); if(eov.is_error()){ return eov; } @@ -344,14 +344,14 @@ struct kelsimple_decode<schema::String, FromEnc> { } to = data<schema::String,FromEnc>{val}; } - const std::size_t str_size = to.size(); - for(std::size_t i = 0; i < str_size; ++i){ + const data<schema::UInt64> str_size = to.size(); + for(data<schema::UInt64> i = 0; i < str_size; ++i){ int8_t val{}; auto eov = stream_value<schema::Int8>::decode(val, from); if(eov.is_error()){ return eov; } - to.set_at(i, val); + to.set_at(i.get(), val); } return void_t{}; } diff --git a/modules/codec/examples/arg_parser.cpp b/modules/codec/examples/arg_parser.cpp index 569c464..34a0b1d 100644 --- a/modules/codec/examples/arg_parser.cpp +++ b/modules/codec/examples/arg_parser.cpp @@ -40,7 +40,7 @@ int main(int argc, char** argv){ std::cout<<"=======\n"; std::cout<<"\nProgram: "; auto& prog = nat_dat.template get<"program">(); - for(uint64_t i = 0; i < prog.size(); ++i){ + for(uint64_t i = 0; i < prog.size().get(); ++i){ std::cout<<prog.at(i); } std::cout<<"\n"; @@ -49,7 +49,7 @@ int main(int argc, char** argv){ { std::cout<<"File: "; auto& file_val = str_val.template get<"file">(); - for(uint64_t i = 0; i < file_val.size(); ++i){ + for(uint64_t i = 0; i < file_val.size().get(); ++i){ std::cout<<file_val.at(i); } std::cout<<"\n"; diff --git a/modules/codec/tests/codec.cpp b/modules/codec/tests/codec.cpp index 7ad1c89..a1f37b8 100644 --- a/modules/codec/tests/codec.cpp +++ b/modules/codec/tests/codec.cpp @@ -58,13 +58,13 @@ SAW_TEST("One Dimensional Array") { int bar = 0; - for(size_t i = 0; i < arr.get_dim_size(0); ++i){ + for(data<schema::UInt64, encode::Native> i = 0; i < arr.size(); ++i){ arr.at(i).set(bar++); } int sum = 0; for(size_t i = 0; i < arr.get_dim_size(0); ++i){ - sum += arr.at(i).get(); + sum += arr.at(data<schema::UInt64>{i}).get(); } SAW_EXPECT(sum == 124750, std::to_string(sum) + " is not 124750. Expected that data stays correct"); @@ -76,7 +76,7 @@ SAW_TEST("One dim Array Default init"){ data<schema::OneDimArray, encode::Native> arr; SAW_EXPECT(arr.get_dim_size(0) == 0, "Dim should be size 0"); - SAW_EXPECT(arr.size() == 0, "Total size should also be zero"); + SAW_EXPECT(arr.size().get() == 0u, "Total size should also be zero"); } SAW_TEST("One dimensional Array Add"){ @@ -87,13 +87,13 @@ SAW_TEST("One dimensional Array Add"){ int bar = 0; for(size_t i = 0; i < arr.get_dim_size(0); ++i){ - arr.at(i).set(bar++); + arr.at(data<schema::UInt64>{i}).set(bar++); } arr.add(7); - SAW_EXPECT(arr.size() == 6u, "Array size is not 6u. Expected that data stays correct"); - SAW_EXPECT(arr.at(5u).get() == 7, "Array at 5u is not 7. Expected that data stays correct"); + SAW_EXPECT(arr.size().get() == 6u, "Array size is not 6u. Expected that data stays correct"); + SAW_EXPECT(arr.at(data<schema::UInt64>{5u}).get() == 7, "Array at 5u is not 7. Expected that data stays correct"); } SAW_TEST("Two Dimensional Array") { @@ -108,13 +108,13 @@ SAW_TEST("Two Dimensional Array") { for(size_t i = 0; i < arr.get_dim_size(0); ++i){ for(size_t j = 0; j < arr.get_dim_size(1); ++j){ ++bar; - arr.at(i,j).set(bar); + arr.at({i,j}).set(bar); } } int sum = 0; for(size_t i = 0; i < arr.get_dim_size(0); ++i){ for(size_t j = 0; j < arr.get_dim_size(1); ++j){ - sum += arr.at(i,j).get(); + sum += arr.at({i,j}).get(); } } SAW_EXPECT(sum == expected_sum, std::to_string(sum) + " is not "+ std::to_string(expected_sum) + ". Expected that data stays correct"); @@ -132,7 +132,7 @@ SAW_TEST("Three Dimensional Array") { for(size_t j = 0; j < arr.get_dim_size(1); ++j){ for(size_t k = 0; k < arr.get_dim_size(2); ++k){ ++bar; - arr.at(i,j,k).set(bar); + arr.at({i,j,k}).set(bar); } } } @@ -140,7 +140,7 @@ SAW_TEST("Three Dimensional Array") { for(size_t i = 0; i < arr.get_dim_size(0); ++i){ for(size_t j = 0; j < arr.get_dim_size(1); ++j){ for(size_t k = 0; k < arr.get_dim_size(2); ++k){ - sum += arr.at(i,j,k).get(); + sum += arr.at({i,j,k}).get(); } } } @@ -202,7 +202,7 @@ SAW_TEST("KelSimple Array write and read back"){ for(std::size_t i = 0; i < 2; ++i) { for(std::size_t j = 0; j < 3; ++j){ - native.at(i,j).set(i+2*j); + native.at({i,j}).set(i+2*j); } } @@ -211,7 +211,7 @@ SAW_TEST("KelSimple Array write and read back"){ for(std::size_t i = 0; i < 2; ++i) { for(std::size_t j = 0; j < 3; ++j){ - native.at(i,j).set(0); + native.at({i,j}).set(0); } } @@ -220,7 +220,7 @@ SAW_TEST("KelSimple Array write and read back"){ for(std::size_t i = 0; i < 2; ++i) { for(std::size_t j = 0; j < 3; ++j){ - SAW_EXPECT(native.at(i,j).get() == static_cast<int32_t>(i+2*j), "Values incorrectly decoded"); + SAW_EXPECT(native.at({i,j}).get() == static_cast<int32_t>(i+2*j), "Values incorrectly decoded"); } } } @@ -234,8 +234,8 @@ SAW_TEST("KelSimple Struct write and read back"){ auto& tda = native.template get<"two_dim_array">(); tda = {1,2}; - tda.at(0,0).set(5); - tda.at(0,1).set(3); + tda.at({0,0}).set(5); + tda.at({0,1}).set(3); native.template get<"number">().set(410); codec<schema::TestStruct, encode::KelSimple> codec; @@ -251,8 +251,8 @@ SAW_TEST("KelSimple Struct write and read back"){ auto& dec_tda = native.template get<"two_dim_array">(); - SAW_EXPECT(dec_tda.at(0,0).get() == 5, "Incorrect Decoding in array 0,0"); - SAW_EXPECT(dec_tda.at(0,1).get() == 3, "Incorrect Decoding in array 0,1"); + SAW_EXPECT(dec_tda.at({0,0}).get() == 5, "Incorrect Decoding in array 0,0"); + SAW_EXPECT(dec_tda.at({0,1}).get() == 3, "Incorrect Decoding in array 0,1"); SAW_EXPECT(native.template get<"number">().get() == 410, "Incorrect Decoding in number"); } @@ -302,8 +302,8 @@ SAW_TEST("KelSimple Tuple write and read back"){ auto& tda = native.template get<0>(); tda = {1,2}; - tda.at(0,0).set(5); - tda.at(0,1).set(3); + tda.at({0,0}).set(5); + tda.at({0,1}).set(3); native.template get<1>().set(410); codec<schema::TestTuple, encode::KelSimple> codec; @@ -319,8 +319,8 @@ SAW_TEST("KelSimple Tuple write and read back"){ auto& dec_tda = native.template get<0>(); - SAW_EXPECT(dec_tda.at(0,0).get() == 5, "Incorrect Decoding in array 0,0"); - SAW_EXPECT(dec_tda.at(0,1).get() == 3, "Incorrect Decoding in array 0,1"); + SAW_EXPECT(dec_tda.at({0,0}).get() == 5, "Incorrect Decoding in array 0,0"); + SAW_EXPECT(dec_tda.at({0,1}).get() == 3, "Incorrect Decoding in array 0,1"); SAW_EXPECT(native.template get<1>().get() == 410, "Incorrect Decoding in number"); } diff --git a/modules/codec/tests/csv.cpp b/modules/codec/tests/csv.cpp index 417a547..5772e20 100644 --- a/modules/codec/tests/csv.cpp +++ b/modules/codec/tests/csv.cpp @@ -28,19 +28,19 @@ SAW_TEST("Codec Csv/Encode Basic"){ size_t n_size = 3u; data <TestArray, encode::Native> native_data{n_size}; { - auto& row = native_data.at(0); + auto& row = native_data.at(data<schema::UInt64>{0}); row.template get<"string">().set("foo"); row.template get<"number">().set(140u); row.template get<"signed">().set(1); } { - auto& row = native_data.at(1); + auto& row = native_data.at(data<schema::UInt64>{1}); row.template get<"string">().set("bar"); row.template get<"number">().set(245u); row.template get<"signed">().set(2); } { - auto& row = native_data.at(2); + auto& row = native_data.at(data<schema::UInt64>{2}); row.template get<"string">().set("ban and anna"); row.template get<"number">().set(42u); row.template get<"signed">().set(3); diff --git a/modules/codec/tests/data.cpp b/modules/codec/tests/data.cpp new file mode 100644 index 0000000..816aa1c --- /dev/null +++ b/modules/codec/tests/data.cpp @@ -0,0 +1,32 @@ +#include <forstio/test/suite.hpp> +#include "../c++/data.hpp" + +namespace { +namespace sch { +using namespace saw::schema; + +using Int32Array = Array< + Int32 +>; +} + +SAW_TEST("Data Native/Array Access with Data Native"){ + using namespace saw; + + data<sch::Int32Array,encode::Native> prim{2u}; + prim.at(1u).set(0); + + data<schema::UInt64, encode::Native> i{1u}; + + auto& a = prim.at({i}); + + a.set(5); + + auto b = prim.at({i}); + b.set(10); + // Check if it's a reference being manipulated + SAW_EXPECT(a.get() == 5, "'a' has unexpected value."); + SAW_EXPECT(b.get() == 10, "'b' has unexpected value."); +} + +} diff --git a/modules/codec/tests/transport.cpp b/modules/codec/tests/transport.cpp index 8c786e9..e0e105f 100644 --- a/modules/codec/tests/transport.cpp +++ b/modules/codec/tests/transport.cpp @@ -33,8 +33,8 @@ SAW_TEST("Transport FixedLen Struct write and slice"){ auto& tda = native.template get<"two_dim_array">(); tda = {1,2}; - tda.at(0,0).set(5); - tda.at(0,1).set(3); + tda.at({0,0}).set(5); + tda.at({0,1}).set(3); native.template get<"number">().set(410); } codec<schema::TestStruct, encode::KelSimple> codec; @@ -67,8 +67,8 @@ SAW_TEST("Transport FixedLen Struct write and slice"){ auto& tda = native.template get<"two_dim_array">(); tda = {1,2}; - tda.at(0,0).set(2); - tda.at(0,1).set(4); + tda.at({0,0}).set(2); + tda.at({0,1}).set(4); native.template get<"number">().set(709); } { @@ -118,8 +118,8 @@ SAW_TEST("Transport FixedLen Struct write and slice"){ { auto& tda = native.template get<"two_dim_array">(); - SAW_EXPECT(tda.at(0,0).get() == 5, "Decoded value (0,0) wrong."); - SAW_EXPECT(tda.at(0,1).get() == 3, "Decoded value (0,1) wrong."); + SAW_EXPECT(tda.at({0,0}).get() == 5, "Decoded value (0,0) wrong."); + SAW_EXPECT(tda.at({0,1}).get() == 3, "Decoded value (0,1) wrong."); SAW_EXPECT(native.template get<"number">().get() == 410, "Decoded value number wrong."); } } @@ -148,8 +148,8 @@ SAW_TEST("Transport FixedLen Struct write and slice"){ { auto& tda = native.template get<"two_dim_array">(); - SAW_EXPECT(tda.at(0,0).get() == 2, "Decoded value (0,0) wrong."); - SAW_EXPECT(tda.at(0,1).get() == 4, "Decoded value (0,1) wrong."); + SAW_EXPECT(tda.at({0,0}).get() == 2, "Decoded value (0,0) wrong."); + SAW_EXPECT(tda.at({0,1}).get() == 4, "Decoded value (0,1) wrong."); SAW_EXPECT(native.template get<"number">().get() == 709, "Decoded value number wrong."); } } |