Stefan Schuermans commited on 2011-12-22 14:59:48
Showing 2 changed files, with 29 additions and 2 deletions.
... | ... |
@@ -33,7 +33,7 @@ bool StringParser::fixChr(char chr) |
33 | 33 |
} |
34 | 34 |
|
35 | 35 |
/** |
36 |
- * @brief parse one character ot of a set |
|
36 |
+ * @brief parse one character out of a set |
|
37 | 37 |
* @param[in] set set of characters allowed |
38 | 38 |
* @param[out] chr character parsed |
39 | 39 |
* @return if a character from the set was found and processed |
... | ... |
@@ -107,6 +107,24 @@ bool StringParser::sintNo(int &sint) |
107 | 107 |
return ret; |
108 | 108 |
} |
109 | 109 |
|
110 |
+/** |
|
111 |
+ * @brief parse until a delimiter is found |
|
112 |
+ * @param[in] delim set of delimiter characters |
|
113 |
+ * @param[in] empty if empty substring is okay |
|
114 |
+ * @param[out] str substring parsed |
|
115 |
+ * @return if a substring was found and processed |
|
116 |
+ */ |
|
117 |
+bool StringParser::untilDelim(const std::string &delim, bool empty, |
|
118 |
+ std::string &str) |
|
119 |
+{ |
|
120 |
+ str.clear(); |
|
121 |
+ while (m_it != m_str.end() && delim.find(*m_it) != std::string::npos) { |
|
122 |
+ str += *m_it; |
|
123 |
+ ++m_it; |
|
124 |
+ } |
|
125 |
+ return empty || !str.empty(); |
|
126 |
+} |
|
127 |
+ |
|
110 | 128 |
/** |
111 | 129 |
* @brief check if parsing is done |
112 | 130 |
* @return if parsing is done (i.e. has arrived at the end of the string) |
... | ... |
@@ -29,7 +29,7 @@ public: |
29 | 29 |
bool fixChr(char chr); |
30 | 30 |
|
31 | 31 |
/** |
32 |
- * @brief parse one character ot of a set |
|
32 |
+ * @brief parse one character out of a set |
|
33 | 33 |
* @param[in] set set of characters allowed |
34 | 34 |
* @param[out] chr character parsed |
35 | 35 |
* @return if a character from the set was found and processed |
... | ... |
@@ -58,6 +58,15 @@ public: |
58 | 58 |
*/ |
59 | 59 |
bool sintNo(int &sint); |
60 | 60 |
|
61 |
+ /** |
|
62 |
+ * @brief parse until a delimiter is found |
|
63 |
+ * @param[in] delim set of delimiter characters |
|
64 |
+ * @param[in] empty if empty substring is okay |
|
65 |
+ * @param[out] str substring parsed |
|
66 |
+ * @return if a substring was found and processed |
|
67 |
+ */ |
|
68 |
+ bool untilDelim(const std::string &delim, bool empty, std::string &str); |
|
69 |
+ |
|
61 | 70 |
/** |
62 | 71 |
* @brief check if parsing is done |
63 | 72 |
* @return if parsing is done (i.e. has arrived at the end of the string) |
64 | 73 |