12 #define BOOL_T_LEN 2048
35 bool_t(
const std::string &err);
47 operator bool()
const;
51 void strncpy(
const char *pSrc);
52 void setErrorString(
const std::string &err);
53 void setErrorString(
const char *pStr);
55 char m_errorString[BOOL_T_LEN];
56 static char s_defaultErrMsg[];
57 static char s_defaultSuccessMsg[];
65 setErrorString(s_defaultErrMsg);
78 inline void bool_t::strncpy(
const char *pSrc)
81 ::strncpy(m_errorString, pSrc, BOOL_T_LEN);
83 strncpy_s(m_errorString, BOOL_T_LEN, pSrc, _TRUNCATE);
85 m_errorString[BOOL_T_LEN-1] = 0;
90 if (b.m_errorString[0] == 0)
93 strncpy(b.m_errorString);
96 inline void bool_t::setErrorString(
const std::string &s)
98 setErrorString(s.c_str());
101 inline void bool_t::setErrorString(
const char *pStr)
103 if (pStr == 0 || pStr[0] == 0)
104 strncpy(s_defaultErrMsg);
111 if (b.m_errorString[0] == 0)
112 m_errorString[0] = 0;
114 strncpy(b.m_errorString);
121 if (m_errorString[0] == 0)
122 return s_defaultSuccessMsg;
123 return m_errorString;
126 inline bool_t::operator bool()
const
131 inline bool bool_t::success()
const
133 return (m_errorString[0] == 0);
Type to return true/false with error description.
Definition: booltype.h:25
bool_t(bool f=true)
Just set true or false, but leave the error description undefined in case of 'false'.
Definition: booltype.h:60
std::string getErrorString() const
Returns a description of the error.
Definition: booltype.h:119
bool_t & operator=(const bool_t &b)
Assignment operator.
Definition: booltype.h:109