1 // Copyright 2017 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_FXCRT_CFX_WIDETEXTBUF_H_ 8 #define CORE_FXCRT_CFX_WIDETEXTBUF_H_ 9 10 #include "core/fxcrt/cfx_binarybuf.h" 11 #include "core/fxcrt/fx_string.h" 12 #include "core/fxcrt/fx_system.h" 13 14 class CFX_WideTextBuf : public CFX_BinaryBuf { 15 public: 16 void AppendChar(wchar_t wch); 17 size_t GetLength() const override; GetBuffer()18 wchar_t* GetBuffer() const { 19 return reinterpret_cast<wchar_t*>(m_pBuffer.get()); 20 } 21 AsStringView()22 WideStringView AsStringView() const { 23 return WideStringView(reinterpret_cast<const wchar_t*>(m_pBuffer.get()), 24 m_DataSize / sizeof(wchar_t)); 25 } MakeString()26 WideString MakeString() const { 27 return WideString(reinterpret_cast<const wchar_t*>(m_pBuffer.get()), 28 m_DataSize / sizeof(wchar_t)); 29 } 30 Delete(int start_index,int count)31 void Delete(int start_index, int count) { 32 CFX_BinaryBuf::Delete(start_index * sizeof(wchar_t), 33 count * sizeof(wchar_t)); 34 } 35 36 CFX_WideTextBuf& operator<<(int i); 37 CFX_WideTextBuf& operator<<(double f); 38 CFX_WideTextBuf& operator<<(const wchar_t* lpsz); 39 CFX_WideTextBuf& operator<<(const WideStringView& str); 40 CFX_WideTextBuf& operator<<(const WideString& str); 41 CFX_WideTextBuf& operator<<(const CFX_WideTextBuf& buf); 42 }; 43 44 #endif // CORE_FXCRT_CFX_WIDETEXTBUF_H_ 45