From 0d0f12b39428ac7ba3de790358f11e183b682865 Mon Sep 17 00:00:00 2001 From: Tomasz Sowa Date: Mon, 4 Jun 2012 17:51:43 +0000 Subject: [PATCH] added: to Requst: std::wstring * PostVarp(const std::wstring & var); added: to misc: template bool Toa(unsigned/signed long/int value, CharType * buffer); some Toa methods which don't get the buffer len (the buffer has to be sufficient big) git-svn-id: svn://ttmath.org/publicrep/winix/trunk@845 e52654a7-88a9-db11-a3e9-0013d4bc506e --- core/misc.h | 43 ++++++++++++++++++++++++++++++++++++++++++- core/request.cpp | 10 ++++++++++ core/request.h | 1 + 3 files changed, 53 insertions(+), 1 deletion(-) diff --git a/core/misc.h b/core/misc.h index 3a405b1..fc11c0f 100755 --- a/core/misc.h +++ b/core/misc.h @@ -120,14 +120,55 @@ bool Toa(int value, CharType * buffer, size_t buf_len, int base = 10) } + + +/* + these methos don't take the buffer size + make sure the buffer size is sufficient big + 2^64 - 1 = 18446744073709551615 = 20 characters (plus minus sign and plus terminating zero) + so the buffer should have at least 22 characters + !! CHECK ME check the size whether is correct +*/ +template +bool Toa(unsigned long value, CharType * buffer) +{ + size_t sufficient_space = 25; + return Toa(value, buffer, sufficient_space); +} + +template +bool Toa(long value, CharType * buffer) +{ + size_t sufficient_space = 25; + return Toa(value, buffer, sufficient_space); +} + +template +bool Toa(unsigned int value, CharType * buffer) +{ + size_t sufficient_space = 25; + return Toa(value, buffer, sufficient_space); +} + +template +bool Toa(int value, CharType * buffer) +{ + size_t sufficient_space = 25; + return Toa(value, buffer, sufficient_space); +} + + + + + // warning: it uses its own static buffer // one buffer for both these functions +// !! REMOVE ME they are deprecated (don't use it) const wchar_t * Toa(unsigned int value, int base = 10); const wchar_t * Toa(unsigned long value, int base = 10); const wchar_t * Toa(int value, int base = 10); const wchar_t * Toa(long value, int base = 10); - void Toa(int value, std::string & res, int base = 10, bool clear = true); void Toa(long value, std::string & res, int base = 10, bool clear = true); void Toa(int value, std::wstring & res, int base = 10, bool clear = true); diff --git a/core/request.cpp b/core/request.cpp index 22118e6..0bb9c93 100755 --- a/core/request.cpp +++ b/core/request.cpp @@ -234,6 +234,16 @@ return &p->second; } +std::wstring * Request::PostVarp(const std::wstring & var) +{ +PostTab::iterator p = post_tab.find(var); + + if( p == post_tab.end() ) + return 0; + +return &p->second; +} + diff --git a/core/request.h b/core/request.h index 4c77f83..9ae09d4 100755 --- a/core/request.h +++ b/core/request.h @@ -167,6 +167,7 @@ struct Request bool PostVar(const std::wstring & var, std::wstring & result); std::wstring * PostVarp(const wchar_t * var); + std::wstring * PostVarp(const std::wstring & var); bool AllPostVarEmpty(); // returning true if all post vars are empty