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

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

Issue 1972053003: Add CFX_ByteStringC::CharAt() to avoid c_str() and casts (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 7 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/fxcrt/fx_xml_composer.cpp ('k') | xfa/fee/fde_txtedtengine.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 #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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 92
93 const uint8_t* raw_str() const { return m_Ptr; } 93 const uint8_t* raw_str() const { return m_Ptr; }
94 const FX_CHAR* c_str() const { 94 const FX_CHAR* c_str() const {
95 return reinterpret_cast<const FX_CHAR*>(m_Ptr); 95 return reinterpret_cast<const FX_CHAR*>(m_Ptr);
96 } 96 }
97 97
98 FX_STRSIZE GetLength() const { return m_Length; } 98 FX_STRSIZE GetLength() const { return m_Length; }
99 bool IsEmpty() const { return m_Length == 0; } 99 bool IsEmpty() const { return m_Length == 0; }
100 100
101 uint8_t GetAt(FX_STRSIZE index) const { return m_Ptr[index]; } 101 uint8_t GetAt(FX_STRSIZE index) const { return m_Ptr[index]; }
102 FX_CHAR CharAt(FX_STRSIZE index) const {
103 return static_cast<FX_CHAR>(m_Ptr[index]);
104 }
102 105
103 FX_STRSIZE Find(FX_CHAR ch) const { 106 FX_STRSIZE Find(FX_CHAR ch) const {
104 const uint8_t* found = 107 const uint8_t* found =
105 static_cast<const uint8_t*>(memchr(m_Ptr, ch, m_Length)); 108 static_cast<const uint8_t*>(memchr(m_Ptr, ch, m_Length));
106 return found ? found - m_Ptr : -1; 109 return found ? found - m_Ptr : -1;
107 } 110 }
108 111
109 CFX_ByteStringC Mid(FX_STRSIZE index, FX_STRSIZE count = -1) const { 112 CFX_ByteStringC Mid(FX_STRSIZE index, FX_STRSIZE count = -1) const {
110 if (index < 0) { 113 if (index < 0) {
111 index = 0; 114 index = 0;
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 } 683 }
681 684
682 FX_FLOAT FX_atof(const CFX_ByteStringC& str); 685 FX_FLOAT FX_atof(const CFX_ByteStringC& str);
683 inline FX_FLOAT FX_atof(const CFX_WideStringC& wsStr) { 686 inline FX_FLOAT FX_atof(const CFX_WideStringC& wsStr) {
684 return FX_atof(FX_UTF8Encode(wsStr.c_str(), wsStr.GetLength()).c_str()); 687 return FX_atof(FX_UTF8Encode(wsStr.c_str(), wsStr.GetLength()).c_str());
685 } 688 }
686 void FX_atonum(const CFX_ByteStringC& str, FX_BOOL& bInteger, void* pData); 689 void FX_atonum(const CFX_ByteStringC& str, FX_BOOL& bInteger, void* pData);
687 FX_STRSIZE FX_ftoa(FX_FLOAT f, FX_CHAR* buf); 690 FX_STRSIZE FX_ftoa(FX_FLOAT f, FX_CHAR* buf);
688 691
689 #endif // CORE_FXCRT_INCLUDE_FX_STRING_H_ 692 #endif // CORE_FXCRT_INCLUDE_FX_STRING_H_
OLDNEW
« no previous file with comments | « core/fxcrt/fx_xml_composer.cpp ('k') | xfa/fee/fde_txtedtengine.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698