12 #define BOOL_T_LEN 2048
35 bool_t(
const std::string &err);
47 operator bool()
const;
49 void strncpy(
const char *pSrc);
50 void setErrorString(
const std::string &err);
51 void setErrorString(
const char *pStr);
53 char m_errorString[BOOL_T_LEN];
54 static char s_defaultErrMsg[];
55 static char s_defaultSuccessMsg[];
63 setErrorString(s_defaultErrMsg);
76 inline void bool_t::strncpy(
const char *pSrc)
79 ::strncpy(m_errorString, pSrc, BOOL_T_LEN);
81 strncpy_s(m_errorString, BOOL_T_LEN, pSrc, _TRUNCATE);
83 m_errorString[BOOL_T_LEN-1] = 0;
88 if (b.m_errorString[0] == 0)
91 strncpy(b.m_errorString);
94 inline void bool_t::setErrorString(
const std::string &s)
96 setErrorString(s.c_str());
99 inline void bool_t::setErrorString(
const char *pStr)
101 if (pStr == 0 || pStr[0] == 0)
102 strncpy(s_defaultErrMsg);
109 if (b.m_errorString[0] == 0)
110 m_errorString[0] = 0;
112 strncpy(b.m_errorString);
119 if (m_errorString[0] == 0)
120 return s_defaultSuccessMsg;
121 return m_errorString;
124 inline bool_t::operator bool()
const
126 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:58
std::string getErrorString() const
Returns a description of the error.
Definition: booltype.h:117
bool_t & operator=(const bool_t &b)
Assignment operator.
Definition: booltype.h:107