All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Parser.h
Go to the documentation of this file.
1 /**
2  * \file Parser.h
3  *
4  * \ingroup core_Base
5  *
6  * \brief List of functions to type-cast std::string to an appropriate value type
7  *
8  * @author Kazu - Nevis 2015
9  */
10 
11 /** \addtogroup core_Base
12 
13  @{*/
14 #ifndef __FLASHMATCHBASE_PARSER_H__
15 #define __FLASHMATCHBASE_PARSER_H__
16 
17 #include <string>
18 #include <vector>
19 #include <algorithm>
20 
21 namespace flashmatch {
22  namespace parser {
23  template <class T>
24  T FromString( const std::string& value );
25  /// Parse flashmatch::PSet configuration file content
26  template<> std::string FromString< std::string > (const std::string& value );
27  /// Parse flashmatch::PSet configuration file content
28  template<> float FromString< float > (const std::string& value );
29  /// Parse flashmatch::PSet configuration file content
30  template<> double FromString< double > (const std::string& value );
31  /// Parse flashmatch::PSet configuration file content
32  template<> short FromString< short > (const std::string& value );
33  /// Parse flashmatch::PSet configuration file content
34  template<> int FromString< int > (const std::string& value );
35  /// Parse flashmatch::PSet configuration file content
36  template<> long FromString< long > (const std::string& value );
37  /// Parse flashmatch::PSet configuration file content
38  template<> unsigned short FromString< unsigned short > (const std::string& value );
39  /// Parse flashmatch::PSet configuration file content
40  template<> unsigned int FromString< unsigned int > (const std::string& value );
41  /// Parse flashmatch::PSet configuration file content
42  template<> unsigned long FromString< unsigned long > (const std::string& value );
43  /// Parse flashmatch::PSet configuration file content
44  template<> bool FromString< bool > (const std::string& value );
45  /// Parse flashmatch::PSet configuration file content
46  template<> std::vector< std::string > FromString< std::vector< std::string > > (const std::string& value );
47  /// Parse flashmatch::PSet configuration file content
48  template<> std::vector< float > FromString< std::vector< float > > (const std::string& value );
49  /// Parse flashmatch::PSet configuration file content
50  template<> std::vector< double > FromString< std::vector< double > > (const std::string& value );
51  /// Parse flashmatch::PSet configuration file content
52  template<> std::vector< short > FromString< std::vector< short > > (const std::string& value );
53  /// Parse flashmatch::PSet configuration file content
54  template<> std::vector< int > FromString< std::vector< int > > (const std::string& value );
55  /// Parse flashmatch::PSet configuration file content
56  template<> std::vector< long > FromString< std::vector< long > > (const std::string& value );
57  /// Parse flashmatch::PSet configuration file content
58  template<> std::vector< unsigned short > FromString< std::vector< unsigned short > > (const std::string& value );
59  /// Parse flashmatch::PSet configuration file content
60  template<> std::vector< unsigned int > FromString< std::vector< unsigned int > > (const std::string& value );
61  /// Parse flashmatch::PSet configuration file content
62  template<> std::vector< unsigned long > FromString< std::vector< unsigned long > > (const std::string& value );
63  /// Parse flashmatch::PSet configuration file content
64  template<> std::vector< bool > FromString< std::vector< bool > > (const std::string& value );
65  /// Parse flashmatch::PSet configuration file content
66  template <class T> std::string ToString(const T& value)
67  { return std::to_string(value); }
68  /// Parse flashmatch::PSet configuration file content
69  template<> std::string ToString<std::string>(const std::string& value);
70  /// Parse flashmatch::PSet configuration file content
71  template <class T> std::string VecToString(const std::vector<T>& value)
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  }
80  }
81 }
82 
83 #endif
84 /** @} */ // end of doxygen group
bool FromString< bool >(const std::string &value)
Parse flashmatch::PSet configuration file content.
float FromString< float >(const std::string &value)
Parse flashmatch::PSet configuration file content.
std::string FromString(const std::string &value)
Definition: Parser.cxx:8
int FromString< int >(const std::string &value)
Parse flashmatch::PSet configuration file content.
unsigned int FromString< unsigned int >(const std::string &value)
Parse flashmatch::PSet configuration file content.
long FromString< long >(const std::string &value)
Parse flashmatch::PSet configuration file content.
double FromString< double >(const std::string &value)
Parse flashmatch::PSet configuration file content.
std::string VecToString(const std::vector< T > &value)
Parse flashmatch::PSet configuration file content.
Definition: Parser.h:71
std::string to_string(WindowPattern const &pattern)
unsigned short FromString< unsigned short >(const std::string &value)
Parse flashmatch::PSet configuration file content.
unsigned long FromString< unsigned long >(const std::string &value)
Parse flashmatch::PSet configuration file content.
std::string ToString(const T &value)
Parse flashmatch::PSet configuration file content.
Definition: Parser.h:66
short FromString< short >(const std::string &value)
Parse flashmatch::PSet configuration file content.
temporary value