38 #include "NptConfig.h" 40 #include "NptStrings.h" 42 #include "NptDataBuffer.h" 45 #if defined (NPT_CONFIG_HAVE_STDIO_H) 49 #if defined (NPT_CONFIG_HAVE_STRING_H) 53 #if defined(NPT_CONFIG_HAVE_STDARG_H) 57 #if defined(TARGET_WINDOWS_STORE) 63 #define NPT_ARRAY_SIZE(_a) (sizeof(_a)/sizeof((_a)[0])) 68 extern void NPT_BytesFromInt64Be(
unsigned char* buffer, NPT_UInt64 value);
69 extern void NPT_BytesFromInt32Be(
unsigned char* buffer, NPT_UInt32 value);
70 extern void NPT_BytesFromInt24Be(
unsigned char* buffer, NPT_UInt32 value);
71 extern void NPT_BytesFromInt16Be(
unsigned char* buffer, NPT_UInt16 value);
72 extern NPT_UInt64 NPT_BytesToInt64Be(
const unsigned char* buffer);
73 extern NPT_UInt32 NPT_BytesToInt32Be(
const unsigned char* buffer);
74 extern NPT_UInt32 NPT_BytesToInt24Be(
const unsigned char* buffer);
75 extern NPT_UInt16 NPT_BytesToInt16Be(
const unsigned char* buffer);
77 extern void NPT_BytesFromInt64Le(
unsigned char* buffer, NPT_UInt64 value);
78 extern void NPT_BytesFromInt32Le(
unsigned char* buffer, NPT_UInt32 value);
79 extern void NPT_BytesFromInt24Le(
unsigned char* buffer, NPT_UInt32 value);
80 extern void NPT_BytesFromInt16Le(
unsigned char* buffer, NPT_UInt16 value);
81 extern NPT_UInt64 NPT_BytesToInt64Le(
const unsigned char* buffer);
82 extern NPT_UInt32 NPT_BytesToInt32Le(
const unsigned char* buffer);
83 extern NPT_UInt32 NPT_BytesToInt24Le(
const unsigned char* buffer);
84 extern NPT_UInt16 NPT_BytesToInt16Le(
const unsigned char* buffer);
90 NPT_ParseFloat(
const char* str,
float& result,
bool relaxed =
true);
93 NPT_ParseInteger(
const char* str,
long& result,
bool relaxed =
true, NPT_Cardinal* chars_used = 0);
96 NPT_ParseInteger(
const char* str,
unsigned long& result,
bool relaxed =
true, NPT_Cardinal* chars_used = 0);
99 NPT_ParseInteger(
const char* str,
int& result,
bool relaxed =
true, NPT_Cardinal* chars_used = 0);
102 NPT_ParseInteger(
const char* str,
unsigned int& result,
bool relaxed =
true, NPT_Cardinal* chars_used = 0);
105 NPT_ParseInteger32(
const char* str, NPT_Int32& result,
bool relaxed =
true, NPT_Cardinal* chars_used = 0);
108 NPT_ParseInteger32(
const char* str, NPT_UInt32& result,
bool relaxed =
true, NPT_Cardinal* chars_used = 0);
111 NPT_ParseInteger64(
const char* str, NPT_Int64& result,
bool relaxed =
true, NPT_Cardinal* chars_used = 0);
114 NPT_ParseInteger64(
const char* str, NPT_UInt64& result,
bool relaxed =
true, NPT_Cardinal* chars_used = 0);
120 NPT_FormatOutput(
void (*
function)(
void* parameter,
const char* message),
121 void* function_parameter,
125 void NPT_ByteToHex(NPT_Byte b,
char* buffer,
bool uppercase=
false);
126 NPT_Result NPT_HexToByte(
const char* buffer, NPT_Byte& b);
127 NPT_Result NPT_HexToBytes(
const char* hex,
NPT_DataBuffer& bytes);
128 NPT_String NPT_HexString(
const unsigned char* data,
130 const char* separator = NULL,
131 bool uppercase=
false);
132 char NPT_NibbleToHex(
unsigned int nibble,
bool uppercase =
true);
133 int NPT_HexToNibble(
char hex);
139 NPT_ParseMimeParameters(
const char* encoded,
147 static NPT_Result Get(
const char* name,
NPT_String& value);
148 static NPT_Result Set(
const char* name,
const char* value);
151 #define NPT_GetEnvironment(_x,_y) NPT_Environment::Get(_x,_y) 156 #if defined (NPT_CONFIG_HAVE_STDIO_H) 160 #if defined (NPT_CONFIG_HAVE_STRING_H) 164 #if defined (NPT_CONFIG_HAVE_SNPRINTF) 165 #define NPT_FormatString NPT_snprintf 167 int NPT_FormatString(
char* str, NPT_Size size,
const char* format, ...);
170 #if defined(NPT_CONFIG_HAVE_VSNPRINTF) 171 #define NPT_FormatStringVN(s,c,f,a) NPT_vsnprintf(s,c,f,a) 173 extern int NPT_FormatStringVN(
char *buffer,
size_t count,
const char *format, va_list argptr);
176 #if defined(NPT_CONFIG_HAVE_MEMCPY) 177 #define NPT_CopyMemory memcpy 179 extern void NPT_CopyMemory(
void* dest,
void* src, NPT_Size size);
182 #if defined(NPT_CONFIG_HAVE_STRCMP) 183 #define NPT_StringsEqual(s1, s2) (strcmp((s1), (s2)) == 0) 185 extern int NPT_StringsEqual(
const char* s1,
const char* s2);
188 #if defined(NPT_CONFIG_HAVE_STRNCMP) 189 #define NPT_StringsEqualN(s1, s2, n) (strncmp((s1), (s2), (n)) == 0) 191 extern int NPT_StringsEqualN(
const char* s1,
const char* s2,
unsigned long size);
194 #if defined(NPT_CONFIG_HAVE_STRLEN) 195 #define NPT_StringLength(s) (NPT_Size)(strlen(s)) 197 extern unsigned long NPT_StringLength(
const char* s);
200 #if defined(NPT_CONFIG_HAVE_STRCPY) 201 #define NPT_CopyString(dst, src) ((void)NPT_strcpy((dst), (src))) 203 extern void NPT_CopyString(
char* dst,
const char* src);
212 #if defined(NPT_CONFIG_HAVE_STRNCPY) 213 #define NPT_CopyStringN(dst, src, n) \ 214 do { ((void)NPT_strncpy((dst), (src), n)); (dst)[(n)] = '\0'; } while(0) 216 extern int NPT_CopyStringN(
char* dst,
const char* src,
unsigned long n);
219 #if defined(NPT_CONFIG_HAVE_MEMSET) 220 #define NPT_SetMemory memset 222 extern void NPT_SetMemory(
void* dest,
int c, NPT_Size size);
225 #if defined(NPT_CONFIG_HAVE_MEMCMP) 226 #define NPT_MemoryEqual(s1, s2, n) (memcmp((s1), (s2), (n)) == 0) 228 extern int NPT_MemoryEqual(
const void* s1,
const void* s2,
unsigned long n);
231 #if defined(TARGET_WINDOWS_STORE) 232 std::wstring win32ConvertUtf8ToW(
const std::string &text);
235 #endif // _NPT_UTILS_H_
Definition: NptDataBuffer.h:44
Definition: NptStrings.h:57
Definition: NptUtils.h:145