tue_config
types.h
Go to the documentation of this file.
1 #ifndef TUE_CONFIG_TYPES_H_
2 #define TUE_CONFIG_TYPES_H_
3 
4 #include <boost/shared_ptr.hpp>
6 
7 #include <string>
8 
9 namespace tue
10 {
11 
12 namespace config
13 {
14 
16 {
19 };
20 
21 class Node;
22 typedef boost::shared_ptr<Node> NodePtr;
23 typedef boost::shared_ptr<const Node> NodeConstPtr;
24 
25 }
26 
27 // Trim functions from https://stackoverflow.com/a/217605
28 // trim from start (in place)
29 static inline void ltrim(std::string &s)
30 {
31  s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](int ch) {return !std::isspace(ch);}));
32 }
33 
34 // trim from end (in place)
35 static inline void rtrim(std::string &s)
36 {
37  s.erase(std::find_if(s.rbegin(), s.rend(), [](int ch) {return !std::isspace(ch);}).base(), s.end());
38 }
39 
40 // trim from both ends (in place)
41 static inline void trim(std::string &s)
42 {
43  ltrim(s);
44  rtrim(s);
45 }
46 
47 // trim from start (copying)
49 {
50  ltrim(s);
51  return s;
52 }
53 
54 // trim from end (copying)
56 {
57  rtrim(s);
58  return s;
59 }
60 
61 // trim from both ends (copying)
63 {
64  trim(s);
65  return s;
66 }
67 
68 } // end namespace tue
69 
70 #endif
std::string
std::find_if
T find_if(T... args)
tue::trim
static void trim(std::string &s)
Definition: types.h:41
tue::config::NodeConstPtr
boost::shared_ptr< const Node > NodeConstPtr
Definition: types.h:23
tue::rtrim_copy
static std::string rtrim_copy(std::string s)
Definition: types.h:55
tue::ltrim
static void ltrim(std::string &s)
Definition: types.h:29
data_pointer.h
tue::config::Node
Definition: node.h:19
tue::config::RequiredOrOptional
RequiredOrOptional
Definition: types.h:15
std::string::erase
T erase(T... args)
tue::ltrim_copy
static std::string ltrim_copy(std::string s)
Definition: types.h:48
tue::config::OPTIONAL
@ OPTIONAL
Definition: types.h:18
tue::trim_copy
static std::string trim_copy(std::string s)
Definition: types.h:62
std::string::rend
T rend(T... args)
std::string::begin
T begin(T... args)
tue::config::NodePtr
boost::shared_ptr< Node > NodePtr
Definition: types.h:21
tue::rtrim
static void rtrim(std::string &s)
Definition: types.h:35
std::string::end
T end(T... args)
tue::config::REQUIRED
@ REQUIRED
Definition: types.h:17
tue
std::string::rbegin
T rbegin(T... args)
config
tue::config::ReaderWriter config
Definition: sdf_gtest.cpp:9
string