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

Side by Side Diff: core/src/fxcrt/fx_basic_buffer.cpp

Issue 1090303003: Add missing operators for CFX_ByteStringC. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: use size_t Created 5 years, 8 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/src/fxcrt/fx_basic_bstring_unittest.cpp ('k') | core/src/fxcrt/fx_basic_maps.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "../../include/fxcrt/fx_basic.h" 7 #include "../../include/fxcrt/fx_basic.h"
8 FX_STRSIZE FX_ftoa(FX_FLOAT f, FX_LPSTR buf); 8 FX_STRSIZE FX_ftoa(FX_FLOAT f, FX_LPSTR buf);
9 CFX_BinaryBuf::CFX_BinaryBuf() 9 CFX_BinaryBuf::CFX_BinaryBuf()
10 : m_AllocStep(0) 10 : m_AllocStep(0)
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 } 136 }
137 FXSYS_memset8(m_pBuffer + m_DataSize, byte, count); 137 FXSYS_memset8(m_pBuffer + m_DataSize, byte, count);
138 m_DataSize += count; 138 m_DataSize += count;
139 } 139 }
140 CFX_ByteStringC CFX_BinaryBuf::GetByteString() const 140 CFX_ByteStringC CFX_BinaryBuf::GetByteString() const
141 { 141 {
142 return CFX_ByteStringC(m_pBuffer, m_DataSize); 142 return CFX_ByteStringC(m_pBuffer, m_DataSize);
143 } 143 }
144 CFX_ByteTextBuf& CFX_ByteTextBuf::operator << (FX_BSTR lpsz) 144 CFX_ByteTextBuf& CFX_ByteTextBuf::operator << (FX_BSTR lpsz)
145 { 145 {
146 AppendBlock((FX_LPCBYTE)lpsz, lpsz.GetLength()); 146 AppendBlock(lpsz.GetPtr(), lpsz.GetLength());
147 return *this; 147 return *this;
148 } 148 }
149 CFX_ByteTextBuf& CFX_ByteTextBuf::operator << (int i) 149 CFX_ByteTextBuf& CFX_ByteTextBuf::operator << (int i)
150 { 150 {
151 char buf[32]; 151 char buf[32];
152 FXSYS_itoa(i, buf, 10); 152 FXSYS_itoa(i, buf, 10);
153 AppendBlock(buf, (FX_STRSIZE)FXSYS_strlen(buf)); 153 AppendBlock(buf, (FX_STRSIZE)FXSYS_strlen(buf));
154 return *this; 154 return *this;
155 } 155 }
156 CFX_ByteTextBuf& CFX_ByteTextBuf::operator << (FX_DWORD i) 156 CFX_ByteTextBuf& CFX_ByteTextBuf::operator << (FX_DWORD i)
(...skipping 10 matching lines...) Expand all
167 AppendBlock(buf, len); 167 AppendBlock(buf, len);
168 return *this; 168 return *this;
169 } 169 }
170 CFX_ByteTextBuf& CFX_ByteTextBuf::operator << (const CFX_ByteTextBuf& buf) 170 CFX_ByteTextBuf& CFX_ByteTextBuf::operator << (const CFX_ByteTextBuf& buf)
171 { 171 {
172 AppendBlock(buf.m_pBuffer, buf.m_DataSize); 172 AppendBlock(buf.m_pBuffer, buf.m_DataSize);
173 return *this; 173 return *this;
174 } 174 }
175 void CFX_ByteTextBuf::operator =(const CFX_ByteStringC& str) 175 void CFX_ByteTextBuf::operator =(const CFX_ByteStringC& str)
176 { 176 {
177 CopyData((FX_LPCBYTE)str, str.GetLength()); 177 CopyData(str.GetPtr(), str.GetLength());
178 } 178 }
179 void CFX_WideTextBuf::AppendChar(FX_WCHAR ch) 179 void CFX_WideTextBuf::AppendChar(FX_WCHAR ch)
180 { 180 {
181 if (m_AllocSize < m_DataSize + (FX_STRSIZE)sizeof(FX_WCHAR)) { 181 if (m_AllocSize < m_DataSize + (FX_STRSIZE)sizeof(FX_WCHAR)) {
182 ExpandBuf(sizeof(FX_WCHAR)); 182 ExpandBuf(sizeof(FX_WCHAR));
183 } 183 }
184 ASSERT(m_pBuffer != NULL); 184 ASSERT(m_pBuffer != NULL);
185 *(FX_WCHAR*)(m_pBuffer + m_DataSize) = ch; 185 *(FX_WCHAR*)(m_pBuffer + m_DataSize) = ch;
186 m_DataSize += sizeof(FX_WCHAR); 186 m_DataSize += sizeof(FX_WCHAR);
187 } 187 }
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 } else { 278 } else {
279 m_SavingBuf.AppendBlock(&f, sizeof(FX_FLOAT)); 279 m_SavingBuf.AppendBlock(&f, sizeof(FX_FLOAT));
280 } 280 }
281 return *this; 281 return *this;
282 } 282 }
283 CFX_ArchiveSaver& CFX_ArchiveSaver::operator << (FX_BSTR bstr) 283 CFX_ArchiveSaver& CFX_ArchiveSaver::operator << (FX_BSTR bstr)
284 { 284 {
285 int len = bstr.GetLength(); 285 int len = bstr.GetLength();
286 if (m_pStream) { 286 if (m_pStream) {
287 m_pStream->WriteBlock(&len, sizeof(int)); 287 m_pStream->WriteBlock(&len, sizeof(int));
288 m_pStream->WriteBlock(bstr, len); 288 m_pStream->WriteBlock(bstr.GetPtr(), len);
289 } else { 289 } else {
290 m_SavingBuf.AppendBlock(&len, sizeof(int)); 290 m_SavingBuf.AppendBlock(&len, sizeof(int));
291 m_SavingBuf.AppendBlock(bstr, len); 291 m_SavingBuf.AppendBlock(bstr.GetPtr(), len);
292 } 292 }
293 return *this; 293 return *this;
294 } 294 }
295 CFX_ArchiveSaver& CFX_ArchiveSaver::operator << (FX_LPCWSTR wstr) 295 CFX_ArchiveSaver& CFX_ArchiveSaver::operator << (FX_LPCWSTR wstr)
296 { 296 {
297 FX_STRSIZE len = (FX_STRSIZE)FXSYS_wcslen(wstr); 297 FX_STRSIZE len = (FX_STRSIZE)FXSYS_wcslen(wstr);
298 if (m_pStream) { 298 if (m_pStream) {
299 m_pStream->WriteBlock(&len, sizeof(int)); 299 m_pStream->WriteBlock(&len, sizeof(int));
300 m_pStream->WriteBlock(wstr, len); 300 m_pStream->WriteBlock(wstr, len);
301 } else { 301 } else {
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 return AppendBlock(&byte, 1); 481 return AppendBlock(&byte, 1);
482 } 482 }
483 FX_INT32 IFX_BufferArchive::AppendDWord(FX_DWORD i) 483 FX_INT32 IFX_BufferArchive::AppendDWord(FX_DWORD i)
484 { 484 {
485 char buf[32]; 485 char buf[32];
486 FXSYS_itoa(i, buf, 10); 486 FXSYS_itoa(i, buf, 10);
487 return AppendBlock(buf, (size_t)FXSYS_strlen(buf)); 487 return AppendBlock(buf, (size_t)FXSYS_strlen(buf));
488 } 488 }
489 FX_INT32 IFX_BufferArchive::AppendString(FX_BSTR lpsz) 489 FX_INT32 IFX_BufferArchive::AppendString(FX_BSTR lpsz)
490 { 490 {
491 return AppendBlock((FX_LPCBYTE)lpsz, lpsz.GetLength()); 491 return AppendBlock(lpsz.GetPtr(), lpsz.GetLength());
492 } 492 }
493 CFX_FileBufferArchive::CFX_FileBufferArchive(FX_STRSIZE size) 493 CFX_FileBufferArchive::CFX_FileBufferArchive(FX_STRSIZE size)
494 : IFX_BufferArchive(size) 494 : IFX_BufferArchive(size)
495 , m_pFile(NULL) 495 , m_pFile(NULL)
496 , m_bTakeover(FALSE) 496 , m_bTakeover(FALSE)
497 { 497 {
498 } 498 }
499 CFX_FileBufferArchive::~CFX_FileBufferArchive() 499 CFX_FileBufferArchive::~CFX_FileBufferArchive()
500 { 500 {
501 Clear(); 501 Clear();
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 FX_BOOL CFX_FileBufferArchive::DoWork(const void* pBuf, size_t size) 554 FX_BOOL CFX_FileBufferArchive::DoWork(const void* pBuf, size_t size)
555 { 555 {
556 if (!m_pFile) { 556 if (!m_pFile) {
557 return FALSE; 557 return FALSE;
558 } 558 }
559 if (!pBuf || size < 1) { 559 if (!pBuf || size < 1) {
560 return TRUE; 560 return TRUE;
561 } 561 }
562 return m_pFile->WriteBlock(pBuf, size); 562 return m_pFile->WriteBlock(pBuf, size);
563 } 563 }
OLDNEW
« no previous file with comments | « core/src/fxcrt/fx_basic_bstring_unittest.cpp ('k') | core/src/fxcrt/fx_basic_maps.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698