#pragma once
#include <string>
#include <stdint.h>
#include <sys/types.h>
#include <vector>
bool StringHasPrefix( const std::string & sString, const std::string & sPrefix );
bool StringHasPrefixCaseSensitive( const std::string & sString, const std::string & sPrefix );
bool StringHasSuffix( const std::string &sString, const std::string &sSuffix );
bool StringHasSuffixCaseSensitive( const std::string &sString, const std::string &sSuffix );
std::string StringReplace( const std::string &sModify, const std::string &sFind, const std::string &sReplace );
std::string UTF16to8( const wchar_t * in );
std::string UTF16to8( const std::wstring & in );
std::wstring UTF8to16(const char * in);
std::wstring UTF8to16( const std::string & in );
#define Utf16FromUtf8 UTF8to16
#if defined( _WIN32 )
std::string DefaultACPtoUTF8( const char *pszStr );
#endif
bool RepairUTF8( const char *begin, const char *end, std::string & sOutputUtf8 );
bool RepairUTF8( const std::string & sInputUtf8, std::string & sOutputUtf8 );
std::string TrimTrailingWhitespace( const std::string& in );
void strcpy_safe( char *pchBuffer, size_t unBufferSizeBytes, const char *pchSource );
template< size_t bufferSize >
void strcpy_safe( char (& buffer) [ bufferSize ], const char *pchSource )
{
strcpy_safe( buffer, bufferSize, pchSource );
}
std::string Format( const char *pchFormat, ... );
std::string StringToUpper( const std::string & sString );
std::string StringToLower( const std::string & sString );
#if defined( OSX ) || defined( LINUX )
int stricmp(const char *pStr1, const char *pStr2);
#ifndef _stricmp
#define _stricmp stricmp
#endif
int strnicmp( const char *pStr1, const char *pStr2, size_t unBufferLen );
#ifndef _strnicmp
#define _strnicmp strnicmp
#endif
#ifndef _vsnprintf_s
#define _vsnprintf_s vsnprintf
#endif
#define _TRUNCATE ((size_t)-1)
#endif
#if defined( OSX )
inline errno_t wcsncpy_s(wchar_t *strDest, size_t numberOfElements, const wchar_t *strSource, size_t count)
{
return wcslcpy(strDest, strSource, numberOfElements);
}
inline errno_t strncpy_s(char *strDest, size_t numberOfElements, const char *strSource, size_t count)
{
return strlcpy(strDest, strSource, numberOfElements);
}
#endif
#if defined( LINUX )
#include "string.h"
inline void wcsncpy_s(wchar_t *strDest, size_t numberOfElements, const wchar_t *strSource, size_t count)
{
wcsncpy(strDest, strSource, numberOfElements);
strDest[numberOfElements-1] = '\0';
}
inline void strncpy_s(char *strDest, size_t numberOfElements, const char *strSource, size_t count)
{
strncpy(strDest, strSource, numberOfElements);
strDest[numberOfElements-1] = '\0';
}
#endif
#if defined( _WIN32 ) && _MSC_VER < 1800
inline uint64_t strtoull(const char *str, char **endptr, int base) { return _strtoui64( str, endptr, base ); }
#endif
uint32_t ReturnStdString( const std::string & sValue, char *pchBuffer, uint32_t unBufferLen );
std::string Uint64ToString( uint64_t ulValue );
uint64_t StringToUint64( const std::string & sValue );
void V_URLEncode( char *pchDest, int nDestLen, const char *pchSource, int nSourceLen );
void V_URLEncodeNoPlusForSpace( char *pchDest, int nDestLen, const char *pchSource, int nSourceLen );
void V_URLEncodeFullPath( char *pchDest, int nDestLen, const char *pchSource, int nSourceLen );
size_t V_URLDecode( char *pchDecodeDest, int nDecodeDestLen, const char *pchEncodedSource, int nEncodedSourceLen );
size_t V_URLDecodeNoPlusForSpace( char *pchDecodeDest, int nDecodeDestLen, const char *pchEncodedSource, int nEncodedSourceLen );
void V_StripExtension( std::string &in );
std::string IpToString( uint32_t unIpH );
std::string IpAndPortToString( uint32_t unIpH, uint16_t usPortH );
std::vector<std::string> TokenizeString( const std::string & sString, char cToken );