54 auto_setenv(
const std::string& _VarName,
const std::string& _NewValue)
57 m_sVarName = _VarName;
58 m_sNewValue = _NewValue;
60 char* chTmp = getenv(m_sVarName.c_str());
66 setenv(m_sVarName.c_str(), m_sNewValue.c_str(), 1);
74 void set(
const std::string& _VarName,
const std::string& _NewValue)
78 m_sVarName = _VarName;
79 m_sNewValue = _NewValue;
81 char* chTmp = getenv(m_sVarName.c_str());
87 setenv(m_sVarName.c_str(), m_sNewValue.c_str(), 1);
94 unsetenv(m_sVarName.c_str());
98 if (!m_sVarName.empty())
101 setenv(m_sVarName.c_str(), m_sOldValue.c_str(), 1);
106 std::string m_sVarName;
107 std::string m_sNewValue;
108 std::string m_sOldValue;
120 template <
typename _T>
126 if (_pString->empty() || (*_pString)[_pString->size() - 1] != _ItemToAdd)
127 _pString->push_back(_ItemToAdd);
140 template <
typename _T>
143 return _pString->erase(_pString->find_last_not_of(_chWhat) + 1);
154 template <
typename _T>
157 return _pString->erase(0, _pString->find_first_not_of(_chWhat));
168 template <
typename _T>
169 _T&
trim(
_T* _pString,
const typename _T::value_type& _chWhat)
183 template <
typename _T>
186 typename _T::size_type pos = 0;
187 typename _T::size_type withLen = _with.length();
188 typename _T::size_type whatLen = _what.length();
189 while ((pos = _pString->find(_what, pos)) != _T::npos)
191 _pString->replace(pos, _what.length(), _with);
192 if (withLen > whatLen)
193 pos += withLen - whatLen + 1;
205 return std::tolower(c);
212 return std::toupper(c);
215 struct IsDigit : std::unary_function<int, int>
219 return std::isdigit(c);
230 template <
typename _T>
233 std::transform(_str.begin(), _str.end(), _str.begin(),
ToUpper());
244 template <
typename _T>
247 std::transform(_str.begin(), _str.end(), _str.begin(),
ToLower());
_T * smart_append(_T *_pString, const typename _T::value_type _ItemToAdd)
appends character _ItemToAdd to the string _pString if there is no such suffix on the end of _pString...
Definition: MiscUtils.h:121
_T & replace(_T *_pString, const _T &_what, const _T &_with)
finds elements in a string match a specified string and replaces it.
Definition: MiscUtils.h:184
_T & trim_left(_T *_pString, const typename _T::value_type &_chWhat)
trims leading characters from the string.
Definition: MiscUtils.h:155
A helper class. Helps to automatically track environment variables.
Definition: MiscUtils.h:47
Definition: MiscUtils.h:208
_T & to_lower(_T &_str)
convert string to lower case.
Definition: MiscUtils.h:245
_T & trim_right(_T *_pString, const typename _T::value_type &_chWhat)
trims trailing characters from the string.
Definition: MiscUtils.h:141
auto_setenv()
Definition: MiscUtils.h:50
Class which makes child to be non-copyable object.
Definition: MiscUtils.h:24
_T & to_upper(_T &_str)
convert string to upper case.
Definition: MiscUtils.h:231
char operator()(char c) const
Definition: MiscUtils.h:210
~auto_setenv()
Definition: MiscUtils.h:68
~NONCopyable()
Definition: MiscUtils.h:30
auto_setenv(const std::string &_VarName, const std::string &_NewValue)
Definition: MiscUtils.h:54
_T & trim(_T *_pString, const typename _T::value_type &_chWhat)
trims trailing and leading characters from the string.
Definition: MiscUtils.h:169
Definition: MiscUtils.h:39
#define _T(s)
Use TCHAR instead of char or wchar_t. It will be appropriately translated.
Definition: def.h:85
NONCopyable()
Definition: MiscUtils.h:27
int operator()(int c) const
Definition: MiscUtils.h:217
Definition: MiscUtils.h:215
void unset()
Definition: MiscUtils.h:89
Definition: MiscUtils.h:201
char operator()(char c) const
Definition: MiscUtils.h:203
Miscellaneous functions and helpers are located here.
Definition: BOOST_FILESYSTEM.h:21