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 CORE_FXCRT_INCLUDE_FX_BASIC_H_ | 7 #ifndef CORE_FXCRT_INCLUDE_FX_BASIC_H_ |
8 #define CORE_FXCRT_INCLUDE_FX_BASIC_H_ | 8 #define CORE_FXCRT_INCLUDE_FX_BASIC_H_ |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
11 #include <memory> | 11 #include <memory> |
12 | 12 |
13 #include "core/fxcrt/include/fx_memory.h" | 13 #include "core/fxcrt/include/fx_memory.h" |
14 #include "core/fxcrt/include/fx_stream.h" | 14 #include "core/fxcrt/include/fx_stream.h" |
15 #include "core/fxcrt/include/fx_string.h" | 15 #include "core/fxcrt/include/fx_string.h" |
16 #include "core/fxcrt/include/fx_system.h" | 16 #include "core/fxcrt/include/fx_system.h" |
17 | 17 |
18 // The FX_ArraySize(arr) macro returns the # of elements in an array arr. | |
19 // The expression is a compile-time constant, and therefore can be | |
20 // used in defining new arrays, for example. If you use FX_ArraySize on | |
21 // a pointer by mistake, you will get a compile-time error. | |
22 // | |
23 // One caveat is that FX_ArraySize() doesn't accept any array of an | |
24 // anonymous type or a type defined inside a function. | |
25 #define FX_ArraySize(array) (sizeof(ArraySizeHelper(array))) | |
26 | |
27 // This template function declaration is used in defining FX_ArraySize. | |
28 // Note that the function doesn't need an implementation, as we only | |
29 // use its type. | |
30 template <typename T, size_t N> | |
31 char(&ArraySizeHelper(T(&array)[N]))[N]; | |
32 | |
33 // Used with std::unique_ptr to FX_Free raw memory. | |
34 struct FxFreeDeleter { | |
35 inline void operator()(void* ptr) const { FX_Free(ptr); } | |
36 }; | |
37 | |
38 // Used with std::unique_ptr to Release() objects that can't be deleted. | |
39 template <class T> | |
40 struct ReleaseDeleter { | |
41 inline void operator()(T* ptr) const { ptr->Release(); } | |
42 }; | |
43 | |
44 class CFX_BinaryBuf { | 18 class CFX_BinaryBuf { |
45 public: | 19 public: |
46 CFX_BinaryBuf(); | 20 CFX_BinaryBuf(); |
47 explicit CFX_BinaryBuf(FX_STRSIZE size); | 21 explicit CFX_BinaryBuf(FX_STRSIZE size); |
48 ~CFX_BinaryBuf(); | 22 ~CFX_BinaryBuf(); |
49 | 23 |
50 uint8_t* GetBuffer() const { return m_pBuffer.get(); } | 24 uint8_t* GetBuffer() const { return m_pBuffer.get(); } |
51 FX_STRSIZE GetSize() const { return m_DataSize; } | 25 FX_STRSIZE GetSize() const { return m_DataSize; } |
52 | 26 |
53 void Clear(); | 27 void Clear(); |
(...skipping 1089 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1143 FX_FLOAT c; | 1117 FX_FLOAT c; |
1144 FX_FLOAT d; | 1118 FX_FLOAT d; |
1145 FX_FLOAT e; | 1119 FX_FLOAT e; |
1146 FX_FLOAT f; | 1120 FX_FLOAT f; |
1147 FX_FLOAT g; | 1121 FX_FLOAT g; |
1148 FX_FLOAT h; | 1122 FX_FLOAT h; |
1149 FX_FLOAT i; | 1123 FX_FLOAT i; |
1150 }; | 1124 }; |
1151 | 1125 |
1152 #endif // CORE_FXCRT_INCLUDE_FX_BASIC_H_ | 1126 #endif // CORE_FXCRT_INCLUDE_FX_BASIC_H_ |
OLD | NEW |