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