CoxIter  1.2
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 <string>
33 #include <sstream>
34 #include <cstdlib>
35 #include <vector>
36 #include <iterator>
37 
38 using namespace std;
39 
49 void str_replace( string &str, const string &from, const string &to );
50 
61 vector<string> explode( const string &separator, string source );
62 
74 void explode( const string &separator, string source, vector<string> &results );
75 
87 void explode( const string &separator, string source, vector<int> &results );
88 
100 void explode( const string &separator, string source, vector<unsigned int> &results );
101 
110 string implode( const string& strSeparator, const vector< string >& strVector );
111 
120 template <typename T>
121 typename std::enable_if<std::is_arithmetic<T>::value, string>::type implode( const string& strSeparator, const vector< T >& iVector )
122 {
123  vector< string > strVector;
124  for( typename vector< T >::const_iterator it( iVector.begin( ) ); it != iVector.end( ); ++it )
125  strVector.push_back( to_string( *it ) );
126 
127  return implode( strSeparator, strVector );
128 }
129 
130 int string_to_int( const string &strNumber );
131 double string_to_double( const string &strNumber );
132 
133 #endif
void str_replace(string &str, const string &from, const string &to)
Rechercher remplacer.
Definition: string.cpp:25
string implode(const string &strSeparator, const vector< string > &strVector)
Definition: string.cpp:118
double string_to_double(const string &strNumber)
vector< string > explode(const string &separator, string source)
Definition: string.cpp:35
int string_to_int(const string &strNumber)