winss
utils.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2016-2017 Morgan Stanley
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef LIB_WINSS_UTILS_HPP_
18 #define LIB_WINSS_UTILS_HPP_
19 
20 #include <chrono>
21 #include <string>
22 #include <map>
23 #include <vector>
24 #include "case_ignore.hpp"
25 
26 namespace winss {
30 typedef std::map<std::string, std::string, winss::case_ignore> env_t;
31 
35 class Utils {
36  private:
40  Utils() {}
41 
42  public:
52  static std::string ExpandEnvironmentVariables(const std::string& value);
53 
60 
67  static std::vector<char> GetEnvironmentString(const winss::env_t& env);
68 
76  static std::vector<std::string> SplitString(const std::string& input);
77 
84  static std::string ConvertToISOString(
85  const std::chrono::system_clock::time_point& time_point);
86 
93  static std::chrono::system_clock::time_point ConvertFromISOString(
94  const std::string& iso_string);
95 };
96 } // namespace winss
97 
98 #endif // LIB_WINSS_UTILS_HPP_
static std::string ConvertToISOString(const std::chrono::system_clock::time_point &time_point)
Convert the time to a ISO string.
Definition: utils.cpp:104
Utility functions.
Definition: utils.hpp:35
static std::chrono::system_clock::time_point ConvertFromISOString(const std::string &iso_string)
Convert an ISO string to a time point.
Definition: utils.cpp:110
std::map< std::string, std::string, winss::case_ignore > env_t
The environment mapping.
Definition: utils.hpp:30
Definition: case_ignore.hpp:23
static winss::env_t GetEnvironmentVariables()
Gets a mapping of the current environment variables.
Definition: utils.cpp:48
static std::vector< std::string > SplitString(const std::string &input)
Splits the string based on a new line.
Definition: utils.cpp:88
static std::vector< char > GetEnvironmentString(const winss::env_t &env)
Gets a string for the given environment variables.
Definition: utils.cpp:71
static std::string ExpandEnvironmentVariables(const std::string &value)
Expand the given string with environment variables.
Definition: utils.cpp:31