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