C++ Utils  0.1
utils/env.h
Go to the documentation of this file.
00001 
00037 #ifndef UTILS_ENV_H
00038 #define UTILS_ENV_H
00039 
00040 #include <cstdlib>
00041 
00042 #include "utils/stringutils.h"
00043 
00044 namespace utils
00045 {
00046 
00050 class Env
00051 {
00052 public:
00053         template<typename T>
00054         static T get(const char* name, T defaultVal)
00055         {
00056                 char* value = getenv(name);
00057 
00058                 if (!value)
00059                         return defaultVal;
00060 
00061                 return StringUtils::parse<T>(value);
00062         }
00063 };
00064 
00065 }
00066 
00067 #endif // UTILS_ENV_H
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Defines