OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #ifndef CORE_INCLUDE_FXCRT_FX_EXT_H_ | 7 #ifndef CORE_INCLUDE_FXCRT_FX_EXT_H_ |
8 #define CORE_INCLUDE_FXCRT_FX_EXT_H_ | 8 #define CORE_INCLUDE_FXCRT_FX_EXT_H_ |
9 | 9 |
10 #include "fx_system.h" | 10 #include "fx_system.h" |
11 | 11 |
12 #ifdef __cplusplus | 12 #ifdef __cplusplus |
13 extern "C" { | 13 extern "C" { |
14 #endif | 14 #endif |
15 | 15 |
16 FX_FLOAT» » FXSYS_tan(FX_FLOAT a); | 16 FX_FLOAT FXSYS_tan(FX_FLOAT a); |
17 FX_FLOAT» » FXSYS_logb(FX_FLOAT b, FX_FLOAT x); | 17 FX_FLOAT FXSYS_logb(FX_FLOAT b, FX_FLOAT x); |
18 FX_FLOAT» » FXSYS_strtof(const FX_CHAR* pcsStr, int32_t iLength = -1
, int32_t *pUsedLen = NULL); | 18 FX_FLOAT FXSYS_strtof(const FX_CHAR* pcsStr, |
19 FX_FLOAT» » FXSYS_wcstof(const FX_WCHAR* pwsStr, int32_t iLength = -
1, int32_t *pUsedLen = NULL); | 19 int32_t iLength = -1, |
20 FX_WCHAR*» » FXSYS_wcsncpy(FX_WCHAR* dstStr, const FX_WCHAR* srcStr,
size_t count); | 20 int32_t* pUsedLen = NULL); |
21 int32_t»» FXSYS_wcsnicmp(const FX_WCHAR* s1, const FX_WCHAR* s2, size_t co
unt); | 21 FX_FLOAT FXSYS_wcstof(const FX_WCHAR* pwsStr, |
22 int32_t»» FXSYS_strnicmp(const FX_CHAR* s1, const FX_CHAR* s2, size_t coun
t); | 22 int32_t iLength = -1, |
| 23 int32_t* pUsedLen = NULL); |
| 24 FX_WCHAR* FXSYS_wcsncpy(FX_WCHAR* dstStr, const FX_WCHAR* srcStr, size_t count); |
| 25 int32_t FXSYS_wcsnicmp(const FX_WCHAR* s1, const FX_WCHAR* s2, size_t count); |
| 26 int32_t FXSYS_strnicmp(const FX_CHAR* s1, const FX_CHAR* s2, size_t count); |
23 | 27 |
24 inline FX_BOOL» FXSYS_islower(int32_t ch) | 28 inline FX_BOOL FXSYS_islower(int32_t ch) { |
25 { | 29 return ch >= 'a' && ch <= 'z'; |
26 return ch >= 'a' && ch <= 'z'; | |
27 } | 30 } |
28 inline FX_BOOL» FXSYS_isupper(int32_t ch) | 31 inline FX_BOOL FXSYS_isupper(int32_t ch) { |
29 { | 32 return ch >= 'A' && ch <= 'Z'; |
30 return ch >= 'A' && ch <= 'Z'; | |
31 } | 33 } |
32 inline int32_t» FXSYS_tolower(int32_t ch) | 34 inline int32_t FXSYS_tolower(int32_t ch) { |
33 { | 35 return ch < 'A' || ch > 'Z' ? ch : (ch + 0x20); |
34 return ch < 'A' || ch > 'Z' ? ch : (ch + 0x20); | |
35 } | 36 } |
36 inline int32_t FXSYS_toupper(int32_t ch) | 37 inline int32_t FXSYS_toupper(int32_t ch) { |
37 { | 38 return ch < 'a' || ch > 'z' ? ch : (ch - 0x20); |
38 return ch < 'a' || ch > 'z' ? ch : (ch - 0x20); | |
39 } | 39 } |
40 | 40 |
41 FX_DWORD» FX_HashCode_String_GetA(const FX_CHAR* pStr, int32_t iLength, FX
_BOOL bIgnoreCase = FALSE); | 41 FX_DWORD FX_HashCode_String_GetA(const FX_CHAR* pStr, |
42 FX_DWORD» FX_HashCode_String_GetW(const FX_WCHAR* pStr, int32_t iLength, F
X_BOOL bIgnoreCase = FALSE); | 42 int32_t iLength, |
| 43 FX_BOOL bIgnoreCase = FALSE); |
| 44 FX_DWORD FX_HashCode_String_GetW(const FX_WCHAR* pStr, |
| 45 int32_t iLength, |
| 46 FX_BOOL bIgnoreCase = FALSE); |
43 | 47 |
44 #ifdef __cplusplus | 48 #ifdef __cplusplus |
45 } | 49 } |
46 #endif | 50 #endif |
47 #ifdef __cplusplus | 51 #ifdef __cplusplus |
48 extern "C" { | 52 extern "C" { |
49 #endif | 53 #endif |
50 | 54 |
51 void*» FX_Random_MT_Start(FX_DWORD dwSeed); | 55 void* FX_Random_MT_Start(FX_DWORD dwSeed); |
52 | 56 |
53 FX_DWORD» FX_Random_MT_Generate(void* pContext); | 57 FX_DWORD FX_Random_MT_Generate(void* pContext); |
54 | 58 |
55 void» » FX_Random_MT_Close(void* pContext); | 59 void FX_Random_MT_Close(void* pContext); |
56 | 60 |
57 void» » FX_Random_GenerateBase(FX_DWORD* pBuffer, int32_t iCount); | 61 void FX_Random_GenerateBase(FX_DWORD* pBuffer, int32_t iCount); |
58 | 62 |
59 void» » FX_Random_GenerateMT(FX_DWORD* pBuffer, int32_t iCount); | 63 void FX_Random_GenerateMT(FX_DWORD* pBuffer, int32_t iCount); |
60 | 64 |
61 void» » FX_Random_GenerateCrypto(FX_DWORD* pBuffer, int32_t iCount); | 65 void FX_Random_GenerateCrypto(FX_DWORD* pBuffer, int32_t iCount); |
62 #ifdef __cplusplus | 66 #ifdef __cplusplus |
63 } | 67 } |
64 #endif | 68 #endif |
65 template<class baseType> | 69 template <class baseType> |
66 class CFX_SSortTemplate | 70 class CFX_SSortTemplate { |
67 { | 71 public: |
68 public: | 72 void ShellSort(baseType* pArray, int32_t iCount) { |
69 void ShellSort(baseType *pArray, int32_t iCount) | 73 FXSYS_assert(pArray != NULL && iCount > 0); |
70 { | 74 int32_t i, j, gap; |
71 FXSYS_assert(pArray != NULL && iCount > 0); | 75 baseType v1, v2; |
72 int32_t i, j, gap; | 76 gap = iCount >> 1; |
73 baseType v1, v2; | 77 while (gap > 0) { |
74 gap = iCount >> 1; | 78 for (i = gap; i < iCount; i++) { |
75 while (gap > 0) { | 79 j = i - gap; |
76 for (i = gap; i < iCount; i ++) { | 80 v1 = pArray[i]; |
77 j = i - gap; | 81 while (j > -1 && (v2 = pArray[j]) > v1) { |
78 v1 = pArray[i]; | 82 pArray[j + gap] = v2; |
79 while (j > -1 && (v2 = pArray[j]) > v1) { | 83 j -= gap; |
80 pArray[j + gap] = v2; | |
81 j -= gap; | |
82 } | |
83 pArray[j + gap] = v1; | |
84 } | |
85 gap >>= 1; | |
86 } | 84 } |
| 85 pArray[j + gap] = v1; |
| 86 } |
| 87 gap >>= 1; |
87 } | 88 } |
| 89 } |
88 }; | 90 }; |
89 | 91 |
90 #endif // CORE_INCLUDE_FXCRT_FX_EXT_H_ | 92 #endif // CORE_INCLUDE_FXCRT_FX_EXT_H_ |
OLD | NEW |