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 XFA_SRC_FGAS_INCLUDE_FX_ALG_H_ | 7 #ifndef XFA_SRC_FGAS_INCLUDE_FX_ALG_H_ |
8 #define XFA_SRC_FGAS_INCLUDE_FX_ALG_H_ | 8 #define XFA_SRC_FGAS_INCLUDE_FX_ALG_H_ |
9 | 9 |
| 10 #include <cstdint> |
| 11 |
| 12 #include "core/include/fxcrt/fx_basic.h" |
| 13 |
10 #define FX_IsOdd(a) ((a)&1) | 14 #define FX_IsOdd(a) ((a)&1) |
| 15 |
11 #ifdef __cplusplus | 16 #ifdef __cplusplus |
12 extern "C" { | 17 extern "C" { |
13 #endif | 18 #endif |
| 19 |
14 int32_t FX_Base64EncodeA(const uint8_t* pSrc, int32_t iSrcLen, FX_CHAR* pDst); | 20 int32_t FX_Base64EncodeA(const uint8_t* pSrc, int32_t iSrcLen, FX_CHAR* pDst); |
15 int32_t FX_Base64DecodeA(const FX_CHAR* pSrc, int32_t iSrcLen, uint8_t* pDst); | 21 int32_t FX_Base64DecodeA(const FX_CHAR* pSrc, int32_t iSrcLen, uint8_t* pDst); |
16 int32_t FX_Base64DecodeW(const FX_WCHAR* pSrc, int32_t iSrcLen, uint8_t* pDst); | 22 int32_t FX_Base64DecodeW(const FX_WCHAR* pSrc, int32_t iSrcLen, uint8_t* pDst); |
17 uint8_t FX_Hex2Dec(uint8_t hexHigh, uint8_t hexLow); | 23 uint8_t FX_Hex2Dec(uint8_t hexHigh, uint8_t hexLow); |
18 int32_t FX_SeparateStringW(const FX_WCHAR* pStr, | 24 int32_t FX_SeparateStringW(const FX_WCHAR* pStr, |
19 int32_t iStrLen, | 25 int32_t iStrLen, |
20 FX_WCHAR delimiter, | 26 FX_WCHAR delimiter, |
21 CFX_WideStringArray& pieces); | 27 CFX_WideStringArray& pieces); |
22 #ifdef __cplusplus | 28 #ifdef __cplusplus |
23 }; | 29 }; |
24 #endif | 30 #endif |
| 31 |
25 template <class baseType> | 32 template <class baseType> |
26 class CFX_DSPATemplate { | 33 class CFX_DSPATemplate { |
27 public: | 34 public: |
28 int32_t Lookup(const baseType& find, const baseType* pArray, int32_t iCount) { | 35 int32_t Lookup(const baseType& find, const baseType* pArray, int32_t iCount) { |
29 FXSYS_assert(pArray != NULL); | 36 FXSYS_assert(pArray != NULL); |
30 if (iCount < 1) { | 37 if (iCount < 1) { |
31 return -1; | 38 return -1; |
32 } | 39 } |
33 int32_t iStart = 0, iEnd = iCount - 1, iMid; | 40 int32_t iStart = 0, iEnd = iCount - 1, iMid; |
34 do { | 41 do { |
35 iMid = (iStart + iEnd) / 2; | 42 iMid = (iStart + iEnd) / 2; |
36 const baseType& v = pArray[iMid]; | 43 const baseType& v = pArray[iMid]; |
37 if (find == v) { | 44 if (find == v) { |
38 return iMid; | 45 return iMid; |
39 } else if (find < v) { | 46 } else if (find < v) { |
40 iEnd = iMid - 1; | 47 iEnd = iMid - 1; |
41 } else { | 48 } else { |
42 iStart = iMid + 1; | 49 iStart = iMid + 1; |
43 } | 50 } |
44 } while (iStart <= iEnd); | 51 } while (iStart <= iEnd); |
45 return -1; | 52 return -1; |
46 } | 53 } |
47 }; | 54 }; |
48 | 55 |
49 #endif // XFA_SRC_FGAS_INCLUDE_FX_ALG_H_ | 56 #endif // XFA_SRC_FGAS_INCLUDE_FX_ALG_H_ |
OLD | NEW |