winss
environment.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_ENVIRONMENT_HPP_
18 #define LIB_WINSS_ENVIRONMENT_HPP_
19 
20 #include <filesystem>
21 #include <vector>
22 #include "utils.hpp"
23 
24 namespace fs = std::experimental::filesystem;
25 
26 namespace winss {
30 class Environment {
31  public:
40  virtual std::vector<char> ReadEnv();
41 
47  virtual winss::env_t ReadEnvSource() = 0;
48 
52  virtual ~Environment() {}
53 };
54 
58 class EnvironmentDir : public Environment {
59  private:
60  fs::path env_dir;
62  public:
68  explicit EnvironmentDir(fs::path env_dir);
69 
75  winss::env_t ReadEnvSource() override;
76 };
77 } // namespace winss
78 
79 #endif // LIB_WINSS_ENVIRONMENT_HPP_
virtual winss::env_t ReadEnvSource()=0
Gets the environment source as key values.
A directory where each file is an environment variable.
Definition: environment.hpp:58
std::map< std::string, std::string, winss::case_ignore > env_t
The environment mapping.
Definition: utils.hpp:30
Definition: case_ignore.hpp:23
Base environment.
Definition: environment.hpp:30
virtual std::vector< char > ReadEnv()
Reads the environment source into an environment block for CreateProcess.
Definition: environment.cpp:31
virtual ~Environment()
Default destructor.
Definition: environment.hpp:52