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

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

Issue 1902953002: Remove a few more char* members from structs/classes. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 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/fpdfdoc/doc_form.cpp ('k') | core/fxge/dib/dib_int.h » ('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 #ifndef CORE_FXCRT_INCLUDE_FX_STRING_H_ 7 #ifndef CORE_FXCRT_INCLUDE_FX_STRING_H_
8 #define CORE_FXCRT_INCLUDE_FX_STRING_H_ 8 #define CORE_FXCRT_INCLUDE_FX_STRING_H_
9 9
10 #include <stdint.h> // For intptr_t. 10 #include <stdint.h> // For intptr_t.
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 m_Length = m_Ptr ? FXSYS_strlen(src) : 0; 67 m_Length = m_Ptr ? FXSYS_strlen(src) : 0;
68 return *this; 68 return *this;
69 } 69 }
70 70
71 CFX_ByteStringC& operator=(const CFX_ByteStringC& src) { 71 CFX_ByteStringC& operator=(const CFX_ByteStringC& src) {
72 m_Ptr = src.m_Ptr; 72 m_Ptr = src.m_Ptr;
73 m_Length = src.m_Length; 73 m_Length = src.m_Length;
74 return *this; 74 return *this;
75 } 75 }
76 76
77 CFX_ByteStringC& operator=(const CFX_ByteString& src);
78
79 bool operator==(const char* ptr) const { 77 bool operator==(const char* ptr) const {
80 return FXSYS_strlen(ptr) == m_Length && 78 return FXSYS_strlen(ptr) == m_Length &&
81 FXSYS_memcmp(ptr, m_Ptr, m_Length) == 0; 79 FXSYS_memcmp(ptr, m_Ptr, m_Length) == 0;
82 } 80 }
83 bool operator==(const CFX_ByteStringC& other) const { 81 bool operator==(const CFX_ByteStringC& other) const {
84 return other.m_Length == m_Length && 82 return other.m_Length == m_Length &&
85 FXSYS_memcmp(other.m_Ptr, m_Ptr, m_Length) == 0; 83 FXSYS_memcmp(other.m_Ptr, m_Ptr, m_Length) == 0;
86 } 84 }
87 bool operator!=(const char* ptr) const { return !(*this == ptr); } 85 bool operator!=(const char* ptr) const { return !(*this == ptr); }
88 bool operator!=(const CFX_ByteStringC& other) const { 86 bool operator!=(const CFX_ByteStringC& other) const {
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 void AllocCopy(CFX_ByteString& dest, 276 void AllocCopy(CFX_ByteString& dest,
279 FX_STRSIZE nCopyLen, 277 FX_STRSIZE nCopyLen,
280 FX_STRSIZE nCopyIndex) const; 278 FX_STRSIZE nCopyIndex) const;
281 void AssignCopy(const FX_CHAR* pSrcData, FX_STRSIZE nSrcLen); 279 void AssignCopy(const FX_CHAR* pSrcData, FX_STRSIZE nSrcLen);
282 void Concat(const FX_CHAR* lpszSrcData, FX_STRSIZE nSrcLen); 280 void Concat(const FX_CHAR* lpszSrcData, FX_STRSIZE nSrcLen);
283 281
284 CFX_RetainPtr<StringData> m_pData; 282 CFX_RetainPtr<StringData> m_pData;
285 friend class fxcrt_ByteStringConcat_Test; 283 friend class fxcrt_ByteStringConcat_Test;
286 }; 284 };
287 285
288 inline CFX_ByteStringC& CFX_ByteStringC::operator=(const CFX_ByteString& src) {
289 m_Ptr = src.raw_str();
290 m_Length = src.GetLength();
291 return *this;
292 }
293
294 inline bool operator==(const char* lhs, const CFX_ByteString& rhs) { 286 inline bool operator==(const char* lhs, const CFX_ByteString& rhs) {
295 return rhs == lhs; 287 return rhs == lhs;
296 } 288 }
297 inline bool operator==(const CFX_ByteStringC& lhs, const CFX_ByteString& rhs) { 289 inline bool operator==(const CFX_ByteStringC& lhs, const CFX_ByteString& rhs) {
298 return rhs == lhs; 290 return rhs == lhs;
299 } 291 }
300 inline bool operator!=(const char* lhs, const CFX_ByteString& rhs) { 292 inline bool operator!=(const char* lhs, const CFX_ByteString& rhs) {
301 return rhs != lhs; 293 return rhs != lhs;
302 } 294 }
303 inline bool operator!=(const CFX_ByteStringC& lhs, const CFX_ByteString& rhs) { 295 inline bool operator!=(const CFX_ByteStringC& lhs, const CFX_ByteString& rhs) {
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 m_Length = FXSYS_wcslen(src); 383 m_Length = FXSYS_wcslen(src);
392 return *this; 384 return *this;
393 } 385 }
394 386
395 CFX_WideStringC& operator=(const CFX_WideStringC& src) { 387 CFX_WideStringC& operator=(const CFX_WideStringC& src) {
396 m_Ptr = src.m_Ptr; 388 m_Ptr = src.m_Ptr;
397 m_Length = src.m_Length; 389 m_Length = src.m_Length;
398 return *this; 390 return *this;
399 } 391 }
400 392
401 CFX_WideStringC& operator=(const CFX_WideString& src);
402
403 bool operator==(const wchar_t* ptr) const { 393 bool operator==(const wchar_t* ptr) const {
404 return FXSYS_wcslen(ptr) == m_Length && wmemcmp(ptr, m_Ptr, m_Length) == 0; 394 return FXSYS_wcslen(ptr) == m_Length && wmemcmp(ptr, m_Ptr, m_Length) == 0;
405 } 395 }
406 bool operator==(const CFX_WideStringC& str) const { 396 bool operator==(const CFX_WideStringC& str) const {
407 return str.m_Length == m_Length && wmemcmp(str.m_Ptr, m_Ptr, m_Length) == 0; 397 return str.m_Length == m_Length && wmemcmp(str.m_Ptr, m_Ptr, m_Length) == 0;
408 } 398 }
409 bool operator!=(const wchar_t* ptr) const { return !(*this == ptr); } 399 bool operator!=(const wchar_t* ptr) const { return !(*this == ptr); }
410 bool operator!=(const CFX_WideStringC& str) const { return !(*this == str); } 400 bool operator!=(const CFX_WideStringC& str) const { return !(*this == str); }
411 401
412 const FX_WCHAR* c_str() const { return m_Ptr; } 402 const FX_WCHAR* c_str() const { return m_Ptr; }
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 void AllocCopy(CFX_WideString& dest, 594 void AllocCopy(CFX_WideString& dest,
605 FX_STRSIZE nCopyLen, 595 FX_STRSIZE nCopyLen,
606 FX_STRSIZE nCopyIndex) const; 596 FX_STRSIZE nCopyIndex) const;
607 void AssignCopy(const FX_WCHAR* pSrcData, FX_STRSIZE nSrcLen); 597 void AssignCopy(const FX_WCHAR* pSrcData, FX_STRSIZE nSrcLen);
608 void Concat(const FX_WCHAR* lpszSrcData, FX_STRSIZE nSrcLen); 598 void Concat(const FX_WCHAR* lpszSrcData, FX_STRSIZE nSrcLen);
609 599
610 CFX_RetainPtr<StringData> m_pData; 600 CFX_RetainPtr<StringData> m_pData;
611 friend class fxcrt_WideStringConcatInPlace_Test; 601 friend class fxcrt_WideStringConcatInPlace_Test;
612 }; 602 };
613 603
614 inline CFX_WideStringC& CFX_WideStringC::operator=(const CFX_WideString& src) {
615 m_Ptr = src.c_str();
616 m_Length = src.GetLength();
617 return *this;
618 }
619
620 inline CFX_WideString operator+(const CFX_WideStringC& str1, 604 inline CFX_WideString operator+(const CFX_WideStringC& str1,
621 const CFX_WideStringC& str2) { 605 const CFX_WideStringC& str2) {
622 return CFX_WideString(str1, str2); 606 return CFX_WideString(str1, str2);
623 } 607 }
624 inline CFX_WideString operator+(const CFX_WideStringC& str1, 608 inline CFX_WideString operator+(const CFX_WideStringC& str1,
625 const FX_WCHAR* str2) { 609 const FX_WCHAR* str2) {
626 return CFX_WideString(str1, str2); 610 return CFX_WideString(str1, str2);
627 } 611 }
628 inline CFX_WideString operator+(const FX_WCHAR* str1, 612 inline CFX_WideString operator+(const FX_WCHAR* str1,
629 const CFX_WideStringC& str2) { 613 const CFX_WideStringC& str2) {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 } 667 }
684 668
685 FX_FLOAT FX_atof(const CFX_ByteStringC& str); 669 FX_FLOAT FX_atof(const CFX_ByteStringC& str);
686 inline FX_FLOAT FX_atof(const CFX_WideStringC& wsStr) { 670 inline FX_FLOAT FX_atof(const CFX_WideStringC& wsStr) {
687 return FX_atof(FX_UTF8Encode(wsStr.c_str(), wsStr.GetLength()).c_str()); 671 return FX_atof(FX_UTF8Encode(wsStr.c_str(), wsStr.GetLength()).c_str());
688 } 672 }
689 void FX_atonum(const CFX_ByteStringC& str, FX_BOOL& bInteger, void* pData); 673 void FX_atonum(const CFX_ByteStringC& str, FX_BOOL& bInteger, void* pData);
690 FX_STRSIZE FX_ftoa(FX_FLOAT f, FX_CHAR* buf); 674 FX_STRSIZE FX_ftoa(FX_FLOAT f, FX_CHAR* buf);
691 675
692 #endif // CORE_FXCRT_INCLUDE_FX_STRING_H_ 676 #endif // CORE_FXCRT_INCLUDE_FX_STRING_H_
OLDNEW
« no previous file with comments | « core/fpdfdoc/doc_form.cpp ('k') | core/fxge/dib/dib_int.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698