fixed Sttp to return T_EOF when EOF is reached

This commit is contained in:
2018-10-21 16:36:03 +00:00
parent 942f33d8d4
commit 1758ba4e1e
5 changed files with 88 additions and 26 deletions

View File

@ -48,11 +48,29 @@ public:
/// A class of an hashable object must implement this function.
virtual qse_size_t getHashCode () const = 0;
static qse_size_t getHashCode (qse_size_t init, const qse_char_t* str)
static qse_size_t getHashCode (qse_size_t init, const qse_mchar_t* str)
{
qse_size_t n = init;
while (*str != QSE_T('\0'))
while (*str != QSE_MT('\0'))
{
n = n * 31 + *((qse_uint8_t*)str);
str++;
}
return n;
}
static qse_size_t getHashCode (const qse_mchar_t* str)
{
return Hashable::getHashCode(0, str);
}
static qse_size_t getHashCode (qse_size_t init, const qse_wchar_t* str)
{
qse_size_t n = init;
while (*str != QSE_WT('\0'))
{
const qse_uint8_t* p = (const qse_uint8_t*)str;
for (qse_size_t i = 0; i < QSE_SIZEOF(*str); i++)
@ -63,9 +81,9 @@ public:
return n;
}
static qse_size_t getHashCode (const qse_char_t* str)
static qse_size_t getHashCode (const qse_wchar_t* str)
{
return Hashable::getHashCode (0, str);
return Hashable::getHashCode(0, str);
}
static qse_size_t getHashCode (qse_size_t init, const void* data, qse_size_t size)
@ -98,7 +116,7 @@ public:
/// pointed to by \a data of the length \a size.
static qse_size_t getHashCode (const void* data, qse_size_t size)
{
return Hashable::getHashCode (0, data, size);
return Hashable::getHashCode(0, data, size);
}
};

View File

@ -232,6 +232,7 @@ public:
E_EINTERN, /**< internal error */
E_ENOMEM,
E_NARGS, /**< wrong number of arguments */
E_EINVAL,
E_EACCES,
E_EPERM,

View File

@ -181,6 +181,35 @@ protected:
int flush_outbuf () QSE_CPP_NOEXCEPT;
};
#if 0
class SttpStdHandler
{
int operator() (const SttpCmd& cmd)
{
}
};
template <class HANDLER>
class SttpX
{
int exec()
{
if (this->receiveCmd(&cmd) <= -1)
{
}
if (this->handler(&cmd) <= -1)
{
}
}
protected:
HANDLER handler;
};
#endif
QSE_END_NAMESPACE(QSE)
#endif

View File

@ -67,6 +67,11 @@ public:
this->name.append (n, size);
}
const QSE::String& getName () const
{
return this->name;
}
bool isNullCmd () const
{
return this->name.getSize() == 0;