All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Functions
flashmatch::parser Namespace Reference

Functions

template<>
std::string FromString (const std::string &value)
 
template<>
float FromString (const std::string &value)
 
template<>
double FromString (const std::string &value)
 
template<>
unsigned short FromString (const std::string &value)
 
template<>
unsigned int FromString (const std::string &value)
 
template<>
unsigned long FromString (const std::string &value)
 
template<>
short FromString (const std::string &value)
 
template<>
int FromString (const std::string &value)
 
template<>
long FromString (const std::string &value)
 
template<>
bool FromString (const std::string &value)
 
template<>
std::vector< std::string > FromString (const std::string &value)
 
template<>
std::vector< float > FromString< std::vector< float > > (const std::string &value)
 Parse flashmatch::PSet configuration file content. More...
 
template<>
std::vector< double > FromString< std::vector< double > > (const std::string &value)
 Parse flashmatch::PSet configuration file content. More...
 
template<>
std::vector< short > FromString< std::vector< short > > (const std::string &value)
 Parse flashmatch::PSet configuration file content. More...
 
template<>
std::vector< int > FromString< std::vector< int > > (const std::string &value)
 Parse flashmatch::PSet configuration file content. More...
 
template<>
std::vector< long > FromString< std::vector< long > > (const std::string &value)
 Parse flashmatch::PSet configuration file content. More...
 
template<>
std::vector< unsigned short > FromString< std::vector< unsigned short > > (const std::string &value)
 Parse flashmatch::PSet configuration file content. More...
 
template<>
std::vector< unsigned int > FromString< std::vector< unsigned int > > (const std::string &value)
 Parse flashmatch::PSet configuration file content. More...
 
template<>
std::vector< unsigned long > FromString< std::vector< unsigned long > > (const std::string &value)
 Parse flashmatch::PSet configuration file content. More...
 
template<>
std::vector< bool > FromString< std::vector< bool > > (const std::string &value)
 Parse flashmatch::PSet configuration file content. More...
 
template<>
std::string ToString< std::string > (const std::string &value)
 Parse flashmatch::PSet configuration file content. More...
 
template<class T >
FromString (const std::string &value)
 
template<>
std::string FromString< std::string > (const std::string &value)
 Parse flashmatch::PSet configuration file content. More...
 
template<>
float FromString< float > (const std::string &value)
 Parse flashmatch::PSet configuration file content. More...
 
template<>
double FromString< double > (const std::string &value)
 Parse flashmatch::PSet configuration file content. More...
 
template<>
short FromString< short > (const std::string &value)
 Parse flashmatch::PSet configuration file content. More...
 
template<>
int FromString< int > (const std::string &value)
 Parse flashmatch::PSet configuration file content. More...
 
template<>
long FromString< long > (const std::string &value)
 Parse flashmatch::PSet configuration file content. More...
 
template<>
unsigned short FromString< unsigned short > (const std::string &value)
 Parse flashmatch::PSet configuration file content. More...
 
template<>
unsigned int FromString< unsigned int > (const std::string &value)
 Parse flashmatch::PSet configuration file content. More...
 
template<>
unsigned long FromString< unsigned long > (const std::string &value)
 Parse flashmatch::PSet configuration file content. More...
 
template<>
bool FromString< bool > (const std::string &value)
 Parse flashmatch::PSet configuration file content. More...
 
template<>
std::vector< std::string > FromString< std::vector< std::string > > (const std::string &value)
 Parse flashmatch::PSet configuration file content. More...
 
template<class T >
std::string ToString (const T &value)
 Parse flashmatch::PSet configuration file content. More...
 
template<class T >
std::string VecToString (const std::vector< T > &value)
 Parse flashmatch::PSet configuration file content. More...
 

Function Documentation

template<>
std::string flashmatch::parser::FromString ( const std::string &  value)

Definition at line 8 of file Parser.cxx.

