10 #ifndef __NODAMUSHI_SVD_DIM_TYPE_HPP__ 11 #define __NODAMUSHI_SVD_DIM_TYPE_HPP__ 40 template<
typename STR>
using dimName = STR;
53 const std::string &s,
size_t f,
size_t e,
size_t f2,
size_t e2):
56 original.reserve(e + e2 - f - f2 + 1);
64 # if __cplusplus >= 201703 70 std::string_view s,
size_t f,
size_t e,
size_t f2,
size_t e2) :
73 original.reserve(e + e2 - f - f2 + 1);
105 return c ==
' ' || c ==
'\t' 106 # ifndef DISABLE_SVD_LINEBREAK_AS_WHITESPACE 107 ||c ==
'\r' || c ==
'\n' 115 # if __cplusplus >= 201703 116 std::string_view s = str;
122 # if __cplusplus >= 201703 125 std::string_view s = str;
136 size_t len = text.length();
174 unsigned int numseq_state = 1;
175 size_t n1_begin_pos=0;
176 size_t n1_end_pos = 0;
177 size_t n2_begin_pos=0;
179 while(i < len && ((c=text[i]) !=
',')){
182 switch(numseq_state){
187 case 5: numseq_state=6;
break;
194 bool is_num =
'0' <= c && c <=
'9';
196 switch(numseq_state){
218 }
else if ((numseq_state == 2 || numseq_state==3)&& c ==
'-'){
219 if(numseq_state == 2){
230 if(numseq_state == 5 || numseq_state == 6){
231 const int from = ::nodamushi::to_int<int>(text,n1_begin_pos,n1_end_pos);
232 const int end = ::nodamushi::to_int<int>(text,n2_begin_pos,e);
233 for(
int k = from;k<=end;k++){
235 dims.emplace_back(k, text, n1_begin_pos, n1_end_pos,n2_begin_pos,e);
237 dims.emplace_back(k);
240 dims.emplace_back(text ,p, e);
246 const std::vector<dimIndex_value>&
get()
const{
return dims;}
247 const std::string&
at(
int index)
const{
return dims.at(index).str;}
248 size_t length()const noexcept{
return dims.size();}
249 size_t size()const noexcept{
return dims.size();}
250 const std::string&
operator[](
size_t i)
const noexcept{
return dims[i].str;}
251 operator bool()const noexcept{
return dims.size() != 0;}
258 void append(std::string& dst,
size_t index)
const{
259 if(index <
size())dst.append(dims[index].str);
260 else dst.append(std::to_string(index));
274 std::vector<dimIndex_value> dims;
288 # if __cplusplus >= 201703 289 static bool set(std::string_view src,
dimIndex& dst)
304 ostream&
operator <<(ostream& o,const ::nodamushi::svd::dimIndex& d)
307 for(
const auto& v:d.get()){
308 if(v.has_original && v.original.empty())
310 if(first) first =
false;
321 #endif // __NODAMUSHI_SVD_DIM_TYPE_HPP__
ostream & operator<<(std::ostream &os, const ::nodamushi::svd::Access &value)
const std::string & at(int index) const
dimIndex_value(int value, const std::string &s, size_t f, size_t e, size_t f2, size_t e2)
for first number
const std::string & string_ref
const std::vector< dimIndex_value > & get() const
dimIndex & operator=(const std::string &text)
dimIndex_value(const std::string &s, size_t f, size_t e)
value
static bool is_white_space(char c)
static bool set(const std::string &src, dimIndex &dst)
bool operator!=(string_ref s) const noexcept
size_t length() const noexcept
std::string str
dimIndex text
bool operator==(string_ref s) const noexcept
This class reperesents SVD(xml) element / attribute.
void append(std::string &dst, size_t index) const
bool has_original
flag for original.
size_t size() const noexcept
dimIndex_value(int value)
for number
dimIndex & operator=(const char *str)
const std::string & operator[](size_t i) const noexcept
bool contains(string_ref s) const noexcept