tlx
expand_environment_variables.hpp
Go to the documentation of this file.
1 /*******************************************************************************
2  * tlx/string/expand_environment_variables.hpp
3  *
4  * Part of tlx - http://panthema.net/tlx
5  *
6  * Copyright (C) 2018 Timo Bingmann <tb@panthema.net>
7  *
8  * All rights reserved. Published under the Boost Software License, Version 1.0
9  ******************************************************************************/
10 
11 #ifndef TLX_STRING_EXPAND_ENVIRONMENT_VARIABLES_HEADER
12 #define TLX_STRING_EXPAND_ENVIRONMENT_VARIABLES_HEADER
13 
14 #include <string>
15 
16 namespace tlx {
17 
18 //! \addtogroup tlx_string
19 //! \{
20 
21 /*!
22  * Expand substrings $ABC_123 and ${ABC_123} into the corresponding environment
23  * variables. Matches all substrings "$[a-zA-Z_][a-zA-Z0-9_]*" and
24  * "${[^}]*}". Replaces all substrings in-place.
25  */
26 std::string& expand_environment_variables(std::string* s);
27 
28 /*!
29  * Expand substrings $ABC_123 and ${ABC_123} into the corresponding environment
30  * variables. Matches all substrings "$[a-zA-Z_][a-zA-Z0-9_]*" and
31  * "${[^}]*}". Returns a copy of the string with all substrings replaced.
32  */
33 std::string expand_environment_variables(const std::string& s);
34 
35 /*!
36  * Expand substrings $ABC_123 and ${ABC_123} into the corresponding environment
37  * variables. Matches all substrings "$[a-zA-Z_][a-zA-Z0-9_]*" and
38  * "${[^}]*}". Returns a copy of the string with all substrings replaced.
39  */
40 std::string expand_environment_variables(const char* s);
41 
42 //! \}
43 
44 } // namespace tlx
45 
46 #endif // !TLX_STRING_EXPAND_ENVIRONMENT_VARIABLES_HEADER
47 
48 /******************************************************************************/
std::string & expand_environment_variables(std::string *sp)
Expand substrings $ABC_123 and ${ABC_123} into the corresponding environment variables.