9  {
10  std::string res(value);
11  if(res.empty()) return res;
12 
13  if(res.find("\"") == 0) res = res.substr(1);
14  if(res.empty()) return res;
15 
16  if(res.rfind("\"") == (res.length()-1)) res = res.substr(0,res.length()-1);
17  return res;
18  }
temporary value
template<>
float flashmatch::parser::FromString ( const std::string &  value)

Definition at line 20 of file Parser.cxx.

21  { return std::stof(value); }
temporary value
template<>
double flashmatch::parser::FromString ( const std::string &  value)

Definition at line 23 of file Parser.cxx.

24  { return std::stod(value); }
temporary value
template<class T >
T flashmatch::parser::FromString ( const std::string &  value)

Definition at line 8 of file Parser.cxx.

9  {
10  std::string res(value);
11  if(res.empty()) return res;
12 
13  if(res.find("\"") == 0) res = res.substr(1);
14  if(res.empty()) return res;
15 
16  if(res.rfind("\"") == (res.length()-1)) res = res.substr(0,res.length()-1);
17  return res;
18  }
temporary value
template<>
unsigned short flashmatch::parser::FromString ( const std::string &  value)

Definition at line 26 of file Parser.cxx.

27  { return std::stoul(value); }
temporary value
template<>
unsigned int flashmatch::parser::FromString ( const std::string &  value)

Definition at line 29 of file Parser.cxx.

30  { return std::stoul(value); }
temporary value
template<>
unsigned long flashmatch::parser::FromString ( const std::string &  value)

Definition at line 32 of file Parser.cxx.

33  { return std::stoul(value); }
temporary value
template<>
short flashmatch::parser::FromString ( const std::string &  value)

Definition at line 35 of file Parser.cxx.

36  { return std::stoi(value); }
temporary value
template<>
int flashmatch::parser::FromString ( const std::string &  value)

Definition at line 38 of file Parser.cxx.

39  { return std::stoi(value); }
temporary value
template<>
long flashmatch::parser::FromString ( const std::string &  value)

Definition at line 41 of file Parser.cxx.

42  { return std::stol(value); }
temporary value
template<>
bool flashmatch::parser::FromString ( const std::string &  value)

Definition at line 44 of file Parser.cxx.

45  {
46  std::string tmp=value;
47  std::transform(tmp.begin(),tmp.end(),tmp.begin(),::tolower);
48  if( value == "true" || value == "1" ) return true;
49  if( value == "false" || value == "0" ) return false;
50  std::cerr << "Invalid bool expression: " << tmp << std::endl;
51  throw std::exception();
52  return false;
53  }
static constexpr Sample_t transform(Sample_t sample)
BEGIN_PROLOG could also be cerr
temporary value
template<>
std::vector< std::string > flashmatch::parser::FromString ( const std::string &  value)

Definition at line 55 of file Parser.cxx.

56  {
57  //std::cout<<value<<std::endl;
58  std::vector<std::string> res;
59  if(value.find("[") != 0 || (value.rfind("]")+1) != value.size()) {
60  std::string msg;
61  std::cerr << "Invalid vector expression: " << value << std::endl;
62  throw std::exception();
63  }
64  size_t index = 1;
65  while((index+1) < value.size()) {
66  size_t next_index = value.find(",",index);
67  if(next_index >= value.size()) break;
68  std::string cand = value.substr(index,next_index-index);
69  res.emplace_back(cand);
70  index = next_index + 1;
71  }
72  if( (index+1) < value.size() )
73  res.push_back(value.substr(index,value.size()-index-1));
74 
75  for(auto& s : res) {
76  if(s.find("\"")==0) s=s.substr(1,s.size()-1);
77  if(s.rfind("\"")+1 == s.size()) s = s.substr(0,s.size()-1);
78  }
79  //for(auto const& s : res) std::cout<<s<<std::endl;
80  return res;
81  }
BEGIN_PROLOG could also be cerr
then echo File list $list not found else cat $list while read file do echo $file sed s
Definition: file_to_url.sh:60
temporary value
template<>
bool flashmatch::parser::FromString< bool > ( const std::string &  value)

