libStatGen Software 1
String.cpp
1/*
2 * Copyright (C) 2010 Regents of the University of Michigan
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#include <iostream>
19
20#include "String.h"
21#include <vector>
22
23#ifdef OBSOLETE
24
25std::vector<csg::string> *csg::string::split(char splitChar)
26{
27 std::vector<csg::string> *result = new std::vector<csg::string>;
28 csg::string word;
29
30 for (size_t i = 0; i<size(); i++)
31 {
32 if ((*this)[i]==splitChar)
33 {
34 result->push_back(word);
35 word.clear();
36 }
37 else
38 word.push_back((*this)[i]);
39 }
40 if (word.size()>0) result->push_back(word);
41 return result;
42}
43
44
45#if defined(TEST)
46
47int main(int argc, const char **argv)
48{
49 csg::string string("abcdef:abcdefghijk");
50
51 std::vector<csg::string> *result = string.split(':');
52
53 for (int i=0; i<result->size(); i++)
54 {
55 std::cout << i << "\t" << (*result)[i] << std::endl;
56 }
57 delete result; // suck
58
59}
60#endif
61
62#endif