7 #ifdef MDDS_MULTI_TYPE_MATRIX_DEBUG
8 #ifndef MDDS_MULTI_TYPE_VECTOR_DEBUG
9 #define MDDS_MULTI_TYPE_VECTOR_DEBUG 1
13 #include "multi_type_vector.hpp"
24 element_empty = mdds::mtv::element_type_empty,
25 element_boolean = mdds::mtv::element_type_boolean,
26 element_string = mdds::mtv::element_type_string,
27 element_numeric = mdds::mtv::element_type_double,
28 element_integer = mdds::mtv::element_type_int32
51 template<
typename Traits>
54 using traits_type = Traits;
57 using string_block_type =
typename traits_type::string_element_block;
58 using integer_block_type =
typename traits_type::integer_element_block;
60 using string_type =
typename string_block_type::value_type;
61 using integer_type =
typename integer_block_type::value_type;
62 using size_type = std::size_t;
69 typename traits_type::string_element_block,
typename traits_type::integer_element_block>;
75 using position_type =
typename store_type::position_type;
76 using const_position_type =
typename store_type::const_position_type;
87 size_pair_type() noexcept(std::is_fundamental_v<size_type>) : row(0), column(0)
89 size_pair_type(size_type _row, size_type _column) noexcept(std::is_fundamental_v<size_type>)
90 : row(_row), column(_column)
97 size_type* ptrs[2] = {&row, &column};
100 for (size_type v : vs)
104 bool operator==(
const size_pair_type& r)
const noexcept(std::is_fundamental_v<size_type>)
106 return row == r.row && column == r.column;
108 bool operator!=(
const size_pair_type& r)
const noexcept(std::is_fundamental_v<size_type>)
110 return !operator==(r);
121 const element_block_type* data;
126 template<
typename _Blk>
127 typename _Blk::const_iterator begin()
const;
129 template<
typename _Blk>
130 typename _Blk::const_iterator end()
const;
133 void assign(
const const_position_type& pos, size_type section_size);
136 static mtm::element_t to_mtm_type(mdds::mtv::element_t mtv_type)
140 case string_block_type::block_type:
141 return mdds::mtm::element_string;
142 case integer_block_type::block_type:
143 return mdds::mtm::element_integer;
144 case mdds::mtv::element_type_double:
145 case mdds::mtv::element_type_boolean:
146 case mdds::mtv::element_type_empty:
148 return static_cast<mtm::element_t
>(mtv_type);
150 throw type_error(
"multi_type_matrix: unknown element type.");
155 template<
typename FuncT>
159 walk_func(FuncT& func) noexcept : m_func(func)
162 void operator()(
const typename store_type::const_iterator::value_type& mtv_node)
164 element_block_node_type mtm_node;
165 mtm_node.type = to_mtm_type(mtv_node.type);
166 mtm_node.size = mtv_node.size;
167 mtm_node.data = mtv_node.data;
172 static constexpr
bool nothrow_default_constructible_v =
173 std::is_nothrow_default_constructible_v<store_type> && std::is_nothrow_default_constructible_v<size_pair_type>;
175 static constexpr
bool nothrow_eq_comparable_v =
176 noexcept(std::declval<store_type>() == std::declval<store_type>()) &&
177 noexcept(std::declval<size_pair_type>() == std::declval<size_pair_type>());
189 static position_type
next_position(
const position_type& pos);
200 static const_position_type
next_position(
const const_position_type& pos);
223 template<typename _T>
238 template<typename _T>
239 multi_type_matrix(size_type rows, size_type cols, const _T& it_begin, const _T& it_end);
256 bool operator==(const
multi_type_matrix& other) const noexcept(nothrow_eq_comparable_v);
257 bool operator!=(const
multi_type_matrix& other) const noexcept(nothrow_eq_comparable_v);
273 position_type
position(size_type row, size_type col);
288 position_type
position(const position_type& pos_hint, size_type row, size_type col);
300 const_position_type
position(size_type row, size_type col) const;
314 const_position_type
position(const const_position_type& pos_hint, size_type row, size_type col) const;
342 const_position_type end_position() const;
352 mtm::element_t
get_type(const const_position_type& pos) const;
360 mtm::element_t
get_type(size_type row, size_type col) const;
373 double get_numeric(size_type row, size_type col) const;
385 double get_numeric(const const_position_type& pos) const;
398 integer_type
get_integer(size_type row, size_type col) const;
410 integer_type
get_integer(const const_position_type& pos) const;
423 bool get_boolean(size_type row, size_type col) const;
435 bool get_boolean(const const_position_type& pos) const;
446 const string_type&
get_string(size_type row, size_type col) const;
456 const string_type&
get_string(const const_position_type& pos) const;
468 template<typename _T>
469 _T
get(size_type row, size_type col) const;
477 void set_empty(size_type row, size_type col);
490 void set_empty(size_type row, size_type col, size_type length);
499 position_type
set_empty(const position_type& pos);
522 void set(size_type row, size_type col,
double val);
532 position_type
set(const position_type& pos,
double val);
541 void set(size_type row, size_type col,
bool val);
551 position_type
set(const position_type& pos,
bool val);
560 void set(size_type row, size_type col, const string_type& str);
570 position_type
set(const position_type& pos, const string_type& str);
579 void set(size_type row, size_type col, integer_type val);
589 position_type
set(const position_type& pos, integer_type val);
607 template<typename _T>
608 void set(size_type row, size_type col, const _T& it_begin, const _T& it_end);
624 template<typename _T>
625 position_type
set(const position_type& pos, const _T& it_begin, const _T& it_end);
638 template<typename _T>
639 void set_column(size_type col, const _T& it_begin, const _T& it_end);
647 size_pair_type
size() const;
679 template<typename _T>
680 void copy(size_type rows, size_type cols, const _T& it_begin, const _T& it_end);
692 void resize(size_type rows, size_type cols);
703 template<typename _T>
704 void resize(size_type rows, size_type cols, const _T& value);
740 template<typename FuncT>
741 FuncT
walk(FuncT func) const;
759 template<typename FuncT>
760 FuncT
walk(FuncT func, const size_pair_type& start, const size_pair_type& end) const;
772 template<typename FuncT>
793 template<typename FuncT>
795 FuncT func, const
multi_type_matrix& right, const size_pair_type& start, const size_pair_type& end) const;
797 #ifdef MDDS_MULTI_TYPE_MATRIX_DEBUG
800 m_store.dump_blocks(std::cout);
815 inline size_type get_pos(size_type row, size_type col)
const
817 return m_size.row * col + row;
820 inline size_type get_pos(
const const_position_type& pos)
const
822 return pos.first->position + pos.second;
827 size_pair_type m_size;
832 #include "multi_type_matrix_def.inl"
_T get(size_type row, size_type col) const
position_type end_position()
static position_type next_position(const position_type &pos)
double get_numeric(size_type row, size_type col) const
bool get_boolean(size_type row, size_type col) const
size_pair_type size() const
void set_column_empty(size_type col)
FuncT walk(FuncT func) const
Definition: global.hpp:90
mtm::element_t get_type(const const_position_type &pos) const
void resize(size_type rows, size_type cols)
integer_type get_integer(size_type row, size_type col) const
Definition: global.hpp:76
Definition: multi_type_matrix.hpp:83
void set_column(size_type col, const _T &it_begin, const _T &it_end)
void set(size_type row, size_type col, double val)
Definition: types.hpp:706
size_pair_type matrix_position(const const_position_type &pos) const
void copy(const multi_type_matrix &src)
multi_type_matrix() noexcept(nothrow_default_constructible_v)
Definition: multi_type_matrix.hpp:52
void set_empty(size_type row, size_type col)
multi_type_matrix & transpose()
const string_type & get_string(size_type row, size_type col) const
Definition: cref_wrapper.hpp:12
void set_row_empty(size_type row)
Definition: block_funcs.hpp:42
Definition: types.hpp:134
position_type position(size_type row, size_type col)
Definition: multi_type_matrix.hpp:34
Definition: multi_type_matrix.hpp:114
void swap(multi_type_matrix &r)