opm-common
String.hpp
1 /*
2  Copyright 2020 Equinor ASA.
3 
4  This file is part of the Open Porous Media project (OPM).
5 
6  OPM is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  OPM is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with OPM. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #ifndef OPM_UTILITY_STRING_HPP
21 #define OPM_UTILITY_STRING_HPP
22 
23 #include <optional>
24 #include <string>
25 #include <type_traits>
26 #include <vector>
27 
28 namespace Opm {
29 
30 template<typename T, typename U>
31 U& uppercase( const T& src, U& dst );
32 
33 template< typename T >
34 typename std::decay< T >::type uppercase( T&& x ) {
35  typename std::decay< T >::type t( std::forward< T >( x ) );
36  return uppercase( t, t );
37 }
38 
39 template<typename T>
40 std::string ltrim_copy(const T& s);
41 
42 template<typename T>
43 std::string rtrim_copy(const T& s);
44 
45 template<typename T>
46 std::string trim_copy(const T& s);
47 
48 template<typename T>
49 void replaceAll(T& data, const T& toSearch, const T& replace);
50 
51 std::vector<std::string> split_string(const std::string& input,
52  char delimiter);
53 
54 std::vector<std::string> split_string(const std::string& input,
55  const std::string& delimiters);
56 
57 std::string format_double(double d);
58 
59 std::optional<double> try_parse_double(const std::string& token);
60 
61 }
62 #endif //OPM_UTILITY_STRING_HPP
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:30