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

Side by Side Diff: core/fxcrt/fx_basic_bstring.cpp

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/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp ('k') | core/fxcrt/fx_basic_gcc.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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cctype> 10 #include <cctype>
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 StringData::Create(reinterpret_cast<const FX_CHAR*>(pStr), nLen)); 92 StringData::Create(reinterpret_cast<const FX_CHAR*>(pStr), nLen));
93 } 93 }
94 } 94 }
95 95
96 CFX_ByteString::CFX_ByteString(char ch) { 96 CFX_ByteString::CFX_ByteString(char ch) {
97 m_pData.Reset(StringData::Create(1)); 97 m_pData.Reset(StringData::Create(1));
98 m_pData->m_String[0] = ch; 98 m_pData->m_String[0] = ch;
99 } 99 }
100 100
101 CFX_ByteString::CFX_ByteString(const CFX_ByteStringC& stringSrc) { 101 CFX_ByteString::CFX_ByteString(const CFX_ByteStringC& stringSrc) {
102 if (!stringSrc.IsEmpty()) { 102 if (!stringSrc.IsEmpty())
103 m_pData.Reset(StringData::Create(stringSrc.c_str(), stringSrc.GetLength())); 103 m_pData.Reset(StringData::Create(stringSrc.c_str(), stringSrc.GetLength()));
104 }
105 } 104 }
106 105
107 CFX_ByteString::CFX_ByteString(const CFX_ByteStringC& str1, 106 CFX_ByteString::CFX_ByteString(const CFX_ByteStringC& str1,
108 const CFX_ByteStringC& str2) { 107 const CFX_ByteStringC& str2) {
109 int nNewLen = str1.GetLength() + str2.GetLength(); 108 int nNewLen = str1.GetLength() + str2.GetLength();
110 if (nNewLen == 0) 109 if (nNewLen == 0)
111 return; 110 return;
112 111
113 m_pData.Reset(StringData::Create(nNewLen)); 112 m_pData.Reset(StringData::Create(nNewLen));
114 m_pData->CopyContents(str1.c_str(), str1.GetLength()); 113 m_pData->CopyContents(str1.c_str(), str1.GetLength());
(...skipping 881 matching lines...) Expand 10 before | Expand all | Expand 10 after
996 fraction %= scale; 995 fraction %= scale;
997 scale /= 10; 996 scale /= 10;
998 } 997 }
999 return buf_size; 998 return buf_size;
1000 } 999 }
1001 CFX_ByteString CFX_ByteString::FormatFloat(FX_FLOAT d, int precision) { 1000 CFX_ByteString CFX_ByteString::FormatFloat(FX_FLOAT d, int precision) {
1002 FX_CHAR buf[32]; 1001 FX_CHAR buf[32];
1003 FX_STRSIZE len = FX_ftoa(d, buf); 1002 FX_STRSIZE len = FX_ftoa(d, buf);
1004 return CFX_ByteString(buf, len); 1003 return CFX_ByteString(buf, len);
1005 } 1004 }
OLDNEW
« no previous file with comments | « core/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp ('k') | core/fxcrt/fx_basic_gcc.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698