Parse flashmatch::PSet configuration file content.

template<>
double flashmatch::parser::FromString< double > ( const std::string &  value)

Parse flashmatch::PSet configuration file content.

template<>
float flashmatch::parser::FromString< float > ( const std::string &  value)

Parse flashmatch::PSet configuration file content.

template<>
int flashmatch::parser::FromString< int > ( const std::string &  value)

Parse flashmatch::PSet configuration file content.

template<>
long flashmatch::parser::FromString< long > ( const std::string &  value)

Parse flashmatch::PSet configuration file content.

template<>
short flashmatch::parser::FromString< short > ( const std::string &  value)

Parse flashmatch::PSet configuration file content.

template<>
std::string flashmatch::parser::FromString< std::string > ( const std::string &  value)

Parse flashmatch::PSet configuration file content.

template<>
std::vector< bool > flashmatch::parser::FromString< std::vector< bool > > ( const std::string &  value)

Parse flashmatch::PSet configuration file content.

Definition at line 163 of file Parser.cxx.

164  {
165  auto str_v = FromString<std::vector<std::string> >(value);
166  std::vector<bool> res;
167  res.reserve(str_v.size());
168  for(auto const& v : str_v)
169  res.push_back( FromString<bool>(v) );
170  return res;
171  }
bool FromString< bool >(const std::string &value)
Parse flashmatch::PSet configuration file content.
temporary value
template<>
std::vector< double > flashmatch::parser::FromString< std::vector< double > > ( const std::string &  value)

Parse flashmatch::PSet configuration file content.

Definition at line 93 of file Parser.cxx.

94  {
95  auto str_v = FromString<std::vector<std::string> >(value);
96  std::vector<double> res;
97  res.reserve(str_v.size());
98  for(auto const& v : str_v)
99  res.push_back( FromString<double>(v) );
100  return res;
101  }
double FromString< double >(const std::string &value)
Parse flashmatch::PSet configuration file content.
temporary value
template<>
std::vector< float > flashmatch::parser::FromString< std::vector< float > > ( const std::string &  value)

Parse flashmatch::PSet configuration file content.

Definition at line 83 of file Parser.cxx.

84  {
85  auto str_v = FromString<std::vector<std::string> >(value);
86  std::vector<float> res;
87  res.reserve(str_v.size());
88  for(auto const& v : str_v)
89  res.push_back( FromString<float>(v) );
90  return res;
91  }
float FromString< float >(const std::string &value)
Parse flashmatch::PSet configuration file content.
temporary value
template<>
std::vector< int > flashmatch::parser::FromString< std::vector< int > > ( const std::string &  value)

Parse flashmatch::PSet configuration file content.

Definition at line 113 of file Parser.cxx.

114  {
115  auto str_v = FromString<std::vector<std::string> >(value);
116  std::vector<int> res;
117  res.reserve(str_v.size());
118  for(auto const& v : str_v)
119  res.push_back( FromString<int>(v) );
120  return res;
121  }
int FromString< int >(const std::string &value)
Parse flashmatch::PSet configuration file content.
temporary value
template<>
std::vector< long > flashmatch::parser::FromString< std::vector< long > > ( const std::string &  value)

Parse flashmatch::PSet configuration file content.

Definition at line 123 of file Parser.cxx.

124  {
125  auto str_v = FromString<std::vector<std::string> >(value);
126  std::vector<long> res;
127  res.reserve(str_v.size());
128  for(auto const& v : str_v)
129  res.push_back( FromString<long>(v) );
130  return res;
131  }
long FromString< long >(const std::string &value)
Parse flashmatch::PSet configuration file content.
temporary value
template<>
std::vector< short > flashmatch::parser::FromString< std::vector< short > > ( const std::string &  value)

Parse flashmatch::PSet configuration file content.

Definition at line 103 of file Parser.cxx.

