aGrUM  0.20.3
a C++ library for (probabilistic) graphical models
utils_string.h
Go to the documentation of this file.
1 /**
2  *
3  * Copyright (c) 2005-2021 by Pierre-Henri WUILLEMIN(@LIP6) & Christophe GONZALES(@AMU)
4  * info_at_agrum_dot_org
5  *
6  * This library is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser 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  * This library 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 Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this library. If not, see <http://www.gnu.org/licenses/>.
18  *
19  */
20 
21 
22 /**
23  * @file
24  * @brief Utilities for manipulating strings.
25  *
26  * @author Christophe GONZALES(@AMU) and Pierre-Henri WUILLEMIN(@LIP6)
27  *
28  */
29 #ifndef GUM_UTILS_STRING_H
30 #define GUM_UTILS_STRING_H
31 
32 #include <cstdlib>
33 #include <sstream>
34 #include <string>
35 #include <vector>
36 
37 #include <agrum/agrum.h>
38 
39 #ifndef HAVE_MKSTEMP // mainly windows
40 # include <io.h>
41 #endif
42 
43 namespace gum {
44  /// @ingroup utilities_group
45  /// @{
46 
47  /**
48  * @brief Returns a path to a unique file name.
49  * @return Returns a path to a unique file name.
50  */
51  std::string getUniqueFileName();
52 
53  /**
54  * @brief Returns the lowercase version of str.
55  * @return Returns the lowercase version of str.
56  */
57  std::string toLower(std::string str);
58 
59  /**
60  * @brief Returns true if value ends with ending.
61  * @return Returns true if value ends with ending.
62  */
63  bool endsWith(std::string const& value, std::string const& ending);
64 
65  /**
66  * @brief Split str using the delimiter
67  * @param orig searched string
68  * @param delimiter string
69  * @return Vector of splitted strings
70  */
71  std::vector< std::string > split(const std::string& orig, const std::string& delimiter);
72 
73  /**
74  * @brief Replace val by new_val in s.
75  * @param s A string.
76  * @param val The value to replace in s.
77  * @param new_val The new value to replace val in s.
78  * @return A new string with val replaced by new_val.
79  */
80  std::string replace(const std::string& s, const std::string& val, const std::string& new_val);
81 
82  /// @}
83 } /* namespace gum */
84 
85 #ifndef GUM_NO_INLINE
86 # include <agrum/tools/core/utils_string_inl.h>
87 #endif // GUM_NO_INLINE
88 
89 #endif /* GUM_UTILS_STRING_H */