source: trunk/yat/split.h @ 1556

Last change on this file since 1556 was 1556, checked in by Peter Johansson, 9 years ago

update to latest yat

  • Property svn:eol-style set to native
File size: 1.9 KB
Line 
1#ifndef _theplu_yat_utility_split_
2#define _theplu_yat_utility_split_
3
4// $Id: split.h 2898 2012-12-12 05:13:02Z peter $
5
6/*
7  Copyright (C) 2010, 2012 Peter Johansson
8
9  This file is part of the yat library, http://dev.thep.lu.se/yat
10
11  The yat library is free software; you can redistribute it and/or
12  modify it under the terms of the GNU General Public License as
13  published by the Free Software Foundation; either version 3 of the
14  License, or (at your option) any later version.
15
16  The yat library is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  General Public License for more details.
20
21  You should have received a copy of the GNU General Public License
22  along with yat. If not, see <http://www.gnu.org/licenses/>.
23*/
24
25#include <string>
26#include <vector>
27
28namespace theplu {
29namespace yat {
30namespace utility {
31
32  /**
33     \brief split a string into several substrings
34
35     Split \a str with respect to \a delim and place result in \a
36     result. If \a str contains N \a delim, the resulting \a result
37     will hold N+1 elements (given that it was empty to start
38     with). If first or last character in \a str is \a delim,
39     corresponding element in \a result will be empty string ("").
40
41     \since New in yat 0.7
42   */
43  void split(std::vector<std::string>& result, const std::string& str,
44             char delim);
45
46  /**
47     \brief split a string into substrings
48
49     Same as
50     void split(std::vector<std::string>&, const std::string&,char delim);
51     but split if character matches any in delims, i.e.,
52     split(vec,"split,me;please", ",;") will be split into "split",
53     "me", and "please".
54
55     \since New in yat 0.10
56   */
57  void split(std::vector<std::string>& result, const std::string& str,
58             const std::string& delim);
59
60}}} // of namespace utility, yat, and theplu
61
62#endif
Note: See TracBrowser for help on using the repository browser.