104  {
105  auto str_v = FromString<std::vector<std::string> >(value);
106  std::vector<short> res;
107  res.reserve(str_v.size());
108  for(auto const& v : str_v)
109  res.push_back( FromString<short>(v) );
110  return res;
111  }
short FromString< short >(const std::string &value)
Parse flashmatch::PSet configuration file content.
temporary value
template<>
std::vector< std::string > flashmatch::parser::FromString< std::vector< std::string > > ( const std::string &  value)

Parse flashmatch::PSet configuration file content.

template<>
std::vector< unsigned int > flashmatch::parser::FromString< std::vector< unsigned int > > ( const std::string &  value)

Parse flashmatch::PSet configuration file content.

Definition at line 143 of file Parser.cxx.

144  {
145  auto str_v = FromString<std::vector<std::string> >(value);
146  std::vector<unsigned int> res;
147  res.reserve(str_v.size());
148  for(auto const& v : str_v)
149  res.push_back( FromString<unsigned int>(v) );
150  return res;
151  }
unsigned int FromString< unsigned int >(const std::string &value)
Parse flashmatch::PSet configuration file content.
temporary value
template<>
std::vector< unsigned long > flashmatch::parser::FromString< std::vector< unsigned long > > ( const std::string &  value)

Parse flashmatch::PSet configuration file content.

Definition at line 153 of file Parser.cxx.

154  {
155  auto str_v = FromString<std::vector<std::string> >(value);
156  std::vector<unsigned long> res;
157  res.reserve(str_v.size());
158  for(auto const& v : str_v)
159  res.push_back( FromString<unsigned long>(v) );
160  return res;
161  }
unsigned long FromString< unsigned long >(const std::string &value)
Parse flashmatch::PSet configuration file content.
temporary value
template<>
std::vector< unsigned short > flashmatch::parser::FromString< std::vector< unsigned short > > ( const std::string &  value)

Parse flashmatch::PSet configuration file content.

Definition at line 133 of file Parser.cxx.

134  {
135  auto str_v = FromString<std::vector<std::string> >(value);
136  std::vector<unsigned short> res;
137  res.reserve(str_v.size());
138  for(auto const& v : str_v)
139  res.push_back( FromString<unsigned short>(v) );
140  return res;
141  }
unsigned short FromString< unsigned short >(const std::string &value)
Parse flashmatch::PSet configuration file content.
temporary value
template<>
unsigned int flashmatch::parser::FromString< unsigned int > ( const std::string &  value)

Parse flashmatch::PSet configuration file content.

template<>
unsigned long flashmatch::parser::FromString< unsigned long > ( const std::string &  value)

Parse flashmatch::PSet configuration file content.

template<>
unsigned short flashmatch::parser::FromString< unsigned short > ( const std::string &  value)

Parse flashmatch::PSet configuration file content.

template<class T >
std::string flashmatch::parser::ToString ( const T &  value)

Parse flashmatch::PSet configuration file content.

Definition at line 66 of file Parser.h.

67  { return std::to_string(value); }
std::string to_string(WindowPattern const &pattern)
temporary value
template<>
std::string flashmatch::parser::ToString< std::string > ( const std::string &  value)

Parse flashmatch::PSet configuration file content.

Definition at line 173 of file Parser.cxx.

174  {
175  std::string res(value);
176  if(res.empty()) return res;
177 
178  if(res.find("\"") == 0) res = res.substr(1);
179  if(res.empty()) return res;
180 
181  if(res.rfind("\"") == (res.length()-1)) res = res.substr(0,res.length()-1);
182  return res;
183  }
temporary value
template<class T >
std::string flashmatch::parser::VecToString ( const std::vector< T > &  value)

Parse flashmatch::PSet configuration file content.

Definition at line 71 of file Parser.h.

72  {
73  std::string res="[";
74  for(auto const& v : value)
75  res += ToString(v) + ",";
76  res = res.substr(0,res.size()-1);
77  res += "]";
78  return res;
79  }
std::string ToString(const T &value)
Parse flashmatch::PSet configuration file content.
Definition: Parser.h:66