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