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

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

Issue 1711893003: Remove CFX_{Byte,Wide}String::ConvertFrom(). (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: address comments Created 4 years, 10 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/fpdfdoc/doc_form.cpp ('k') | core/src/fxcrt/fx_basic_wstring.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> // For offsetof(). 7 #include <stddef.h> // For offsetof().
8 #include <cctype> 8 #include <cctype>
9 9
10 #include "core/include/fxcrt/fx_basic.h" 10 #include "core/include/fxcrt/fx_basic.h"
(...skipping 892 matching lines...) Expand 10 before | Expand all | Expand 10 after
903 CopyBeforeWrite(); 903 CopyBeforeWrite();
904 m_pData->m_String[nIndex] = ch; 904 m_pData->m_String[nIndex] = ch;
905 } 905 }
906 CFX_WideString CFX_ByteString::UTF8Decode() const { 906 CFX_WideString CFX_ByteString::UTF8Decode() const {
907 CFX_UTF8Decoder decoder; 907 CFX_UTF8Decoder decoder;
908 for (FX_STRSIZE i = 0; i < GetLength(); i++) { 908 for (FX_STRSIZE i = 0; i < GetLength(); i++) {
909 decoder.Input((uint8_t)m_pData->m_String[i]); 909 decoder.Input((uint8_t)m_pData->m_String[i]);
910 } 910 }
911 return decoder.GetResult(); 911 return decoder.GetResult();
912 } 912 }
913
914 // static
913 CFX_ByteString CFX_ByteString::FromUnicode(const FX_WCHAR* str, 915 CFX_ByteString CFX_ByteString::FromUnicode(const FX_WCHAR* str,
914 FX_STRSIZE len) { 916 FX_STRSIZE len) {
915 if (len < 0) { 917 FX_STRSIZE str_len = len >= 0 ? len : FXSYS_wcslen(str);
916 len = FXSYS_wcslen(str); 918 return FromUnicode(CFX_WideString(str, str_len));
917 }
918 CFX_ByteString bstr;
919 bstr.ConvertFrom(CFX_WideString(str, len));
920 return bstr;
921 } 919 }
920
921 // static
922 CFX_ByteString CFX_ByteString::FromUnicode(const CFX_WideString& str) { 922 CFX_ByteString CFX_ByteString::FromUnicode(const CFX_WideString& str) {
923 return FromUnicode(str.c_str(), str.GetLength()); 923 CFX_CharMap* pCharMap = CFX_CharMap::GetDefaultMapper();
924 return (*pCharMap->m_GetByteString)(pCharMap, str);
924 } 925 }
925 void CFX_ByteString::ConvertFrom(const CFX_WideString& str, 926
926 CFX_CharMap* pCharMap) {
927 if (!pCharMap) {
928 pCharMap = CFX_CharMap::GetDefaultMapper();
929 }
930 *this = (*pCharMap->m_GetByteString)(pCharMap, str);
931 }
932 int CFX_ByteString::Compare(const CFX_ByteStringC& str) const { 927 int CFX_ByteString::Compare(const CFX_ByteStringC& str) const {
933 if (!m_pData) { 928 if (!m_pData) {
934 return str.IsEmpty() ? 0 : -1; 929 return str.IsEmpty() ? 0 : -1;
935 } 930 }
936 int this_len = m_pData->m_nDataLength; 931 int this_len = m_pData->m_nDataLength;
937 int that_len = str.GetLength(); 932 int that_len = str.GetLength();
938 int min_len = this_len < that_len ? this_len : that_len; 933 int min_len = this_len < that_len ? this_len : that_len;
939 for (int i = 0; i < min_len; i++) { 934 for (int i = 0; i < min_len; i++) {
940 if ((uint8_t)m_pData->m_String[i] < str.GetAt(i)) { 935 if ((uint8_t)m_pData->m_String[i] < str.GetAt(i)) {
941 return -1; 936 return -1;
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
1087 fraction %= scale; 1082 fraction %= scale;
1088 scale /= 10; 1083 scale /= 10;
1089 } 1084 }
1090 return buf_size; 1085 return buf_size;
1091 } 1086 }
1092 CFX_ByteString CFX_ByteString::FormatFloat(FX_FLOAT d, int precision) { 1087 CFX_ByteString CFX_ByteString::FormatFloat(FX_FLOAT d, int precision) {
1093 FX_CHAR buf[32]; 1088 FX_CHAR buf[32];
1094 FX_STRSIZE len = FX_ftoa(d, buf); 1089 FX_STRSIZE len = FX_ftoa(d, buf);
1095 return CFX_ByteString(buf, len); 1090 return CFX_ByteString(buf, len);
1096 } 1091 }
OLDNEW
« no previous file with comments | « core/src/fpdfdoc/doc_form.cpp ('k') | core/src/fxcrt/fx_basic_wstring.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698