canonical_string.h
Go to the documentation of this file.
1 #ifndef cetlib_canonical_string_h
2 #define cetlib_canonical_string_h
3 
4 // ======================================================================
5 //
6 // canonical_string: Transform a string into a canonical form
7 //
8 // ======================================================================
9 
10 #include <string>
11 
12 namespace cet {
13 
14  // Escape a string.
16 
17  // Unescape a string.
19 
20  // Check quoting for string.
23  bool is_quoted_string(std::string const& str); // Either single or double.,
24 
25  // Cannot throw; returns false on error or empty.
26  // N.B. appends to result.
28 
29  // Throw on error; returns empty string on empty.
31 
32  // Underlying function for internal use:
33  namespace detail {
34  // Check if string is quoted by the specified character.
35  bool is_quoted_string(std::string const& s, char quot);
36  }
37 }
38 
39 inline bool
41 {
42  return detail::is_quoted_string(str, '\'');
43 }
44 
45 inline bool
47 {
48  return detail::is_quoted_string(str, '"');
49 }
50 
51 inline bool
53 {
55 }
56 
57 inline bool
59  bool success = false;
60  if (!s.empty()) {
61  result.append(canonical_string(s));
62  success = true;
63  }
64  return success;
65 }
66 catch (...) {
67  return false;
68 } // canonical_string()
69 
70 // ======================================================================
71 
72 #endif /* cetlib_canonical_string_h */
73 
74 // Local Variables:
75 // mode: c++
76 // End:
std::string unescape(std::string const &str)
const XML_Char * s
Definition: expat.h:262
bool is_double_quoted_string(std::string const &str)
def success(message)
Definition: log.py:5
bool canonical_string(std::string const &str, std::string &result)
bool is_quoted_string(std::string const &s, char quot)
bool is_single_quoted_string(std::string const &str)
std::string escape(std::string const &str)
bool is_quoted_string(std::string const &str)
enum BeamMode string