2015-12-17 21:04:38 +00:00
|
|
|
#ifndef ENGINE_SERVER_SQL_STRING_HELPERS_H
|
|
|
|
#define ENGINE_SERVER_SQL_STRING_HELPERS_H
|
2015-11-21 23:52:12 +00:00
|
|
|
|
2016-05-04 14:51:18 +00:00
|
|
|
namespace sqlstr
|
|
|
|
{
|
|
|
|
|
2016-09-25 08:41:34 +00:00
|
|
|
void FuzzyString(char *pString, int size);
|
2015-11-21 23:52:12 +00:00
|
|
|
|
|
|
|
// anti SQL injection
|
2016-05-09 21:35:23 +00:00
|
|
|
void ClearString(char *pString, int size = 32);
|
2015-11-21 23:52:12 +00:00
|
|
|
|
2017-03-21 10:24:44 +00:00
|
|
|
void AgoTimeToString(int agoTime, char *pAgoString);
|
2015-11-21 23:52:12 +00:00
|
|
|
|
2017-03-21 10:24:44 +00:00
|
|
|
void GetTimeStamp(char *pDest, unsigned int Size);
|
2015-11-21 23:52:12 +00:00
|
|
|
|
|
|
|
|
2016-05-09 21:35:23 +00:00
|
|
|
template<unsigned int size>
|
|
|
|
class CSqlString
|
2015-11-21 23:52:12 +00:00
|
|
|
{
|
2016-05-09 21:35:23 +00:00
|
|
|
public:
|
|
|
|
CSqlString() {}
|
2015-11-21 23:52:12 +00:00
|
|
|
|
2017-03-21 10:24:44 +00:00
|
|
|
CSqlString(const char *pStr)
|
2015-11-21 23:52:12 +00:00
|
|
|
{
|
2016-05-09 21:35:23 +00:00
|
|
|
str_copy(m_aString, pStr, size);
|
|
|
|
str_copy(m_aClearString, pStr, size);
|
|
|
|
ClearString(m_aClearString, sizeof(m_aClearString));
|
2015-11-21 23:52:12 +00:00
|
|
|
}
|
|
|
|
|
2016-05-09 21:35:23 +00:00
|
|
|
const char* Str() const { return m_aString; }
|
|
|
|
const char* ClrStr() const { return m_aClearString; }
|
2015-11-21 23:52:12 +00:00
|
|
|
|
2017-03-21 10:24:44 +00:00
|
|
|
CSqlString& operator = (const char *pStr)
|
2015-11-21 23:52:12 +00:00
|
|
|
{
|
2016-05-09 21:35:23 +00:00
|
|
|
str_copy(m_aString, pStr, size);
|
|
|
|
str_copy(m_aClearString, pStr, size);
|
|
|
|
ClearString(m_aClearString, sizeof(m_aClearString));
|
|
|
|
return *this;
|
2015-11-21 23:52:12 +00:00
|
|
|
}
|
|
|
|
|
2016-05-09 21:35:23 +00:00
|
|
|
private:
|
|
|
|
char m_aString[size];
|
|
|
|
char m_aClearString[size * 2 - 1];
|
|
|
|
};
|
2016-05-04 14:47:53 +00:00
|
|
|
|
2016-05-04 14:51:18 +00:00
|
|
|
}
|
2016-05-04 14:47:53 +00:00
|
|
|
|
2015-11-21 23:52:12 +00:00
|
|
|
#endif
|