Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: core/include/fxcrt/fx_ext.h

Issue 1825953002: Move core/include/fxcrt to core/fxcrt/include. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/include/fxcrt/fx_coordinates.h ('k') | core/include/fxcrt/fx_memory.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 CORE_INCLUDE_FXCRT_FX_EXT_H_
8 #define CORE_INCLUDE_FXCRT_FX_EXT_H_
9
10 #include <cctype>
11 #include <cwctype>
12
13 #include "core/include/fxcrt/fx_basic.h"
14
15 // TODO(thestig) Using unique_ptr with ReleaseDeleter is still not ideal.
16 // Come up or wait for something better. This appears in this file rather
17 // than fx_stream.h due to include ordering restrictions.
18 using ScopedFileStream =
19 std::unique_ptr<IFX_FileStream, ReleaseDeleter<IFX_FileStream>>;
20
21 FX_FLOAT FXSYS_tan(FX_FLOAT a);
22 FX_FLOAT FXSYS_logb(FX_FLOAT b, FX_FLOAT x);
23 FX_FLOAT FXSYS_strtof(const FX_CHAR* pcsStr,
24 int32_t iLength = -1,
25 int32_t* pUsedLen = NULL);
26 FX_FLOAT FXSYS_wcstof(const FX_WCHAR* pwsStr,
27 int32_t iLength = -1,
28 int32_t* pUsedLen = NULL);
29 FX_WCHAR* FXSYS_wcsncpy(FX_WCHAR* dstStr, const FX_WCHAR* srcStr, size_t count);
30 int32_t FXSYS_wcsnicmp(const FX_WCHAR* s1, const FX_WCHAR* s2, size_t count);
31 int32_t FXSYS_strnicmp(const FX_CHAR* s1, const FX_CHAR* s2, size_t count);
32
33 inline bool FXSYS_islower(int32_t ch) {
34 return ch >= 'a' && ch <= 'z';
35 }
36 inline bool FXSYS_isupper(int32_t ch) {
37 return ch >= 'A' && ch <= 'Z';
38 }
39 inline int32_t FXSYS_tolower(int32_t ch) {
40 return ch < 'A' || ch > 'Z' ? ch : (ch + 0x20);
41 }
42 inline int32_t FXSYS_toupper(int32_t ch) {
43 return ch < 'a' || ch > 'z' ? ch : (ch - 0x20);
44 }
45 inline bool FXSYS_iswalpha(wchar_t wch) {
46 return (wch >= L'A' && wch <= L'Z') || (wch >= L'a' && wch <= L'z');
47 }
48 inline bool FXSYS_iswdigit(wchar_t wch) {
49 return wch >= L'0' && wch <= L'9';
50 }
51 inline bool FXSYS_iswalnum(wchar_t wch) {
52 return FXSYS_iswalpha(wch) || FXSYS_iswdigit(wch);
53 }
54
55 inline int FXSYS_toHexDigit(const FX_CHAR c) {
56 if (!std::isxdigit(c))
57 return 0;
58 char upchar = std::toupper(c);
59 return upchar > '9' ? upchar - 'A' + 10 : upchar - '0';
60 }
61
62 inline bool FXSYS_isDecimalDigit(const FX_CHAR c) {
63 return !!std::isdigit(c);
64 }
65
66 inline bool FXSYS_isDecimalDigit(const FX_WCHAR c) {
67 return !!std::iswdigit(c);
68 }
69
70 inline int FXSYS_toDecimalDigit(const FX_CHAR c) {
71 return std::isdigit(c) ? c - '0' : 0;
72 }
73
74 inline int FXSYS_toDecimalDigit(const FX_WCHAR c) {
75 return std::iswdigit(c) ? c - L'0' : 0;
76 }
77
78 FX_DWORD FX_HashCode_String_GetA(const FX_CHAR* pStr,
79 int32_t iLength,
80 FX_BOOL bIgnoreCase = FALSE);
81 FX_DWORD FX_HashCode_String_GetW(const FX_WCHAR* pStr,
82 int32_t iLength,
83 FX_BOOL bIgnoreCase = FALSE);
84
85 void* FX_Random_MT_Start(FX_DWORD dwSeed);
86
87 FX_DWORD FX_Random_MT_Generate(void* pContext);
88
89 void FX_Random_MT_Close(void* pContext);
90
91 void FX_Random_GenerateBase(FX_DWORD* pBuffer, int32_t iCount);
92
93 void FX_Random_GenerateMT(FX_DWORD* pBuffer, int32_t iCount);
94
95 void FX_Random_GenerateCrypto(FX_DWORD* pBuffer, int32_t iCount);
96
97 #ifdef PDF_ENABLE_XFA
98 typedef struct FX_GUID {
99 FX_DWORD data1;
100 uint16_t data2;
101 uint16_t data3;
102 uint8_t data4[8];
103 } FX_GUID, *FX_LPGUID;
104 typedef FX_GUID const* FX_LPCGUID;
105 void FX_GUID_CreateV4(FX_LPGUID pGUID);
106 void FX_GUID_ToString(FX_LPCGUID pGUID,
107 CFX_ByteString& bsStr,
108 FX_BOOL bSeparator = TRUE);
109 #endif // PDF_ENABLE_XFA
110
111 template <class baseType>
112 class CFX_SSortTemplate {
113 public:
114 void ShellSort(baseType* pArray, int32_t iCount) {
115 FXSYS_assert(pArray && iCount > 0);
116 int32_t i, j, gap;
117 baseType v1, v2;
118 gap = iCount >> 1;
119 while (gap > 0) {
120 for (i = gap; i < iCount; i++) {
121 j = i - gap;
122 v1 = pArray[i];
123 while (j > -1 && (v2 = pArray[j]) > v1) {
124 pArray[j + gap] = v2;
125 j -= gap;
126 }
127 pArray[j + gap] = v1;
128 }
129 gap >>= 1;
130 }
131 }
132 };
133
134 #endif // CORE_INCLUDE_FXCRT_FX_EXT_H_
OLDNEW
« no previous file with comments | « core/include/fxcrt/fx_coordinates.h ('k') | core/include/fxcrt/fx_memory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698