This commit adds StrVar class which reads string value from environment
(as it is). Default value will be used if corresponding environment variable
does not exists.
Signed-off-by: Jonghyun Park <jh1302.park@samsung.com>
int32_t _value;
};
+class StrVar
+{
+public:
+ StrVar(const std::string &name, const std::string &value);
+
+public:
+ const std::string &operator()(void) const { return _value; }
+
+private:
+ std::string _value;
+};
+
#endif // __ENV_UTILS_H__
{
nnfw::util::env::IntAccessor{name}.access(_value);
}
+
+//
+// String variable
+//
+#include <cstdlib>
+
+StrVar::StrVar(const std::string &name, const std::string &value) : _value{value}
+{
+ auto env = std::getenv(name.c_str());
+
+ if (env)
+ {
+ _value = std::string{env};
+ }
+}