iash  v0.5
Library to provide a bash-like shell in an application
Environment.h
1 /*
2  * Environment.h
3  *
4  * Created on: Oct 10, 2016
5  * Author: paul
6  */
7 
8 #ifndef SRC_ENVIRONMENT_H_
9 #define SRC_ENVIRONMENT_H_
10 
11 #include <map>
12 #include <vector>
13 
33 class Environment {
34 public:
35  friend class iash;
36 
44  Environment (const std::string appName = "iash");
45  virtual ~Environment ();
46 
54  void set (const std::string &key, const std::string &value);
55 
63  void set (const std::string &key, const bool value);
64 
72  void set (const std::string &key, const int value);
73 
82  void set (const std::string &key, const double value);
83 
91  const std::string& getString (const std::string &key) const;
92 
100  bool getBool (const std::string &key) const;
101 
109  int getInt (const std::string &key) const;
110 
118  double getDouble (const std::string &key) const;
119 
126  void rm (const std::string &key);
127 private:
128  void setProtected (const std::string &key, const std::string &value);
129  bool isBuiltinVar (const std::string &key) const;
130  static std::string convName (const std::string &key);
131 
132  std::map<std::string,std::string> m_envMap;
133  std::vector<std::string> m_builtins;
134 };
135 
136 #endif /* SRC_ENVIRONMENT_H_ */
const std::string & getString(const std::string &key) const
Gets the environment variable key as a string.
Definition: Environment.cpp:52
int getInt(const std::string &key) const
Gets the environment variable key as an integer.
Definition: Environment.cpp:68
Environment(const std::string appName="iash")
Creates an Environment instance with the given application name.
Definition: Environment.cpp:17
bool getBool(const std::string &key) const
Gets the environment variable key as a boolean value.
Definition: Environment.cpp:59
The main shell class for iash.
Definition: iash.h:56
void rm(const std::string &key)
Removes the environment variable key.
Definition: Environment.cpp:86
Environment variable manager for iash.
Definition: Environment.h:33
double getDouble(const std::string &key) const
Gets the environment variable key as a floating-point value.
Definition: Environment.cpp:77