NSVD Reader  0.0.1
dim_info.hpp
Go to the documentation of this file.
1 
5 #ifndef __NODAMUSHI_SVD_NORMALIZED_DIM_INFO_HPP__
6 #define __NODAMUSHI_SVD_NORMALIZED_DIM_INFO_HPP__
7 
8 # include <cstdint>
9 
10 
11 namespace nodamushi{
12 namespace svd{
13 namespace normalized{
14 
16 enum class dim_type
17 {
19  NON=0,
21  SEQ,
23  ARRAY
24 };
25 
27 struct dim_info
28 {
29  using id_t = unsigned int;
33  size_t index;
35  size_t length;
38 
40  constexpr operator bool()const noexcept{return type != dim_type::NON;}
41 
43  constexpr bool is_array()const noexcept{return type == dim_type::ARRAY;}
45  constexpr bool is_seq()const noexcept{return type == dim_type::SEQ;}
47  constexpr bool is_first()const noexcept{return index == 0;}
49  constexpr bool is_last()const noexcept{return index == length-1;}
50 };
51 
52 
53 }}}// end namespace nodamushi::svd::normalized
54 
55 
56 # include <ostream>
57 namespace std{
59 {
61  switch(d){
62  case dt::NON:o << "non" ;break;
63  case dt::SEQ:o << "seq" ;break;
64  case dt::ARRAY:o << "array";break;
65  }
66  return o;
67 }
68 ostream& operator<<(ostream& o,const ::nodamushi::svd::normalized::dim_info& d)
69 {
71 
72  if(d.type == dt::NON){
73  o << "[dim:non:id="<<d.id<<"]";
74  }else{
75  o << "[dim:" << d.type << ":i="<<d.index<<":length="<<d.length<<":id="<<d.id<<"]";
76  }
77  return o;
78 }
79 
80 }
81 
82 #endif // __NODAMUSHI_SVD_NORMALIZED_DIM_INFO_HPP__
ostream & operator<<(std::ostream &os, const ::nodamushi::svd::Access &value)
Definition: Access.hpp:144
dim_type type
array or seq or non
Definition: dim_info.hpp:31
Definition: Access.hpp:143
dim_type
Array or Sequence or not.
Definition: dim_info.hpp:16
constexpr bool is_last() const noexcept
is the index is the last index
Definition: dim_info.hpp:49
constexpr bool is_array() const noexcept
is the dimension type array
Definition: dim_info.hpp:43
id_t id
dimension group id.this value is unique in the parent.
Definition: dim_info.hpp:37
constexpr bool is_first() const noexcept
is the index is 0
Definition: dim_info.hpp:47
dim,dimIndex,array information object.
Definition: dim_info.hpp:27
size_t length
dimension length
Definition: dim_info.hpp:35
constexpr bool is_seq() const noexcept
is the dimension type sequence
Definition: dim_info.hpp:45