2305 |
02 Aug 10 |
peter |
1 |
#ifndef _theplu_yat_utility_split_ |
2879 |
16 Nov 12 |
peter |
2 |
#define _theplu_yat_utility_split_ |
2305 |
02 Aug 10 |
peter |
3 |
|
2305 |
02 Aug 10 |
peter |
// $Id$ |
2305 |
02 Aug 10 |
peter |
5 |
|
2305 |
02 Aug 10 |
peter |
6 |
/* |
2879 |
16 Nov 12 |
peter |
Copyright (C) 2010, 2012 Peter Johansson |
2305 |
02 Aug 10 |
peter |
8 |
|
2305 |
02 Aug 10 |
peter |
This file is part of the yat library, http://dev.thep.lu.se/yat |
2305 |
02 Aug 10 |
peter |
10 |
|
2305 |
02 Aug 10 |
peter |
The yat library is free software; you can redistribute it and/or |
2305 |
02 Aug 10 |
peter |
modify it under the terms of the GNU General Public License as |
2305 |
02 Aug 10 |
peter |
published by the Free Software Foundation; either version 3 of the |
2305 |
02 Aug 10 |
peter |
License, or (at your option) any later version. |
2305 |
02 Aug 10 |
peter |
15 |
|
2305 |
02 Aug 10 |
peter |
The yat library is distributed in the hope that it will be useful, |
2305 |
02 Aug 10 |
peter |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
2305 |
02 Aug 10 |
peter |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
2305 |
02 Aug 10 |
peter |
General Public License for more details. |
2305 |
02 Aug 10 |
peter |
20 |
|
2305 |
02 Aug 10 |
peter |
You should have received a copy of the GNU General Public License |
2305 |
02 Aug 10 |
peter |
along with yat. If not, see <http://www.gnu.org/licenses/>. |
2305 |
02 Aug 10 |
peter |
23 |
*/ |
2305 |
02 Aug 10 |
peter |
24 |
|
2305 |
02 Aug 10 |
peter |
25 |
#include <string> |
2305 |
02 Aug 10 |
peter |
26 |
#include <vector> |
2305 |
02 Aug 10 |
peter |
27 |
|
2305 |
02 Aug 10 |
peter |
28 |
namespace theplu { |
2305 |
02 Aug 10 |
peter |
29 |
namespace yat { |
2305 |
02 Aug 10 |
peter |
30 |
namespace utility { |
2305 |
02 Aug 10 |
peter |
31 |
|
2305 |
02 Aug 10 |
peter |
32 |
/** |
2305 |
02 Aug 10 |
peter |
\brief split a string into several substrings |
2305 |
02 Aug 10 |
peter |
34 |
|
2305 |
02 Aug 10 |
peter |
Split \a str with respect to \a delim and place result in \a |
2305 |
02 Aug 10 |
peter |
result. If \a str contains N \a delim, the resulting \a result |
2305 |
02 Aug 10 |
peter |
will hold N+1 elements (given that it was empty to start |
2898 |
12 Dec 12 |
peter |
with). If first or last character in \a str is \a delim, |
2305 |
02 Aug 10 |
peter |
corresponding element in \a result will be empty string (""). |
2305 |
02 Aug 10 |
peter |
40 |
|
2305 |
02 Aug 10 |
peter |
\since New in yat 0.7 |
2305 |
02 Aug 10 |
peter |
42 |
*/ |
2879 |
16 Nov 12 |
peter |
43 |
void split(std::vector<std::string>& result, const std::string& str, |
2305 |
02 Aug 10 |
peter |
44 |
char delim); |
2305 |
02 Aug 10 |
peter |
45 |
|
2879 |
16 Nov 12 |
peter |
46 |
/** |
2879 |
16 Nov 12 |
peter |
\brief split a string into substrings |
2879 |
16 Nov 12 |
peter |
48 |
|
2879 |
16 Nov 12 |
peter |
Same as |
2879 |
16 Nov 12 |
peter |
void split(std::vector<std::string>&, const std::string&,char delim); |
2879 |
16 Nov 12 |
peter |
but split if character matches any in delims, i.e., |
2879 |
16 Nov 12 |
peter |
split(vec,"split,me;please", ",;") will be split into "split", |
2879 |
16 Nov 12 |
peter |
"me", and "please". |
2879 |
16 Nov 12 |
peter |
54 |
|
2879 |
16 Nov 12 |
peter |
\since New in yat 0.10 |
2879 |
16 Nov 12 |
peter |
56 |
*/ |
2879 |
16 Nov 12 |
peter |
57 |
void split(std::vector<std::string>& result, const std::string& str, |
2879 |
16 Nov 12 |
peter |
58 |
const std::string& delim); |
2879 |
16 Nov 12 |
peter |
59 |
|
2305 |
02 Aug 10 |
peter |
60 |
}}} // of namespace utility, yat, and theplu |
2305 |
02 Aug 10 |
peter |
61 |
|
2305 |
02 Aug 10 |
peter |
62 |
#endif |