35 std::stringstream ss(s);
40 if(temp.empty())
break;
43 intFound = stoi(temp, &sz, 0);
45 throw std::exception();
46 }
catch (
const std::exception &e) {
54 return std::string(
"");
59 std::stringstream ss(s);
60 std::string temp, ret =
"";
64 if(temp.empty())
break;
67 intFound = stoi(temp, &sz, 0);
69 throw std::exception();
70 }
catch (
const std::exception &e) {
83 std::stringstream ss(s);
90 if(temp.empty())
break;
93 intFound = stoi(temp, &sz, 0);
95 throw std::exception();
96 }
catch (
const std::exception &e) {
107 std::stringstream ss(s);
115 if(temp.empty())
break;
118 intFound = stoi(temp, &sz, 0);
119 if(temp.size() != sz)
120 throw std::exception();
121 }
catch (
const std::exception &e) {
135 std::stringstream ss(s);
141 if(temp.empty())
break;
144 intFound = stoi(temp, &sz, 0);
145 if(temp.size() != sz)
146 throw std::exception();
152 }
catch (
const std::exception &e) {
164 std::stringstream ss(s);
167 bool intWasFound =
false;
168 for (
int i = 0 ; i < arrsize ; i++)
171 while ((!ss.eof()) && (!intWasFound)) {
173 if(temp.empty())
break;
176 intFound = (uint32_t)(stoll(temp, &sz, 0));
177 if(temp.size() != sz)
178 throw std::exception();
181 }
catch (
const std::exception &e) {
186 if(ss.eof() && (!intWasFound))
192 template<
typename ... Rest>
inline bool multipleInts(std::stringstream & ss)
197 template<
typename ... Rest>
inline bool multipleInts(std::stringstream & ss,
int & x, Rest & ... args)
199 int numArgs =
sizeof...(args);
202 bool intWasFound =
false;
203 while ((!ss.eof()) && (!intWasFound)) {
205 if(temp.empty())
break;
208 intFound = stoi(temp, &sz, 0);
209 if(temp.size() != sz)
210 throw std::exception();
213 }
catch (
const std::exception &e) {
218 if(ss.eof() && (!intWasFound))
223 template<
typename ... Args>
inline bool multipleInts(std::string s, Args & ... args)
225 std::stringstream ss(s);
229 template<
typename ... Rest>
inline bool multipleUints(std::stringstream & ss)
234 template<
typename ... Rest>
inline bool multipleUints(std::stringstream & ss, uint32_t & x, Rest & ... args)
236 int numArgs =
sizeof...(args);
238 unsigned long uintFound;
239 bool intWasFound =
false;
240 while ((!ss.eof()) && (!intWasFound)) {
242 if(temp.empty())
break;
245 uintFound = stoul(temp, &sz, 0);
246 if(temp.size() != sz)
247 throw std::exception();
248 x = (uint32_t)uintFound;
250 }
catch (
const std::exception &e) {
255 if(ss.eof() && (!intWasFound))
260 template<
typename ... Args>
inline bool multipleUints(std::string s, Args & ... args)
262 std::stringstream ss(s);
std::string lastStringWord(std::string s)
Parses a string s, removes all integers and returns the last of all string words.
bool arrayOfUints(std::string s, int arrsize, uint32_t *arr)
Removes all string words from a given string s and returns the parsed arrsize number of integers into...
bool multipleUints(std::stringstream &ss)
bool nthInteger(std::string s, int n, int &x)
Parses a string s, returns the n-th integer.
std::string allStringWordsWithoutLastStringWord(std::string s)
Parses a string s, removes all integers and the last string word. Returns the rest.
std::string allStringWords(std::string s)
Parses a string s, removes all integers and returns the rest.
bool multipleInts(std::stringstream &ss)
std::string nthStringWord(std::string s, int n)
Parses a string s, returns the n-th string word that is not an integer.