flexiblesusy is hosted by Hepforge, IPPP Durham
FlexibleSUSY
string_utils.hpp
Go to the documentation of this file.
1// ====================================================================
2// This file is part of FlexibleSUSY.
3//
4// FlexibleSUSY is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published
6// by the Free Software Foundation, either version 3 of the License,
7// or (at your option) any later version.
8//
9// FlexibleSUSY is distributed in the hope that it will be useful, but
10// WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12// General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with FlexibleSUSY. If not, see
16// <http://www.gnu.org/licenses/>.
17// ====================================================================
18
19#ifndef STRING_UTILS_H
20#define STRING_UTILS_H
21
22#include <string>
23#include <sstream>
24#include <vector>
25
26namespace flexiblesusy {
27
29std::string concat(const std::vector<std::string>&);
30
31
33std::string concat(const std::vector<std::string>&, const std::string&);
34
35
37std::string concat(const std::vector<std::string>&, char);
38
39
41template <class InputIterator>
42std::string concat(InputIterator start, InputIterator end, const std::string& separator)
43{
44 std::ostringstream result;
45
46 for (InputIterator it = start; it != end; ++it) {
47 if (it != start) {
48 result << separator;
49 }
50 result << *it;
51 }
52
53 return result.str();
54}
55
56
58template <class InputIterator>
59std::string concat(InputIterator start, InputIterator end, char separator)
60{
61 return concat(start, end, std::string(1, separator));
62}
63
64} // namespace flexiblesusy
65
66#endif
double * end(GSL_vector &v)
iterator to end of GSL_vector
Definition: gsl_vector.cpp:254
std::string concat(const std::vector< std::string > &strings)
concatenate strings