CoxIter  1.3
CoxIter - Computing invariants of hyperbolic Coxeter groups
string.h
Go to the documentation of this file.
1 /*
2 Copyright (C) 2013, 2014
3 Rafael Guglielmetti, rafael.guglielmetti@unifr.ch
4 */
5 
6 /*
7 This file is part of CoxIter and AlVin.
8 
9 CoxIter is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as
11 published by the Free Software Foundation, either version 3 of the
12 License, or (at your option) any later version.
13 
14 CoxIter is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18 
19 You should have received a copy of the GNU General Public License
20 along with CoxIter. If not, see <http://www.gnu.org/licenses/>.
21 */
22 
29 #ifndef __STRING_H__
30 #define __STRING_H__ 1
31 
32 #include <cstdlib>
33 #include <iterator>
34 #include <sstream>
35 #include <string>
36 #include <vector>
37 
38 using namespace std;
39 
49 void str_replace(string &str, const string &from, const string &to);
50 
62 vector<string> explode(const string &separator, string source);
63 
78 void explode(const string &separator, string source, vector<string> &results);
79 
94 void explode(const string &separator, string source, vector<int> &results);
95 
110 void explode(const string &separator, string source,
111  vector<unsigned int> &results);
112 
121 string implode(const string &separator, const vector<string> &vector);
122 
131 template <typename T>
132 typename std::enable_if<std::is_arithmetic<T>::value, string>::type
133 implode(const string &separator, const vector<T> &v) {
134  vector<string> result;
135  for (const auto &element : v)
136  result.push_back(to_string(element));
137 
138  return implode(separator, result);
139 }
140 
141 int string_to_int(const string &number);
142 double string_to_double(const string &number);
143 
144 #endif
string implode(const string &separator, const vector< string > &vector)
Definition: string.cpp:112
void str_replace(string &str, const string &from, const string &to)
Rechercher remplacer.
Definition: string.cpp:25
double string_to_double(const string &number)
int string_to_int(const string &number)
vector< string > explode(const string &separator, string source)
Definition: string.cpp:33