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 class CFX_BinaryBuf { | 18 class CFX_BinaryBuf { |
19 public: | 19 public: |
20 CFX_BinaryBuf(); | 20 CFX_BinaryBuf(); |
21 explicit CFX_BinaryBuf(FX_STRSIZE size); | 21 explicit CFX_BinaryBuf(FX_STRSIZE size); |
22 ~CFX_BinaryBuf(); | 22 ~CFX_BinaryBuf(); |
23 | 23 |
24 uint8_t* GetBuffer() const { return m_pBuffer.get(); } | 24 uint8_t* GetBuffer() const { return m_pBuffer.get(); } |
25 FX_STRSIZE GetSize() const { return m_DataSize; } | 25 FX_STRSIZE GetSize() const { return m_DataSize; } |
26 | 26 |
27 void Clear(); | 27 void Clear(); |
28 void EstimateSize(FX_STRSIZE size, FX_STRSIZE alloc_step = 0); | 28 void EstimateSize(FX_STRSIZE size, FX_STRSIZE alloc_step = 0); |
29 void AppendBlock(const void* pBuf, FX_STRSIZE size); | 29 void AppendBlock(const void* pBuf, FX_STRSIZE size); |
30 void AppendString(const CFX_ByteStringC& str) { | 30 void AppendString(const CFX_ByteString& str) { |
31 AppendBlock(str.GetPtr(), str.GetLength()); | 31 AppendBlock(str.c_str(), str.GetLength()); |
32 } | 32 } |
33 | 33 |
34 void AppendByte(uint8_t byte) { | 34 void AppendByte(uint8_t byte) { |
35 ExpandBuf(1); | 35 ExpandBuf(1); |
36 m_pBuffer.get()[m_DataSize++] = byte; | 36 m_pBuffer.get()[m_DataSize++] = byte; |
37 } | 37 } |
38 | 38 |
39 void InsertBlock(FX_STRSIZE pos, const void* pBuf, FX_STRSIZE size); | 39 void InsertBlock(FX_STRSIZE pos, const void* pBuf, FX_STRSIZE size); |
40 void Delete(int start_index, int count); | 40 void Delete(int start_index, int count); |
41 | 41 |
(...skipping 14 matching lines...) Expand all Loading... |
56 | 56 |
57 class CFX_ByteTextBuf : public CFX_BinaryBuf { | 57 class CFX_ByteTextBuf : public CFX_BinaryBuf { |
58 public: | 58 public: |
59 void AppendChar(int ch) { AppendByte((uint8_t)ch); } | 59 void AppendChar(int ch) { AppendByte((uint8_t)ch); } |
60 FX_STRSIZE GetLength() const { return m_DataSize; } | 60 FX_STRSIZE GetLength() const { return m_DataSize; } |
61 CFX_ByteStringC GetByteString() const; | 61 CFX_ByteStringC GetByteString() const; |
62 | 62 |
63 CFX_ByteTextBuf& operator<<(int i); | 63 CFX_ByteTextBuf& operator<<(int i); |
64 CFX_ByteTextBuf& operator<<(uint32_t i); | 64 CFX_ByteTextBuf& operator<<(uint32_t i); |
65 CFX_ByteTextBuf& operator<<(double f); | 65 CFX_ByteTextBuf& operator<<(double f); |
| 66 CFX_ByteTextBuf& operator<<(const FX_CHAR* pStr) { |
| 67 return *this << CFX_ByteStringC(pStr); |
| 68 } |
| 69 CFX_ByteTextBuf& operator<<(const CFX_ByteString& str) { |
| 70 return *this << str.AsByteStringC(); |
| 71 } |
66 CFX_ByteTextBuf& operator<<(const CFX_ByteStringC& lpsz); | 72 CFX_ByteTextBuf& operator<<(const CFX_ByteStringC& lpsz); |
67 CFX_ByteTextBuf& operator<<(const CFX_ByteTextBuf& buf); | 73 CFX_ByteTextBuf& operator<<(const CFX_ByteTextBuf& buf); |
68 }; | 74 }; |
69 | 75 |
70 class CFX_WideTextBuf : public CFX_BinaryBuf { | 76 class CFX_WideTextBuf : public CFX_BinaryBuf { |
71 public: | 77 public: |
72 void AppendChar(FX_WCHAR wch); | 78 void AppendChar(FX_WCHAR wch); |
73 FX_STRSIZE GetLength() const { return m_DataSize / sizeof(FX_WCHAR); } | 79 FX_STRSIZE GetLength() const { return m_DataSize / sizeof(FX_WCHAR); } |
74 FX_WCHAR* GetBuffer() const { | 80 FX_WCHAR* GetBuffer() const { |
75 return reinterpret_cast<FX_WCHAR*>(m_pBuffer.get()); | 81 return reinterpret_cast<FX_WCHAR*>(m_pBuffer.get()); |
(...skipping 1041 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1117 FX_FLOAT c; | 1123 FX_FLOAT c; |
1118 FX_FLOAT d; | 1124 FX_FLOAT d; |
1119 FX_FLOAT e; | 1125 FX_FLOAT e; |
1120 FX_FLOAT f; | 1126 FX_FLOAT f; |
1121 FX_FLOAT g; | 1127 FX_FLOAT g; |
1122 FX_FLOAT h; | 1128 FX_FLOAT h; |
1123 FX_FLOAT i; | 1129 FX_FLOAT i; |
1124 }; | 1130 }; |
1125 | 1131 |
1126 #endif // CORE_FXCRT_INCLUDE_FX_BASIC_H_ | 1132 #endif // CORE_FXCRT_INCLUDE_FX_BASIC_H_ |
OLD | NEW |