summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorRyan Harrison <rharrison@chromium.org>2017-09-18 14:23:18 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-09-18 18:40:16 +0000
commit275e260a6cd4a8e506ba974feb85ebcd926c1739 (patch)
tree2029b9158ec044764ceff122fe5fb5d0a3f123d1 /core
parent450fbeaaabf1ab340c1018de2e58f1950657517e (diff)
downloadpdfium-275e260a6cd4a8e506ba974feb85ebcd926c1739.tar.xz
Convert string class names
Automated using git grep & sed. Replace StringC classes with StringView classes. Remove the CFX_ prefix and put string classes in fxcrt namespace. Change AsStringC() to AsStringView(). Rename tests from TEST(fxcrt, *String*Foo) to TEST(*String*, Foo). Couple of tests needed to have their names regularlized. BUG=pdfium:894 Change-Id: I7ca038685c8d803795f3ed02545124f7a224c83d Reviewed-on: https://pdfium-review.googlesource.com/14151 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Diffstat (limited to 'core')
-rw-r--r--core/fpdfapi/cmaps/cmap_int.h2
-rw-r--r--core/fpdfapi/cmaps/fpdf_cmaps.cpp2
-rw-r--r--core/fpdfapi/edit/cpdf_creator.cpp34
-rw-r--r--core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp16
-rw-r--r--core/fpdfapi/edit/cpdf_pagecontentgenerator.h4
-rw-r--r--core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp43
-rw-r--r--core/fpdfapi/font/cpdf_cidfont.cpp22
-rw-r--r--core/fpdfapi/font/cpdf_cidfont.h2
-rw-r--r--core/fpdfapi/font/cpdf_cmap.cpp8
-rw-r--r--core/fpdfapi/font/cpdf_cmap.h4
-rw-r--r--core/fpdfapi/font/cpdf_cmapmanager.cpp4
-rw-r--r--core/fpdfapi/font/cpdf_cmapmanager.h8
-rw-r--r--core/fpdfapi/font/cpdf_cmapparser.cpp16
-rw-r--r--core/fpdfapi/font/cpdf_cmapparser.h12
-rw-r--r--core/fpdfapi/font/cpdf_font.cpp30
-rw-r--r--core/fpdfapi/font/cpdf_font.h14
-rw-r--r--core/fpdfapi/font/cpdf_fontencoding.cpp6
-rw-r--r--core/fpdfapi/font/cpdf_fontencoding.h4
-rw-r--r--core/fpdfapi/font/cpdf_simplefont.cpp6
-rw-r--r--core/fpdfapi/font/cpdf_simplefont.h4
-rw-r--r--core/fpdfapi/font/cpdf_tounicodemap.cpp47
-rw-r--r--core/fpdfapi/font/cpdf_tounicodemap.h6
-rw-r--r--core/fpdfapi/font/cpdf_tounicodemap_unittest.cpp2
-rw-r--r--core/fpdfapi/font/cpdf_truetypefont.cpp2
-rw-r--r--core/fpdfapi/page/cpdf_allstates.cpp2
-rw-r--r--core/fpdfapi/page/cpdf_colorspace.cpp11
-rw-r--r--core/fpdfapi/page/cpdf_colorspace.h2
-rw-r--r--core/fpdfapi/page/cpdf_contentmark.cpp8
-rw-r--r--core/fpdfapi/page/cpdf_contentmark.h10
-rw-r--r--core/fpdfapi/page/cpdf_contentmarkitem.h6
-rw-r--r--core/fpdfapi/page/cpdf_docpagedata.cpp6
-rw-r--r--core/fpdfapi/page/cpdf_docpagedata.h4
-rw-r--r--core/fpdfapi/page/cpdf_generalstate.cpp44
-rw-r--r--core/fpdfapi/page/cpdf_generalstate.h8
-rw-r--r--core/fpdfapi/page/cpdf_image.cpp2
-rw-r--r--core/fpdfapi/page/cpdf_page.cpp4
-rw-r--r--core/fpdfapi/page/cpdf_page.h4
-rw-r--r--core/fpdfapi/page/cpdf_pageobjectholder.h8
-rw-r--r--core/fpdfapi/page/cpdf_psengine.cpp6
-rw-r--r--core/fpdfapi/page/cpdf_streamcontentparser.cpp100
-rw-r--r--core/fpdfapi/page/cpdf_streamcontentparser.h29
-rw-r--r--core/fpdfapi/page/cpdf_streamcontentparser_unittest.cpp40
-rw-r--r--core/fpdfapi/page/cpdf_streamparser.cpp41
-rw-r--r--core/fpdfapi/page/cpdf_streamparser.h12
-rw-r--r--core/fpdfapi/page/cpdf_textobject.cpp4
-rw-r--r--core/fpdfapi/page/cpdf_textobject.h6
-rw-r--r--core/fpdfapi/parser/cfdf_document.cpp8
-rw-r--r--core/fpdfapi/parser/cfdf_document.h2
-rw-r--r--core/fpdfapi/parser/cpdf_array.cpp10
-rw-r--r--core/fpdfapi/parser/cpdf_array.h8
-rw-r--r--core/fpdfapi/parser/cpdf_boolean.cpp6
-rw-r--r--core/fpdfapi/parser/cpdf_boolean.h4
-rw-r--r--core/fpdfapi/parser/cpdf_crypto_handler.cpp8
-rw-r--r--core/fpdfapi/parser/cpdf_crypto_handler.h4
-rw-r--r--core/fpdfapi/parser/cpdf_data_avail.cpp22
-rw-r--r--core/fpdfapi/parser/cpdf_data_avail.h4
-rw-r--r--core/fpdfapi/parser/cpdf_dictionary.cpp65
-rw-r--r--core/fpdfapi/parser/cpdf_dictionary.h67
-rw-r--r--core/fpdfapi/parser/cpdf_document.cpp26
-rw-r--r--core/fpdfapi/parser/cpdf_document.h2
-rw-r--r--core/fpdfapi/parser/cpdf_indirect_object_holder.cpp2
-rw-r--r--core/fpdfapi/parser/cpdf_indirect_object_holder.h4
-rw-r--r--core/fpdfapi/parser/cpdf_name.cpp11
-rw-r--r--core/fpdfapi/parser/cpdf_name.h10
-rw-r--r--core/fpdfapi/parser/cpdf_number.cpp14
-rw-r--r--core/fpdfapi/parser/cpdf_number.h6
-rw-r--r--core/fpdfapi/parser/cpdf_object.cpp10
-rw-r--r--core/fpdfapi/parser/cpdf_object.h6
-rw-r--r--core/fpdfapi/parser/cpdf_object_walker.cpp8
-rw-r--r--core/fpdfapi/parser/cpdf_object_walker.h4
-rw-r--r--core/fpdfapi/parser/cpdf_parser.cpp17
-rw-r--r--core/fpdfapi/parser/cpdf_parser.h4
-rw-r--r--core/fpdfapi/parser/cpdf_reference.cpp4
-rw-r--r--core/fpdfapi/parser/cpdf_reference.h2
-rw-r--r--core/fpdfapi/parser/cpdf_security_handler.cpp70
-rw-r--r--core/fpdfapi/parser/cpdf_security_handler.h6
-rw-r--r--core/fpdfapi/parser/cpdf_simple_parser.cpp18
-rw-r--r--core/fpdfapi/parser/cpdf_simple_parser.h6
-rw-r--r--core/fpdfapi/parser/cpdf_simple_parser_unittest.cpp2
-rw-r--r--core/fpdfapi/parser/cpdf_stream.cpp2
-rw-r--r--core/fpdfapi/parser/cpdf_stream.h2
-rw-r--r--core/fpdfapi/parser/cpdf_stream_acc.h4
-rw-r--r--core/fpdfapi/parser/cpdf_string.cpp16
-rw-r--r--core/fpdfapi/parser/cpdf_string.h14
-rw-r--r--core/fpdfapi/parser/cpdf_syntax_parser.cpp61
-rw-r--r--core/fpdfapi/parser/cpdf_syntax_parser.h20
-rw-r--r--core/fpdfapi/parser/fpdf_parser_decode.cpp24
-rw-r--r--core/fpdfapi/parser/fpdf_parser_decode.h18
-rw-r--r--core/fpdfapi/parser/fpdf_parser_decode_unittest.cpp2
-rw-r--r--core/fpdfapi/parser/fpdf_parser_utility.cpp20
-rw-r--r--core/fpdfapi/parser/fpdf_parser_utility.h2
-rw-r--r--core/fpdfapi/render/cpdf_charposlist.cpp2
-rw-r--r--core/fpdfapi/render/cpdf_dibsource.cpp12
-rw-r--r--core/fpdfapi/render/cpdf_imagerenderer.cpp4
-rw-r--r--core/fpdfapi/render/cpdf_textrenderer.cpp2
-rw-r--r--core/fpdfapi/render/cpdf_textrenderer.h2
-rw-r--r--core/fpdfapi/render/cpdf_type3cache.cpp2
-rw-r--r--core/fpdfapi/render/cpdf_type3cache.h2
-rw-r--r--core/fpdfdoc/cpdf_action.cpp22
-rw-r--r--core/fpdfdoc/cpdf_action.h8
-rw-r--r--core/fpdfdoc/cpdf_actionfields.cpp6
-rw-r--r--core/fpdfdoc/cpdf_annot.cpp12
-rw-r--r--core/fpdfdoc/cpdf_annot.h5
-rw-r--r--core/fpdfdoc/cpdf_annotlist.cpp4
-rw-r--r--core/fpdfdoc/cpdf_apsettings.cpp15
-rw-r--r--core/fpdfdoc/cpdf_apsettings.h18
-rw-r--r--core/fpdfdoc/cpdf_bookmark.cpp12
-rw-r--r--core/fpdfdoc/cpdf_bookmark.h2
-rw-r--r--core/fpdfdoc/cpdf_defaultappearance.cpp41
-rw-r--r--core/fpdfdoc/cpdf_defaultappearance.h15
-rw-r--r--core/fpdfdoc/cpdf_dest.cpp6
-rw-r--r--core/fpdfdoc/cpdf_dest.h2
-rw-r--r--core/fpdfdoc/cpdf_docjsactions.cpp9
-rw-r--r--core/fpdfdoc/cpdf_docjsactions.h6
-rw-r--r--core/fpdfdoc/cpdf_filespec.cpp49
-rw-r--r--core/fpdfdoc/cpdf_filespec.h8
-rw-r--r--core/fpdfdoc/cpdf_formcontrol.cpp54
-rw-r--r--core/fpdfdoc/cpdf_formcontrol.h26
-rw-r--r--core/fpdfdoc/cpdf_formfield.cpp118
-rw-r--r--core/fpdfdoc/cpdf_formfield.h46
-rw-r--r--core/fpdfdoc/cpdf_formfield_unittest.cpp2
-rw-r--r--core/fpdfdoc/cpdf_iconfit.cpp2
-rw-r--r--core/fpdfdoc/cpdf_interform.cpp152
-rw-r--r--core/fpdfdoc/cpdf_interform.h31
-rw-r--r--core/fpdfdoc/cpdf_nametree.cpp49
-rw-r--r--core/fpdfdoc/cpdf_nametree.h12
-rw-r--r--core/fpdfdoc/cpdf_nametree_unittest.cpp8
-rw-r--r--core/fpdfdoc/cpdf_occontext.cpp24
-rw-r--r--core/fpdfdoc/cpdf_occontext.h2
-rw-r--r--core/fpdfdoc/cpdf_pagelabel.cpp36
-rw-r--r--core/fpdfdoc/cpdf_pagelabel.h6
-rw-r--r--core/fpdfdoc/cpdf_structelement.cpp4
-rw-r--r--core/fpdfdoc/cpdf_structelement.h8
-rw-r--r--core/fpdfdoc/cpdf_variabletext.cpp4
-rw-r--r--core/fpdfdoc/cpdf_variabletext.h2
-rw-r--r--core/fpdfdoc/cpdf_viewerpreferences.cpp8
-rw-r--r--core/fpdfdoc/cpdf_viewerpreferences.h4
-rw-r--r--core/fpdfdoc/cpvt_color.cpp4
-rw-r--r--core/fpdfdoc/cpvt_color.h2
-rw-r--r--core/fpdfdoc/cpvt_fontmap.cpp8
-rw-r--r--core/fpdfdoc/cpvt_fontmap.h10
-rw-r--r--core/fpdfdoc/cpvt_generateap.cpp153
-rw-r--r--core/fpdfdoc/cpvt_generateap.h50
-rw-r--r--core/fpdfdoc/ipdf_formnotify.h4
-rw-r--r--core/fpdfdoc/ipvt_fontmap.h2
-rw-r--r--core/fpdftext/cpdf_linkextract.cpp16
-rw-r--r--core/fpdftext/cpdf_linkextract.h10
-rw-r--r--core/fpdftext/cpdf_linkextract_unittest.cpp10
-rw-r--r--core/fpdftext/cpdf_textpage.cpp49
-rw-r--r--core/fpdftext/cpdf_textpage.h4
-rw-r--r--core/fpdftext/cpdf_textpagefind.cpp18
-rw-r--r--core/fpdftext/cpdf_textpagefind.h14
-rw-r--r--core/fxcodec/codec/ccodec_gifmodule.cpp2
-rw-r--r--core/fxcodec/codec/ccodec_pngmodule.cpp4
-rw-r--r--core/fxcodec/fx_codec.h2
-rw-r--r--core/fxcodec/lgif/cgifcontext.h2
-rw-r--r--core/fxcodec/lgif/fx_gif.cpp2
-rw-r--r--core/fxcrt/bytestring.cpp (renamed from core/fxcrt/cfx_bytestring.cpp)184
-rw-r--r--core/fxcrt/bytestring.h279
-rw-r--r--core/fxcrt/bytestring_unittest.cpp (renamed from core/fxcrt/cfx_bytestring_unittest.cpp)558
-rw-r--r--core/fxcrt/cfx_binarybuf.h2
-rw-r--r--core/fxcrt/cfx_blockbuffer.cpp10
-rw-r--r--core/fxcrt/cfx_blockbuffer.h2
-rw-r--r--core/fxcrt/cfx_bytestring.h273
-rw-r--r--core/fxcrt/cfx_checksumcontext.cpp4
-rw-r--r--core/fxcrt/cfx_checksumcontext.h6
-rw-r--r--core/fxcrt/cfx_crtfileaccess.cpp2
-rw-r--r--core/fxcrt/cfx_crtfileaccess.h4
-rw-r--r--core/fxcrt/cfx_decimal.cpp8
-rw-r--r--core/fxcrt/cfx_decimal.h4
-rw-r--r--core/fxcrt/cfx_fileaccess_posix.cpp6
-rw-r--r--core/fxcrt/cfx_fileaccess_posix.h4
-rw-r--r--core/fxcrt/cfx_fileaccess_windows.cpp4
-rw-r--r--core/fxcrt/cfx_fileaccess_windows.h4
-rw-r--r--core/fxcrt/cfx_seekablestreamproxy.cpp2
-rw-r--r--core/fxcrt/cfx_seekablestreamproxy.h2
-rw-r--r--core/fxcrt/cfx_string_pool_template.h8
-rw-r--r--core/fxcrt/cfx_string_pool_template_unittest.cpp52
-rw-r--r--core/fxcrt/cfx_utf8decoder.h2
-rw-r--r--core/fxcrt/cfx_widestring.h276
-rw-r--r--core/fxcrt/cfx_widetextbuf.cpp4
-rw-r--r--core/fxcrt/cfx_widetextbuf.h16
-rw-r--r--core/fxcrt/css/cfx_csscomputedstyle.cpp6
-rw-r--r--core/fxcrt/css/cfx_csscomputedstyle.h5
-rw-r--r--core/fxcrt/css/cfx_csscustomproperty.cpp4
-rw-r--r--core/fxcrt/css/cfx_csscustomproperty.h11
-rw-r--r--core/fxcrt/css/cfx_cssdatatable.cpp2
-rw-r--r--core/fxcrt/css/cfx_cssdatatable.h2
-rw-r--r--core/fxcrt/css/cfx_cssdeclaration.cpp32
-rw-r--r--core/fxcrt/css/cfx_cssdeclaration.h4
-rw-r--r--core/fxcrt/css/cfx_cssrulecollection.cpp2
-rw-r--r--core/fxcrt/css/cfx_cssrulecollection.h2
-rw-r--r--core/fxcrt/css/cfx_cssselector.cpp4
-rw-r--r--core/fxcrt/css/cfx_cssselector.h3
-rw-r--r--core/fxcrt/css/cfx_cssstringvalue.cpp2
-rw-r--r--core/fxcrt/css/cfx_cssstringvalue.h6
-rw-r--r--core/fxcrt/css/cfx_cssstyleselector.cpp22
-rw-r--r--core/fxcrt/css/cfx_cssstyleselector.h11
-rw-r--r--core/fxcrt/css/cfx_cssstylesheet.cpp12
-rw-r--r--core/fxcrt/css/cfx_cssstylesheet_unittest.cpp4
-rw-r--r--core/fxcrt/css/cfx_csssyntaxparser.cpp4
-rw-r--r--core/fxcrt/css/cfx_csssyntaxparser.h2
-rw-r--r--core/fxcrt/css/cfx_cssvaluelistparser_unittest.cpp40
-rw-r--r--core/fxcrt/fx_bidi.cpp2
-rw-r--r--core/fxcrt/fx_bidi.h4
-rw-r--r--core/fxcrt/fx_extension.cpp4
-rw-r--r--core/fxcrt/fx_stream.cpp10
-rw-r--r--core/fxcrt/fx_stream.h8
-rw-r--r--core/fxcrt/fx_string.cpp14
-rw-r--r--core/fxcrt/fx_string.h12
-rw-r--r--core/fxcrt/ifx_fileaccess.h4
-rw-r--r--core/fxcrt/ifx_locale.h20
-rw-r--r--core/fxcrt/string_view_template.h (renamed from core/fxcrt/cfx_string_c_template.h)83
-rw-r--r--core/fxcrt/widestring.cpp (renamed from core/fxcrt/cfx_widestring.cpp)207
-rw-r--r--core/fxcrt/widestring.h277
-rw-r--r--core/fxcrt/widestring_unittest.cpp (renamed from core/fxcrt/cfx_widestring_unittest.cpp)528
-rw-r--r--core/fxcrt/xml/cfx_saxcontext.h2
-rw-r--r--core/fxcrt/xml/cfx_saxreader.cpp18
-rw-r--r--core/fxcrt/xml/cfx_saxreader.h12
-rw-r--r--core/fxcrt/xml/cfx_saxreader_unittest.cpp12
-rw-r--r--core/fxcrt/xml/cfx_saxreaderhandler.cpp16
-rw-r--r--core/fxcrt/xml/cfx_saxreaderhandler.h12
-rw-r--r--core/fxcrt/xml/cfx_xmlattributenode.cpp15
-rw-r--r--core/fxcrt/xml/cfx_xmlattributenode.h20
-rw-r--r--core/fxcrt/xml/cfx_xmlchardata.cpp2
-rw-r--r--core/fxcrt/xml/cfx_xmlchardata.h2
-rw-r--r--core/fxcrt/xml/cfx_xmldoc.cpp34
-rw-r--r--core/fxcrt/xml/cfx_xmlelement.cpp22
-rw-r--r--core/fxcrt/xml/cfx_xmlelement.h12
-rw-r--r--core/fxcrt/xml/cfx_xmlinstruction.cpp4
-rw-r--r--core/fxcrt/xml/cfx_xmlinstruction.h10
-rw-r--r--core/fxcrt/xml/cfx_xmlnode.cpp38
-rw-r--r--core/fxcrt/xml/cfx_xmlparser.cpp2
-rw-r--r--core/fxcrt/xml/cfx_xmlparser.h4
-rw-r--r--core/fxcrt/xml/cfx_xmlsyntaxparser.cpp2
-rw-r--r--core/fxcrt/xml/cfx_xmlsyntaxparser.h12
-rw-r--r--core/fxcrt/xml/cfx_xmltext.cpp2
-rw-r--r--core/fxcrt/xml/cfx_xmltext.h8
-rw-r--r--core/fxcrt/xml/cxml_attritem.cpp4
-rw-r--r--core/fxcrt/xml/cxml_attritem.h8
-rw-r--r--core/fxcrt/xml/cxml_attrmap.cpp12
-rw-r--r--core/fxcrt/xml/cxml_attrmap.h10
-rw-r--r--core/fxcrt/xml/cxml_content.cpp2
-rw-r--r--core/fxcrt/xml/cxml_content.h4
-rw-r--r--core/fxcrt/xml/cxml_element.cpp95
-rw-r--r--core/fxcrt/xml/cxml_element.h75
-rw-r--r--core/fxcrt/xml/cxml_parser.cpp47
-rw-r--r--core/fxcrt/xml/cxml_parser.h18
-rw-r--r--core/fxge/android/cfpf_skiafont.cpp12
-rw-r--r--core/fxge/android/cfpf_skiafont.h6
-rw-r--r--core/fxge/android/cfpf_skiafontmgr.cpp30
-rw-r--r--core/fxge/android/cfpf_skiafontmgr.h8
-rw-r--r--core/fxge/android/cfx_androidfontinfo.cpp2
-rw-r--r--core/fxge/android/cfx_androidfontinfo.h2
-rw-r--r--core/fxge/apple/fx_mac_imp.cpp8
-rw-r--r--core/fxge/cfx_facecache.cpp6
-rw-r--r--core/fxge/cfx_facecache.h4
-rw-r--r--core/fxge/cfx_folderfontinfo.cpp47
-rw-r--r--core/fxge/cfx_folderfontinfo.h16
-rw-r--r--core/fxge/cfx_font.cpp24
-rw-r--r--core/fxge/cfx_fontmapper.cpp62
-rw-r--r--core/fxge/cfx_fontmapper.h22
-rw-r--r--core/fxge/cfx_fontmgr.cpp20
-rw-r--r--core/fxge/cfx_fontmgr.h8
-rw-r--r--core/fxge/cfx_renderdevice.cpp2
-rw-r--r--core/fxge/cfx_substfont.h2
-rw-r--r--core/fxge/fx_font.h28
-rw-r--r--core/fxge/fx_ge_fontmap.cpp32
-rw-r--r--core/fxge/fx_ge_linux.cpp2
-rw-r--r--core/fxge/ifx_systemfontinfo.h2
-rw-r--r--core/fxge/win32/cfx_psrenderer.cpp4
-rw-r--r--core/fxge/win32/cfx_windowsdib.h3
-rw-r--r--core/fxge/win32/cpsoutput.cpp2
-rw-r--r--core/fxge/win32/cpsoutput.h2
-rw-r--r--core/fxge/win32/fx_win32_device.cpp52
-rw-r--r--core/fxge/win32/fx_win32_dib.cpp12
-rw-r--r--core/fxge/win32/fx_win32_gdipext.cpp2
-rw-r--r--core/fxge/win32/fx_win32_print.cpp8
278 files changed, 3247 insertions, 3298 deletions
diff --git a/core/fpdfapi/cmaps/cmap_int.h b/core/fpdfapi/cmaps/cmap_int.h
index e84dc11e5a..e661792843 100644
--- a/core/fpdfapi/cmaps/cmap_int.h
+++ b/core/fpdfapi/cmaps/cmap_int.h
@@ -23,7 +23,7 @@ struct FXCMAP_CMap {
int m_UseOffset;
};
-void FPDFAPI_FindEmbeddedCMap(const CFX_ByteString& name,
+void FPDFAPI_FindEmbeddedCMap(const ByteString& name,
int charset,
int coding,
const FXCMAP_CMap*& pMap);
diff --git a/core/fpdfapi/cmaps/fpdf_cmaps.cpp b/core/fpdfapi/cmaps/fpdf_cmaps.cpp
index 80ebbdef70..01c8da9691 100644
--- a/core/fpdfapi/cmaps/fpdf_cmaps.cpp
+++ b/core/fpdfapi/cmaps/fpdf_cmaps.cpp
@@ -53,7 +53,7 @@ static int compareDWordSingle(const void* p1, const void* p2) {
}; // extern "C"
-void FPDFAPI_FindEmbeddedCMap(const CFX_ByteString& bsName,
+void FPDFAPI_FindEmbeddedCMap(const ByteString& bsName,
int charset,
int coding,
const FXCMAP_CMap*& pMap) {
diff --git a/core/fpdfapi/edit/cpdf_creator.cpp b/core/fpdfapi/edit/cpdf_creator.cpp
index 38a21ba0cb..c3143b5322 100644
--- a/core/fpdfapi/edit/cpdf_creator.cpp
+++ b/core/fpdfapi/edit/cpdf_creator.cpp
@@ -33,7 +33,7 @@ class CFX_FileBufferArchive : public IFX_ArchiveStream {
bool WriteBlock(const void* pBuf, size_t size) override;
bool WriteByte(uint8_t byte) override;
bool WriteDWord(uint32_t i) override;
- bool WriteString(const CFX_ByteStringC& str) override;
+ bool WriteString(const ByteStringView& str) override;
FX_FILESIZE CurrentOffset() const override { return offset_; }
@@ -105,7 +105,7 @@ bool CFX_FileBufferArchive::WriteDWord(uint32_t i) {
return WriteBlock(buf, static_cast<size_t>(FXSYS_strlen(buf)));
}
-bool CFX_FileBufferArchive::WriteString(const CFX_ByteStringC& str) {
+bool CFX_FileBufferArchive::WriteString(const ByteStringView& str) {
return WriteBlock(str.raw_str(), str.GetLength());
}
@@ -220,7 +220,7 @@ bool CPDF_Creator::WriteDirectObj(uint32_t objnum,
break;
case CPDF_Object::STRING: {
- CFX_ByteString str = pObj->GetString();
+ ByteString str = pObj->GetString();
bool bHex = pObj->AsString()->IsHex();
if (!m_pCryptoHandler || !bEncrypt) {
if (!pObj->WriteTo(m_Archive.get()))
@@ -229,9 +229,9 @@ bool CPDF_Creator::WriteDirectObj(uint32_t objnum,
}
CPDF_Encryptor encryptor(m_pCryptoHandler.Get(), objnum,
(uint8_t*)str.c_str(), str.GetLength());
- CFX_ByteString content = PDF_EncodeString(
- CFX_ByteString(encryptor.GetData(), encryptor.GetSize()), bHex);
- if (!m_Archive->WriteString(content.AsStringC()))
+ ByteString content = PDF_EncodeString(
+ ByteString(encryptor.GetData(), encryptor.GetSize()), bHex);
+ if (!m_Archive->WriteString(content.AsStringView()))
return false;
break;
}
@@ -290,10 +290,10 @@ bool CPDF_Creator::WriteDirectObj(uint32_t objnum,
bool bSignDict = p->IsSignatureDict();
for (const auto& it : *p) {
bool bSignValue = false;
- const CFX_ByteString& key = it.first;
+ const ByteString& key = it.first;
CPDF_Object* pValue = it.second.get();
if (!m_Archive->WriteString("/") ||
- !m_Archive->WriteString(PDF_NameEncode(key).AsStringC())) {
+ !m_Archive->WriteString(PDF_NameEncode(key).AsStringView())) {
return false;
}
@@ -521,11 +521,11 @@ int32_t CPDF_Creator::WriteDoc_Stage3() {
m_XrefStart = m_Archive->CurrentOffset();
if (!IsIncremental() || !m_pParser->IsXRefStream()) {
if (!IsIncremental() || m_pParser->GetLastXRefOffset() == 0) {
- CFX_ByteString str;
+ ByteString str;
str = pdfium::ContainsKey(m_ObjectOffsets, 1)
? "xref\r\n"
: "xref\r\n0 1\r\n0000000000 65535 f\r\n";
- if (!m_Archive->WriteString(str.AsStringC()))
+ if (!m_Archive->WriteString(str.AsStringView()))
return -1;
m_CurObjNum = 1;
@@ -542,7 +542,7 @@ int32_t CPDF_Creator::WriteDoc_Stage3() {
}
}
if (m_iStage == 81) {
- CFX_ByteString str;
+ ByteString str;
uint32_t i = m_CurObjNum;
uint32_t j;
while (i <= dwLastObjNum) {
@@ -575,7 +575,7 @@ int32_t CPDF_Creator::WriteDoc_Stage3() {
m_iStage = 90;
}
if (m_iStage == 82) {
- CFX_ByteString str;
+ ByteString str;
uint32_t iCount = pdfium::CollectionSize<uint32_t>(m_NewObjNumArray);
uint32_t i = m_CurObjNum;
while (i < iCount) {
@@ -627,7 +627,7 @@ int32_t CPDF_Creator::WriteDoc_Stage4() {
if (m_pParser) {
CPDF_Dictionary* p = m_pParser->GetTrailer();
for (const auto& it : *p) {
- const CFX_ByteString& key = it.first;
+ const ByteString& key = it.first;
CPDF_Object* pValue = it.second.get();
if (key == "Encrypt" || key == "Size" || key == "Filter" ||
key == "Index" || key == "Length" || key == "Prev" || key == "W" ||
@@ -635,7 +635,7 @@ int32_t CPDF_Creator::WriteDoc_Stage4() {
continue;
}
if (!m_Archive->WriteString(("/")) ||
- !m_Archive->WriteString(PDF_NameEncode(key).AsStringC())) {
+ !m_Archive->WriteString(PDF_NameEncode(key).AsStringView())) {
return -1;
}
if (!pValue->IsInline()) {
@@ -782,7 +782,7 @@ void CPDF_Creator::InitID() {
} else {
std::vector<uint8_t> buffer =
GenerateFileID((uint32_t)(uintptr_t)this, m_dwLastObjNum);
- CFX_ByteString bsBuffer(buffer.data(), buffer.size());
+ ByteString bsBuffer(buffer.data(), buffer.size());
m_pIDArray->AddNew<CPDF_String>(bsBuffer, true);
}
}
@@ -795,7 +795,7 @@ void CPDF_Creator::InitID() {
}
std::vector<uint8_t> buffer =
GenerateFileID((uint32_t)(uintptr_t)this, m_dwLastObjNum);
- CFX_ByteString bsBuffer(buffer.data(), buffer.size());
+ ByteString bsBuffer(buffer.data(), buffer.size());
m_pIDArray->AddNew<CPDF_String>(bsBuffer, true);
return;
}
@@ -803,7 +803,7 @@ void CPDF_Creator::InitID() {
m_pIDArray->Add(m_pIDArray->GetObjectAt(0)->Clone());
if (m_pEncryptDict && !pOldIDArray && m_pParser && !idArrayPreExisting) {
if (m_pEncryptDict->GetStringFor("Filter") == "Standard") {
- CFX_ByteString user_pass = m_pParser->GetPassword();
+ ByteString user_pass = m_pParser->GetPassword();
uint32_t flag = PDF_ENCRYPT_CONTENT;
CPDF_SecurityHandler handler;
handler.OnCreate(m_pEncryptDict.Get(), m_pIDArray.get(),
diff --git a/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp b/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp
index 9153bf4cea..c0c6604671 100644
--- a/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp
+++ b/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp
@@ -121,9 +121,9 @@ void CPDF_PageContentGenerator::GenerateContent() {
pStream->GetObjNum());
}
-CFX_ByteString CPDF_PageContentGenerator::RealizeResource(
+ByteString CPDF_PageContentGenerator::RealizeResource(
uint32_t dwResourceObjNum,
- const CFX_ByteString& bsType) {
+ const ByteString& bsType) {
ASSERT(dwResourceObjNum);
if (!m_pObjHolder->m_pResources) {
m_pObjHolder->m_pResources = m_pDocument->NewIndirect<CPDF_Dictionary>();
@@ -135,7 +135,7 @@ CFX_ByteString CPDF_PageContentGenerator::RealizeResource(
if (!pResList)
pResList = m_pObjHolder->m_pResources->SetNewFor<CPDF_Dictionary>(bsType);
- CFX_ByteString name;
+ ByteString name;
int idnum = 1;
while (1) {
name.Format("FX%c%d", bsType[0], idnum);
@@ -188,7 +188,7 @@ void CPDF_PageContentGenerator::ProcessImage(std::ostringstream* buf,
pImage->ConvertStreamToIndirectObject();
uint32_t dwObjNum = pStream->GetObjNum();
- CFX_ByteString name = RealizeResource(dwObjNum, "XObject");
+ ByteString name = RealizeResource(dwObjNum, "XObject");
if (bWasInline)
pImageObj->SetImage(m_pDocument->GetPageData()->GetImage(dwObjNum));
@@ -295,7 +295,7 @@ void CPDF_PageContentGenerator::ProcessGraphics(std::ostringstream* buf,
return;
}
- CFX_ByteString name;
+ ByteString name;
auto it = m_pObjHolder->m_GraphicsMap.find(graphD);
if (it != m_pObjHolder->m_GraphicsMap.end()) {
name = it->second;
@@ -330,7 +330,7 @@ void CPDF_PageContentGenerator::ProcessDefaultGraphics(
defaultGraphics.strokeAlpha = 1.0f;
defaultGraphics.blendType = FXDIB_BLEND_NORMAL;
auto it = m_pObjHolder->m_GraphicsMap.find(defaultGraphics);
- CFX_ByteString name;
+ ByteString name;
if (it != m_pObjHolder->m_GraphicsMap.end()) {
name = it->second;
} else {
@@ -368,7 +368,7 @@ void CPDF_PageContentGenerator::ProcessText(std::ostringstream* buf,
return;
fontD.baseFont = pFont->GetBaseFont();
auto it = m_pObjHolder->m_FontsMap.find(fontD);
- CFX_ByteString dictName;
+ ByteString dictName;
if (it != m_pObjHolder->m_FontsMap.end()) {
dictName = it->second;
} else {
@@ -387,7 +387,7 @@ void CPDF_PageContentGenerator::ProcessText(std::ostringstream* buf,
}
*buf << "/" << PDF_NameEncode(dictName) << " " << pTextObj->GetFontSize()
<< " Tf ";
- CFX_ByteString text;
+ ByteString text;
for (uint32_t charcode : pTextObj->m_CharCodes) {
if (charcode != CPDF_Font::kInvalidCharCode)
pFont->AppendChar(&text, charcode);
diff --git a/core/fpdfapi/edit/cpdf_pagecontentgenerator.h b/core/fpdfapi/edit/cpdf_pagecontentgenerator.h
index 518d358451..433ad3361a 100644
--- a/core/fpdfapi/edit/cpdf_pagecontentgenerator.h
+++ b/core/fpdfapi/edit/cpdf_pagecontentgenerator.h
@@ -37,8 +37,8 @@ class CPDF_PageContentGenerator {
void ProcessGraphics(std::ostringstream* buf, CPDF_PageObject* pPageObj);
void ProcessDefaultGraphics(std::ostringstream* buf);
void ProcessText(std::ostringstream* buf, CPDF_TextObject* pTextObj);
- CFX_ByteString RealizeResource(uint32_t dwResourceObjNum,
- const CFX_ByteString& bsType);
+ ByteString RealizeResource(uint32_t dwResourceObjNum,
+ const ByteString& bsType);
CFX_UnownedPtr<CPDF_PageObjectHolder> const m_pObjHolder;
CFX_UnownedPtr<CPDF_Document> const m_pDocument;
diff --git a/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp b/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp
index 1dd6d25e2a..a0db869410 100644
--- a/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp
+++ b/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp
@@ -36,8 +36,8 @@ class CPDF_PageContentGeneratorTest : public testing::Test {
}
CPDF_Dictionary* TestGetResource(CPDF_PageContentGenerator* pGen,
- const CFX_ByteString& type,
- const CFX_ByteString& name) {
+ const ByteString& type,
+ const ByteString& name) {
return pGen->m_pObjHolder->m_pResources->GetDictFor(type)->GetDictFor(name);
}
@@ -58,7 +58,7 @@ TEST_F(CPDF_PageContentGeneratorTest, ProcessRect) {
CPDF_PageContentGenerator generator(pTestPage.get());
std::ostringstream buf;
TestProcessPath(&generator, &buf, pPathObj.get());
- EXPECT_EQ("q 1 0 0 1 0 0 cm 10 5 3 25 re B* Q\n", CFX_ByteString(buf));
+ EXPECT_EQ("q 1 0 0 1 0 0 cm 10 5 3 25 re B* Q\n", ByteString(buf));
pPathObj = pdfium::MakeUnique<CPDF_PathObject>();
pPathObj->m_Path.AppendPoint(CFX_PointF(0, 0), FXPT_TYPE::MoveTo, false);
@@ -71,7 +71,7 @@ TEST_F(CPDF_PageContentGeneratorTest, ProcessRect) {
buf.str("");
TestProcessPath(&generator, &buf, pPathObj.get());
- EXPECT_EQ("q 1 0 0 1 0 0 cm 0 0 5.2 3.78 re n Q\n", CFX_ByteString(buf));
+ EXPECT_EQ("q 1 0 0 1 0 0 cm 0 0 5.2 3.78 re n Q\n", ByteString(buf));
}
TEST_F(CPDF_PageContentGeneratorTest, ProcessPath) {
@@ -105,7 +105,7 @@ TEST_F(CPDF_PageContentGeneratorTest, ProcessPath) {
EXPECT_EQ(
"q 1 0 0 1 0 0 cm 3.102 4.67 m 5.45 0.29 l 4.24 3.15 4.65 2.98 3.456 0.24"
" c 10.6 11.15 l 11 12.5 l 11.46 12.67 11.84 12.96 12 13.64 c h f Q\n",
- CFX_ByteString(buf));
+ ByteString(buf));
}
TEST_F(CPDF_PageContentGeneratorTest, ProcessGraphics) {
@@ -132,7 +132,7 @@ TEST_F(CPDF_PageContentGeneratorTest, ProcessGraphics) {
CPDF_PageContentGenerator generator(pTestPage.get());
std::ostringstream buf;
TestProcessPath(&generator, &buf, pPathObj.get());
- CFX_ByteString pathString(buf);
+ ByteString pathString(buf);
// Color RGB values used are integers divided by 255.
EXPECT_EQ("q 0.501961 0.701961 0.34902 rg 1 0.901961 0 RG /",
@@ -150,7 +150,7 @@ TEST_F(CPDF_PageContentGeneratorTest, ProcessGraphics) {
pPathObj->m_GraphState.SetLineWidth(10.5f);
buf.str("");
TestProcessPath(&generator, &buf, pPathObj.get());
- CFX_ByteString pathString2(buf);
+ ByteString pathString2(buf);
EXPECT_EQ("q 0.501961 0.701961 0.34902 rg 1 0.901961 0 RG 10.5 w /",
pathString2.Left(55));
EXPECT_EQ(" gs 1 0 0 1 0 0 cm 1 2 m 3 4 l 5 6 l h B Q\n",
@@ -185,25 +185,25 @@ TEST_F(CPDF_PageContentGeneratorTest, ProcessStandardText) {
pTextObj->SetText("Hello World");
std::ostringstream buf;
TestProcessText(&generator, &buf, pTextObj.get());
- CFX_ByteString textString(buf);
+ ByteString textString(buf);
auto firstResourceAt = textString.Find('/');
ASSERT_TRUE(firstResourceAt.has_value());
firstResourceAt = firstResourceAt.value() + 1;
auto secondResourceAt = textString.ReverseFind('/');
ASSERT_TRUE(secondResourceAt.has_value());
secondResourceAt = secondResourceAt.value() + 1;
- CFX_ByteString firstString = textString.Left(firstResourceAt.value());
- CFX_ByteString midString =
+ ByteString firstString = textString.Left(firstResourceAt.value());
+ ByteString midString =
textString.Mid(firstResourceAt.value(),
secondResourceAt.value() - firstResourceAt.value());
- CFX_ByteString lastString =
+ ByteString lastString =
textString.Right(textString.GetLength() - secondResourceAt.value());
// q and Q must be outside the BT .. ET operations
- CFX_ByteString compareString1 =
+ ByteString compareString1 =
"q 0.501961 0.701961 0.34902 rg 1 0.901961 0 RG /";
// Color RGB values used are integers divided by 255.
- CFX_ByteString compareString2 = " gs BT 1 0 0 1 100 100 Tm /";
- CFX_ByteString compareString3 = " 10 Tf <48656C6C6F20576F726C64> Tj ET Q\n";
+ ByteString compareString2 = " gs BT 1 0 0 1 100 100 Tm /";
+ ByteString compareString3 = " 10 Tf <48656C6C6F20576F726C64> Tj ET Q\n";
EXPECT_LT(compareString1.GetLength() + compareString2.GetLength() +
compareString3.GetLength(),
textString.GetLength());
@@ -257,17 +257,16 @@ TEST_F(CPDF_PageContentGeneratorTest, ProcessText) {
TestProcessText(&generator, &buf, pTextObj.get());
}
- CFX_ByteString textString(buf);
+ ByteString textString(buf);
auto firstResourceAt = textString.Find('/');
ASSERT_TRUE(firstResourceAt.has_value());
firstResourceAt = firstResourceAt.value() + 1;
- CFX_ByteString firstString = textString.Left(firstResourceAt.value());
- CFX_ByteString lastString =
+ ByteString firstString = textString.Left(firstResourceAt.value());
+ ByteString lastString =
textString.Right(textString.GetLength() - firstResourceAt.value());
// q and Q must be outside the BT .. ET operations
- CFX_ByteString compareString1 = "q BT 1 0 0 1 0 0 Tm /";
- CFX_ByteString compareString2 =
- " 15.5 Tf <4920616D20696E646972656374> Tj ET Q\n";
+ ByteString compareString1 = "q BT 1 0 0 1 0 0 Tm /";
+ ByteString compareString2 = " 15.5 Tf <4920616D20696E646972656374> Tj ET Q\n";
EXPECT_LT(compareString1.GetLength() + compareString2.GetLength(),
textString.GetLength());
EXPECT_EQ(compareString1, textString.Left(compareString1.GetLength()));
@@ -305,7 +304,7 @@ TEST_F(CPDF_PageContentGeneratorTest, ProcessEmptyForm) {
CPDF_PageContentGenerator generator(pTestForm.get());
std::ostringstream buf;
generator.ProcessPageObjects(&buf);
- EXPECT_EQ("", CFX_ByteString(buf));
+ EXPECT_EQ("", ByteString(buf));
}
TEST_F(CPDF_PageContentGeneratorTest, ProcessFormWithPath) {
@@ -330,5 +329,5 @@ TEST_F(CPDF_PageContentGeneratorTest, ProcessFormWithPath) {
CPDF_PageContentGenerator generator(pTestForm.get());
std::ostringstream process_buf;
generator.ProcessPageObjects(&process_buf);
- EXPECT_EQ(content, CFX_ByteString(process_buf));
+ EXPECT_EQ(content, ByteString(process_buf));
}
diff --git a/core/fpdfapi/font/cpdf_cidfont.cpp b/core/fpdfapi/font/cpdf_cidfont.cpp
index a67abd29ac..9b326f5c4f 100644
--- a/core/fpdfapi/font/cpdf_cidfont.cpp
+++ b/core/fpdfapi/font/cpdf_cidfont.cpp
@@ -239,12 +239,12 @@ bool CPDF_CIDFont::IsVertWriting() const {
return m_pCMap && m_pCMap->IsVertWriting();
}
-CFX_WideString CPDF_CIDFont::UnicodeFromCharCode(uint32_t charcode) const {
- CFX_WideString str = CPDF_Font::UnicodeFromCharCode(charcode);
+WideString CPDF_CIDFont::UnicodeFromCharCode(uint32_t charcode) const {
+ WideString str = CPDF_Font::UnicodeFromCharCode(charcode);
if (!str.IsEmpty())
return str;
wchar_t ret = GetUnicodeFromCharCode(charcode);
- return ret ? ret : CFX_WideString();
+ return ret ? ret : WideString();
}
wchar_t CPDF_CIDFont::GetUnicodeFromCharCode(uint32_t charcode) const {
@@ -356,12 +356,12 @@ bool CPDF_CIDFont::Load() {
if (!pEncoding)
return false;
- CFX_ByteString subtype = pCIDFontDict->GetStringFor("Subtype");
+ ByteString subtype = pCIDFontDict->GetStringFor("Subtype");
m_bType1 = (subtype == "CIDFontType0");
CPDF_CMapManager& manager = GetFontGlobals()->m_CMapManager;
if (pEncoding->IsName()) {
- CFX_ByteString cmap = pEncoding->GetString();
+ ByteString cmap = pEncoding->GetString();
bool bPromptCJK = m_pFontFile && m_bType1;
m_pCMap = manager.GetPredefinedCMap(cmap, bPromptCJK);
if (!m_pCMap)
@@ -380,7 +380,7 @@ bool CPDF_CIDFont::Load() {
CPDF_Dictionary* pCIDInfo = pCIDFontDict->GetDictFor("CIDSystemInfo");
if (pCIDInfo) {
m_Charset = CPDF_CMapParser::CharsetFromOrdering(
- pCIDInfo->GetStringFor("Ordering").AsStringC());
+ pCIDInfo->GetStringFor("Ordering").AsStringView());
}
}
if (m_Charset != CIDSET_UNKNOWN) {
@@ -621,7 +621,7 @@ int CPDF_CIDFont::GlyphFromCharCode(uint32_t charcode, bool* pVertGlyph) {
if (m_Flags & FXFONT_SYMBOLIC)
return cid;
- CFX_WideString uni_str = UnicodeFromCharCode(charcode);
+ WideString uni_str = UnicodeFromCharCode(charcode);
if (uni_str.IsEmpty())
return cid;
@@ -633,7 +633,7 @@ int CPDF_CIDFont::GlyphFromCharCode(uint32_t charcode, bool* pVertGlyph) {
if (unicode == 0)
unicode = GetUnicodeFromCharCode(charcode);
if (unicode == 0) {
- CFX_WideString unicode_str = UnicodeFromCharCode(charcode);
+ WideString unicode_str = UnicodeFromCharCode(charcode);
if (!unicode_str.IsEmpty())
unicode = unicode_str[0];
}
@@ -651,8 +651,8 @@ int CPDF_CIDFont::GlyphFromCharCode(uint32_t charcode, bool* pVertGlyph) {
iBaseEncoding = PDFFONT_ENCODING_WINANSI;
else if (bMacRoman)
iBaseEncoding = PDFFONT_ENCODING_MACROMAN;
- const char* name = GetAdobeCharName(
- iBaseEncoding, std::vector<CFX_ByteString>(), charcode);
+ const char* name =
+ GetAdobeCharName(iBaseEncoding, std::vector<ByteString>(), charcode);
if (!name)
return charcode ? static_cast<int>(charcode) : -1;
@@ -729,7 +729,7 @@ int CPDF_CIDFont::GlyphFromCharCode(uint32_t charcode, bool* pVertGlyph) {
}
if (FXFT_Get_Charmap_Encoding(FXFT_Get_Face_Charmap(m_Font.GetFace())) ==
FXFT_ENCODING_UNICODE) {
- CFX_WideString unicode_str = UnicodeFromCharCode(charcode);
+ WideString unicode_str = UnicodeFromCharCode(charcode);
if (unicode_str.IsEmpty())
return -1;
diff --git a/core/fpdfapi/font/cpdf_cidfont.h b/core/fpdfapi/font/cpdf_cidfont.h
index 07982a418f..f4ddcfd577 100644
--- a/core/fpdfapi/font/cpdf_cidfont.h
+++ b/core/fpdfapi/font/cpdf_cidfont.h
@@ -54,7 +54,7 @@ class CPDF_CIDFont : public CPDF_Font {
bool IsVertWriting() const override;
bool IsUnicodeCompatible() const override;
bool Load() override;
- CFX_WideString UnicodeFromCharCode(uint32_t charcode) const override;
+ WideString UnicodeFromCharCode(uint32_t charcode) const override;
uint32_t CharCodeFromUnicode(wchar_t Unicode) const override;
uint16_t CIDFromCharCode(uint32_t charcode) const;
diff --git a/core/fpdfapi/font/cpdf_cmap.cpp b/core/fpdfapi/font/cpdf_cmap.cpp
index 0d3745e44a..54f7b34ca0 100644
--- a/core/fpdfapi/font/cpdf_cmap.cpp
+++ b/core/fpdfapi/font/cpdf_cmap.cpp
@@ -248,7 +248,7 @@ CPDF_CMap::CPDF_CMap()
CPDF_CMap::~CPDF_CMap() {}
void CPDF_CMap::LoadPredefined(CPDF_CMapManager* pMgr,
- const CFX_ByteString& bsName,
+ const ByteString& bsName,
bool bPromptCJK) {
m_PredefinedCMap = bsName;
if (m_PredefinedCMap == "Identity-H" || m_PredefinedCMap == "Identity-V") {
@@ -257,14 +257,14 @@ void CPDF_CMap::LoadPredefined(CPDF_CMapManager* pMgr,
m_bLoaded = true;
return;
}
- CFX_ByteString cmapid = m_PredefinedCMap;
+ ByteString cmapid = m_PredefinedCMap;
m_bVertical = cmapid.Last() == 'V';
if (cmapid.GetLength() > 2) {
cmapid = cmapid.Left(cmapid.GetLength() - 2);
}
const PredefinedCMap* map = nullptr;
for (size_t i = 0; i < FX_ArraySize(g_PredefinedCMaps); ++i) {
- if (cmapid == CFX_ByteStringC(g_PredefinedCMaps[i].m_pName)) {
+ if (cmapid == ByteStringView(g_PredefinedCMaps[i].m_pName)) {
map = &g_PredefinedCMaps[i];
break;
}
@@ -295,7 +295,7 @@ void CPDF_CMap::LoadEmbedded(const uint8_t* pData, uint32_t size) {
CPDF_CMapParser parser(this);
CPDF_SimpleParser syntax(pData, size);
while (1) {
- CFX_ByteStringC word = syntax.GetWord();
+ ByteStringView word = syntax.GetWord();
if (word.IsEmpty()) {
break;
}
diff --git a/core/fpdfapi/font/cpdf_cmap.h b/core/fpdfapi/font/cpdf_cmap.h
index f4d6ca9113..3e23d03a01 100644
--- a/core/fpdfapi/font/cpdf_cmap.h
+++ b/core/fpdfapi/font/cpdf_cmap.h
@@ -51,7 +51,7 @@ class CPDF_CMap : public CFX_Retainable {
friend CFX_RetainPtr<T> pdfium::MakeRetain(Args&&... args);
void LoadPredefined(CPDF_CMapManager* pMgr,
- const CFX_ByteString& name,
+ const ByteString& name,
bool bPromptCJK);
void LoadEmbedded(const uint8_t* pData, uint32_t dwSize);
@@ -70,7 +70,7 @@ class CPDF_CMap : public CFX_Retainable {
CPDF_CMap();
~CPDF_CMap() override;
- CFX_ByteString m_PredefinedCMap;
+ ByteString m_PredefinedCMap;
bool m_bLoaded;
bool m_bVertical;
CIDSet m_Charset;
diff --git a/core/fpdfapi/font/cpdf_cmapmanager.cpp b/core/fpdfapi/font/cpdf_cmapmanager.cpp
index 040af5556a..a449db6a45 100644
--- a/core/fpdfapi/font/cpdf_cmapmanager.cpp
+++ b/core/fpdfapi/font/cpdf_cmapmanager.cpp
@@ -17,7 +17,7 @@ CPDF_CMapManager::CPDF_CMapManager() {}
CPDF_CMapManager::~CPDF_CMapManager() {}
CFX_RetainPtr<CPDF_CMap> CPDF_CMapManager::GetPredefinedCMap(
- const CFX_ByteString& name,
+ const ByteString& name,
bool bPromptCJK) {
auto it = m_CMaps.find(name);
if (it != m_CMaps.end())
@@ -31,7 +31,7 @@ CFX_RetainPtr<CPDF_CMap> CPDF_CMapManager::GetPredefinedCMap(
}
CFX_RetainPtr<CPDF_CMap> CPDF_CMapManager::LoadPredefinedCMap(
- const CFX_ByteString& name,
+ const ByteString& name,
bool bPromptCJK) {
const char* pname = name.c_str();
if (*pname == '/')
diff --git a/core/fpdfapi/font/cpdf_cmapmanager.h b/core/fpdfapi/font/cpdf_cmapmanager.h
index 1bc1c6f839..6a860e6859 100644
--- a/core/fpdfapi/font/cpdf_cmapmanager.h
+++ b/core/fpdfapi/font/cpdf_cmapmanager.h
@@ -11,7 +11,7 @@
#include <memory>
#include "core/fpdfapi/font/cpdf_cidfont.h"
-#include "core/fxcrt/cfx_bytestring.h"
+#include "core/fxcrt/bytestring.h"
#include "core/fxcrt/cfx_retain_ptr.h"
class CPDF_CMapManager {
@@ -19,17 +19,17 @@ class CPDF_CMapManager {
CPDF_CMapManager();
~CPDF_CMapManager();
- CFX_RetainPtr<CPDF_CMap> GetPredefinedCMap(const CFX_ByteString& name,
+ CFX_RetainPtr<CPDF_CMap> GetPredefinedCMap(const ByteString& name,
bool bPromptCJK);
CPDF_CID2UnicodeMap* GetCID2UnicodeMap(CIDSet charset, bool bPromptCJK);
private:
- CFX_RetainPtr<CPDF_CMap> LoadPredefinedCMap(const CFX_ByteString& name,
+ CFX_RetainPtr<CPDF_CMap> LoadPredefinedCMap(const ByteString& name,
bool bPromptCJK);
std::unique_ptr<CPDF_CID2UnicodeMap> LoadCID2UnicodeMap(CIDSet charset,
bool bPromptCJK);
- std::map<CFX_ByteString, CFX_RetainPtr<CPDF_CMap>> m_CMaps;
+ std::map<ByteString, CFX_RetainPtr<CPDF_CMap>> m_CMaps;
std::unique_ptr<CPDF_CID2UnicodeMap> m_CID2UnicodeMaps[6];
};
diff --git a/core/fpdfapi/font/cpdf_cmapparser.cpp b/core/fpdfapi/font/cpdf_cmapparser.cpp
index 101ae5f0c8..f7d4dc1c33 100644
--- a/core/fpdfapi/font/cpdf_cmapparser.cpp
+++ b/core/fpdfapi/font/cpdf_cmapparser.cpp
@@ -32,9 +32,9 @@ CIDSet CIDSetFromSizeT(size_t index) {
return static_cast<CIDSet>(index);
}
-CFX_ByteStringC CMap_GetString(const CFX_ByteStringC& word) {
+ByteStringView CMap_GetString(const ByteStringView& word) {
if (word.GetLength() <= 2)
- return CFX_ByteStringC();
+ return ByteStringView();
return word.Right(word.GetLength() - 2);
}
@@ -45,7 +45,7 @@ CPDF_CMapParser::CPDF_CMapParser(CPDF_CMap* pCMap)
CPDF_CMapParser::~CPDF_CMapParser() {}
-void CPDF_CMapParser::ParseWord(const CFX_ByteStringC& word) {
+void CPDF_CMapParser::ParseWord(const ByteStringView& word) {
if (word.IsEmpty()) {
return;
}
@@ -126,7 +126,7 @@ void CPDF_CMapParser::ParseWord(const CFX_ByteStringC& word) {
}
if (m_CodeSeq % 2) {
CPDF_CMap::CodeRange range;
- if (CMap_GetCodeRange(range, m_LastWord.AsStringC(), word))
+ if (CMap_GetCodeRange(range, m_LastWord.AsStringView(), word))
m_CodeRanges.push_back(range);
}
m_CodeSeq++;
@@ -136,7 +136,7 @@ void CPDF_CMapParser::ParseWord(const CFX_ByteStringC& word) {
}
// Static.
-uint32_t CPDF_CMapParser::CMap_GetCode(const CFX_ByteStringC& word) {
+uint32_t CPDF_CMapParser::CMap_GetCode(const ByteStringView& word) {
if (word.IsEmpty())
return 0;
pdfium::base::CheckedNumeric<uint32_t> num = 0;
@@ -160,8 +160,8 @@ uint32_t CPDF_CMapParser::CMap_GetCode(const CFX_ByteStringC& word) {
// Static.
bool CPDF_CMapParser::CMap_GetCodeRange(CPDF_CMap::CodeRange& range,
- const CFX_ByteStringC& first,
- const CFX_ByteStringC& second) {
+ const ByteStringView& first,
+ const ByteStringView& second) {
if (first.GetLength() == 0 || first[0] != '<')
return false;
@@ -193,7 +193,7 @@ bool CPDF_CMapParser::CMap_GetCodeRange(CPDF_CMap::CodeRange& range,
}
// static
-CIDSet CPDF_CMapParser::CharsetFromOrdering(const CFX_ByteStringC& ordering) {
+CIDSet CPDF_CMapParser::CharsetFromOrdering(const ByteStringView& ordering) {
for (size_t charset = 1; charset < FX_ArraySize(g_CharsetNames); ++charset) {
if (ordering == g_CharsetNames[charset])
return CIDSetFromSizeT(charset);
diff --git a/core/fpdfapi/font/cpdf_cmapparser.h b/core/fpdfapi/font/cpdf_cmapparser.h
index b0a0ced30f..b3c8326b98 100644
--- a/core/fpdfapi/font/cpdf_cmapparser.h
+++ b/core/fpdfapi/font/cpdf_cmapparser.h
@@ -20,7 +20,7 @@ class CPDF_CMapParser {
explicit CPDF_CMapParser(CPDF_CMap* pMap);
~CPDF_CMapParser();
- void ParseWord(const CFX_ByteStringC& str);
+ void ParseWord(const ByteStringView& str);
bool HasAdditionalMappings() const {
return !m_AdditionalCharcodeToCIDMappings.empty();
}
@@ -28,16 +28,16 @@ class CPDF_CMapParser {
return std::move(m_AdditionalCharcodeToCIDMappings);
}
- static CIDSet CharsetFromOrdering(const CFX_ByteStringC& ordering);
+ static CIDSet CharsetFromOrdering(const ByteStringView& ordering);
private:
friend class cpdf_cmapparser_CMap_GetCode_Test;
friend class cpdf_cmapparser_CMap_GetCodeRange_Test;
- static uint32_t CMap_GetCode(const CFX_ByteStringC& word);
+ static uint32_t CMap_GetCode(const ByteStringView& word);
static bool CMap_GetCodeRange(CPDF_CMap::CodeRange& range,
- const CFX_ByteStringC& first,
- const CFX_ByteStringC& second);
+ const ByteStringView& first,
+ const ByteStringView& second);
CFX_UnownedPtr<CPDF_CMap> const m_pCMap;
int m_Status;
@@ -45,7 +45,7 @@ class CPDF_CMapParser {
uint32_t m_CodePoints[4];
std::vector<CPDF_CMap::CodeRange> m_CodeRanges;
std::vector<CPDF_CMap::CIDRange> m_AdditionalCharcodeToCIDMappings;
- CFX_ByteString m_LastWord;
+ ByteString m_LastWord;
};
#endif // CORE_FPDFAPI_FONT_CPDF_CMAPPARSER_H_
diff --git a/core/fpdfapi/font/cpdf_font.cpp b/core/fpdfapi/font/cpdf_font.cpp
index 0fd8b45326..9aaaa27b2e 100644
--- a/core/fpdfapi/font/cpdf_font.cpp
+++ b/core/fpdfapi/font/cpdf_font.cpp
@@ -37,7 +37,7 @@ const uint8_t kChineseFontNames[][5] = {{0xCB, 0xCE, 0xCC, 0xE5, 0x00},
{0xB7, 0xC2, 0xCB, 0xCE, 0x00},
{0xD0, 0xC2, 0xCB, 0xCE, 0x00}};
-void GetPredefinedEncoding(const CFX_ByteString& value, int* basemap) {
+void GetPredefinedEncoding(const ByteString& value, int* basemap) {
if (value == "WinAnsiEncoding")
*basemap = PDFFONT_ENCODING_WINANSI;
else if (value == "MacRomanEncoding")
@@ -140,17 +140,17 @@ int CPDF_Font::AppendChar(char* buf, uint32_t charcode) const {
return 1;
}
-void CPDF_Font::AppendChar(CFX_ByteString* str, uint32_t charcode) const {
+void CPDF_Font::AppendChar(ByteString* str, uint32_t charcode) const {
char buf[4];
int len = AppendChar(buf, charcode);
- *str += CFX_ByteStringC(buf, len);
+ *str += ByteStringView(buf, len);
}
-CFX_WideString CPDF_Font::UnicodeFromCharCode(uint32_t charcode) const {
+WideString CPDF_Font::UnicodeFromCharCode(uint32_t charcode) const {
if (!m_bToUnicodeLoaded)
LoadUnicodeMap();
- return m_pToUnicodeMap ? m_pToUnicodeMap->Lookup(charcode) : CFX_WideString();
+ return m_pToUnicodeMap ? m_pToUnicodeMap->Lookup(charcode) : WideString();
}
uint32_t CPDF_Font::CharCodeFromUnicode(wchar_t unicode) const {
@@ -297,8 +297,8 @@ int CPDF_Font::GetStringWidth(const char* pString, int size) {
// static
CPDF_Font* CPDF_Font::GetStockFont(CPDF_Document* pDoc,
- const CFX_ByteStringC& name) {
- CFX_ByteString fontname(name);
+ const ByteStringView& name) {
+ ByteString fontname(name);
int font_id = PDF_GetStandardFontName(&fontname);
if (font_id < 0)
return nullptr;
@@ -319,12 +319,12 @@ CPDF_Font* CPDF_Font::GetStockFont(CPDF_Document* pDoc,
std::unique_ptr<CPDF_Font> CPDF_Font::Create(CPDF_Document* pDoc,
CPDF_Dictionary* pFontDict) {
- CFX_ByteString type = pFontDict->GetStringFor("Subtype");
+ ByteString type = pFontDict->GetStringFor("Subtype");
std::unique_ptr<CPDF_Font> pFont;
if (type == "TrueType") {
- CFX_ByteString tag = pFontDict->GetStringFor("BaseFont").Left(4);
+ ByteString tag = pFontDict->GetStringFor("BaseFont").Left(4);
for (size_t i = 0; i < FX_ArraySize(kChineseFontNames); ++i) {
- if (tag == CFX_ByteString(kChineseFontNames[i], 4)) {
+ if (tag == ByteString(kChineseFontNames[i], 4)) {
CPDF_Dictionary* pFontDesc = pFontDict->GetDictFor("FontDescriptor");
if (!pFontDesc || !pFontDesc->KeyExist("FontFile2"))
pFont = pdfium::MakeUnique<CPDF_CIDFont>();
@@ -358,7 +358,7 @@ uint32_t CPDF_Font::GetNextChar(const char* pString,
void CPDF_Font::LoadPDFEncoding(CPDF_Object* pEncoding,
int& iBaseEncoding,
- std::vector<CFX_ByteString>* pCharNames,
+ std::vector<ByteString>* pCharNames,
bool bEmbedded,
bool bTrueType) {
if (!pEncoding) {
@@ -380,7 +380,7 @@ void CPDF_Font::LoadPDFEncoding(CPDF_Object* pEncoding,
iBaseEncoding = PDFFONT_ENCODING_ADOBE_SYMBOL;
return;
}
- CFX_ByteString bsEncoding = pEncoding->GetString();
+ ByteString bsEncoding = pEncoding->GetString();
if (bsEncoding.Compare("MacExpertEncoding") == 0) {
bsEncoding = "WinAnsiEncoding";
}
@@ -394,7 +394,7 @@ void CPDF_Font::LoadPDFEncoding(CPDF_Object* pEncoding,
if (iBaseEncoding != PDFFONT_ENCODING_ADOBE_SYMBOL &&
iBaseEncoding != PDFFONT_ENCODING_ZAPFDINGBATS) {
- CFX_ByteString bsEncoding = pDict->GetStringFor("BaseEncoding");
+ ByteString bsEncoding = pDict->GetStringFor("BaseEncoding");
if (bsEncoding.Compare("MacExpertEncoding") == 0 && bTrueType) {
bsEncoding = "WinAnsiEncoding";
}
@@ -436,7 +436,7 @@ bool CPDF_Font::IsStandardFont() const {
const char* CPDF_Font::GetAdobeCharName(
int iBaseEncoding,
- const std::vector<CFX_ByteString>& charnames,
+ const std::vector<ByteString>& charnames,
int charcode) {
if (charcode < 0 || charcode >= 256) {
NOTREACHED();
@@ -466,7 +466,7 @@ int CPDF_Font::FallbackGlyphFromCharcode(int fallbackFont, uint32_t charcode) {
if (!pdfium::IndexInBounds(m_FontFallbacks, fallbackFont))
return -1;
- CFX_WideString str = UnicodeFromCharCode(charcode);
+ WideString str = UnicodeFromCharCode(charcode);
uint32_t unicode = !str.IsEmpty() ? str[0] : charcode;
int glyph =
FXFT_Get_Char_Index(m_FontFallbacks[fallbackFont]->GetFace(), unicode);
diff --git a/core/fpdfapi/font/cpdf_font.h b/core/fpdfapi/font/cpdf_font.h
index f70542223c..e92e2f24e5 100644
--- a/core/fpdfapi/font/cpdf_font.h
+++ b/core/fpdfapi/font/cpdf_font.h
@@ -32,7 +32,7 @@ class CPDF_Font {
static std::unique_ptr<CPDF_Font> Create(CPDF_Document* pDoc,
CPDF_Dictionary* pFontDict);
static CPDF_Font* GetStockFont(CPDF_Document* pDoc,
- const CFX_ByteStringC& fontname);
+ const ByteStringView& fontname);
static const uint32_t kInvalidCharCode = static_cast<uint32_t>(-1);
virtual ~CPDF_Font();
@@ -59,17 +59,17 @@ class CPDF_Font {
virtual int AppendChar(char* buf, uint32_t charcode) const;
virtual int GlyphFromCharCode(uint32_t charcode, bool* pVertGlyph) = 0;
virtual int GlyphFromCharCodeExt(uint32_t charcode);
- virtual CFX_WideString UnicodeFromCharCode(uint32_t charcode) const;
+ virtual WideString UnicodeFromCharCode(uint32_t charcode) const;
virtual uint32_t CharCodeFromUnicode(wchar_t Unicode) const;
virtual bool HasFontWidths() const;
- const CFX_ByteString& GetBaseFont() const { return m_BaseFont; }
+ const ByteString& GetBaseFont() const { return m_BaseFont; }
CFX_SubstFont* GetSubstFont() const { return m_Font.GetSubstFont(); }
bool IsEmbedded() const { return IsType3Font() || m_pFontFile != nullptr; }
CPDF_Dictionary* GetFontDict() const { return m_pFontDict; }
bool IsStandardFont() const;
FXFT_Face GetFace() const { return m_Font.GetFace(); }
- void AppendChar(CFX_ByteString* str, uint32_t charcode) const;
+ void AppendChar(ByteString* str, uint32_t charcode) const;
void GetFontBBox(FX_RECT& rect) const { rect = m_FontBBox; }
int GetTypeAscent() const { return m_Ascent; }
@@ -97,20 +97,20 @@ class CPDF_Font {
void LoadUnicodeMap() const; // logically const only.
void LoadPDFEncoding(CPDF_Object* pEncoding,
int& iBaseEncoding,
- std::vector<CFX_ByteString>* pCharNames,
+ std::vector<ByteString>* pCharNames,
bool bEmbedded,
bool bTrueType);
void LoadFontDescriptor(CPDF_Dictionary* pDict);
void CheckFontMetrics();
const char* GetAdobeCharName(int iBaseEncoding,
- const std::vector<CFX_ByteString>& charnames,
+ const std::vector<ByteString>& charnames,
int charcode);
CFX_UnownedPtr<CPDF_Document> m_pDocument;
CFX_Font m_Font;
std::vector<std::unique_ptr<CFX_Font>> m_FontFallbacks;
- CFX_ByteString m_BaseFont;
+ ByteString m_BaseFont;
CFX_RetainPtr<CPDF_StreamAcc> m_pFontFile;
CPDF_Dictionary* m_pFontDict;
mutable std::unique_ptr<CPDF_ToUnicodeMap> m_pToUnicodeMap;
diff --git a/core/fpdfapi/font/cpdf_fontencoding.cpp b/core/fpdfapi/font/cpdf_fontencoding.cpp
index 2cc6445ab2..6290f20f5e 100644
--- a/core/fpdfapi/font/cpdf_fontencoding.cpp
+++ b/core/fpdfapi/font/cpdf_fontencoding.cpp
@@ -1672,7 +1672,7 @@ bool CPDF_FontEncoding::IsIdentical(CPDF_FontEncoding* pAnother) const {
}
std::unique_ptr<CPDF_Object> CPDF_FontEncoding::Realize(
- CFX_WeakPtr<CFX_ByteStringPool> pPool) {
+ CFX_WeakPtr<ByteStringPool> pPool) {
int predefined = 0;
for (int cs = PDFFONT_ENCODING_WINANSI; cs < PDFFONT_ENCODING_ZAPFDINGBATS;
cs++) {
@@ -1761,10 +1761,10 @@ wchar_t PDF_UnicodeFromAdobeName(const char* name) {
return (wchar_t)(FXFT_unicode_from_adobe_name(name) & 0x7FFFFFFF);
}
-CFX_ByteString PDF_AdobeNameFromUnicode(wchar_t unicode) {
+ByteString PDF_AdobeNameFromUnicode(wchar_t unicode) {
char glyph_name[64];
FXFT_adobe_name_from_unicode(glyph_name, unicode);
- return CFX_ByteString(glyph_name);
+ return ByteString(glyph_name);
}
const char* PDF_CharNameFromPredefinedCharSet(int encoding, uint8_t charcode) {
diff --git a/core/fpdfapi/font/cpdf_fontencoding.h b/core/fpdfapi/font/cpdf_fontencoding.h
index 7a94db9f0e..075cc04c7c 100644
--- a/core/fpdfapi/font/cpdf_fontencoding.h
+++ b/core/fpdfapi/font/cpdf_fontencoding.h
@@ -28,7 +28,7 @@ uint32_t FT_CharCodeFromUnicode(int encoding, wchar_t unicode);
wchar_t FT_UnicodeFromCharCode(int encoding, uint32_t charcode);
wchar_t PDF_UnicodeFromAdobeName(const char* name);
-CFX_ByteString PDF_AdobeNameFromUnicode(wchar_t unicode);
+ByteString PDF_AdobeNameFromUnicode(wchar_t unicode);
const uint16_t* PDF_UnicodesForPredefinedCharSet(int encoding);
const char* PDF_CharNameFromPredefinedCharSet(int encoding, uint8_t charcode);
@@ -53,7 +53,7 @@ class CPDF_FontEncoding {
m_Unicodes[charcode] = unicode;
}
- std::unique_ptr<CPDF_Object> Realize(CFX_WeakPtr<CFX_ByteStringPool> pPool);
+ std::unique_ptr<CPDF_Object> Realize(CFX_WeakPtr<ByteStringPool> pPool);
public:
wchar_t m_Unicodes[256];
diff --git a/core/fpdfapi/font/cpdf_simplefont.cpp b/core/fpdfapi/font/cpdf_simplefont.cpp
index 56a4b13cb3..ccf514db07 100644
--- a/core/fpdfapi/font/cpdf_simplefont.cpp
+++ b/core/fpdfapi/font/cpdf_simplefont.cpp
@@ -196,13 +196,13 @@ bool CPDF_SimpleFont::IsUnicodeCompatible() const {
m_BaseEncoding != PDFFONT_ENCODING_ZAPFDINGBATS;
}
-CFX_WideString CPDF_SimpleFont::UnicodeFromCharCode(uint32_t charcode) const {
- CFX_WideString unicode = CPDF_Font::UnicodeFromCharCode(charcode);
+WideString CPDF_SimpleFont::UnicodeFromCharCode(uint32_t charcode) const {
+ WideString unicode = CPDF_Font::UnicodeFromCharCode(charcode);
if (!unicode.IsEmpty())
return unicode;
wchar_t ret = m_Encoding.UnicodeFromCharCode((uint8_t)charcode);
if (ret == 0)
- return CFX_WideString();
+ return WideString();
return ret;
}
diff --git a/core/fpdfapi/font/cpdf_simplefont.h b/core/fpdfapi/font/cpdf_simplefont.h
index 6a22f46966..5291211b24 100644
--- a/core/fpdfapi/font/cpdf_simplefont.h
+++ b/core/fpdfapi/font/cpdf_simplefont.h
@@ -24,7 +24,7 @@ class CPDF_SimpleFont : public CPDF_Font {
FX_RECT GetCharBBox(uint32_t charcode) override;
int GlyphFromCharCode(uint32_t charcode, bool* pVertGlyph) override;
bool IsUnicodeCompatible() const override;
- CFX_WideString UnicodeFromCharCode(uint32_t charcode) const override;
+ WideString UnicodeFromCharCode(uint32_t charcode) const override;
uint32_t CharCodeFromUnicode(wchar_t Unicode) const override;
CPDF_FontEncoding* GetEncoding() { return &m_Encoding; }
@@ -41,7 +41,7 @@ class CPDF_SimpleFont : public CPDF_Font {
CPDF_FontEncoding m_Encoding;
uint16_t m_GlyphIndex[256];
uint16_t m_ExtGID[256];
- std::vector<CFX_ByteString> m_CharNames;
+ std::vector<ByteString> m_CharNames;
int m_BaseEncoding;
uint16_t m_CharWidth[256];
FX_RECT m_CharBBox[256];
diff --git a/core/fpdfapi/font/cpdf_tounicodemap.cpp b/core/fpdfapi/font/cpdf_tounicodemap.cpp
index 9076f4a737..354f5061c3 100644
--- a/core/fpdfapi/font/cpdf_tounicodemap.cpp
+++ b/core/fpdfapi/font/cpdf_tounicodemap.cpp
@@ -14,7 +14,7 @@
#include "core/fxcrt/fx_safe_types.h"
#include "third_party/base/numerics/safe_conversions.h"
-CFX_WideString CPDF_ToUnicodeMap::Lookup(uint32_t charcode) const {
+WideString CPDF_ToUnicodeMap::Lookup(uint32_t charcode) const {
auto it = m_Map.find(charcode);
if (it != m_Map.end()) {
uint32_t value = it->second;
@@ -25,22 +25,22 @@ CFX_WideString CPDF_ToUnicodeMap::Lookup(uint32_t charcode) const {
const wchar_t* buf = m_MultiCharBuf.GetBuffer();
uint32_t buf_len = m_MultiCharBuf.GetLength();
if (!buf || buf_len == 0) {
- return CFX_WideString();
+ return WideString();
}
uint32_t index = value >> 16;
if (index >= buf_len) {
- return CFX_WideString();
+ return WideString();
}
uint32_t len = buf[index];
if (index + len < index || index + len >= buf_len) {
- return CFX_WideString();
+ return WideString();
}
- return CFX_WideString(buf + index + 1, len);
+ return WideString(buf + index + 1, len);
}
if (m_pBaseMap) {
return m_pBaseMap->UnicodeFromCID((uint16_t)charcode);
}
- return CFX_WideString();
+ return WideString();
}
uint32_t CPDF_ToUnicodeMap::ReverseLookup(wchar_t unicode) const {
@@ -52,7 +52,7 @@ uint32_t CPDF_ToUnicodeMap::ReverseLookup(wchar_t unicode) const {
}
// Static.
-uint32_t CPDF_ToUnicodeMap::StringToCode(const CFX_ByteStringC& str) {
+uint32_t CPDF_ToUnicodeMap::StringToCode(const ByteStringView& str) {
int len = str.GetLength();
if (len == 0)
return 0;
@@ -70,8 +70,8 @@ uint32_t CPDF_ToUnicodeMap::StringToCode(const CFX_ByteStringC& str) {
return result;
}
-static CFX_WideString StringDataAdd(CFX_WideString str) {
- CFX_WideString ret;
+static WideString StringDataAdd(WideString str) {
+ WideString ret;
int len = str.GetLength();
wchar_t value = 1;
for (int i = len - 1; i >= 0; --i) {
@@ -89,13 +89,12 @@ static CFX_WideString StringDataAdd(CFX_WideString str) {
}
// Static.
-CFX_WideString CPDF_ToUnicodeMap::StringToWideString(
- const CFX_ByteStringC& str) {
+WideString CPDF_ToUnicodeMap::StringToWideString(const ByteStringView& str) {
int len = str.GetLength();
if (len == 0)
- return CFX_WideString();
+ return WideString();
- CFX_WideString result;
+ WideString result;
if (str[0] == '<') {
int byte_pos = 0;
wchar_t ch = 0;
@@ -129,7 +128,7 @@ void CPDF_ToUnicodeMap::Load(CPDF_Stream* pStream) {
pAcc->LoadAllData(false);
CPDF_SimpleParser parser(pAcc->GetData(), pAcc->GetSize());
while (1) {
- CFX_ByteStringC word = parser.GetWord();
+ ByteStringView word = parser.GetWord();
if (word.IsEmpty()) {
break;
}
@@ -141,7 +140,7 @@ void CPDF_ToUnicodeMap::Load(CPDF_Stream* pStream) {
}
uint32_t srccode = StringToCode(word);
word = parser.GetWord();
- CFX_WideString destcode = StringToWideString(word);
+ WideString destcode = StringToWideString(word);
int len = destcode.GetLength();
if (len == 0) {
continue;
@@ -156,23 +155,23 @@ void CPDF_ToUnicodeMap::Load(CPDF_Stream* pStream) {
}
} else if (word == "beginbfrange") {
while (1) {
- CFX_ByteString low, high;
+ ByteString low, high;
low = parser.GetWord();
if (low.IsEmpty() || low == "endbfrange") {
break;
}
high = parser.GetWord();
- uint32_t lowcode = StringToCode(low.AsStringC());
+ uint32_t lowcode = StringToCode(low.AsStringView());
uint32_t highcode =
- (lowcode & 0xffffff00) | (StringToCode(high.AsStringC()) & 0xff);
+ (lowcode & 0xffffff00) | (StringToCode(high.AsStringView()) & 0xff);
if (highcode == (uint32_t)-1) {
break;
}
- CFX_ByteString start(parser.GetWord());
+ ByteString start(parser.GetWord());
if (start == "[") {
for (uint32_t code = lowcode; code <= highcode; code++) {
- CFX_ByteString dest(parser.GetWord());
- CFX_WideString destcode = StringToWideString(dest.AsStringC());
+ ByteString dest(parser.GetWord());
+ WideString destcode = StringToWideString(dest.AsStringView());
int len = destcode.GetLength();
if (len == 0) {
continue;
@@ -187,17 +186,17 @@ void CPDF_ToUnicodeMap::Load(CPDF_Stream* pStream) {
}
parser.GetWord();
} else {
- CFX_WideString destcode = StringToWideString(start.AsStringC());
+ WideString destcode = StringToWideString(start.AsStringView());
int len = destcode.GetLength();
uint32_t value = 0;
if (len == 1) {
- value = StringToCode(start.AsStringC());
+ value = StringToCode(start.AsStringView());
for (uint32_t code = lowcode; code <= highcode; code++) {
m_Map[code] = value++;
}
} else {
for (uint32_t code = lowcode; code <= highcode; code++) {
- CFX_WideString retcode;
+ WideString retcode;
if (code == lowcode) {
retcode = destcode;
} else {
diff --git a/core/fpdfapi/font/cpdf_tounicodemap.h b/core/fpdfapi/font/cpdf_tounicodemap.h
index 90a2638462..4e11140e75 100644
--- a/core/fpdfapi/font/cpdf_tounicodemap.h
+++ b/core/fpdfapi/font/cpdf_tounicodemap.h
@@ -22,15 +22,15 @@ class CPDF_ToUnicodeMap {
void Load(CPDF_Stream* pStream);
- CFX_WideString Lookup(uint32_t charcode) const;
+ WideString Lookup(uint32_t charcode) const;
uint32_t ReverseLookup(wchar_t unicode) const;
private:
friend class cpdf_tounicodemap_StringToCode_Test;
friend class cpdf_tounicodemap_StringToWideString_Test;
- static uint32_t StringToCode(const CFX_ByteStringC& str);
- static CFX_WideString StringToWideString(const CFX_ByteStringC& str);
+ static uint32_t StringToCode(const ByteStringView& str);
+ static WideString StringToWideString(const ByteStringView& str);
uint32_t GetUnicode();
diff --git a/core/fpdfapi/font/cpdf_tounicodemap_unittest.cpp b/core/fpdfapi/font/cpdf_tounicodemap_unittest.cpp
index 299f4d9b1e..4a5dc25a4c 100644
--- a/core/fpdfapi/font/cpdf_tounicodemap_unittest.cpp
+++ b/core/fpdfapi/font/cpdf_tounicodemap_unittest.cpp
@@ -21,7 +21,7 @@ TEST(cpdf_tounicodemap, StringToWideString) {
EXPECT_EQ(L"", CPDF_ToUnicodeMap::StringToWideString("<c2"));
- CFX_WideString res = L"\xc2ab";
+ WideString res = L"\xc2ab";
EXPECT_EQ(res, CPDF_ToUnicodeMap::StringToWideString("<c2ab"));
EXPECT_EQ(res, CPDF_ToUnicodeMap::StringToWideString("<c2abab"));
EXPECT_EQ(res, CPDF_ToUnicodeMap::StringToWideString("<c2ab 1234"));
diff --git a/core/fpdfapi/font/cpdf_truetypefont.cpp b/core/fpdfapi/font/cpdf_truetypefont.cpp
index 5fde64693a..a0542ecba4 100644
--- a/core/fpdfapi/font/cpdf_truetypefont.cpp
+++ b/core/fpdfapi/font/cpdf_truetypefont.cpp
@@ -137,7 +137,7 @@ void CPDF_TrueTypeFont::LoadGlyphMap() {
if (m_GlyphIndex[charcode] != 0 || !bToUnicode)
continue;
- CFX_WideString wsUnicode = UnicodeFromCharCode(charcode);
+ WideString wsUnicode = UnicodeFromCharCode(charcode);
if (!wsUnicode.IsEmpty()) {
m_GlyphIndex[charcode] =
FXFT_Get_Char_Index(m_Font.GetFace(), wsUnicode[0]);
diff --git a/core/fpdfapi/page/cpdf_allstates.cpp b/core/fpdfapi/page/cpdf_allstates.cpp
index cedc8479bc..afc87a2b5a 100644
--- a/core/fpdfapi/page/cpdf_allstates.cpp
+++ b/core/fpdfapi/page/cpdf_allstates.cpp
@@ -39,7 +39,7 @@ void CPDF_AllStates::SetLineDash(CPDF_Array* pArray, float phase, float scale) {
void CPDF_AllStates::ProcessExtGS(CPDF_Dictionary* pGS,
CPDF_StreamContentParser* pParser) {
for (const auto& it : *pGS) {
- const CFX_ByteString& key_str = it.first;
+ const ByteString& key_str = it.first;
CPDF_Object* pElement = it.second.get();
CPDF_Object* pObject = pElement ? pElement->GetDirect() : nullptr;
if (!pObject)
diff --git a/core/fpdfapi/page/cpdf_colorspace.cpp b/core/fpdfapi/page/cpdf_colorspace.cpp
index aee7316bdf..c37b5a4177 100644
--- a/core/fpdfapi/page/cpdf_colorspace.cpp
+++ b/core/fpdfapi/page/cpdf_colorspace.cpp
@@ -198,7 +198,7 @@ class CPDF_IndexedCS : public CPDF_ColorSpace {
CFX_UnownedPtr<CPDF_CountedColorSpace> m_pCountedBaseCS;
int m_nBaseComponents;
int m_MaxIndex;
- CFX_ByteString m_Table;
+ ByteString m_Table;
float* m_pCompMinMax;
};
@@ -364,8 +364,7 @@ void XYZ_to_sRGB_WhitePoint(float X,
} // namespace
-CPDF_ColorSpace* CPDF_ColorSpace::ColorspaceFromName(
- const CFX_ByteString& name) {
+CPDF_ColorSpace* CPDF_ColorSpace::ColorspaceFromName(const ByteString& name) {
if (name == "DeviceRGB" || name == "RGB")
return CPDF_ColorSpace::GetStockCS(PDFCS_DEVICERGB);
if (name == "DeviceGray" || name == "G")
@@ -422,7 +421,7 @@ std::unique_ptr<CPDF_ColorSpace> CPDF_ColorSpace::Load(
if (!pFamilyObj)
return nullptr;
- CFX_ByteString familyname = pFamilyObj->GetString();
+ ByteString familyname = pFamilyObj->GetString();
if (pArray->GetCount() == 1)
return std::unique_ptr<CPDF_ColorSpace>(ColorspaceFromName(familyname));
@@ -1029,7 +1028,7 @@ bool CPDF_IndexedCS::v_Load(CPDF_Document* pDoc,
} else if (CPDF_Stream* pStream = pTableObj->AsStream()) {
auto pAcc = pdfium::MakeRetain<CPDF_StreamAcc>(pStream);
pAcc->LoadAllData(false);
- m_Table = CFX_ByteStringC(pAcc->GetData(), pAcc->GetSize());
+ m_Table = ByteStringView(pAcc->GetData(), pAcc->GetSize());
}
return true;
}
@@ -1080,7 +1079,7 @@ void CPDF_SeparationCS::GetDefaultValue(int iComponent,
bool CPDF_SeparationCS::v_Load(CPDF_Document* pDoc,
CPDF_Array* pArray,
std::set<CPDF_Object*>* pVisited) {
- CFX_ByteString name = pArray->GetStringAt(1);
+ ByteString name = pArray->GetStringAt(1);
if (name == "None") {
m_Type = None;
return true;
diff --git a/core/fpdfapi/page/cpdf_colorspace.h b/core/fpdfapi/page/cpdf_colorspace.h
index 31dd32629b..d9f9a1dd44 100644
--- a/core/fpdfapi/page/cpdf_colorspace.h
+++ b/core/fpdfapi/page/cpdf_colorspace.h
@@ -42,7 +42,7 @@ struct PatternValue {
class CPDF_ColorSpace {
public:
static CPDF_ColorSpace* GetStockCS(int Family);
- static CPDF_ColorSpace* ColorspaceFromName(const CFX_ByteString& name);
+ static CPDF_ColorSpace* ColorspaceFromName(const ByteString& name);
static std::unique_ptr<CPDF_ColorSpace> Load(CPDF_Document* pDoc,
CPDF_Object* pCSObj);
static std::unique_ptr<CPDF_ColorSpace> Load(
diff --git a/core/fpdfapi/page/cpdf_contentmark.cpp b/core/fpdfapi/page/cpdf_contentmark.cpp
index 07f0bd931d..7d411b2084 100644
--- a/core/fpdfapi/page/cpdf_contentmark.cpp
+++ b/core/fpdfapi/page/cpdf_contentmark.cpp
@@ -36,7 +36,7 @@ int CPDF_ContentMark::GetMCID() const {
return pData ? pData->GetMCID() : -1;
}
-void CPDF_ContentMark::AddMark(const CFX_ByteString& name,
+void CPDF_ContentMark::AddMark(const ByteString& name,
CPDF_Dictionary* pDict,
bool bDirect) {
m_Ref.GetPrivateCopy()->AddMark(name, pDict, bDirect);
@@ -48,7 +48,7 @@ void CPDF_ContentMark::DeleteLastMark() {
m_Ref.SetNull();
}
-bool CPDF_ContentMark::HasMark(const CFX_ByteStringC& mark) const {
+bool CPDF_ContentMark::HasMark(const ByteStringView& mark) const {
const MarkData* pData = m_Ref.GetObject();
if (!pData)
return false;
@@ -60,7 +60,7 @@ bool CPDF_ContentMark::HasMark(const CFX_ByteStringC& mark) const {
return false;
}
-bool CPDF_ContentMark::LookupMark(const CFX_ByteStringC& mark,
+bool CPDF_ContentMark::LookupMark(const ByteStringView& mark,
CPDF_Dictionary*& pDict) const {
const MarkData* pData = m_Ref.GetObject();
if (!pData)
@@ -105,7 +105,7 @@ int CPDF_ContentMark::MarkData::GetMCID() const {
return -1;
}
-void CPDF_ContentMark::MarkData::AddMark(const CFX_ByteString& name,
+void CPDF_ContentMark::MarkData::AddMark(const ByteString& name,
CPDF_Dictionary* pDict,
bool bDirect) {
CPDF_ContentMarkItem item;
diff --git a/core/fpdfapi/page/cpdf_contentmark.h b/core/fpdfapi/page/cpdf_contentmark.h
index ab966c0728..1b2fe79e3c 100644
--- a/core/fpdfapi/page/cpdf_contentmark.h
+++ b/core/fpdfapi/page/cpdf_contentmark.h
@@ -27,11 +27,9 @@ class CPDF_ContentMark {
int CountItems() const;
const CPDF_ContentMarkItem& GetItem(int i) const;
- bool HasMark(const CFX_ByteStringC& mark) const;
- bool LookupMark(const CFX_ByteStringC& mark, CPDF_Dictionary*& pDict) const;
- void AddMark(const CFX_ByteString& name,
- CPDF_Dictionary* pDict,
- bool bDirect);
+ bool HasMark(const ByteStringView& mark) const;
+ bool LookupMark(const ByteStringView& mark, CPDF_Dictionary*& pDict) const;
+ void AddMark(const ByteString& name, CPDF_Dictionary* pDict, bool bDirect);
void DeleteLastMark();
bool HasRef() const { return !!m_Ref; }
@@ -48,7 +46,7 @@ class CPDF_ContentMark {
const CPDF_ContentMarkItem& GetItem(int index) const;
int GetMCID() const;
- void AddMark(const CFX_ByteString& name,
+ void AddMark(const ByteString& name,
CPDF_Dictionary* pDict,
bool bDictNeedClone);
void DeleteLastMark();
diff --git a/core/fpdfapi/page/cpdf_contentmarkitem.h b/core/fpdfapi/page/cpdf_contentmarkitem.h
index afd2833691..83c700fc52 100644
--- a/core/fpdfapi/page/cpdf_contentmarkitem.h
+++ b/core/fpdfapi/page/cpdf_contentmarkitem.h
@@ -26,17 +26,17 @@ class CPDF_ContentMarkItem {
CPDF_ContentMarkItem& operator=(CPDF_ContentMarkItem&& other) = default;
- CFX_ByteString GetName() const { return m_MarkName; }
+ ByteString GetName() const { return m_MarkName; }
ParamType GetParamType() const { return m_ParamType; }
CPDF_Dictionary* GetParam() const;
bool HasMCID() const;
- void SetName(const CFX_ByteString& name) { m_MarkName = name; }
+ void SetName(const ByteString& name) { m_MarkName = name; }
void SetDirectDict(std::unique_ptr<CPDF_Dictionary> pDict);
void SetPropertiesDict(CPDF_Dictionary* pDict);
private:
- CFX_ByteString m_MarkName;
+ ByteString m_MarkName;
ParamType m_ParamType;
CFX_UnownedPtr<CPDF_Dictionary> m_pPropertiesDict;
std::unique_ptr<CPDF_Dictionary> m_pDirectDict;
diff --git a/core/fpdfapi/page/cpdf_docpagedata.cpp b/core/fpdfapi/page/cpdf_docpagedata.cpp
index 1af9d6ee22..08345dac78 100644
--- a/core/fpdfapi/page/cpdf_docpagedata.cpp
+++ b/core/fpdfapi/page/cpdf_docpagedata.cpp
@@ -144,7 +144,7 @@ CPDF_Font* CPDF_DocPageData::GetFont(CPDF_Dictionary* pFontDict) {
return pFontData->AddRef();
}
-CPDF_Font* CPDF_DocPageData::GetStandardFont(const CFX_ByteString& fontName,
+CPDF_Font* CPDF_DocPageData::GetStandardFont(const ByteString& fontName,
CPDF_FontEncoding* pEncoding) {
if (fontName.IsEmpty())
return nullptr;
@@ -228,7 +228,7 @@ CPDF_ColorSpace* CPDF_DocPageData::GetColorSpaceGuarded(
pdfium::ScopedSetInsertion<CPDF_Object*> insertion(pVisited, pCSObj);
if (pCSObj->IsName()) {
- CFX_ByteString name = pCSObj->GetString();
+ ByteString name = pCSObj->GetString();
CPDF_ColorSpace* pCS = CPDF_ColorSpace::ColorspaceFromName(name);
if (!pCS && pResources) {
CPDF_Dictionary* pList = pResources->GetDictFor("ColorSpace");
@@ -422,7 +422,7 @@ CFX_RetainPtr<CPDF_IccProfile> CPDF_DocPageData::GetIccProfile(
uint8_t digest[20];
CRYPT_SHA1Generate(pAccessor->GetData(), pAccessor->GetSize(), digest);
- CFX_ByteString bsDigest(digest, 20);
+ ByteString bsDigest(digest, 20);
auto hash_it = m_HashProfileMap.find(bsDigest);
if (hash_it != m_HashProfileMap.end()) {
auto it_copied_stream = m_IccProfileMap.find(hash_it->second);
diff --git a/core/fpdfapi/page/cpdf_docpagedata.h b/core/fpdfapi/page/cpdf_docpagedata.h
index 40647bc9a6..3f1d392262 100644
--- a/core/fpdfapi/page/cpdf_docpagedata.h
+++ b/core/fpdfapi/page/cpdf_docpagedata.h
@@ -35,7 +35,7 @@ class CPDF_DocPageData {
bool IsForceClear() const { return m_bForceClear; }
CPDF_Font* GetFont(CPDF_Dictionary* pFontDict);
- CPDF_Font* GetStandardFont(const CFX_ByteString& fontName,
+ CPDF_Font* GetStandardFont(const ByteString& fontName,
CPDF_FontEncoding* pEncoding);
void ReleaseFont(const CPDF_Dictionary* pFontDict);
@@ -70,7 +70,7 @@ class CPDF_DocPageData {
bool m_bForceClear;
CFX_UnownedPtr<CPDF_Document> const m_pPDFDoc;
- std::map<CFX_ByteString, CPDF_Stream*> m_HashProfileMap;
+ std::map<ByteString, CPDF_Stream*> m_HashProfileMap;
std::map<const CPDF_Object*, CPDF_CountedColorSpace*> m_ColorSpaceMap;
std::map<const CPDF_Stream*, CFX_RetainPtr<CPDF_StreamAcc>> m_FontFileMap;
std::map<const CPDF_Dictionary*, CPDF_CountedFont*> m_FontMap;
diff --git a/core/fpdfapi/page/cpdf_generalstate.cpp b/core/fpdfapi/page/cpdf_generalstate.cpp
index 540707447e..c5c259f051 100644
--- a/core/fpdfapi/page/cpdf_generalstate.cpp
+++ b/core/fpdfapi/page/cpdf_generalstate.cpp
@@ -13,7 +13,7 @@
namespace {
-int RI_StringToId(const CFX_ByteString& ri) {
+int RI_StringToId(const ByteString& ri) {
uint32_t id = ri.GetID();
if (id == FXBSTR_ID('A', 'b', 's', 'o'))
return 1;
@@ -27,7 +27,7 @@ int RI_StringToId(const CFX_ByteString& ri) {
return 0;
}
-int GetBlendTypeInternal(const CFX_ByteString& mode) {
+int GetBlendTypeInternal(const ByteString& mode) {
switch (mode.GetID()) {
case FXBSTR_ID('N', 'o', 'r', 'm'):
case FXBSTR_ID('C', 'o', 'm', 'p'):
@@ -75,45 +75,45 @@ CPDF_GeneralState::CPDF_GeneralState(const CPDF_GeneralState& that)
CPDF_GeneralState::~CPDF_GeneralState() {}
-void CPDF_GeneralState::SetRenderIntent(const CFX_ByteString& ri) {
+void CPDF_GeneralState::SetRenderIntent(const ByteString& ri) {
m_Ref.GetPrivateCopy()->m_RenderIntent = RI_StringToId(ri);
}
-CFX_ByteString CPDF_GeneralState::GetBlendMode() const {
+ByteString CPDF_GeneralState::GetBlendMode() const {
switch (GetBlendType()) {
case FXDIB_BLEND_NORMAL:
- return CFX_ByteString("Normal");
+ return ByteString("Normal");
case FXDIB_BLEND_MULTIPLY:
- return CFX_ByteString("Multiply");
+ return ByteString("Multiply");
case FXDIB_BLEND_SCREEN:
- return CFX_ByteString("Screen");
+ return ByteString("Screen");
case FXDIB_BLEND_OVERLAY:
- return CFX_ByteString("Overlay");
+ return ByteString("Overlay");
case FXDIB_BLEND_DARKEN:
- return CFX_ByteString("Darken");
+ return ByteString("Darken");
case FXDIB_BLEND_LIGHTEN:
- return CFX_ByteString("Lighten");
+ return ByteString("Lighten");
case FXDIB_BLEND_COLORDODGE:
- return CFX_ByteString("ColorDodge");
+ return ByteString("ColorDodge");
case FXDIB_BLEND_COLORBURN:
- return CFX_ByteString("ColorBurn");
+ return ByteString("ColorBurn");
case FXDIB_BLEND_HARDLIGHT:
- return CFX_ByteString("HardLight");
+ return ByteString("HardLight");
case FXDIB_BLEND_SOFTLIGHT:
- return CFX_ByteString("SoftLight");
+ return ByteString("SoftLight");
case FXDIB_BLEND_DIFFERENCE:
- return CFX_ByteString("Difference");
+ return ByteString("Difference");
case FXDIB_BLEND_EXCLUSION:
- return CFX_ByteString("Exclusion");
+ return ByteString("Exclusion");
case FXDIB_BLEND_HUE:
- return CFX_ByteString("Hue");
+ return ByteString("Hue");
case FXDIB_BLEND_SATURATION:
- return CFX_ByteString("Saturation");
+ return ByteString("Saturation");
case FXDIB_BLEND_COLOR:
- return CFX_ByteString("Color");
+ return ByteString("Color");
case FXDIB_BLEND_LUMINOSITY:
- return CFX_ByteString("Luminosity");
+ return ByteString("Luminosity");
}
- return CFX_ByteString("Normal");
+ return ByteString("Normal");
}
int CPDF_GeneralState::GetBlendType() const {
@@ -171,7 +171,7 @@ void CPDF_GeneralState::SetTransferFunc(
m_Ref.GetPrivateCopy()->m_pTransferFunc = pFunc;
}
-void CPDF_GeneralState::SetBlendMode(const CFX_ByteString& mode) {
+void CPDF_GeneralState::SetBlendMode(const ByteString& mode) {
StateData* pData = m_Ref.GetPrivateCopy();
pData->m_BlendMode = mode;
pData->m_BlendType = GetBlendTypeInternal(mode);
diff --git a/core/fpdfapi/page/cpdf_generalstate.h b/core/fpdfapi/page/cpdf_generalstate.h
index b5b48a94cd..95f59784f2 100644
--- a/core/fpdfapi/page/cpdf_generalstate.h
+++ b/core/fpdfapi/page/cpdf_generalstate.h
@@ -25,9 +25,9 @@ class CPDF_GeneralState {
void Emplace() { m_Ref.Emplace(); }
bool HasRef() const { return !!m_Ref; }
- void SetRenderIntent(const CFX_ByteString& ri);
+ void SetRenderIntent(const ByteString& ri);
- CFX_ByteString GetBlendMode() const;
+ ByteString GetBlendMode() const;
int GetBlendType() const;
void SetBlendType(int type);
@@ -46,7 +46,7 @@ class CPDF_GeneralState {
CFX_RetainPtr<CPDF_TransferFunc> GetTransferFunc() const;
void SetTransferFunc(const CFX_RetainPtr<CPDF_TransferFunc>& pFunc);
- void SetBlendMode(const CFX_ByteString& mode);
+ void SetBlendMode(const ByteString& mode);
const CFX_Matrix* GetSMaskMatrix() const;
void SetSMaskMatrix(const CFX_Matrix& matrix);
@@ -83,7 +83,7 @@ class CPDF_GeneralState {
StateData(const StateData& that);
~StateData();
- CFX_ByteString m_BlendMode;
+ ByteString m_BlendMode;
int m_BlendType;
CFX_UnownedPtr<CPDF_Object> m_pSoftMask;
CFX_Matrix m_SMaskMatrix;
diff --git a/core/fpdfapi/page/cpdf_image.cpp b/core/fpdfapi/page/cpdf_image.cpp
index a551bd1811..6e8c0e13c0 100644
--- a/core/fpdfapi/page/cpdf_image.cpp
+++ b/core/fpdfapi/page/cpdf_image.cpp
@@ -201,7 +201,7 @@ void CPDF_Image::SetImage(const CFX_RetainPtr<CFX_DIBitmap>& pBitmap) {
pCS->AddNew<CPDF_Name>("Indexed");
pCS->AddNew<CPDF_Name>("DeviceRGB");
pCS->AddNew<CPDF_Number>(1);
- CFX_ByteString ct;
+ ByteString ct;
char* pBuf = ct.GetBuffer(6);
pBuf[0] = (char)reset_r;
pBuf[1] = (char)reset_g;
diff --git a/core/fpdfapi/page/cpdf_page.cpp b/core/fpdfapi/page/cpdf_page.cpp
index 6213e5fccb..148b30a51c 100644
--- a/core/fpdfapi/page/cpdf_page.cpp
+++ b/core/fpdfapi/page/cpdf_page.cpp
@@ -97,7 +97,7 @@ void CPDF_Page::SetRenderContext(
m_pRenderContext = std::move(pContext);
}
-CPDF_Object* CPDF_Page::GetPageAttr(const CFX_ByteString& name) const {
+CPDF_Object* CPDF_Page::GetPageAttr(const ByteString& name) const {
CPDF_Dictionary* pPageDict = m_pFormDict.Get();
std::set<CPDF_Dictionary*> visited;
while (1) {
@@ -112,7 +112,7 @@ CPDF_Object* CPDF_Page::GetPageAttr(const CFX_ByteString& name) const {
return nullptr;
}
-CFX_FloatRect CPDF_Page::GetBox(const CFX_ByteString& name) const {
+CFX_FloatRect CPDF_Page::GetBox(const ByteString& name) const {
CFX_FloatRect box;
CPDF_Array* pBox = ToArray(GetPageAttr(name));
if (pBox) {
diff --git a/core/fpdfapi/page/cpdf_page.h b/core/fpdfapi/page/cpdf_page.h
index 47fba3caec..e32a7f0fe8 100644
--- a/core/fpdfapi/page/cpdf_page.h
+++ b/core/fpdfapi/page/cpdf_page.h
@@ -62,8 +62,8 @@ class CPDF_Page : public CPDF_PageObjectHolder {
private:
void StartParse();
- CPDF_Object* GetPageAttr(const CFX_ByteString& name) const;
- CFX_FloatRect GetBox(const CFX_ByteString& name) const;
+ CPDF_Object* GetPageAttr(const ByteString& name) const;
+ CFX_FloatRect GetBox(const ByteString& name) const;
float m_PageWidth;
float m_PageHeight;
diff --git a/core/fpdfapi/page/cpdf_pageobjectholder.h b/core/fpdfapi/page/cpdf_pageobjectholder.h
index 9ac1a3bdba..c223d4b523 100644
--- a/core/fpdfapi/page/cpdf_pageobjectholder.h
+++ b/core/fpdfapi/page/cpdf_pageobjectholder.h
@@ -37,8 +37,8 @@ struct GraphicsData {
};
struct FontData {
- CFX_ByteString baseFont;
- CFX_ByteString type;
+ ByteString baseFont;
+ ByteString type;
bool operator<(const FontData& other) const;
};
@@ -76,8 +76,8 @@ class CPDF_PageObjectHolder {
CFX_UnownedPtr<CPDF_Document> m_pDocument;
CFX_UnownedPtr<CPDF_Dictionary> m_pPageResources;
CFX_UnownedPtr<CPDF_Dictionary> m_pResources;
- std::map<GraphicsData, CFX_ByteString> m_GraphicsMap;
- std::map<FontData, CFX_ByteString> m_FontsMap;
+ std::map<GraphicsData, ByteString> m_GraphicsMap;
+ std::map<FontData, ByteString> m_FontsMap;
CFX_FloatRect m_BBox;
int m_Transparency;
diff --git a/core/fpdfapi/page/cpdf_psengine.cpp b/core/fpdfapi/page/cpdf_psengine.cpp
index 658d73cda3..63560fccc0 100644
--- a/core/fpdfapi/page/cpdf_psengine.cpp
+++ b/core/fpdfapi/page/cpdf_psengine.cpp
@@ -133,7 +133,7 @@ float CPDF_PSEngine::Pop() {
bool CPDF_PSEngine::Parse(const char* str, int size) {
CPDF_SimpleParser parser(reinterpret_cast<const uint8_t*>(str), size);
- CFX_ByteStringC word = parser.GetWord();
+ ByteStringView word = parser.GetWord();
return word == "{" ? m_MainProc.Parse(&parser, 0) : false;
}
@@ -142,7 +142,7 @@ bool CPDF_PSProc::Parse(CPDF_SimpleParser* parser, int depth) {
return false;
while (1) {
- CFX_ByteStringC word = parser->GetWord();
+ ByteStringView word = parser->GetWord();
if (word.IsEmpty())
return false;
@@ -158,7 +158,7 @@ bool CPDF_PSProc::Parse(CPDF_SimpleParser* parser, int depth) {
std::unique_ptr<CPDF_PSOP> op;
for (const PDF_PSOpName& op_name : kPsOpNames) {
- if (word == CFX_ByteStringC(op_name.name)) {
+ if (word == ByteStringView(op_name.name)) {
op = pdfium::MakeUnique<CPDF_PSOP>(op_name.op);
break;
}
diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.cpp b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
index 3755b2985a..c58e456238 100644
--- a/core/fpdfapi/page/cpdf_streamcontentparser.cpp
+++ b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
@@ -156,18 +156,17 @@ const AbbrPair InlineValueAbbr[] = {
struct AbbrReplacementOp {
bool is_replace_key;
- CFX_ByteString key;
- CFX_ByteStringC replacement;
+ ByteString key;
+ ByteStringView replacement;
};
-CFX_ByteStringC FindFullName(const AbbrPair* table,
- size_t count,
- const CFX_ByteStringC& abbr) {
+ByteStringView FindFullName(const AbbrPair* table,
+ size_t count,
+ const ByteStringView& abbr) {
auto* it = std::find_if(table, table + count, [abbr](const AbbrPair& pair) {
return pair.abbr == abbr;
});
- return it != table + count ? CFX_ByteStringC(it->full_name)
- : CFX_ByteStringC();
+ return it != table + count ? ByteStringView(it->full_name) : ByteStringView();
}
void ReplaceAbbr(CPDF_Object* pObj) {
@@ -176,10 +175,10 @@ void ReplaceAbbr(CPDF_Object* pObj) {
CPDF_Dictionary* pDict = pObj->AsDictionary();
std::vector<AbbrReplacementOp> replacements;
for (const auto& it : *pDict) {
- CFX_ByteString key = it.first;
+ ByteString key = it.first;
CPDF_Object* value = it.second.get();
- CFX_ByteStringC fullname = FindFullName(
- InlineKeyAbbr, FX_ArraySize(InlineKeyAbbr), key.AsStringC());
+ ByteStringView fullname = FindFullName(
+ InlineKeyAbbr, FX_ArraySize(InlineKeyAbbr), key.AsStringView());
if (!fullname.IsEmpty()) {
AbbrReplacementOp op;
op.is_replace_key = true;
@@ -190,9 +189,10 @@ void ReplaceAbbr(CPDF_Object* pObj) {
}
if (value->IsName()) {
- CFX_ByteString name = value->GetString();
- fullname = FindFullName(
- InlineValueAbbr, FX_ArraySize(InlineValueAbbr), name.AsStringC());
+ ByteString name = value->GetString();
+ fullname =
+ FindFullName(InlineValueAbbr, FX_ArraySize(InlineValueAbbr),
+ name.AsStringView());
if (!fullname.IsEmpty()) {
AbbrReplacementOp op;
op.is_replace_key = false;
@@ -206,9 +206,9 @@ void ReplaceAbbr(CPDF_Object* pObj) {
}
for (const auto& op : replacements) {
if (op.is_replace_key)
- pDict->ReplaceKey(op.key, CFX_ByteString(op.replacement));
+ pDict->ReplaceKey(op.key, ByteString(op.replacement));
else
- pDict->SetNewFor<CPDF_Name>(op.key, CFX_ByteString(op.replacement));
+ pDict->SetNewFor<CPDF_Name>(op.key, ByteString(op.replacement));
}
break;
}
@@ -217,11 +217,12 @@ void ReplaceAbbr(CPDF_Object* pObj) {
for (size_t i = 0; i < pArray->GetCount(); i++) {
CPDF_Object* pElement = pArray->GetObjectAt(i);
if (pElement->IsName()) {
- CFX_ByteString name = pElement->GetString();
- CFX_ByteStringC fullname = FindFullName(
- InlineValueAbbr, FX_ArraySize(InlineValueAbbr), name.AsStringC());
+ ByteString name = pElement->GetString();
+ ByteStringView fullname =
+ FindFullName(InlineValueAbbr, FX_ArraySize(InlineValueAbbr),
+ name.AsStringView());
if (!fullname.IsEmpty())
- pArray->SetNewAt<CPDF_Name>(i, CFX_ByteString(fullname));
+ pArray->SetNewAt<CPDF_Name>(i, ByteString(fullname));
} else {
ReplaceAbbr(pElement);
}
@@ -307,7 +308,7 @@ int CPDF_StreamContentParser::GetNextParamPos() {
return index;
}
-void CPDF_StreamContentParser::AddNameParam(const CFX_ByteStringC& bsName) {
+void CPDF_StreamContentParser::AddNameParam(const ByteStringView& bsName) {
ContentParam& param = m_ParamBuf[GetNextParamPos()];
if (bsName.GetLength() > 32) {
param.m_Type = ContentParam::OBJECT;
@@ -316,7 +317,7 @@ void CPDF_StreamContentParser::AddNameParam(const CFX_ByteStringC& bsName) {
} else {
param.m_Type = ContentParam::NAME;
if (bsName.Contains('#')) {
- CFX_ByteString str = PDF_NameDecode(bsName);
+ ByteString str = PDF_NameDecode(bsName);
memcpy(param.m_Name.m_Buffer, str.c_str(), str.GetLength());
param.m_Name.m_Len = str.GetLength();
} else {
@@ -326,7 +327,7 @@ void CPDF_StreamContentParser::AddNameParam(const CFX_ByteStringC& bsName) {
}
}
-void CPDF_StreamContentParser::AddNumberParam(const CFX_ByteStringC& str) {
+void CPDF_StreamContentParser::AddNumberParam(const ByteStringView& str) {
ContentParam& param = m_ParamBuf[GetNextParamPos()];
param.m_Type = ContentParam::NUMBER;
param.m_Number.m_bInteger = FX_atonum(str, &param.m_Number.m_Integer);
@@ -373,7 +374,7 @@ CPDF_Object* CPDF_StreamContentParser::GetObject(uint32_t index) {
param.m_Type = ContentParam::OBJECT;
param.m_pObject = pdfium::MakeUnique<CPDF_Name>(
m_pDocument->GetByteStringPool(),
- CFX_ByteString(param.m_Name.m_Buffer, param.m_Name.m_Len));
+ ByteString(param.m_Name.m_Buffer, param.m_Name.m_Len));
return param.m_pObject.get();
}
if (param.m_Type == ContentParam::OBJECT)
@@ -383,9 +384,9 @@ CPDF_Object* CPDF_StreamContentParser::GetObject(uint32_t index) {
return nullptr;
}
-CFX_ByteString CPDF_StreamContentParser::GetString(uint32_t index) {
+ByteString CPDF_StreamContentParser::GetString(uint32_t index) {
if (index >= m_ParamCount) {
- return CFX_ByteString();
+ return ByteString();
}
int real_index = m_ParamStartPos + m_ParamCount - index - 1;
if (real_index >= kParamBufSize) {
@@ -393,12 +394,12 @@ CFX_ByteString CPDF_StreamContentParser::GetString(uint32_t index) {
}
ContentParam& param = m_ParamBuf[real_index];
if (param.m_Type == ContentParam::NAME) {
- return CFX_ByteString(param.m_Name.m_Buffer, param.m_Name.m_Len);
+ return ByteString(param.m_Name.m_Buffer, param.m_Name.m_Len);
}
if (param.m_Type == 0 && param.m_pObject) {
return param.m_pObject->GetString();
}
- return CFX_ByteString();
+ return ByteString();
}
float CPDF_StreamContentParser::GetNumber(uint32_t index) {
@@ -559,7 +560,7 @@ CPDF_StreamContentParser::InitializeOpCodes() {
});
}
-void CPDF_StreamContentParser::OnOperator(const CFX_ByteStringC& op) {
+void CPDF_StreamContentParser::OnOperator(const ByteStringView& op) {
static const OpCodes s_OpCodes = InitializeOpCodes();
auto it = s_OpCodes.find(op.GetID());
@@ -586,7 +587,7 @@ void CPDF_StreamContentParser::Handle_EOFillStrokePath() {
}
void CPDF_StreamContentParser::Handle_BeginMarkedContent_Dictionary() {
- CFX_ByteString tag = GetString(1);
+ ByteString tag = GetString(1);
CPDF_Object* pProperty = GetObject(0);
if (!pProperty) {
return;
@@ -619,7 +620,7 @@ void CPDF_StreamContentParser::Handle_BeginImage() {
break;
}
auto word = m_pSyntax->GetWord();
- CFX_ByteString key(word.Right(word.GetLength() - 1));
+ ByteString key(word.Right(word.GetLength() - 1));
auto pObj = m_pSyntax->ReadNextObject(false, false, 0);
if (!key.IsEmpty()) {
uint32_t dwObjNum = pObj ? pObj->GetObjNum() : 0;
@@ -634,7 +635,7 @@ void CPDF_StreamContentParser::Handle_BeginImage() {
if (pDict->KeyExist("ColorSpace")) {
pCSObj = pDict->GetDirectObjectFor("ColorSpace");
if (pCSObj->IsName()) {
- CFX_ByteString name = pCSObj->GetString();
+ ByteString name = pCSObj->GetString();
if (name != "DeviceRGB" && name != "DeviceGray" && name != "DeviceCMYK") {
pCSObj = FindResourceObj("ColorSpace", name);
if (pCSObj && pCSObj->IsInline())
@@ -727,7 +728,7 @@ void CPDF_StreamContentParser::Handle_SetCachedDevice() {
}
void CPDF_StreamContentParser::Handle_ExecuteXObject() {
- CFX_ByteString name = GetString(0);
+ ByteString name = GetString(0);
if (name == m_LastImageName && m_pLastImage && m_pLastImage->GetStream() &&
m_pLastImage->GetStream()->GetObjNum()) {
CPDF_ImageObject* pObj = AddImage(m_pLastImage);
@@ -744,7 +745,7 @@ void CPDF_StreamContentParser::Handle_ExecuteXObject() {
return;
}
- CFX_ByteString type;
+ ByteString type;
if (pXObject->GetDict())
type = pXObject->GetDict()->GetStringFor("Subtype");
@@ -875,7 +876,7 @@ void CPDF_StreamContentParser::Handle_SetGray_Stroke() {
}
void CPDF_StreamContentParser::Handle_SetExtendGraphState() {
- CFX_ByteString name = GetString(0);
+ ByteString name = GetString(0);
CPDF_Dictionary* pGS = ToDictionary(FindResourceObj("ExtGState", name));
if (!pGS) {
m_bResourceMissing = true;
@@ -1155,9 +1156,8 @@ void CPDF_StreamContentParser::Handle_SetFont() {
}
}
-CPDF_Object* CPDF_StreamContentParser::FindResourceObj(
- const CFX_ByteString& type,
- const CFX_ByteString& name) {
+CPDF_Object* CPDF_StreamContentParser::FindResourceObj(const ByteString& type,
+ const ByteString& name) {
if (!m_pResources)
return nullptr;
CPDF_Dictionary* pDict = m_pResources->GetDictFor(type);
@@ -1170,7 +1170,7 @@ CPDF_Object* CPDF_StreamContentParser::FindResourceObj(
return pPageDict ? pPageDict->GetDirectObjectFor(name) : nullptr;
}
-CPDF_Font* CPDF_StreamContentParser::FindFont(const CFX_ByteString& name) {
+CPDF_Font* CPDF_StreamContentParser::FindFont(const ByteString& name) {
CPDF_Dictionary* pFontDict = ToDictionary(FindResourceObj("Font", name));
if (!pFontDict) {
m_bResourceMissing = true;
@@ -1186,12 +1186,12 @@ CPDF_Font* CPDF_StreamContentParser::FindFont(const CFX_ByteString& name) {
}
CPDF_ColorSpace* CPDF_StreamContentParser::FindColorSpace(
- const CFX_ByteString& name) {
+ const ByteString& name) {
if (name == "Pattern") {
return CPDF_ColorSpace::GetStockCS(PDFCS_PATTERN);
}
if (name == "DeviceGray" || name == "DeviceCMYK" || name == "DeviceRGB") {
- CFX_ByteString defname = "Default";
+ ByteString defname = "Default";
defname += name.Right(name.GetLength() - 7);
CPDF_Object* pDefObj = FindResourceObj("ColorSpace", defname);
if (!pDefObj) {
@@ -1213,7 +1213,7 @@ CPDF_ColorSpace* CPDF_StreamContentParser::FindColorSpace(
return m_pDocument->LoadColorSpace(pCSObj);
}
-CPDF_Pattern* CPDF_StreamContentParser::FindPattern(const CFX_ByteString& name,
+CPDF_Pattern* CPDF_StreamContentParser::FindPattern(const ByteString& name,
bool bShading) {
CPDF_Object* pPattern =
FindResourceObj(bShading ? "Shading" : "Pattern", name);
@@ -1225,7 +1225,7 @@ CPDF_Pattern* CPDF_StreamContentParser::FindPattern(const CFX_ByteString& name,
m_pCurStates->m_ParentMatrix);
}
-void CPDF_StreamContentParser::AddTextObject(CFX_ByteString* pStrs,
+void CPDF_StreamContentParser::AddTextObject(ByteString* pStrs,
float fInitKerning,
float* pKerning,
int nsegs) {
@@ -1290,7 +1290,7 @@ void CPDF_StreamContentParser::AddTextObject(CFX_ByteString* pStrs,
}
void CPDF_StreamContentParser::Handle_ShowText() {
- CFX_ByteString str = GetString(0);
+ ByteString str = GetString(0);
if (str.IsEmpty()) {
return;
}
@@ -1317,14 +1317,14 @@ void CPDF_StreamContentParser::Handle_ShowText_Positioning() {
}
return;
}
- std::vector<CFX_ByteString> strs(nsegs);
+ std::vector<ByteString> strs(nsegs);
std::vector<float> kernings(nsegs);
size_t iSegment = 0;
float fInitKerning = 0;
for (size_t i = 0; i < n; i++) {
CPDF_Object* pObj = pArray->GetDirectObjectAt(i);
if (pObj->IsString()) {
- CFX_ByteString str = pObj->GetString();
+ ByteString str = pObj->GetString();
if (str.IsEmpty())
continue;
strs[iSegment] = str;
@@ -1556,7 +1556,7 @@ void CPDF_StreamContentParser::ParsePathObject() {
case CPDF_StreamParser::EndOfData:
return;
case CPDF_StreamParser::Keyword: {
- CFX_ByteStringC strc = m_pSyntax->GetWord();
+ ByteStringView strc = m_pSyntax->GetWord();
int len = strc.GetLength();
if (len == 1) {
switch (strc[0]) {
@@ -1631,14 +1631,14 @@ void CPDF_StreamContentParser::ParsePathObject() {
}
// static
-CFX_ByteStringC CPDF_StreamContentParser::FindKeyAbbreviationForTesting(
- const CFX_ByteStringC& abbr) {
+ByteStringView CPDF_StreamContentParser::FindKeyAbbreviationForTesting(
+ const ByteStringView& abbr) {
return FindFullName(InlineKeyAbbr, FX_ArraySize(InlineKeyAbbr), abbr);
}
// static
-CFX_ByteStringC CPDF_StreamContentParser::FindValueAbbreviationForTesting(
- const CFX_ByteStringC& abbr) {
+ByteStringView CPDF_StreamContentParser::FindValueAbbreviationForTesting(
+ const ByteStringView& abbr) {
return FindFullName(InlineValueAbbr, FX_ArraySize(InlineValueAbbr), abbr);
}
diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.h b/core/fpdfapi/page/cpdf_streamcontentparser.h
index a027129c31..c30c6b7d3c 100644
--- a/core/fpdfapi/page/cpdf_streamcontentparser.h
+++ b/core/fpdfapi/page/cpdf_streamcontentparser.h
@@ -50,12 +50,12 @@ class CPDF_StreamContentParser {
CPDF_AllStates* GetCurStates() const { return m_pCurStates.get(); }
bool IsColored() const { return m_bColored; }
const float* GetType3Data() const { return m_Type3Data; }
- CPDF_Font* FindFont(const CFX_ByteString& name);
+ CPDF_Font* FindFont(const ByteString& name);
- static CFX_ByteStringC FindKeyAbbreviationForTesting(
- const CFX_ByteStringC& abbr);
- static CFX_ByteStringC FindValueAbbreviationForTesting(
- const CFX_ByteStringC& abbr);
+ static ByteStringView FindKeyAbbreviationForTesting(
+ const ByteStringView& abbr);
+ static ByteStringView FindValueAbbreviationForTesting(
+ const ByteStringView& abbr);
private:
struct ContentParam {
@@ -84,17 +84,17 @@ class CPDF_StreamContentParser {
using OpCodes = std::map<uint32_t, void (CPDF_StreamContentParser::*)()>;
static OpCodes InitializeOpCodes();
- void AddNameParam(const CFX_ByteStringC& str);
- void AddNumberParam(const CFX_ByteStringC& str);
+ void AddNameParam(const ByteStringView& str);
+ void AddNumberParam(const ByteStringView& str);
void AddObjectParam(std::unique_ptr<CPDF_Object> pObj);
int GetNextParamPos();
void ClearAllParams();
CPDF_Object* GetObject(uint32_t index);
- CFX_ByteString GetString(uint32_t index);
+ ByteString GetString(uint32_t index);
float GetNumber(uint32_t index);
int GetInteger(uint32_t index) { return (int32_t)(GetNumber(index)); }
- void OnOperator(const CFX_ByteStringC& op);
- void AddTextObject(CFX_ByteString* pText,
+ void OnOperator(const ByteStringView& op);
+ void AddTextObject(ByteString* pText,
float fInitKerning,
float* pKerning,
int count);
@@ -113,10 +113,9 @@ class CPDF_StreamContentParser {
bool bColor,
bool bText,
bool bGraph);
- CPDF_ColorSpace* FindColorSpace(const CFX_ByteString& name);
- CPDF_Pattern* FindPattern(const CFX_ByteString& name, bool bShading);
- CPDF_Object* FindResourceObj(const CFX_ByteString& type,
- const CFX_ByteString& name);
+ CPDF_ColorSpace* FindColorSpace(const ByteString& name);
+ CPDF_Pattern* FindPattern(const ByteString& name, bool bShading);
+ CPDF_Object* FindResourceObj(const ByteString& type, const ByteString& name);
// Takes ownership of |pImageObj|, returns unowned pointer to it.
CPDF_ImageObject* AddImageObject(std::unique_ptr<CPDF_ImageObject> pImageObj);
@@ -217,7 +216,7 @@ class CPDF_StreamContentParser {
float m_PathCurrentX;
float m_PathCurrentY;
uint8_t m_PathClipType;
- CFX_ByteString m_LastImageName;
+ ByteString m_LastImageName;
CFX_RetainPtr<CPDF_Image> m_pLastImage;
bool m_bColored;
float m_Type3Data[6];
diff --git a/core/fpdfapi/page/cpdf_streamcontentparser_unittest.cpp b/core/fpdfapi/page/cpdf_streamcontentparser_unittest.cpp
index 6b43935a1d..0f4fc1e87a 100644
--- a/core/fpdfapi/page/cpdf_streamcontentparser_unittest.cpp
+++ b/core/fpdfapi/page/cpdf_streamcontentparser_unittest.cpp
@@ -6,39 +6,39 @@
#include "testing/gtest/include/gtest/gtest.h"
TEST(cpdf_streamcontentparser, PDF_FindKeyAbbreviation) {
- EXPECT_EQ(CFX_ByteStringC("BitsPerComponent"),
+ EXPECT_EQ(ByteStringView("BitsPerComponent"),
CPDF_StreamContentParser::FindKeyAbbreviationForTesting(
- CFX_ByteStringC("BPC")));
- EXPECT_EQ(CFX_ByteStringC("Width"),
+ ByteStringView("BPC")));
+ EXPECT_EQ(ByteStringView("Width"),
CPDF_StreamContentParser::FindKeyAbbreviationForTesting(
- CFX_ByteStringC("W")));
- EXPECT_EQ(CFX_ByteStringC(""),
+ ByteStringView("W")));
+ EXPECT_EQ(ByteStringView(""),
CPDF_StreamContentParser::FindKeyAbbreviationForTesting(
- CFX_ByteStringC("")));
- EXPECT_EQ(CFX_ByteStringC(""),
+ ByteStringView("")));
+ EXPECT_EQ(ByteStringView(""),
CPDF_StreamContentParser::FindKeyAbbreviationForTesting(
- CFX_ByteStringC("NoInList")));
+ ByteStringView("NoInList")));
// Prefix should not match.
- EXPECT_EQ(CFX_ByteStringC(""),
+ EXPECT_EQ(ByteStringView(""),
CPDF_StreamContentParser::FindKeyAbbreviationForTesting(
- CFX_ByteStringC("WW")));
+ ByteStringView("WW")));
}
TEST(cpdf_streamcontentparser, PDF_FindValueAbbreviation) {
- EXPECT_EQ(CFX_ByteStringC("DeviceGray"),
+ EXPECT_EQ(ByteStringView("DeviceGray"),
CPDF_StreamContentParser::FindValueAbbreviationForTesting(
- CFX_ByteStringC("G")));
- EXPECT_EQ(CFX_ByteStringC("DCTDecode"),
+ ByteStringView("G")));
+ EXPECT_EQ(ByteStringView("DCTDecode"),
CPDF_StreamContentParser::FindValueAbbreviationForTesting(
- CFX_ByteStringC("DCT")));
- EXPECT_EQ(CFX_ByteStringC(""),
+ ByteStringView("DCT")));
+ EXPECT_EQ(ByteStringView(""),
CPDF_StreamContentParser::FindValueAbbreviationForTesting(
- CFX_ByteStringC("")));
- EXPECT_EQ(CFX_ByteStringC(""),
+ ByteStringView("")));
+ EXPECT_EQ(ByteStringView(""),
CPDF_StreamContentParser::FindValueAbbreviationForTesting(
- CFX_ByteStringC("NoInList")));
+ ByteStringView("NoInList")));
// Prefix should not match.
- EXPECT_EQ(CFX_ByteStringC(""),
+ EXPECT_EQ(ByteStringView(""),
CPDF_StreamContentParser::FindValueAbbreviationForTesting(
- CFX_ByteStringC("II")));
+ ByteStringView("II")));
}
diff --git a/core/fpdfapi/page/cpdf_streamparser.cpp b/core/fpdfapi/page/cpdf_streamparser.cpp
index f745331818..46cbfeb1fe 100644
--- a/core/fpdfapi/page/cpdf_streamparser.cpp
+++ b/core/fpdfapi/page/cpdf_streamparser.cpp
@@ -64,7 +64,7 @@ uint32_t DecodeInlineStream(const uint8_t* src_buf,
uint32_t limit,
int width,
int height,
- const CFX_ByteString& decoder,
+ const ByteString& decoder,
CPDF_Dictionary* pParam,
uint8_t** dest_buf,
uint32_t* dest_size) {
@@ -104,10 +104,9 @@ uint32_t DecodeInlineStream(const uint8_t* src_buf,
CPDF_StreamParser::CPDF_StreamParser(const uint8_t* pData, uint32_t dwSize)
: m_pBuf(pData), m_Size(dwSize), m_Pos(0), m_pPool(nullptr) {}
-CPDF_StreamParser::CPDF_StreamParser(
- const uint8_t* pData,
- uint32_t dwSize,
- const CFX_WeakPtr<CFX_ByteStringPool>& pPool)
+CPDF_StreamParser::CPDF_StreamParser(const uint8_t* pData,
+ uint32_t dwSize,
+ const CFX_WeakPtr<ByteStringPool>& pPool)
: m_pBuf(pData), m_Size(dwSize), m_Pos(0), m_pPool(pPool) {}
CPDF_StreamParser::~CPDF_StreamParser() {}
@@ -122,7 +121,7 @@ std::unique_ptr<CPDF_Stream> CPDF_StreamParser::ReadInlineStream(
if (PDFCharIsWhitespace(m_pBuf[m_Pos]))
m_Pos++;
- CFX_ByteString Decoder;
+ ByteString Decoder;
CPDF_Dictionary* pParam = nullptr;
CPDF_Object* pFilter = pDict->GetDirectObjectFor("Filter");
if (pFilter) {
@@ -312,18 +311,18 @@ std::unique_ptr<CPDF_Object> CPDF_StreamParser::ReadNextObject(
if (bIsNumber) {
m_WordBuffer[m_WordSize] = 0;
return pdfium::MakeUnique<CPDF_Number>(
- CFX_ByteStringC(m_WordBuffer, m_WordSize));
+ ByteStringView(m_WordBuffer, m_WordSize));
}
int first_char = m_WordBuffer[0];
if (first_char == '/') {
- CFX_ByteString name =
- PDF_NameDecode(CFX_ByteStringC(m_WordBuffer + 1, m_WordSize - 1));
+ ByteString name =
+ PDF_NameDecode(ByteStringView(m_WordBuffer + 1, m_WordSize - 1));
return pdfium::MakeUnique<CPDF_Name>(m_pPool, name);
}
if (first_char == '(') {
- CFX_ByteString str = ReadString();
+ ByteString str = ReadString();
return pdfium::MakeUnique<CPDF_String>(m_pPool, str, false);
}
@@ -340,8 +339,8 @@ std::unique_ptr<CPDF_Object> CPDF_StreamParser::ReadNextObject(
if (!m_WordSize || m_WordBuffer[0] != '/')
return nullptr;
- CFX_ByteString key =
- PDF_NameDecode(CFX_ByteStringC(m_WordBuffer + 1, m_WordSize - 1));
+ ByteString key =
+ PDF_NameDecode(ByteStringView(m_WordBuffer + 1, m_WordSize - 1));
std::unique_ptr<CPDF_Object> pObj =
ReadNextObject(true, bInArray, dwRecursionLevel + 1);
if (!pObj)
@@ -464,9 +463,9 @@ void CPDF_StreamParser::GetNextWord(bool& bIsNumber) {
}
}
-CFX_ByteString CPDF_StreamParser::ReadString() {
+ByteString CPDF_StreamParser::ReadString() {
if (!PositionIsInBounds())
- return CFX_ByteString();
+ return ByteString();
uint8_t ch = m_pBuf[m_Pos++];
std::ostringstream buf;
@@ -478,9 +477,9 @@ CFX_ByteString CPDF_StreamParser::ReadString() {
case 0:
if (ch == ')') {
if (parlevel == 0) {
- return CFX_ByteString(buf.str().c_str(),
- std::min(static_cast<FX_STRSIZE>(buf.tellp()),
- kMaxStringLength));
+ return ByteString(buf.str().c_str(),
+ std::min(static_cast<FX_STRSIZE>(buf.tellp()),
+ kMaxStringLength));
}
parlevel--;
buf << ')';
@@ -555,14 +554,14 @@ CFX_ByteString CPDF_StreamParser::ReadString() {
if (PositionIsInBounds())
++m_Pos;
- return CFX_ByteString(
+ return ByteString(
buf.str().c_str(),
std::min(static_cast<FX_STRSIZE>(buf.tellp()), kMaxStringLength));
}
-CFX_ByteString CPDF_StreamParser::ReadHexString() {
+ByteString CPDF_StreamParser::ReadHexString() {
if (!PositionIsInBounds())
- return CFX_ByteString();
+ return ByteString();
std::ostringstream buf;
bool bFirst = true;
@@ -588,7 +587,7 @@ CFX_ByteString CPDF_StreamParser::ReadHexString() {
if (!bFirst)
buf << static_cast<char>(code);
- return CFX_ByteString(
+ return ByteString(
buf.str().c_str(),
std::min(static_cast<FX_STRSIZE>(buf.tellp()), kMaxStringLength));
}
diff --git a/core/fpdfapi/page/cpdf_streamparser.h b/core/fpdfapi/page/cpdf_streamparser.h
index fdc418c634..32001a8b6e 100644
--- a/core/fpdfapi/page/cpdf_streamparser.h
+++ b/core/fpdfapi/page/cpdf_streamparser.h
@@ -24,12 +24,12 @@ class CPDF_StreamParser {
CPDF_StreamParser(const uint8_t* pData, uint32_t dwSize);
CPDF_StreamParser(const uint8_t* pData,
uint32_t dwSize,
- const CFX_WeakPtr<CFX_ByteStringPool>& pPool);
+ const CFX_WeakPtr<ByteStringPool>& pPool);
~CPDF_StreamParser();
SyntaxType ParseNextElement();
- CFX_ByteStringC GetWord() const {
- return CFX_ByteStringC(m_WordBuffer, m_WordSize);
+ ByteStringView GetWord() const {
+ return ByteStringView(m_WordBuffer, m_WordSize);
}
uint32_t GetPos() const { return m_Pos; }
void SetPos(uint32_t pos) { m_Pos = pos; }
@@ -46,8 +46,8 @@ class CPDF_StreamParser {
friend class cpdf_streamparser_ReadHexString_Test;
void GetNextWord(bool& bIsNumber);
- CFX_ByteString ReadString();
- CFX_ByteString ReadHexString();
+ ByteString ReadString();
+ ByteString ReadHexString();
bool PositionIsInBounds() const;
const uint8_t* m_pBuf;
@@ -56,7 +56,7 @@ class CPDF_StreamParser {
uint8_t m_WordBuffer[256];
uint32_t m_WordSize;
std::unique_ptr<CPDF_Object> m_pLastObj;
- CFX_WeakPtr<CFX_ByteStringPool> m_pPool;
+ CFX_WeakPtr<ByteStringPool> m_pPool;
};
#endif // CORE_FPDFAPI_PAGE_CPDF_STREAMPARSER_H_
diff --git a/core/fpdfapi/page/cpdf_textobject.cpp b/core/fpdfapi/page/cpdf_textobject.cpp
index a4d714ff72..4baf61dd72 100644
--- a/core/fpdfapi/page/cpdf_textobject.cpp
+++ b/core/fpdfapi/page/cpdf_textobject.cpp
@@ -136,7 +136,7 @@ CFX_Matrix CPDF_TextObject::GetTextMatrix() const {
pTextMatrix[3], m_Pos.x, m_Pos.y);
}
-void CPDF_TextObject::SetSegments(const CFX_ByteString* pStrs,
+void CPDF_TextObject::SetSegments(const ByteString* pStrs,
const float* pKerning,
int nsegs) {
m_CharCodes.clear();
@@ -162,7 +162,7 @@ void CPDF_TextObject::SetSegments(const CFX_ByteString* pStrs,
}
}
-void CPDF_TextObject::SetText(const CFX_ByteString& str) {
+void CPDF_TextObject::SetText(const ByteString& str) {
SetSegments(&str, nullptr, 1);
RecalcPositionData();
SetDirty(true);
diff --git a/core/fpdfapi/page/cpdf_textobject.h b/core/fpdfapi/page/cpdf_textobject.h
index e08b7280de..5cffbd1434 100644
--- a/core/fpdfapi/page/cpdf_textobject.h
+++ b/core/fpdfapi/page/cpdf_textobject.h
@@ -47,7 +47,7 @@ class CPDF_TextObject : public CPDF_PageObject {
CPDF_Font* GetFont() const;
float GetFontSize() const;
- void SetText(const CFX_ByteString& text);
+ void SetText(const ByteString& text);
void SetPosition(float x, float y);
void RecalcPositionData();
@@ -58,9 +58,7 @@ class CPDF_TextObject : public CPDF_PageObject {
friend class CPDF_TextRenderer;
friend class CPDF_PageContentGenerator;
- void SetSegments(const CFX_ByteString* pStrs,
- const float* pKerning,
- int nSegs);
+ void SetSegments(const ByteString* pStrs, const float* pKerning, int nSegs);
CFX_PointF CalcPositionData(float horz_scale);
diff --git a/core/fpdfapi/parser/cfdf_document.cpp b/core/fpdfapi/parser/cfdf_document.cpp
index 41827db0d9..1f84f56547 100644
--- a/core/fpdfapi/parser/cfdf_document.cpp
+++ b/core/fpdfapi/parser/cfdf_document.cpp
@@ -52,7 +52,7 @@ void CFDF_Document::ParseStream(
parser.InitParser(m_pFile, 0);
while (1) {
bool bNumber;
- CFX_ByteString word = parser.GetNextWord(&bNumber);
+ ByteString word = parser.GetNextWord(&bNumber);
if (bNumber) {
uint32_t objnum = FXSYS_atoui(word.c_str());
if (!objnum)
@@ -89,9 +89,9 @@ void CFDF_Document::ParseStream(
}
}
-CFX_ByteString CFDF_Document::WriteToString() const {
+ByteString CFDF_Document::WriteToString() const {
if (!m_pRootDict)
- return CFX_ByteString();
+ return ByteString();
std::ostringstream buf;
buf << "%FDF-1.2\r\n";
@@ -102,5 +102,5 @@ CFX_ByteString CFDF_Document::WriteToString() const {
buf << "trailer\r\n<</Root " << m_pRootDict->GetObjNum()
<< " 0 R>>\r\n%%EOF\r\n";
- return CFX_ByteString(buf);
+ return ByteString(buf);
}
diff --git a/core/fpdfapi/parser/cfdf_document.h b/core/fpdfapi/parser/cfdf_document.h
index d58f93ced4..a24415b099 100644
--- a/core/fpdfapi/parser/cfdf_document.h
+++ b/core/fpdfapi/parser/cfdf_document.h
@@ -27,7 +27,7 @@ class CFDF_Document : public CPDF_IndirectObjectHolder {
CFDF_Document();
~CFDF_Document() override;
- CFX_ByteString WriteToString() const;
+ ByteString WriteToString() const;
CPDF_Dictionary* GetRoot() const { return m_pRootDict.Get(); }
protected:
diff --git a/core/fpdfapi/parser/cpdf_array.cpp b/core/fpdfapi/parser/cpdf_array.cpp
index a0957b6c2b..f4907ffdf1 100644
--- a/core/fpdfapi/parser/cpdf_array.cpp
+++ b/core/fpdfapi/parser/cpdf_array.cpp
@@ -20,7 +20,7 @@
CPDF_Array::CPDF_Array() {}
-CPDF_Array::CPDF_Array(const CFX_WeakPtr<CFX_ByteStringPool>& pPool)
+CPDF_Array::CPDF_Array(const CFX_WeakPtr<ByteStringPool>& pPool)
: m_pPool(pPool) {}
CPDF_Array::~CPDF_Array() {
@@ -100,15 +100,15 @@ CPDF_Object* CPDF_Array::GetDirectObjectAt(size_t i) const {
return m_Objects[i]->GetDirect();
}
-CFX_ByteString CPDF_Array::GetStringAt(size_t i) const {
+ByteString CPDF_Array::GetStringAt(size_t i) const {
if (i >= m_Objects.size())
- return CFX_ByteString();
+ return ByteString();
return m_Objects[i]->GetString();
}
-CFX_WideString CPDF_Array::GetUnicodeTextAt(size_t i) const {
+WideString CPDF_Array::GetUnicodeTextAt(size_t i) const {
if (i >= m_Objects.size())
- return CFX_WideString();
+ return WideString();
return m_Objects[i]->GetUnicodeText();
}
diff --git a/core/fpdfapi/parser/cpdf_array.h b/core/fpdfapi/parser/cpdf_array.h
index d1be233652..3b18025b2d 100644
--- a/core/fpdfapi/parser/cpdf_array.h
+++ b/core/fpdfapi/parser/cpdf_array.h
@@ -24,7 +24,7 @@ class CPDF_Array : public CPDF_Object {
std::vector<std::unique_ptr<CPDF_Object>>::const_iterator;
CPDF_Array();
- explicit CPDF_Array(const CFX_WeakPtr<CFX_ByteStringPool>& pPool);
+ explicit CPDF_Array(const CFX_WeakPtr<ByteStringPool>& pPool);
~CPDF_Array() override;
// CPDF_Object:
@@ -39,8 +39,8 @@ class CPDF_Array : public CPDF_Object {
size_t GetCount() const { return m_Objects.size(); }
CPDF_Object* GetObjectAt(size_t index) const;
CPDF_Object* GetDirectObjectAt(size_t index) const;
- CFX_ByteString GetStringAt(size_t index) const;
- CFX_WideString GetUnicodeTextAt(size_t index) const;
+ ByteString GetStringAt(size_t index) const;
+ WideString GetUnicodeTextAt(size_t index) const;
int GetIntegerAt(size_t index) const;
float GetNumberAt(size_t index) const;
CPDF_Dictionary* GetDictAt(size_t index) const;
@@ -112,7 +112,7 @@ class CPDF_Array : public CPDF_Object {
std::set<const CPDF_Object*>* pVisited) const override;
std::vector<std::unique_ptr<CPDF_Object>> m_Objects;
- CFX_WeakPtr<CFX_ByteStringPool> m_pPool;
+ CFX_WeakPtr<ByteStringPool> m_pPool;
};
inline CPDF_Array* ToArray(CPDF_Object* obj) {
diff --git a/core/fpdfapi/parser/cpdf_boolean.cpp b/core/fpdfapi/parser/cpdf_boolean.cpp
index 2633c876d3..a1dc450519 100644
--- a/core/fpdfapi/parser/cpdf_boolean.cpp
+++ b/core/fpdfapi/parser/cpdf_boolean.cpp
@@ -22,7 +22,7 @@ std::unique_ptr<CPDF_Object> CPDF_Boolean::Clone() const {
return pdfium::MakeUnique<CPDF_Boolean>(m_bValue);
}
-CFX_ByteString CPDF_Boolean::GetString() const {
+ByteString CPDF_Boolean::GetString() const {
return m_bValue ? "true" : "false";
}
@@ -30,7 +30,7 @@ int CPDF_Boolean::GetInteger() const {
return m_bValue;
}
-void CPDF_Boolean::SetString(const CFX_ByteString& str) {
+void CPDF_Boolean::SetString(const ByteString& str) {
m_bValue = (str == "true");
}
@@ -48,5 +48,5 @@ const CPDF_Boolean* CPDF_Boolean::AsBoolean() const {
bool CPDF_Boolean::WriteTo(IFX_ArchiveStream* archive) const {
return archive->WriteString(" ") &&
- archive->WriteString(GetString().AsStringC());
+ archive->WriteString(GetString().AsStringView());
}
diff --git a/core/fpdfapi/parser/cpdf_boolean.h b/core/fpdfapi/parser/cpdf_boolean.h
index 2dd1486b6a..c0a69d8932 100644
--- a/core/fpdfapi/parser/cpdf_boolean.h
+++ b/core/fpdfapi/parser/cpdf_boolean.h
@@ -22,9 +22,9 @@ class CPDF_Boolean : public CPDF_Object {
// CPDF_Object:
Type GetType() const override;
std::unique_ptr<CPDF_Object> Clone() const override;
- CFX_ByteString GetString() const override;
+ ByteString GetString() const override;
int GetInteger() const override;
- void SetString(const CFX_ByteString& str) override;
+ void SetString(const ByteString& str) override;
bool IsBoolean() const override;
CPDF_Boolean* AsBoolean() override;
const CPDF_Boolean* AsBoolean() const override;
diff --git a/core/fpdfapi/parser/cpdf_crypto_handler.cpp b/core/fpdfapi/parser/cpdf_crypto_handler.cpp
index 74428ba6a8..cae95f2c19 100644
--- a/core/fpdfapi/parser/cpdf_crypto_handler.cpp
+++ b/core/fpdfapi/parser/cpdf_crypto_handler.cpp
@@ -230,14 +230,14 @@ bool CPDF_CryptoHandler::CryptFinish(void* context,
return true;
}
-CFX_ByteString CPDF_CryptoHandler::Decrypt(uint32_t objnum,
- uint32_t gennum,
- const CFX_ByteString& str) {
+ByteString CPDF_CryptoHandler::Decrypt(uint32_t objnum,
+ uint32_t gennum,
+ const ByteString& str) {
CFX_BinaryBuf dest_buf;
void* context = DecryptStart(objnum, gennum);
DecryptStream(context, str.raw_str(), str.GetLength(), dest_buf);
DecryptFinish(context, dest_buf);
- return CFX_ByteString(dest_buf.GetBuffer(), dest_buf.GetSize());
+ return ByteString(dest_buf.GetBuffer(), dest_buf.GetSize());
}
void* CPDF_CryptoHandler::DecryptStart(uint32_t objnum, uint32_t gennum) {
diff --git a/core/fpdfapi/parser/cpdf_crypto_handler.h b/core/fpdfapi/parser/cpdf_crypto_handler.h
index adf0c6c680..252f41c333 100644
--- a/core/fpdfapi/parser/cpdf_crypto_handler.h
+++ b/core/fpdfapi/parser/cpdf_crypto_handler.h
@@ -28,9 +28,7 @@ class CPDF_CryptoHandler : public CFX_Retainable {
CPDF_SecurityHandler* pSecurityHandler);
uint32_t DecryptGetSize(uint32_t src_size);
void* DecryptStart(uint32_t objnum, uint32_t gennum);
- CFX_ByteString Decrypt(uint32_t objnum,
- uint32_t gennum,
- const CFX_ByteString& str);
+ ByteString Decrypt(uint32_t objnum, uint32_t gennum, const ByteString& str);
bool DecryptStream(void* context,
const uint8_t* src_buf,
uint32_t src_size,
diff --git a/core/fpdfapi/parser/cpdf_data_avail.cpp b/core/fpdfapi/parser/cpdf_data_avail.cpp
index b10029d4ce..994d082712 100644
--- a/core/fpdfapi/parser/cpdf_data_avail.cpp
+++ b/core/fpdfapi/parser/cpdf_data_avail.cpp
@@ -473,7 +473,7 @@ bool CPDF_DataAvail::CheckPage() {
if (!pObj->IsDictionary())
continue;
- CFX_ByteString type = pObj->GetDict()->GetStringFor("Type");
+ ByteString type = pObj->GetDict()->GetStringFor("Type");
if (type == "Pages") {
m_PagesArray.push_back(std::move(pObj));
continue;
@@ -661,7 +661,7 @@ std::unique_ptr<CPDF_Object> CPDF_DataAvail::ParseIndirectObjectAt(
m_syntaxParser.SetPos(pos);
bool bIsNumber;
- CFX_ByteString word = m_syntaxParser.GetNextWord(&bIsNumber);
+ ByteString word = m_syntaxParser.GetNextWord(&bIsNumber);
if (!bIsNumber)
return nullptr;
@@ -723,7 +723,7 @@ bool CPDF_DataAvail::IsLinearizedFile(uint8_t* pData, uint32_t dwLen) {
m_syntaxParser.SetPos(m_syntaxParser.m_HeaderOffset + 9);
bool bNumber;
- CFX_ByteString wordObjNum = m_syntaxParser.GetNextWord(&bNumber);
+ ByteString wordObjNum = m_syntaxParser.GetNextWord(&bNumber);
if (!bNumber)
return false;
@@ -761,7 +761,7 @@ bool CPDF_DataAvail::CheckEnd() {
m_syntaxParser.GetNextWord(nullptr);
bool bNumber;
- CFX_ByteString xrefpos_str = m_syntaxParser.GetNextWord(&bNumber);
+ ByteString xrefpos_str = m_syntaxParser.GetNextWord(&bNumber);
if (!bNumber) {
m_docStatus = PDF_DATAAVAIL_ERROR;
return false;
@@ -781,7 +781,7 @@ void CPDF_DataAvail::SetStartOffset(FX_FILESIZE dwOffset) {
m_Pos = dwOffset;
}
-bool CPDF_DataAvail::GetNextToken(CFX_ByteString* token) {
+bool CPDF_DataAvail::GetNextToken(ByteString* token) {
uint8_t ch;
if (!GetNextChar(ch))
return false;
@@ -814,7 +814,7 @@ bool CPDF_DataAvail::GetNextToken(CFX_ByteString* token) {
if (!PDFCharIsOther(ch) && !PDFCharIsNumeric(ch)) {
m_Pos--;
- *token = CFX_ByteString(buffer, index);
+ *token = ByteString(buffer, index);
return true;
}
if (index < sizeof(buffer))
@@ -837,7 +837,7 @@ bool CPDF_DataAvail::GetNextToken(CFX_ByteString* token) {
else
m_Pos--;
}
- *token = CFX_ByteString(buffer, index);
+ *token = ByteString(buffer, index);
return true;
}
@@ -854,7 +854,7 @@ bool CPDF_DataAvail::GetNextToken(CFX_ByteString* token) {
}
}
- *token = CFX_ByteString(buffer, index);
+ *token = ByteString(buffer, index);
return true;
}
@@ -885,7 +885,7 @@ bool CPDF_DataAvail::GetNextChar(uint8_t& ch) {
}
bool CPDF_DataAvail::CheckCrossRefItem() {
- CFX_ByteString token;
+ ByteString token;
while (1) {
const CPDF_ReadValidator::Session read_session(GetValidator().Get());
if (!GetNextToken(&token)) {
@@ -904,7 +904,7 @@ bool CPDF_DataAvail::CheckCrossRefItem() {
bool CPDF_DataAvail::CheckCrossRef() {
const CPDF_ReadValidator::Session read_session(GetValidator().Get());
- CFX_ByteString token;
+ ByteString token;
if (!GetNextToken(&token)) {
if (!GetValidator()->has_read_problems())
m_docStatus = PDF_DATAAVAIL_ERROR;
@@ -1046,7 +1046,7 @@ bool CPDF_DataAvail::CheckUnknownPageNode(uint32_t dwPageNo,
pPageNode->m_dwPageNo = dwPageNo;
CPDF_Dictionary* pDict = pPage->GetDict();
- const CFX_ByteString type = pDict->GetStringFor("Type");
+ const ByteString type = pDict->GetStringFor("Type");
if (type == "Page") {
pPageNode->m_type = PDF_PAGENODE_PAGE;
return true;
diff --git a/core/fpdfapi/parser/cpdf_data_avail.h b/core/fpdfapi/parser/cpdf_data_avail.h
index e2a4a20aa1..850ceeaae2 100644
--- a/core/fpdfapi/parser/cpdf_data_avail.h
+++ b/core/fpdfapi/parser/cpdf_data_avail.h
@@ -145,7 +145,7 @@ class CPDF_DataAvail final {
bool IsLinearizedFile(uint8_t* pData, uint32_t dwLen);
void SetStartOffset(FX_FILESIZE dwOffset);
- bool GetNextToken(CFX_ByteString* token);
+ bool GetNextToken(ByteString* token);
bool GetNextChar(uint8_t& ch);
std::unique_ptr<CPDF_Object> ParseIndirectObjectAt(
FX_FILESIZE pos,
@@ -200,7 +200,7 @@ class CPDF_DataAvail final {
FX_FILESIZE m_Pos;
FX_FILESIZE m_bufferOffset;
uint32_t m_bufferSize;
- CFX_ByteString m_WordBuf;
+ ByteString m_WordBuf;
uint8_t m_bufferData[512];
std::vector<uint32_t> m_XRefStreamList;
std::vector<uint32_t> m_PageObjList;
diff --git a/core/fpdfapi/parser/cpdf_dictionary.cpp b/core/fpdfapi/parser/cpdf_dictionary.cpp
index 4c035871df..570c57e557 100644
--- a/core/fpdfapi/parser/cpdf_dictionary.cpp
+++ b/core/fpdfapi/parser/cpdf_dictionary.cpp
@@ -22,9 +22,9 @@
#include "third_party/base/stl_util.h"
CPDF_Dictionary::CPDF_Dictionary()
- : CPDF_Dictionary(CFX_WeakPtr<CFX_ByteStringPool>()) {}
+ : CPDF_Dictionary(CFX_WeakPtr<ByteStringPool>()) {}
-CPDF_Dictionary::CPDF_Dictionary(const CFX_WeakPtr<CFX_ByteStringPool>& pPool)
+CPDF_Dictionary::CPDF_Dictionary(const CFX_WeakPtr<ByteStringPool>& pPool)
: m_pPool(pPool) {}
CPDF_Dictionary::~CPDF_Dictionary() {
@@ -78,58 +78,56 @@ std::unique_ptr<CPDF_Object> CPDF_Dictionary::CloneNonCyclic(
return std::move(pCopy);
}
-CPDF_Object* CPDF_Dictionary::GetObjectFor(const CFX_ByteString& key) const {
+CPDF_Object* CPDF_Dictionary::GetObjectFor(const ByteString& key) const {
auto it = m_Map.find(key);
return it != m_Map.end() ? it->second.get() : nullptr;
}
-CPDF_Object* CPDF_Dictionary::GetDirectObjectFor(
- const CFX_ByteString& key) const {
+CPDF_Object* CPDF_Dictionary::GetDirectObjectFor(const ByteString& key) const {
CPDF_Object* p = GetObjectFor(key);
return p ? p->GetDirect() : nullptr;
}
-CFX_ByteString CPDF_Dictionary::GetStringFor(const CFX_ByteString& key) const {
+ByteString CPDF_Dictionary::GetStringFor(const ByteString& key) const {
CPDF_Object* p = GetObjectFor(key);
- return p ? p->GetString() : CFX_ByteString();
+ return p ? p->GetString() : ByteString();
}
-CFX_WideString CPDF_Dictionary::GetUnicodeTextFor(
- const CFX_ByteString& key) const {
+WideString CPDF_Dictionary::GetUnicodeTextFor(const ByteString& key) const {
CPDF_Object* p = GetObjectFor(key);
if (CPDF_Reference* pRef = ToReference(p))
p = pRef->GetDirect();
- return p ? p->GetUnicodeText() : CFX_WideString();
+ return p ? p->GetUnicodeText() : WideString();
}
-CFX_ByteString CPDF_Dictionary::GetStringFor(const CFX_ByteString& key,
- const CFX_ByteString& def) const {
+ByteString CPDF_Dictionary::GetStringFor(const ByteString& key,
+ const ByteString& def) const {
CPDF_Object* p = GetObjectFor(key);
- return p ? p->GetString() : CFX_ByteString(def);
+ return p ? p->GetString() : ByteString(def);
}
-int CPDF_Dictionary::GetIntegerFor(const CFX_ByteString& key) const {
+int CPDF_Dictionary::GetIntegerFor(const ByteString& key) const {
CPDF_Object* p = GetObjectFor(key);
return p ? p->GetInteger() : 0;
}
-int CPDF_Dictionary::GetIntegerFor(const CFX_ByteString& key, int def) const {
+int CPDF_Dictionary::GetIntegerFor(const ByteString& key, int def) const {
CPDF_Object* p = GetObjectFor(key);
return p ? p->GetInteger() : def;
}
-float CPDF_Dictionary::GetNumberFor(const CFX_ByteString& key) const {
+float CPDF_Dictionary::GetNumberFor(const ByteString& key) const {
CPDF_Object* p = GetObjectFor(key);
return p ? p->GetNumber() : 0;
}
-bool CPDF_Dictionary::GetBooleanFor(const CFX_ByteString& key,
+bool CPDF_Dictionary::GetBooleanFor(const ByteString& key,
bool bDefault) const {
CPDF_Object* p = GetObjectFor(key);
return ToBoolean(p) ? p->GetInteger() != 0 : bDefault;
}
-CPDF_Dictionary* CPDF_Dictionary::GetDictFor(const CFX_ByteString& key) const {
+CPDF_Dictionary* CPDF_Dictionary::GetDictFor(const ByteString& key) const {
CPDF_Object* p = GetDirectObjectFor(key);
if (!p)
return nullptr;
@@ -140,15 +138,15 @@ CPDF_Dictionary* CPDF_Dictionary::GetDictFor(const CFX_ByteString& key) const {
return nullptr;
}
-CPDF_Array* CPDF_Dictionary::GetArrayFor(const CFX_ByteString& key) const {
+CPDF_Array* CPDF_Dictionary::GetArrayFor(const ByteString& key) const {
return ToArray(GetDirectObjectFor(key));
}
-CPDF_Stream* CPDF_Dictionary::GetStreamFor(const CFX_ByteString& key) const {
+CPDF_Stream* CPDF_Dictionary::GetStreamFor(const ByteString& key) const {
return ToStream(GetDirectObjectFor(key));
}
-CFX_FloatRect CPDF_Dictionary::GetRectFor(const CFX_ByteString& key) const {
+CFX_FloatRect CPDF_Dictionary::GetRectFor(const ByteString& key) const {
CFX_FloatRect rect;
CPDF_Array* pArray = GetArrayFor(key);
if (pArray)
@@ -156,7 +154,7 @@ CFX_FloatRect CPDF_Dictionary::GetRectFor(const CFX_ByteString& key) const {
return rect;
}
-CFX_Matrix CPDF_Dictionary::GetMatrixFor(const CFX_ByteString& key) const {
+CFX_Matrix CPDF_Dictionary::GetMatrixFor(const ByteString& key) const {
CFX_Matrix matrix;
CPDF_Array* pArray = GetArrayFor(key);
if (pArray)
@@ -164,7 +162,7 @@ CFX_Matrix CPDF_Dictionary::GetMatrixFor(const CFX_ByteString& key) const {
return matrix;
}
-bool CPDF_Dictionary::KeyExist(const CFX_ByteString& key) const {
+bool CPDF_Dictionary::KeyExist(const ByteString& key) const {
return pdfium::ContainsKey(m_Map, key);
}
@@ -175,7 +173,7 @@ bool CPDF_Dictionary::IsSignatureDict() const {
return pType && pType->GetString() == "Sig";
}
-CPDF_Object* CPDF_Dictionary::SetFor(const CFX_ByteString& key,
+CPDF_Object* CPDF_Dictionary::SetFor(const ByteString& key,
std::unique_ptr<CPDF_Object> pObj) {
if (!pObj) {
m_Map.erase(key);
@@ -188,7 +186,7 @@ CPDF_Object* CPDF_Dictionary::SetFor(const CFX_ByteString& key,
}
void CPDF_Dictionary::ConvertToIndirectObjectFor(
- const CFX_ByteString& key,
+ const ByteString& key,
CPDF_IndirectObjectHolder* pHolder) {
auto it = m_Map.find(key);
if (it == m_Map.end() || it->second->IsReference())
@@ -198,8 +196,7 @@ void CPDF_Dictionary::ConvertToIndirectObjectFor(
it->second = pdfium::MakeUnique<CPDF_Reference>(pHolder, pObj->GetObjNum());
}
-std::unique_ptr<CPDF_Object> CPDF_Dictionary::RemoveFor(
- const CFX_ByteString& key) {
+std::unique_ptr<CPDF_Object> CPDF_Dictionary::RemoveFor(const ByteString& key) {
std::unique_ptr<CPDF_Object> result;
auto it = m_Map.find(key);
if (it != m_Map.end()) {
@@ -209,8 +206,8 @@ std::unique_ptr<CPDF_Object> CPDF_Dictionary::RemoveFor(
return result;
}
-void CPDF_Dictionary::ReplaceKey(const CFX_ByteString& oldkey,
- const CFX_ByteString& newkey) {
+void CPDF_Dictionary::ReplaceKey(const ByteString& oldkey,
+ const ByteString& newkey) {
auto old_it = m_Map.find(oldkey);
if (old_it == m_Map.end())
return;
@@ -223,7 +220,7 @@ void CPDF_Dictionary::ReplaceKey(const CFX_ByteString& oldkey,
m_Map.erase(old_it);
}
-void CPDF_Dictionary::SetRectFor(const CFX_ByteString& key,
+void CPDF_Dictionary::SetRectFor(const ByteString& key,
const CFX_FloatRect& rect) {
CPDF_Array* pArray = SetNewFor<CPDF_Array>(key);
pArray->AddNew<CPDF_Number>(rect.left);
@@ -232,7 +229,7 @@ void CPDF_Dictionary::SetRectFor(const CFX_ByteString& key,
pArray->AddNew<CPDF_Number>(rect.top);
}
-void CPDF_Dictionary::SetMatrixFor(const CFX_ByteString& key,
+void CPDF_Dictionary::SetMatrixFor(const ByteString& key,
const CFX_Matrix& matrix) {
CPDF_Array* pArray = SetNewFor<CPDF_Array>(key);
pArray->AddNew<CPDF_Number>(matrix.a);
@@ -243,7 +240,7 @@ void CPDF_Dictionary::SetMatrixFor(const CFX_ByteString& key,
pArray->AddNew<CPDF_Number>(matrix.f);
}
-CFX_ByteString CPDF_Dictionary::MaybeIntern(const CFX_ByteString& str) {
+ByteString CPDF_Dictionary::MaybeIntern(const ByteString& str) {
return m_pPool ? m_pPool->Intern(str) : str;
}
@@ -252,10 +249,10 @@ bool CPDF_Dictionary::WriteTo(IFX_ArchiveStream* archive) const {
return false;
for (const auto& it : *this) {
- const CFX_ByteString& key = it.first;
+ const ByteString& key = it.first;
CPDF_Object* pValue = it.second.get();
if (!archive->WriteString("/") ||
- !archive->WriteString(PDF_NameEncode(key).AsStringC())) {
+ !archive->WriteString(PDF_NameEncode(key).AsStringView())) {
return false;
}
diff --git a/core/fpdfapi/parser/cpdf_dictionary.h b/core/fpdfapi/parser/cpdf_dictionary.h
index 31a09d954d..93c00c8c10 100644
--- a/core/fpdfapi/parser/cpdf_dictionary.h
+++ b/core/fpdfapi/parser/cpdf_dictionary.h
@@ -24,10 +24,10 @@ class CPDF_IndirectObjectHolder;
class CPDF_Dictionary : public CPDF_Object {
public:
using const_iterator =
- std::map<CFX_ByteString, std::unique_ptr<CPDF_Object>>::const_iterator;
+ std::map<ByteString, std::unique_ptr<CPDF_Object>>::const_iterator;
CPDF_Dictionary();
- explicit CPDF_Dictionary(const CFX_WeakPtr<CFX_ByteStringPool>& pPool);
+ explicit CPDF_Dictionary(const CFX_WeakPtr<ByteStringPool>& pPool);
~CPDF_Dictionary() override;
// CPDF_Object:
@@ -40,76 +40,73 @@ class CPDF_Dictionary : public CPDF_Object {
bool WriteTo(IFX_ArchiveStream* archive) const override;
size_t GetCount() const { return m_Map.size(); }
- CPDF_Object* GetObjectFor(const CFX_ByteString& key) const;
- CPDF_Object* GetDirectObjectFor(const CFX_ByteString& key) const;
- CFX_ByteString GetStringFor(const CFX_ByteString& key) const;
- CFX_ByteString GetStringFor(const CFX_ByteString& key,
- const CFX_ByteString& default_str) const;
- CFX_WideString GetUnicodeTextFor(const CFX_ByteString& key) const;
- int GetIntegerFor(const CFX_ByteString& key) const;
- int GetIntegerFor(const CFX_ByteString& key, int default_int) const;
- bool GetBooleanFor(const CFX_ByteString& key, bool bDefault = false) const;
- float GetNumberFor(const CFX_ByteString& key) const;
- CPDF_Dictionary* GetDictFor(const CFX_ByteString& key) const;
- CPDF_Stream* GetStreamFor(const CFX_ByteString& key) const;
- CPDF_Array* GetArrayFor(const CFX_ByteString& key) const;
- CFX_FloatRect GetRectFor(const CFX_ByteString& key) const;
- CFX_Matrix GetMatrixFor(const CFX_ByteString& key) const;
- float GetFloatFor(const CFX_ByteString& key) const {
- return GetNumberFor(key);
- }
-
- bool KeyExist(const CFX_ByteString& key) const;
+ CPDF_Object* GetObjectFor(const ByteString& key) const;
+ CPDF_Object* GetDirectObjectFor(const ByteString& key) const;
+ ByteString GetStringFor(const ByteString& key) const;
+ ByteString GetStringFor(const ByteString& key,
+ const ByteString& default_str) const;
+ WideString GetUnicodeTextFor(const ByteString& key) const;
+ int GetIntegerFor(const ByteString& key) const;
+ int GetIntegerFor(const ByteString& key, int default_int) const;
+ bool GetBooleanFor(const ByteString& key, bool bDefault = false) const;
+ float GetNumberFor(const ByteString& key) const;
+ CPDF_Dictionary* GetDictFor(const ByteString& key) const;
+ CPDF_Stream* GetStreamFor(const ByteString& key) const;
+ CPDF_Array* GetArrayFor(const ByteString& key) const;
+ CFX_FloatRect GetRectFor(const ByteString& key) const;
+ CFX_Matrix GetMatrixFor(const ByteString& key) const;
+ float GetFloatFor(const ByteString& key) const { return GetNumberFor(key); }
+
+ bool KeyExist(const ByteString& key) const;
bool IsSignatureDict() const;
// Set* functions invalidate iterators for the element with the key |key|.
// Takes ownership of |pObj|, returns an unowned pointer to it.
- CPDF_Object* SetFor(const CFX_ByteString& key,
- std::unique_ptr<CPDF_Object> pObj);
+ CPDF_Object* SetFor(const ByteString& key, std::unique_ptr<CPDF_Object> pObj);
// Creates a new object owned by the dictionary and returns an unowned
// pointer to it.
template <typename T, typename... Args>
typename std::enable_if<!CanInternStrings<T>::value, T*>::type SetNewFor(
- const CFX_ByteString& key,
+ const ByteString& key,
Args&&... args) {
return static_cast<T*>(
SetFor(key, pdfium::MakeUnique<T>(std::forward<Args>(args)...)));
}
template <typename T, typename... Args>
typename std::enable_if<CanInternStrings<T>::value, T*>::type SetNewFor(
- const CFX_ByteString& key,
+ const ByteString& key,
Args&&... args) {
return static_cast<T*>(SetFor(
key, pdfium::MakeUnique<T>(m_pPool, std::forward<Args>(args)...)));
}
// Convenience functions to convert native objects to array form.
- void SetRectFor(const CFX_ByteString& key, const CFX_FloatRect& rect);
- void SetMatrixFor(const CFX_ByteString& key, const CFX_Matrix& matrix);
+ void SetRectFor(const ByteString& key, const CFX_FloatRect& rect);
+ void SetMatrixFor(const ByteString& key, const CFX_Matrix& matrix);
- void ConvertToIndirectObjectFor(const CFX_ByteString& key,
+ void ConvertToIndirectObjectFor(const ByteString& key,
CPDF_IndirectObjectHolder* pHolder);
// Invalidates iterators for the element with the key |key|.
- std::unique_ptr<CPDF_Object> RemoveFor(const CFX_ByteString& key);
+ std::unique_ptr<CPDF_Object> RemoveFor(const ByteString& key);
// Invalidates iterators for the element with the key |oldkey|.
- void ReplaceKey(const CFX_ByteString& oldkey, const CFX_ByteString& newkey);
+ void ReplaceKey(const ByteString& oldkey, const ByteString& newkey);
const_iterator begin() const { return m_Map.begin(); }
const_iterator end() const { return m_Map.end(); }
- CFX_WeakPtr<CFX_ByteStringPool> GetByteStringPool() const { return m_pPool; }
+ CFX_WeakPtr<ByteStringPool> GetByteStringPool() const { return m_pPool; }
protected:
- CFX_ByteString MaybeIntern(const CFX_ByteString& str);
+ ByteString MaybeIntern(const ByteString& str);
std::unique_ptr<CPDF_Object> CloneNonCyclic(
bool bDirect,
std::set<const CPDF_Object*>* visited) const override;
- CFX_WeakPtr<CFX_ByteStringPool> m_pPool;
- std::map<CFX_ByteString, std::unique_ptr<CPDF_Object>> m_Map;
+ CFX_WeakPtr<ByteStringPool> m_pPool;
+ std::map<ByteString, std::unique_ptr<CPDF_Object>> m_Map;
};
inline CPDF_Dictionary* ToDictionary(CPDF_Object* obj) {
diff --git a/core/fpdfapi/parser/cpdf_document.cpp b/core/fpdfapi/parser/cpdf_document.cpp
index 47155176ae..f47551f82b 100644
--- a/core/fpdfapi/parser/cpdf_document.cpp
+++ b/core/fpdfapi/parser/cpdf_document.cpp
@@ -217,8 +217,8 @@ void InsertWidthArray(HDC hDC, int start, int end, CPDF_Array* pWidthArray) {
InsertWidthArrayImpl(widths, size, pWidthArray);
}
-CFX_ByteString FPDF_GetPSNameFromTT(HDC hDC) {
- CFX_ByteString result;
+ByteString FPDF_GetPSNameFromTT(HDC hDC) {
+ ByteString result;
DWORD size = ::GetFontData(hDC, 'eman', 0, nullptr, 0);
if (size != GDI_ERROR) {
LPBYTE buffer = FX_Alloc(BYTE, size);
@@ -299,7 +299,7 @@ int CalculateFlags(bool bold,
void ProcessNonbCJK(CPDF_Dictionary* pBaseDict,
bool bold,
bool italic,
- CFX_ByteString basefont,
+ ByteString basefont,
std::unique_ptr<CPDF_Array> pWidths) {
if (bold && italic)
basefont += ",BoldItalic";
@@ -316,7 +316,7 @@ void ProcessNonbCJK(CPDF_Dictionary* pBaseDict,
std::unique_ptr<CPDF_Dictionary> CalculateFontDesc(
CPDF_Document* pDoc,
- CFX_ByteString basefont,
+ ByteString basefont,
int flags,
int italicangle,
int ascend,
@@ -769,7 +769,7 @@ void CPDF_Document::DeletePage(int iPage) {
CPDF_Font* CPDF_Document::AddStandardFont(const char* font,
CPDF_FontEncoding* pEncoding) {
- CFX_ByteString name(font);
+ ByteString name(font);
if (PDF_GetStandardFontName(&name) < 0)
return nullptr;
return GetPageData()->GetStandardFont(name, pEncoding);
@@ -793,7 +793,7 @@ size_t CPDF_Document::CalculateEncodingDict(int charset,
const uint16_t* pUnicodes = g_FX_CharsetUnicodes[i].m_pUnicodes;
for (int j = 0; j < 128; j++) {
- CFX_ByteString name = PDF_AdobeNameFromUnicode(pUnicodes[j]);
+ ByteString name = PDF_AdobeNameFromUnicode(pUnicodes[j]);
pArray->AddNew<CPDF_Name>(name.IsEmpty() ? ".notdef" : name);
}
pBaseDict->SetNewFor<CPDF_Reference>("Encoding", this,
@@ -805,11 +805,11 @@ CPDF_Dictionary* CPDF_Document::ProcessbCJK(
CPDF_Dictionary* pBaseDict,
int charset,
bool bVert,
- CFX_ByteString basefont,
+ ByteString basefont,
std::function<void(wchar_t, wchar_t, CPDF_Array*)> Insert) {
CPDF_Dictionary* pFontDict = NewIndirect<CPDF_Dictionary>();
- CFX_ByteString cmap;
- CFX_ByteString ordering;
+ ByteString cmap;
+ ByteString ordering;
int supplement = 0;
CPDF_Array* pWidthArray = pFontDict->SetNewFor<CPDF_Array>("W");
switch (charset) {
@@ -875,7 +875,7 @@ CPDF_Font* CPDF_Document::AddFont(CFX_Font* pFont, int charset, bool bVert) {
bool bCJK = charset == FX_CHARSET_ChineseTraditional ||
charset == FX_CHARSET_ChineseSimplified ||
charset == FX_CHARSET_Hangul || charset == FX_CHARSET_ShiftJIS;
- CFX_ByteString basefont = pFont->GetFamilyName();
+ ByteString basefont = pFont->GetFamilyName();
basefont.Replace(" ", "");
int flags =
CalculateFlags(pFont->IsBold(), pFont->IsItalic(), pFont->IsFixedWidth(),
@@ -958,12 +958,12 @@ CPDF_Font* CPDF_Document::AddWindowsFont(LOGFONTW* pLogFont,
bool bTranslateName) {
LOGFONTA lfa;
memcpy(&lfa, pLogFont, (char*)lfa.lfFaceName - (char*)&lfa);
- CFX_ByteString face = CFX_ByteString::FromUnicode(pLogFont->lfFaceName);
+ ByteString face = ByteString::FromUnicode(pLogFont->lfFaceName);
if (face.GetLength() >= LF_FACESIZE)
return nullptr;
strncpy(lfa.lfFaceName, face.c_str(),
- (face.GetLength() + 1) * sizeof(CFX_ByteString::CharType));
+ (face.GetLength() + 1) * sizeof(ByteString::CharType));
return AddWindowsFont(&lfa, bVert, bTranslateName);
}
@@ -996,7 +996,7 @@ CPDF_Font* CPDF_Document::AddWindowsFont(LOGFONTA* pLogFont,
pLogFont->lfCharSet == FX_CHARSET_ChineseSimplified ||
pLogFont->lfCharSet == FX_CHARSET_Hangul ||
pLogFont->lfCharSet == FX_CHARSET_ShiftJIS;
- CFX_ByteString basefont;
+ ByteString basefont;
if (bTranslateName && bCJK)
basefont = FPDF_GetPSNameFromTT(hDC);
diff --git a/core/fpdfapi/parser/cpdf_document.h b/core/fpdfapi/parser/cpdf_document.h
index cc5076379e..ff80fa85c3 100644
--- a/core/fpdfapi/parser/cpdf_document.h
+++ b/core/fpdfapi/parser/cpdf_document.h
@@ -122,7 +122,7 @@ class CPDF_Document : public CPDF_IndirectObjectHolder {
CPDF_Dictionary* pBaseDict,
int charset,
bool bVert,
- CFX_ByteString basefont,
+ ByteString basefont,
std::function<void(wchar_t, wchar_t, CPDF_Array*)> Insert);
bool InsertDeletePDFPage(CPDF_Dictionary* pPages,
int nPagesToGo,
diff --git a/core/fpdfapi/parser/cpdf_indirect_object_holder.cpp b/core/fpdfapi/parser/cpdf_indirect_object_holder.cpp
index 434470abeb..2a57411368 100644
--- a/core/fpdfapi/parser/cpdf_indirect_object_holder.cpp
+++ b/core/fpdfapi/parser/cpdf_indirect_object_holder.cpp
@@ -23,7 +23,7 @@ CPDF_Object* FilterInvalidObjNum(CPDF_Object* obj) {
CPDF_IndirectObjectHolder::CPDF_IndirectObjectHolder()
: m_LastObjNum(0),
- m_pByteStringPool(pdfium::MakeUnique<CFX_ByteStringPool>()) {}
+ m_pByteStringPool(pdfium::MakeUnique<ByteStringPool>()) {}
CPDF_IndirectObjectHolder::~CPDF_IndirectObjectHolder() {
m_pByteStringPool.DeleteObject(); // Make weak.
diff --git a/core/fpdfapi/parser/cpdf_indirect_object_holder.h b/core/fpdfapi/parser/cpdf_indirect_object_holder.h
index b82377e5b7..ab99dd5fcc 100644
--- a/core/fpdfapi/parser/cpdf_indirect_object_holder.h
+++ b/core/fpdfapi/parser/cpdf_indirect_object_holder.h
@@ -58,7 +58,7 @@ class CPDF_IndirectObjectHolder {
uint32_t GetLastObjNum() const { return m_LastObjNum; }
void SetLastObjNum(uint32_t objnum) { m_LastObjNum = objnum; }
- CFX_WeakPtr<CFX_ByteStringPool> GetByteStringPool() const {
+ CFX_WeakPtr<ByteStringPool> GetByteStringPool() const {
return m_pByteStringPool;
}
@@ -72,7 +72,7 @@ class CPDF_IndirectObjectHolder {
uint32_t m_LastObjNum;
std::map<uint32_t, std::unique_ptr<CPDF_Object>> m_IndirectObjs;
std::vector<std::unique_ptr<CPDF_Object>> m_OrphanObjs;
- CFX_WeakPtr<CFX_ByteStringPool> m_pByteStringPool;
+ CFX_WeakPtr<ByteStringPool> m_pByteStringPool;
};
#endif // CORE_FPDFAPI_PARSER_CPDF_INDIRECT_OBJECT_HOLDER_H_
diff --git a/core/fpdfapi/parser/cpdf_name.cpp b/core/fpdfapi/parser/cpdf_name.cpp
index ae33bc7fa0..0dd9890702 100644
--- a/core/fpdfapi/parser/cpdf_name.cpp
+++ b/core/fpdfapi/parser/cpdf_name.cpp
@@ -10,8 +10,7 @@
#include "core/fxcrt/fx_stream.h"
#include "third_party/base/ptr_util.h"
-CPDF_Name::CPDF_Name(CFX_WeakPtr<CFX_ByteStringPool> pPool,
- const CFX_ByteString& str)
+CPDF_Name::CPDF_Name(CFX_WeakPtr<ByteStringPool> pPool, const ByteString& str)
: m_Name(str) {
if (pPool)
m_Name = pPool->Intern(m_Name);
@@ -27,11 +26,11 @@ std::unique_ptr<CPDF_Object> CPDF_Name::Clone() const {
return pdfium::MakeUnique<CPDF_Name>(nullptr, m_Name);
}
-CFX_ByteString CPDF_Name::GetString() const {
+ByteString CPDF_Name::GetString() const {
return m_Name;
}
-void CPDF_Name::SetString(const CFX_ByteString& str) {
+void CPDF_Name::SetString(const ByteString& str) {
m_Name = str;
}
@@ -47,11 +46,11 @@ const CPDF_Name* CPDF_Name::AsName() const {
return this;
}
-CFX_WideString CPDF_Name::GetUnicodeText() const {
+WideString CPDF_Name::GetUnicodeText() const {
return PDF_DecodeText(m_Name);
}
bool CPDF_Name::WriteTo(IFX_ArchiveStream* archive) const {
return archive->WriteString("/") &&
- archive->WriteString(PDF_NameEncode(GetString()).AsStringC());
+ archive->WriteString(PDF_NameEncode(GetString()).AsStringView());
}
diff --git a/core/fpdfapi/parser/cpdf_name.h b/core/fpdfapi/parser/cpdf_name.h
index 616f35f9bc..72a72a3a66 100644
--- a/core/fpdfapi/parser/cpdf_name.h
+++ b/core/fpdfapi/parser/cpdf_name.h
@@ -15,22 +15,22 @@
class CPDF_Name : public CPDF_Object {
public:
- CPDF_Name(CFX_WeakPtr<CFX_ByteStringPool> pPool, const CFX_ByteString& str);
+ CPDF_Name(CFX_WeakPtr<ByteStringPool> pPool, const ByteString& str);
~CPDF_Name() override;
// CPDF_Object:
Type GetType() const override;
std::unique_ptr<CPDF_Object> Clone() const override;
- CFX_ByteString GetString() const override;
- CFX_WideString GetUnicodeText() const override;
- void SetString(const CFX_ByteString& str) override;
+ ByteString GetString() const override;
+ WideString GetUnicodeText() const override;
+ void SetString(const ByteString& str) override;
bool IsName() const override;
CPDF_Name* AsName() override;
const CPDF_Name* AsName() const override;
bool WriteTo(IFX_ArchiveStream* archive) const override;
protected:
- CFX_ByteString m_Name;
+ ByteString m_Name;
};
inline CPDF_Name* ToName(CPDF_Object* obj) {
diff --git a/core/fpdfapi/parser/cpdf_number.cpp b/core/fpdfapi/parser/cpdf_number.cpp
index 9afe30adca..dac1f40b7f 100644
--- a/core/fpdfapi/parser/cpdf_number.cpp
+++ b/core/fpdfapi/parser/cpdf_number.cpp
@@ -14,7 +14,7 @@ CPDF_Number::CPDF_Number(int value) : m_bInteger(true), m_Integer(value) {}
CPDF_Number::CPDF_Number(float value) : m_bInteger(false), m_Float(value) {}
-CPDF_Number::CPDF_Number(const CFX_ByteStringC& str)
+CPDF_Number::CPDF_Number(const ByteStringView& str)
: m_bInteger(FX_atonum(str, &m_Integer)) {}
CPDF_Number::~CPDF_Number() {}
@@ -48,16 +48,16 @@ const CPDF_Number* CPDF_Number::AsNumber() const {
return this;
}
-void CPDF_Number::SetString(const CFX_ByteString& str) {
- m_bInteger = FX_atonum(str.AsStringC(), &m_Integer);
+void CPDF_Number::SetString(const ByteString& str) {
+ m_bInteger = FX_atonum(str.AsStringView(), &m_Integer);
}
-CFX_ByteString CPDF_Number::GetString() const {
- return m_bInteger ? CFX_ByteString::FormatInteger(m_Integer)
- : CFX_ByteString::FormatFloat(m_Float);
+ByteString CPDF_Number::GetString() const {
+ return m_bInteger ? ByteString::FormatInteger(m_Integer)
+ : ByteString::FormatFloat(m_Float);
}
bool CPDF_Number::WriteTo(IFX_ArchiveStream* archive) const {
return archive->WriteString(" ") &&
- archive->WriteString(GetString().AsStringC());
+ archive->WriteString(GetString().AsStringView());
}
diff --git a/core/fpdfapi/parser/cpdf_number.h b/core/fpdfapi/parser/cpdf_number.h
index 57f82274cb..661177363b 100644
--- a/core/fpdfapi/parser/cpdf_number.h
+++ b/core/fpdfapi/parser/cpdf_number.h
@@ -18,16 +18,16 @@ class CPDF_Number : public CPDF_Object {
CPDF_Number();
explicit CPDF_Number(int value);
explicit CPDF_Number(float value);
- explicit CPDF_Number(const CFX_ByteStringC& str);
+ explicit CPDF_Number(const ByteStringView& str);
~CPDF_Number() override;
// CPDF_Object:
Type GetType() const override;
std::unique_ptr<CPDF_Object> Clone() const override;
- CFX_ByteString GetString() const override;
+ ByteString GetString() const override;
float GetNumber() const override;
int GetInteger() const override;
- void SetString(const CFX_ByteString& str) override;
+ void SetString(const ByteString& str) override;
bool IsNumber() const override;
CPDF_Number* AsNumber() override;
const CPDF_Number* AsNumber() const override;
diff --git a/core/fpdfapi/parser/cpdf_object.cpp b/core/fpdfapi/parser/cpdf_object.cpp
index b35c6e5b6f..67632a040c 100644
--- a/core/fpdfapi/parser/cpdf_object.cpp
+++ b/core/fpdfapi/parser/cpdf_object.cpp
@@ -39,12 +39,12 @@ std::unique_ptr<CPDF_Object> CPDF_Object::CloneNonCyclic(
return Clone();
}
-CFX_ByteString CPDF_Object::GetString() const {
- return CFX_ByteString();
+ByteString CPDF_Object::GetString() const {
+ return ByteString();
}
-CFX_WideString CPDF_Object::GetUnicodeText() const {
- return CFX_WideString();
+WideString CPDF_Object::GetUnicodeText() const {
+ return WideString();
}
float CPDF_Object::GetNumber() const {
@@ -59,7 +59,7 @@ CPDF_Dictionary* CPDF_Object::GetDict() const {
return nullptr;
}
-void CPDF_Object::SetString(const CFX_ByteString& str) {
+void CPDF_Object::SetString(const ByteString& str) {
NOTREACHED();
}
diff --git a/core/fpdfapi/parser/cpdf_object.h b/core/fpdfapi/parser/cpdf_object.h
index a07ba677e8..4d4279f98a 100644
--- a/core/fpdfapi/parser/cpdf_object.h
+++ b/core/fpdfapi/parser/cpdf_object.h
@@ -55,13 +55,13 @@ class CPDF_Object {
virtual std::unique_ptr<CPDF_Object> CloneDirectObject() const;
virtual CPDF_Object* GetDirect() const;
- virtual CFX_ByteString GetString() const;
- virtual CFX_WideString GetUnicodeText() const;
+ virtual ByteString GetString() const;
+ virtual WideString GetUnicodeText() const;
virtual float GetNumber() const;
virtual int GetInteger() const;
virtual CPDF_Dictionary* GetDict() const;
- virtual void SetString(const CFX_ByteString& str);
+ virtual void SetString(const ByteString& str);
virtual bool IsArray() const;
virtual bool IsBoolean() const;
diff --git a/core/fpdfapi/parser/cpdf_object_walker.cpp b/core/fpdfapi/parser/cpdf_object_walker.cpp
index c6e0f0091d..cb59a05d06 100644
--- a/core/fpdfapi/parser/cpdf_object_walker.cpp
+++ b/core/fpdfapi/parser/cpdf_object_walker.cpp
@@ -57,11 +57,11 @@ class DictionaryIterator : public CPDF_ObjectWalker::SubobjectIterator {
dict_iterator_ = object()->GetDict()->begin();
}
- const CFX_ByteString& dict_key() const { return dict_key_; }
+ const ByteString& dict_key() const { return dict_key_; }
private:
CPDF_Dictionary::const_iterator dict_iterator_;
- CFX_ByteString dict_key_;
+ ByteString dict_key_;
};
class ArrayIterator : public CPDF_ObjectWalker::SubobjectIterator {
@@ -149,11 +149,11 @@ const CPDF_Object* CPDF_ObjectWalker::GetNext() {
parent_object_ = it->object();
dict_key_ = parent_object_->IsDictionary()
? static_cast<DictionaryIterator*>(it)->dict_key()
- : CFX_ByteString();
+ : ByteString();
current_depth_ = stack_.size();
}
}
- dict_key_ = CFX_ByteString();
+ dict_key_ = ByteString();
current_depth_ = 0;
return nullptr;
}
diff --git a/core/fpdfapi/parser/cpdf_object_walker.h b/core/fpdfapi/parser/cpdf_object_walker.h
index 5590440f8f..8cad3c32f3 100644
--- a/core/fpdfapi/parser/cpdf_object_walker.h
+++ b/core/fpdfapi/parser/cpdf_object_walker.h
@@ -41,7 +41,7 @@ class CPDF_ObjectWalker {
size_t current_depth() const { return current_depth_; }
const CPDF_Object* GetParent() const { return parent_object_; }
- const CFX_ByteString& dictionary_key() const { return dict_key_; }
+ const ByteString& dictionary_key() const { return dict_key_; }
private:
static std::unique_ptr<SubobjectIterator> MakeIterator(
@@ -50,7 +50,7 @@ class CPDF_ObjectWalker {
const CPDF_Object* next_object_;
const CPDF_Object* parent_object_;
- CFX_ByteString dict_key_;
+ ByteString dict_key_;
size_t current_depth_;
std::stack<std::unique_ptr<SubobjectIterator>> stack_;
diff --git a/core/fpdfapi/parser/cpdf_parser.cpp b/core/fpdfapi/parser/cpdf_parser.cpp
index a9cad02f5e..b0a8126a3d 100644
--- a/core/fpdfapi/parser/cpdf_parser.cpp
+++ b/core/fpdfapi/parser/cpdf_parser.cpp
@@ -239,7 +239,7 @@ CPDF_Parser::Error CPDF_Parser::StartParseInternal(CPDF_Document* pDocument) {
m_pSyntax->GetKeyword();
bool bNumber;
- CFX_ByteString xrefpos_str = m_pSyntax->GetNextWord(&bNumber);
+ ByteString xrefpos_str = m_pSyntax->GetNextWord(&bNumber);
if (!bNumber)
return FORMAT_ERROR;
@@ -314,7 +314,7 @@ CPDF_Parser::Error CPDF_Parser::SetEncryptHandler() {
}
if (m_pEncryptDict) {
- CFX_ByteString filter = m_pEncryptDict->GetStringFor("Filter");
+ ByteString filter = m_pEncryptDict->GetStringFor("Filter");
if (filter != "Standard")
return HANDLER_ERROR;
@@ -364,7 +364,7 @@ bool CPDF_Parser::VerifyCrossRefV4() {
FX_FILESIZE SavedPos = m_pSyntax->GetPos();
m_pSyntax->SetPos(it.second.pos);
bool is_num = false;
- CFX_ByteString num_str = m_pSyntax->GetNextWord(&is_num);
+ ByteString num_str = m_pSyntax->GetNextWord(&is_num);
m_pSyntax->SetPos(SavedPos);
if (!is_num || num_str.IsEmpty() ||
FXSYS_atoui(num_str.c_str()) != it.first) {
@@ -593,7 +593,7 @@ bool CPDF_Parser::ParseCrossRefV4(std::vector<CrossRefObjData>* out_objects) {
while (1) {
FX_FILESIZE SavedPos = m_pSyntax->GetPos();
bool bIsNumber;
- CFX_ByteString word = m_pSyntax->GetNextWord(&bIsNumber);
+ ByteString word = m_pSyntax->GetNextWord(&bIsNumber);
if (word.IsEmpty()) {
return false;
}
@@ -884,7 +884,7 @@ bool CPDF_Parser::RebuildCrossRef() {
m_ObjectInfo[pRef->GetRefObjNum()].pos != 0)) {
auto it = pTrailer->begin();
while (it != pTrailer->end()) {
- const CFX_ByteString& key = it->first;
+ const ByteString& key = it->first;
CPDF_Object* pElement = it->second.get();
++it;
uint32_t dwObjNum =
@@ -903,11 +903,10 @@ bool CPDF_Parser::RebuildCrossRef() {
: std::move(pObj)));
FX_FILESIZE dwSavePos = m_pSyntax->GetPos();
- CFX_ByteString strWord = m_pSyntax->GetKeyword();
+ ByteString strWord = m_pSyntax->GetKeyword();
if (!strWord.Compare("startxref")) {
bool bNumber;
- CFX_ByteString bsOffset =
- m_pSyntax->GetNextWord(&bNumber);
+ ByteString bsOffset = m_pSyntax->GetNextWord(&bNumber);
if (bNumber)
m_LastXRefOffset = FXSYS_atoi(bsOffset.c_str());
}
@@ -1316,7 +1315,7 @@ bool CPDF_Parser::ParseLinearizedHeader() {
FX_FILESIZE SavedPos = m_pSyntax->GetPos();
bool bIsNumber;
- CFX_ByteString word = m_pSyntax->GetNextWord(&bIsNumber);
+ ByteString word = m_pSyntax->GetNextWord(&bIsNumber);
if (!bIsNumber)
return false;
diff --git a/core/fpdfapi/parser/cpdf_parser.h b/core/fpdfapi/parser/cpdf_parser.h
index b4d0bee329..20bd6be9b4 100644
--- a/core/fpdfapi/parser/cpdf_parser.h
+++ b/core/fpdfapi/parser/cpdf_parser.h
@@ -63,7 +63,7 @@ class CPDF_Parser {
CPDF_Document* pDocument);
void SetPassword(const char* password) { m_Password = password; }
- CFX_ByteString GetPassword() { return m_Password; }
+ ByteString GetPassword() { return m_Password; }
CPDF_Dictionary* GetTrailer() const;
FX_FILESIZE GetLastXRefOffset() const { return m_LastXRefOffset; }
@@ -199,7 +199,7 @@ class CPDF_Parser {
CFX_UnownedPtr<CPDF_Dictionary> m_pEncryptDict;
FX_FILESIZE m_LastXRefOffset;
std::unique_ptr<CPDF_SecurityHandler> m_pSecurityHandler;
- CFX_ByteString m_Password;
+ ByteString m_Password;
std::unique_ptr<TrailerData> m_TrailerData;
std::unique_ptr<CPDF_LinearizedHeader> m_pLinearized;
uint32_t m_dwLinearizedFirstPageXRefStartObjNum;
diff --git a/core/fpdfapi/parser/cpdf_reference.cpp b/core/fpdfapi/parser/cpdf_reference.cpp
index ce4c308d8c..2ca0bddc4f 100644
--- a/core/fpdfapi/parser/cpdf_reference.cpp
+++ b/core/fpdfapi/parser/cpdf_reference.cpp
@@ -20,9 +20,9 @@ CPDF_Object::Type CPDF_Reference::GetType() const {
return REFERENCE;
}
-CFX_ByteString CPDF_Reference::GetString() const {
+ByteString CPDF_Reference::GetString() const {
CPDF_Object* obj = SafeGetDirect();
- return obj ? obj->GetString() : CFX_ByteString();
+ return obj ? obj->GetString() : ByteString();
}
float CPDF_Reference::GetNumber() const {
diff --git a/core/fpdfapi/parser/cpdf_reference.h b/core/fpdfapi/parser/cpdf_reference.h
index ab160302fe..f564ab5b9b 100644
--- a/core/fpdfapi/parser/cpdf_reference.h
+++ b/core/fpdfapi/parser/cpdf_reference.h
@@ -24,7 +24,7 @@ class CPDF_Reference : public CPDF_Object {
Type GetType() const override;
std::unique_ptr<CPDF_Object> Clone() const override;
CPDF_Object* GetDirect() const override;
- CFX_ByteString GetString() const override;
+ ByteString GetString() const override;
float GetNumber() const override;
int GetInteger() const override;
CPDF_Dictionary* GetDict() const override;
diff --git a/core/fpdfapi/parser/cpdf_security_handler.cpp b/core/fpdfapi/parser/cpdf_security_handler.cpp
index 03b90abf4a..b838e9cf05 100644
--- a/core/fpdfapi/parser/cpdf_security_handler.cpp
+++ b/core/fpdfapi/parser/cpdf_security_handler.cpp
@@ -42,12 +42,12 @@ void CalcEncryptKey(CPDF_Dictionary* pEncrypt,
CRYPT_md5_context md5;
CRYPT_MD5Start(&md5);
CRYPT_MD5Update(&md5, passcode, 32);
- CFX_ByteString okey = pEncrypt->GetStringFor("O");
+ ByteString okey = pEncrypt->GetStringFor("O");
CRYPT_MD5Update(&md5, (uint8_t*)okey.c_str(), okey.GetLength());
uint32_t perm = pEncrypt->GetIntegerFor("P");
CRYPT_MD5Update(&md5, (uint8_t*)&perm, 4);
if (pIdArray) {
- CFX_ByteString id = pIdArray->GetStringAt(0);
+ ByteString id = pIdArray->GetStringAt(0);
CRYPT_MD5Update(&md5, (uint8_t*)id.c_str(), id.GetLength());
}
if (!bIgnoreMeta && revision >= 3 &&
@@ -97,7 +97,7 @@ bool CPDF_SecurityHandler::OnInit(CPDF_Parser* pParser,
}
bool CPDF_SecurityHandler::CheckSecurity(int32_t key_len) {
- CFX_ByteString password = m_pParser->GetPassword();
+ ByteString password = m_pParser->GetPassword();
if (!password.IsEmpty() &&
CheckPassword(password.raw_str(), password.GetLength(), true,
m_EncryptKey, key_len)) {
@@ -113,7 +113,7 @@ uint32_t CPDF_SecurityHandler::GetPermissions() {
}
static bool LoadCryptInfo(CPDF_Dictionary* pEncryptDict,
- const CFX_ByteString& name,
+ const ByteString& name,
int& cipher,
int& keylen) {
int Version = pEncryptDict->GetIntegerFor("V");
@@ -144,7 +144,7 @@ static bool LoadCryptInfo(CPDF_Dictionary* pEncryptDict,
nKeyBits *= 8;
}
keylen = nKeyBits / 8;
- CFX_ByteString cipher_name = pDefFilter->GetStringFor("CFM");
+ ByteString cipher_name = pDefFilter->GetStringFor("CFM");
if (cipher_name == "AESV2" || cipher_name == "AESV3") {
cipher = FXCIPHER_AES;
}
@@ -164,10 +164,10 @@ bool CPDF_SecurityHandler::LoadDict(CPDF_Dictionary* pEncryptDict) {
m_Revision = pEncryptDict->GetIntegerFor("R");
m_Permissions = pEncryptDict->GetIntegerFor("P", -1);
if (m_Version < 4)
- return LoadCryptInfo(pEncryptDict, CFX_ByteString(), m_Cipher, m_KeyLen);
+ return LoadCryptInfo(pEncryptDict, ByteString(), m_Cipher, m_KeyLen);
- CFX_ByteString stmf_name = pEncryptDict->GetStringFor("StmF");
- CFX_ByteString strf_name = pEncryptDict->GetStringFor("StrF");
+ ByteString stmf_name = pEncryptDict->GetStringFor("StmF");
+ ByteString strf_name = pEncryptDict->GetStringFor("StrF");
if (stmf_name != strf_name)
return false;
@@ -183,8 +183,8 @@ bool CPDF_SecurityHandler::LoadDict(CPDF_Dictionary* pEncryptDict,
m_Revision = pEncryptDict->GetIntegerFor("R");
m_Permissions = pEncryptDict->GetIntegerFor("P", -1);
- CFX_ByteString strf_name;
- CFX_ByteString stmf_name;
+ ByteString strf_name;
+ ByteString stmf_name;
if (m_Version >= 4) {
stmf_name = pEncryptDict->GetStringFor("StmF");
strf_name = pEncryptDict->GetStringFor("StrF");
@@ -310,11 +310,11 @@ bool CPDF_SecurityHandler::AES256_CheckPassword(const uint8_t* password,
if (!m_pEncryptDict)
return false;
- CFX_ByteString okey = m_pEncryptDict->GetStringFor("O");
+ ByteString okey = m_pEncryptDict->GetStringFor("O");
if (okey.GetLength() < 48)
return false;
- CFX_ByteString ukey = m_pEncryptDict->GetStringFor("U");
+ ByteString ukey = m_pEncryptDict->GetStringFor("U");
if (ukey.GetLength() < 48)
return false;
@@ -351,9 +351,9 @@ bool CPDF_SecurityHandler::AES256_CheckPassword(const uint8_t* password,
CRYPT_SHA256Finish(&sha, digest);
}
- CFX_ByteString ekey = m_pEncryptDict
- ? m_pEncryptDict->GetStringFor(bOwner ? "OE" : "UE")
- : CFX_ByteString();
+ ByteString ekey = m_pEncryptDict
+ ? m_pEncryptDict->GetStringFor(bOwner ? "OE" : "UE")
+ : ByteString();
if (ekey.GetLength() < 32)
return false;
@@ -366,7 +366,7 @@ bool CPDF_SecurityHandler::AES256_CheckPassword(const uint8_t* password,
CRYPT_AESDecrypt(&aes, key, ekey.raw_str(), 32);
CRYPT_AESSetKey(&aes, 16, key, 32, false);
CRYPT_AESSetIV(&aes, iv);
- CFX_ByteString perms = m_pEncryptDict->GetStringFor("Perms");
+ ByteString perms = m_pEncryptDict->GetStringFor("Perms");
if (perms.IsEmpty())
return false;
@@ -415,8 +415,8 @@ bool CPDF_SecurityHandler::CheckUserPassword(const uint8_t* password,
int32_t key_len) {
CalcEncryptKey(m_pEncryptDict.Get(), password, pass_size, key, key_len,
bIgnoreEncryptMeta, m_pParser->GetIDArray());
- CFX_ByteString ukey =
- m_pEncryptDict ? m_pEncryptDict->GetStringFor("U") : CFX_ByteString();
+ ByteString ukey =
+ m_pEncryptDict ? m_pEncryptDict->GetStringFor("U") : ByteString();
if (ukey.GetLength() < 16) {
return false;
}
@@ -443,7 +443,7 @@ bool CPDF_SecurityHandler::CheckUserPassword(const uint8_t* password,
CRYPT_MD5Update(&md5, defpasscode, 32);
CPDF_Array* pIdArray = m_pParser->GetIDArray();
if (pIdArray) {
- CFX_ByteString id = pIdArray->GetStringAt(0);
+ ByteString id = pIdArray->GetStringAt(0);
CRYPT_MD5Update(&md5, (uint8_t*)id.c_str(), id.GetLength());
}
CRYPT_MD5Finish(&md5, ukeybuf);
@@ -452,10 +452,10 @@ bool CPDF_SecurityHandler::CheckUserPassword(const uint8_t* password,
return memcmp(ukey.c_str(), ukeybuf, 16) == 0;
}
-CFX_ByteString CPDF_SecurityHandler::GetUserPassword(const uint8_t* owner_pass,
- uint32_t pass_size,
- int32_t key_len) {
- CFX_ByteString okey = m_pEncryptDict->GetStringFor("O");
+ByteString CPDF_SecurityHandler::GetUserPassword(const uint8_t* owner_pass,
+ uint32_t pass_size,
+ int32_t key_len) {
+ ByteString okey = m_pEncryptDict->GetStringFor("O");
uint8_t passcode[32];
for (uint32_t i = 0; i < 32; i++) {
passcode[i] = i < pass_size ? owner_pass[i] : defpasscode[i - pass_size];
@@ -496,13 +496,13 @@ CFX_ByteString CPDF_SecurityHandler::GetUserPassword(const uint8_t* owner_pass,
while (len && defpasscode[len - 1] == okeybuf[len - 1]) {
len--;
}
- return CFX_ByteString(okeybuf, len);
+ return ByteString(okeybuf, len);
}
bool CPDF_SecurityHandler::CheckOwnerPassword(const uint8_t* password,
uint32_t pass_size,
uint8_t* key,
int32_t key_len) {
- CFX_ByteString user_pass = GetUserPassword(password, pass_size, key_len);
+ ByteString user_pass = GetUserPassword(password, pass_size, key_len);
if (CheckUserPassword(user_pass.raw_str(), user_pass.GetLength(), false, key,
key_len)) {
return true;
@@ -575,8 +575,7 @@ void CPDF_SecurityHandler::OnCreate(CPDF_Dictionary* pEncryptDict,
CRYPT_ArcFourCryptBlock(passcode, 32, tempkey, key_len);
}
}
- pEncryptDict->SetNewFor<CPDF_String>("O", CFX_ByteString(passcode, 32),
- false);
+ pEncryptDict->SetNewFor<CPDF_String>("O", ByteString(passcode, 32), false);
}
CalcEncryptKey(m_pEncryptDict.Get(), (uint8_t*)user_pass, user_size,
m_EncryptKey, key_len, false, pIdArray);
@@ -584,14 +583,13 @@ void CPDF_SecurityHandler::OnCreate(CPDF_Dictionary* pEncryptDict,
uint8_t tempbuf[32];
memcpy(tempbuf, defpasscode, 32);
CRYPT_ArcFourCryptBlock(tempbuf, 32, m_EncryptKey, key_len);
- pEncryptDict->SetNewFor<CPDF_String>("U", CFX_ByteString(tempbuf, 32),
- false);
+ pEncryptDict->SetNewFor<CPDF_String>("U", ByteString(tempbuf, 32), false);
} else {
CRYPT_md5_context md5;
CRYPT_MD5Start(&md5);
CRYPT_MD5Update(&md5, defpasscode, 32);
if (pIdArray) {
- CFX_ByteString id = pIdArray->GetStringAt(0);
+ ByteString id = pIdArray->GetStringAt(0);
CRYPT_MD5Update(&md5, (uint8_t*)id.c_str(), id.GetLength());
}
uint8_t digest[32];
@@ -605,8 +603,7 @@ void CPDF_SecurityHandler::OnCreate(CPDF_Dictionary* pEncryptDict,
CRYPT_ArcFourCryptBlock(digest, 16, tempkey, key_len);
}
CRYPT_MD5Generate(digest, 16, digest + 16);
- pEncryptDict->SetNewFor<CPDF_String>("U", CFX_ByteString(digest, 32),
- false);
+ pEncryptDict->SetNewFor<CPDF_String>("U", ByteString(digest, 32), false);
}
}
void CPDF_SecurityHandler::OnCreate(CPDF_Dictionary* pEncryptDict,
@@ -640,7 +637,7 @@ void CPDF_SecurityHandler::AES256_SetPassword(CPDF_Dictionary* pEncryptDict,
uint8_t digest[20];
CRYPT_SHA1Finish(&sha, digest);
- CFX_ByteString ukey = pEncryptDict->GetStringFor("U");
+ ByteString ukey = pEncryptDict->GetStringFor("U");
CRYPT_sha2_context sha2;
uint8_t digest1[48];
if (m_Revision >= 6) {
@@ -657,7 +654,7 @@ void CPDF_SecurityHandler::AES256_SetPassword(CPDF_Dictionary* pEncryptDict,
}
memcpy(digest1 + 32, digest, 16);
pEncryptDict->SetNewFor<CPDF_String>(bOwner ? "O" : "U",
- CFX_ByteString(digest1, 48), false);
+ ByteString(digest1, 48), false);
if (m_Revision >= 6) {
Revision6_Hash(password, size, digest + 8,
bOwner ? ukey.raw_str() : nullptr, digest1);
@@ -678,7 +675,7 @@ void CPDF_SecurityHandler::AES256_SetPassword(CPDF_Dictionary* pEncryptDict,
CRYPT_AESSetIV(&aes, iv);
CRYPT_AESEncrypt(&aes, digest1, key, 32);
pEncryptDict->SetNewFor<CPDF_String>(bOwner ? "OE" : "UE",
- CFX_ByteString(digest1, 32), false);
+ ByteString(digest1, 32), false);
}
void CPDF_SecurityHandler::AES256_SetPerms(CPDF_Dictionary* pEncryptDict,
@@ -709,6 +706,5 @@ void CPDF_SecurityHandler::AES256_SetPerms(CPDF_Dictionary* pEncryptDict,
uint8_t buf1[16];
CRYPT_AESEncrypt(&aes, buf1, buf, 16);
- pEncryptDict->SetNewFor<CPDF_String>("Perms", CFX_ByteString(buf1, 16),
- false);
+ pEncryptDict->SetNewFor<CPDF_String>("Perms", ByteString(buf1, 16), false);
}
diff --git a/core/fpdfapi/parser/cpdf_security_handler.h b/core/fpdfapi/parser/cpdf_security_handler.h
index 27f7f7c610..eb7d13f2e6 100644
--- a/core/fpdfapi/parser/cpdf_security_handler.h
+++ b/core/fpdfapi/parser/cpdf_security_handler.h
@@ -46,9 +46,9 @@ class CPDF_SecurityHandler {
uint32_t user_size,
uint32_t type = PDF_ENCRYPT_CONTENT);
- CFX_ByteString GetUserPassword(const uint8_t* owner_pass,
- uint32_t pass_size,
- int32_t key_len);
+ ByteString GetUserPassword(const uint8_t* owner_pass,
+ uint32_t pass_size,
+ int32_t key_len);
bool CheckPassword(const uint8_t* password,
uint32_t pass_size,
bool bOwner,
diff --git a/core/fpdfapi/parser/cpdf_simple_parser.cpp b/core/fpdfapi/parser/cpdf_simple_parser.cpp
index 650c216e05..d800796d58 100644
--- a/core/fpdfapi/parser/cpdf_simple_parser.cpp
+++ b/core/fpdfapi/parser/cpdf_simple_parser.cpp
@@ -11,7 +11,7 @@
CPDF_SimpleParser::CPDF_SimpleParser(const uint8_t* pData, uint32_t dwSize)
: m_pData(pData), m_dwSize(dwSize), m_dwCurPos(0) {}
-CPDF_SimpleParser::CPDF_SimpleParser(const CFX_ByteStringC& str)
+CPDF_SimpleParser::CPDF_SimpleParser(const ByteStringView& str)
: m_pData(str.raw_str()), m_dwSize(str.GetLength()), m_dwCurPos(0) {}
void CPDF_SimpleParser::ParseWord(const uint8_t*& pStart, uint32_t& dwSize) {
@@ -91,7 +91,7 @@ void CPDF_SimpleParser::ParseWord(const uint8_t*& pStart, uint32_t& dwSize) {
}
}
-CFX_ByteStringC CPDF_SimpleParser::GetWord() {
+ByteStringView CPDF_SimpleParser::GetWord() {
const uint8_t* pStart;
uint32_t dwSize;
ParseWord(pStart, dwSize);
@@ -102,8 +102,8 @@ CFX_ByteStringC CPDF_SimpleParser::GetWord() {
if (m_dwCurPos < m_dwSize) {
m_dwCurPos++;
}
- return CFX_ByteStringC(pStart,
- (FX_STRSIZE)(m_dwCurPos - (pStart - m_pData)));
+ return ByteStringView(pStart,
+ (FX_STRSIZE)(m_dwCurPos - (pStart - m_pData)));
}
if (dwSize == 1 && pStart[0] == '(') {
int level = 1;
@@ -130,13 +130,13 @@ CFX_ByteStringC CPDF_SimpleParser::GetWord() {
if (m_dwCurPos < m_dwSize) {
m_dwCurPos++;
}
- return CFX_ByteStringC(pStart,
- (FX_STRSIZE)(m_dwCurPos - (pStart - m_pData)));
+ return ByteStringView(pStart,
+ (FX_STRSIZE)(m_dwCurPos - (pStart - m_pData)));
}
- return CFX_ByteStringC(pStart, dwSize);
+ return ByteStringView(pStart, dwSize);
}
-bool CPDF_SimpleParser::FindTagParamFromStart(const CFX_ByteStringC& token,
+bool CPDF_SimpleParser::FindTagParamFromStart(const ByteStringView& token,
int nParams) {
nParams++;
uint32_t* pBuf = FX_Alloc(uint32_t, nParams);
@@ -152,7 +152,7 @@ bool CPDF_SimpleParser::FindTagParamFromStart(const CFX_ByteStringC& token,
if (buf_count > nParams) {
buf_count = nParams;
}
- CFX_ByteStringC word = GetWord();
+ ByteStringView word = GetWord();
if (word.IsEmpty()) {
FX_Free(pBuf);
return false;
diff --git a/core/fpdfapi/parser/cpdf_simple_parser.h b/core/fpdfapi/parser/cpdf_simple_parser.h
index 0ff6985660..72cf700f60 100644
--- a/core/fpdfapi/parser/cpdf_simple_parser.h
+++ b/core/fpdfapi/parser/cpdf_simple_parser.h
@@ -13,13 +13,13 @@
class CPDF_SimpleParser {
public:
CPDF_SimpleParser(const uint8_t* pData, uint32_t dwSize);
- explicit CPDF_SimpleParser(const CFX_ByteStringC& str);
+ explicit CPDF_SimpleParser(const ByteStringView& str);
- CFX_ByteStringC GetWord();
+ ByteStringView GetWord();
// Find the token and its |nParams| parameters from the start of data,
// and move the current position to the start of those parameters.
- bool FindTagParamFromStart(const CFX_ByteStringC& token, int nParams);
+ bool FindTagParamFromStart(const ByteStringView& token, int nParams);
// For testing only.
uint32_t GetCurPos() const { return m_dwCurPos; }
diff --git a/core/fpdfapi/parser/cpdf_simple_parser_unittest.cpp b/core/fpdfapi/parser/cpdf_simple_parser_unittest.cpp
index bdb532d3e0..a2f43386e7 100644
--- a/core/fpdfapi/parser/cpdf_simple_parser_unittest.cpp
+++ b/core/fpdfapi/parser/cpdf_simple_parser_unittest.cpp
@@ -50,7 +50,7 @@ TEST(SimpleParserTest, GetWord) {
for (size_t i = 0; i < FX_ArraySize(test_data); ++i) {
const pdfium::StrFuncTestData& data = test_data[i];
CPDF_SimpleParser parser(data.input, data.input_size);
- CFX_ByteStringC word = parser.GetWord();
+ ByteStringView word = parser.GetWord();
EXPECT_EQ(std::string(reinterpret_cast<const char*>(data.expected),
data.expected_size),
std::string(word.unterminated_c_str(), word.GetLength()))
diff --git a/core/fpdfapi/parser/cpdf_stream.cpp b/core/fpdfapi/parser/cpdf_stream.cpp
index fadaec1b7e..c00096df8b 100644
--- a/core/fpdfapi/parser/cpdf_stream.cpp
+++ b/core/fpdfapi/parser/cpdf_stream.cpp
@@ -145,7 +145,7 @@ bool CPDF_Stream::HasFilter() const {
return m_pDict && m_pDict->KeyExist("Filter");
}
-CFX_WideString CPDF_Stream::GetUnicodeText() const {
+WideString CPDF_Stream::GetUnicodeText() const {
auto pAcc = pdfium::MakeRetain<CPDF_StreamAcc>(this);
pAcc->LoadAllData(false);
return PDF_DecodeText(pAcc->GetData(), pAcc->GetSize());
diff --git a/core/fpdfapi/parser/cpdf_stream.h b/core/fpdfapi/parser/cpdf_stream.h
index 3c3b674a48..be70e05e72 100644
--- a/core/fpdfapi/parser/cpdf_stream.h
+++ b/core/fpdfapi/parser/cpdf_stream.h
@@ -30,7 +30,7 @@ class CPDF_Stream : public CPDF_Object {
Type GetType() const override;
std::unique_ptr<CPDF_Object> Clone() const override;
CPDF_Dictionary* GetDict() const override;
- CFX_WideString GetUnicodeText() const override;
+ WideString GetUnicodeText() const override;
bool IsStream() const override;
CPDF_Stream* AsStream() override;
const CPDF_Stream* AsStream() const override;
diff --git a/core/fpdfapi/parser/cpdf_stream_acc.h b/core/fpdfapi/parser/cpdf_stream_acc.h
index bc03cb097b..2161dd1950 100644
--- a/core/fpdfapi/parser/cpdf_stream_acc.h
+++ b/core/fpdfapi/parser/cpdf_stream_acc.h
@@ -34,7 +34,7 @@ class CPDF_StreamAcc : public CFX_Retainable {
const uint8_t* GetData() const;
uint32_t GetSize() const;
- const CFX_ByteString& GetImageDecoder() const { return m_ImageDecoder; }
+ const ByteString& GetImageDecoder() const { return m_ImageDecoder; }
const CPDF_Dictionary* GetImageParam() const { return m_pImageParam; }
std::unique_ptr<uint8_t, FxFreeDeleter> DetachData();
@@ -45,7 +45,7 @@ class CPDF_StreamAcc : public CFX_Retainable {
uint8_t* m_pData;
uint32_t m_dwSize;
bool m_bNewBuf;
- CFX_ByteString m_ImageDecoder;
+ ByteString m_ImageDecoder;
CPDF_Dictionary* m_pImageParam;
CFX_UnownedPtr<const CPDF_Stream> const m_pStream;
uint8_t* m_pSrcData;
diff --git a/core/fpdfapi/parser/cpdf_string.cpp b/core/fpdfapi/parser/cpdf_string.cpp
index 6ce6bf3473..1539861622 100644
--- a/core/fpdfapi/parser/cpdf_string.cpp
+++ b/core/fpdfapi/parser/cpdf_string.cpp
@@ -14,16 +14,16 @@
CPDF_String::CPDF_String() : m_bHex(false) {}
-CPDF_String::CPDF_String(CFX_WeakPtr<CFX_ByteStringPool> pPool,
- const CFX_ByteString& str,
+CPDF_String::CPDF_String(CFX_WeakPtr<ByteStringPool> pPool,
+ const ByteString& str,
bool bHex)
: m_String(str), m_bHex(bHex) {
if (pPool)
m_String = pPool->Intern(m_String);
}
-CPDF_String::CPDF_String(CFX_WeakPtr<CFX_ByteStringPool> pPool,
- const CFX_WideString& str)
+CPDF_String::CPDF_String(CFX_WeakPtr<ByteStringPool> pPool,
+ const WideString& str)
: m_String(PDF_EncodeText(str)), m_bHex(false) {
if (pPool)
m_String = pPool->Intern(m_String);
@@ -42,11 +42,11 @@ std::unique_ptr<CPDF_Object> CPDF_String::Clone() const {
return std::move(pRet);
}
-CFX_ByteString CPDF_String::GetString() const {
+ByteString CPDF_String::GetString() const {
return m_String;
}
-void CPDF_String::SetString(const CFX_ByteString& str) {
+void CPDF_String::SetString(const ByteString& str) {
m_String = str;
}
@@ -62,11 +62,11 @@ const CPDF_String* CPDF_String::AsString() const {
return this;
}
-CFX_WideString CPDF_String::GetUnicodeText() const {
+WideString CPDF_String::GetUnicodeText() const {
return PDF_DecodeText(m_String);
}
bool CPDF_String::WriteTo(IFX_ArchiveStream* archive) const {
return archive->WriteString(
- PDF_EncodeString(GetString(), IsHex()).AsStringC());
+ PDF_EncodeString(GetString(), IsHex()).AsStringView());
}
diff --git a/core/fpdfapi/parser/cpdf_string.h b/core/fpdfapi/parser/cpdf_string.h
index ccd6f530c1..9fd3e6ae8a 100644
--- a/core/fpdfapi/parser/cpdf_string.h
+++ b/core/fpdfapi/parser/cpdf_string.h
@@ -18,18 +18,18 @@
class CPDF_String : public CPDF_Object {
public:
CPDF_String();
- CPDF_String(CFX_WeakPtr<CFX_ByteStringPool> pPool,
- const CFX_ByteString& str,
+ CPDF_String(CFX_WeakPtr<ByteStringPool> pPool,
+ const ByteString& str,
bool bHex);
- CPDF_String(CFX_WeakPtr<CFX_ByteStringPool> pPool, const CFX_WideString& str);
+ CPDF_String(CFX_WeakPtr<ByteStringPool> pPool, const WideString& str);
~CPDF_String() override;
// CPDF_Object:
Type GetType() const override;
std::unique_ptr<CPDF_Object> Clone() const override;
- CFX_ByteString GetString() const override;
- CFX_WideString GetUnicodeText() const override;
- void SetString(const CFX_ByteString& str) override;
+ ByteString GetString() const override;
+ WideString GetUnicodeText() const override;
+ void SetString(const ByteString& str) override;
bool IsString() const override;
CPDF_String* AsString() override;
const CPDF_String* AsString() const override;
@@ -38,7 +38,7 @@ class CPDF_String : public CPDF_Object {
bool IsHex() const { return m_bHex; }
protected:
- CFX_ByteString m_String;
+ ByteString m_String;
bool m_bHex;
};
diff --git a/core/fpdfapi/parser/cpdf_syntax_parser.cpp b/core/fpdfapi/parser/cpdf_syntax_parser.cpp
index 779bf81e0f..4412105c7b 100644
--- a/core/fpdfapi/parser/cpdf_syntax_parser.cpp
+++ b/core/fpdfapi/parser/cpdf_syntax_parser.cpp
@@ -41,10 +41,9 @@ enum class ReadStatus { Normal, Backslash, Octal, FinishOctal, CarriageReturn };
int CPDF_SyntaxParser::s_CurrentRecursionDepth = 0;
CPDF_SyntaxParser::CPDF_SyntaxParser()
- : CPDF_SyntaxParser(CFX_WeakPtr<CFX_ByteStringPool>()) {}
+ : CPDF_SyntaxParser(CFX_WeakPtr<ByteStringPool>()) {}
-CPDF_SyntaxParser::CPDF_SyntaxParser(
- const CFX_WeakPtr<CFX_ByteStringPool>& pPool)
+CPDF_SyntaxParser::CPDF_SyntaxParser(const CFX_WeakPtr<ByteStringPool>& pPool)
: m_MetadataObjnum(0),
m_pFileAccess(nullptr),
m_pFileBuf(nullptr),
@@ -187,10 +186,10 @@ void CPDF_SyntaxParser::GetNextWordInternal(bool* bIsNumber) {
}
}
-CFX_ByteString CPDF_SyntaxParser::ReadString() {
+ByteString CPDF_SyntaxParser::ReadString() {
uint8_t ch;
if (!GetNextChar(ch))
- return CFX_ByteString();
+ return ByteString();
std::ostringstream buf;
int32_t parlevel = 0;
@@ -201,7 +200,7 @@ CFX_ByteString CPDF_SyntaxParser::ReadString() {
case ReadStatus::Normal:
if (ch == ')') {
if (parlevel == 0)
- return CFX_ByteString(buf);
+ return ByteString(buf);
parlevel--;
} else if (ch == '(') {
parlevel++;
@@ -270,13 +269,13 @@ CFX_ByteString CPDF_SyntaxParser::ReadString() {
}
GetNextChar(ch);
- return CFX_ByteString(buf);
+ return ByteString(buf);
}
-CFX_ByteString CPDF_SyntaxParser::ReadHexString() {
+ByteString CPDF_SyntaxParser::ReadHexString() {
uint8_t ch;
if (!GetNextChar(ch))
- return CFX_ByteString();
+ return ByteString();
std::ostringstream buf;
bool bFirst = true;
@@ -302,7 +301,7 @@ CFX_ByteString CPDF_SyntaxParser::ReadHexString() {
if (!bFirst)
buf << static_cast<char>(code);
- return CFX_ByteString(buf);
+ return ByteString(buf);
}
void CPDF_SyntaxParser::ToNextLine() {
@@ -344,20 +343,20 @@ void CPDF_SyntaxParser::ToNextWord() {
m_Pos--;
}
-CFX_ByteString CPDF_SyntaxParser::GetNextWord(bool* bIsNumber) {
+ByteString CPDF_SyntaxParser::GetNextWord(bool* bIsNumber) {
const CPDF_ReadValidator::Session read_session(GetValidator().Get());
GetNextWordInternal(bIsNumber);
return GetValidator()->has_read_problems()
- ? CFX_ByteString()
- : CFX_ByteString((const char*)m_WordBuffer, m_WordSize);
+ ? ByteString()
+ : ByteString((const char*)m_WordBuffer, m_WordSize);
}
-CFX_ByteString CPDF_SyntaxParser::PeekNextWord(bool* bIsNumber) {
+ByteString CPDF_SyntaxParser::PeekNextWord(bool* bIsNumber) {
const CFX_AutoRestorer<FX_FILESIZE> save_pos(&m_Pos);
return GetNextWord(bIsNumber);
}
-CFX_ByteString CPDF_SyntaxParser::GetKeyword() {
+ByteString CPDF_SyntaxParser::GetKeyword() {
return GetNextWord(nullptr);
}
@@ -386,15 +385,15 @@ std::unique_ptr<CPDF_Object> CPDF_SyntaxParser::GetObjectInternal(
FX_FILESIZE SavedObjPos = m_Pos;
bool bIsNumber;
- CFX_ByteString word = GetNextWord(&bIsNumber);
+ ByteString word = GetNextWord(&bIsNumber);
if (word.GetLength() == 0)
return nullptr;
if (bIsNumber) {
FX_FILESIZE SavedPos = m_Pos;
- CFX_ByteString nextword = GetNextWord(&bIsNumber);
+ ByteString nextword = GetNextWord(&bIsNumber);
if (bIsNumber) {
- CFX_ByteString nextword2 = GetNextWord(nullptr);
+ ByteString nextword2 = GetNextWord(nullptr);
if (nextword2 == "R") {
uint32_t refnum = FXSYS_atoui(word.c_str());
if (refnum == CPDF_Object::kInvalidObjNum)
@@ -403,7 +402,7 @@ std::unique_ptr<CPDF_Object> CPDF_SyntaxParser::GetObjectInternal(
}
}
m_Pos = SavedPos;
- return pdfium::MakeUnique<CPDF_Number>(word.AsStringC());
+ return pdfium::MakeUnique<CPDF_Number>(word.AsStringView());
}
if (word == "true" || word == "false")
@@ -413,13 +412,13 @@ std::unique_ptr<CPDF_Object> CPDF_SyntaxParser::GetObjectInternal(
return pdfium::MakeUnique<CPDF_Null>();
if (word == "(") {
- CFX_ByteString str = ReadString();
+ ByteString str = ReadString();
if (m_pCryptoHandler && bDecrypt)
str = m_pCryptoHandler->Decrypt(objnum, gennum, str);
return pdfium::MakeUnique<CPDF_String>(m_pPool, str, false);
}
if (word == "<") {
- CFX_ByteString str = ReadHexString();
+ ByteString str = ReadHexString();
if (m_pCryptoHandler && bDecrypt)
str = m_pCryptoHandler->Decrypt(objnum, gennum, str);
return pdfium::MakeUnique<CPDF_String>(m_pPool, str, true);
@@ -437,14 +436,14 @@ std::unique_ptr<CPDF_Object> CPDF_SyntaxParser::GetObjectInternal(
if (word[0] == '/') {
return pdfium::MakeUnique<CPDF_Name>(
m_pPool,
- PDF_NameDecode(CFX_ByteStringC(m_WordBuffer + 1, m_WordSize - 1)));
+ PDF_NameDecode(ByteStringView(m_WordBuffer + 1, m_WordSize - 1)));
}
if (word == "<<") {
FX_FILESIZE dwSignValuePos = 0;
std::unique_ptr<CPDF_Dictionary> pDict =
pdfium::MakeUnique<CPDF_Dictionary>(m_pPool);
while (1) {
- CFX_ByteString key = GetNextWord(nullptr);
+ ByteString key = GetNextWord(nullptr);
if (key.IsEmpty())
return nullptr;
@@ -477,7 +476,7 @@ std::unique_ptr<CPDF_Object> CPDF_SyntaxParser::GetObjectInternal(
}
if (!key.IsEmpty()) {
- CFX_ByteString keyNoSlash(key.raw_str() + 1, key.GetLength() - 1);
+ ByteString keyNoSlash(key.raw_str() + 1, key.GetLength() - 1);
pDict->SetFor(keyNoSlash, std::move(pObj));
}
}
@@ -492,7 +491,7 @@ std::unique_ptr<CPDF_Object> CPDF_SyntaxParser::GetObjectInternal(
}
FX_FILESIZE SavedPos = m_Pos;
- CFX_ByteString nextword = GetNextWord(nullptr);
+ ByteString nextword = GetNextWord(nullptr);
if (nextword != "stream") {
m_Pos = SavedPos;
return std::move(pDict);
@@ -526,7 +525,7 @@ std::unique_ptr<CPDF_Object> CPDF_SyntaxParser::GetIndirectObject(
const CPDF_ReadValidator::Session read_session(GetValidator().Get());
const FX_FILESIZE saved_pos = GetPos();
bool is_number = false;
- CFX_ByteString word = GetNextWord(&is_number);
+ ByteString word = GetNextWord(&is_number);
if (!is_number || word.IsEmpty()) {
SetPos(saved_pos);
return nullptr;
@@ -588,8 +587,8 @@ std::unique_ptr<CPDF_Stream> CPDF_SyntaxParser::ReadStream(
ToNextLine();
FX_FILESIZE streamStartPos = m_Pos;
- const CFX_ByteStringC kEndStreamStr("endstream");
- const CFX_ByteStringC kEndObjStr("endobj");
+ const ByteStringView kEndStreamStr("endstream");
+ const ByteStringView kEndObjStr("endobj");
CPDF_CryptoHandler* pCryptoHandler =
objnum == m_MetadataObjnum ? nullptr : m_pCryptoHandler.Get();
@@ -757,7 +756,7 @@ uint32_t CPDF_SyntaxParser::GetDirectNum() {
bool CPDF_SyntaxParser::IsWholeWord(FX_FILESIZE startpos,
FX_FILESIZE limit,
- const CFX_ByteStringC& tag,
+ const ByteStringView& tag,
bool checkKeyword) {
const uint32_t taglen = tag.GetLength();
@@ -783,7 +782,7 @@ bool CPDF_SyntaxParser::IsWholeWord(FX_FILESIZE startpos,
return true;
}
-bool CPDF_SyntaxParser::BackwardsSearchToWord(const CFX_ByteStringC& tag,
+bool CPDF_SyntaxParser::BackwardsSearchToWord(const ByteStringView& tag,
FX_FILESIZE limit) {
int32_t taglen = tag.GetLength();
if (taglen == 0)
@@ -817,7 +816,7 @@ bool CPDF_SyntaxParser::BackwardsSearchToWord(const CFX_ByteStringC& tag,
}
}
-FX_FILESIZE CPDF_SyntaxParser::FindTag(const CFX_ByteStringC& tag,
+FX_FILESIZE CPDF_SyntaxParser::FindTag(const ByteStringView& tag,
FX_FILESIZE limit) {
int32_t taglen = tag.GetLength();
int32_t match = 0;
diff --git a/core/fpdfapi/parser/cpdf_syntax_parser.h b/core/fpdfapi/parser/cpdf_syntax_parser.h
index 179058edf8..4e28c2fb92 100644
--- a/core/fpdfapi/parser/cpdf_syntax_parser.h
+++ b/core/fpdfapi/parser/cpdf_syntax_parser.h
@@ -26,7 +26,7 @@ class CPDF_SyntaxParser {
enum class ParseType { kStrict, kLoose };
CPDF_SyntaxParser();
- explicit CPDF_SyntaxParser(const CFX_WeakPtr<CFX_ByteStringPool>& pPool);
+ explicit CPDF_SyntaxParser(const CFX_WeakPtr<ByteStringPool>& pPool);
~CPDF_SyntaxParser();
void InitParser(const CFX_RetainPtr<IFX_SeekableReadStream>& pFileAccess,
@@ -56,16 +56,16 @@ class CPDF_SyntaxParser {
bool bDecrypt,
ParseType parse_type);
- CFX_ByteString GetKeyword();
+ ByteString GetKeyword();
void ToNextLine();
void ToNextWord();
- bool BackwardsSearchToWord(const CFX_ByteStringC& word, FX_FILESIZE limit);
- FX_FILESIZE FindTag(const CFX_ByteStringC& tag, FX_FILESIZE limit);
+ bool BackwardsSearchToWord(const ByteStringView& word, FX_FILESIZE limit);
+ FX_FILESIZE FindTag(const ByteStringView& tag, FX_FILESIZE limit);
void SetEncrypt(const CFX_RetainPtr<CPDF_CryptoHandler>& pCryptoHandler);
bool ReadBlock(uint8_t* pBuf, uint32_t size);
bool GetCharAt(FX_FILESIZE pos, uint8_t& ch);
- CFX_ByteString GetNextWord(bool* bIsNumber);
- CFX_ByteString PeekNextWord(bool* bIsNumber);
+ ByteString GetNextWord(bool* bIsNumber);
+ ByteString PeekNextWord(bool* bIsNumber);
CFX_RetainPtr<IFX_SeekableReadStream> GetFileAccess() const;
@@ -88,11 +88,11 @@ class CPDF_SyntaxParser {
void GetNextWordInternal(bool* bIsNumber);
bool IsWholeWord(FX_FILESIZE startpos,
FX_FILESIZE limit,
- const CFX_ByteStringC& tag,
+ const ByteStringView& tag,
bool checkKeyword);
- CFX_ByteString ReadString();
- CFX_ByteString ReadHexString();
+ ByteString ReadString();
+ ByteString ReadHexString();
unsigned int ReadEOLMarkers(FX_FILESIZE pos);
std::unique_ptr<CPDF_Stream> ReadStream(
std::unique_ptr<CPDF_Dictionary> pDict,
@@ -122,7 +122,7 @@ class CPDF_SyntaxParser {
CFX_RetainPtr<CPDF_CryptoHandler> m_pCryptoHandler;
uint8_t m_WordBuffer[257];
uint32_t m_WordSize;
- CFX_WeakPtr<CFX_ByteStringPool> m_pPool;
+ CFX_WeakPtr<ByteStringPool> m_pPool;
};
#endif // CORE_FPDFAPI_PARSER_CPDF_SYNTAX_PARSER_H_
diff --git a/core/fpdfapi/parser/fpdf_parser_decode.cpp b/core/fpdfapi/parser/fpdf_parser_decode.cpp
index 77024f2f09..0180aaf749 100644
--- a/core/fpdfapi/parser/fpdf_parser_decode.cpp
+++ b/core/fpdfapi/parser/fpdf_parser_decode.cpp
@@ -328,7 +328,7 @@ bool PDF_DataDecode(const uint8_t* src_buf,
bool bImageAcc,
uint8_t** dest_buf,
uint32_t* dest_size,
- CFX_ByteString* ImageEncoding,
+ ByteString* ImageEncoding,
CPDF_Dictionary** pImageParms) {
CPDF_Object* pDecoder = pDict ? pDict->GetDirectObjectFor("Filter") : nullptr;
if (!pDecoder || (!pDecoder->IsArray() && !pDecoder->IsName()))
@@ -337,7 +337,7 @@ bool PDF_DataDecode(const uint8_t* src_buf,
CPDF_Object* pParams =
pDict ? pDict->GetDirectObjectFor("DecodeParms") : nullptr;
- std::vector<std::pair<CFX_ByteString, CPDF_Object*>> DecoderArray;
+ std::vector<std::pair<ByteString, CPDF_Object*>> DecoderArray;
if (CPDF_Array* pDecoders = pDecoder->AsArray()) {
CPDF_Array* pParamsArray = ToArray(pParams);
for (size_t i = 0; i < pDecoders->GetCount(); ++i) {
@@ -354,7 +354,7 @@ bool PDF_DataDecode(const uint8_t* src_buf,
int nSize = pdfium::CollectionSize<int>(DecoderArray);
for (int i = 0; i < nSize; ++i) {
int estimated_size = i == nSize - 1 ? last_estimated_size : 0;
- CFX_ByteString decoder = DecoderArray[i].first;
+ ByteString decoder = DecoderArray[i].first;
CPDF_Dictionary* pParam = ToDictionary(DecoderArray[i].second);
uint8_t* new_buf = nullptr;
uint32_t new_size = 0xFFFFFFFF;
@@ -415,8 +415,8 @@ bool PDF_DataDecode(const uint8_t* src_buf,
return true;
}
-CFX_WideString PDF_DecodeText(const uint8_t* src_data, uint32_t src_len) {
- CFX_WideString result;
+WideString PDF_DecodeText(const uint8_t* src_data, uint32_t src_len) {
+ WideString result;
if (src_len >= 2 && ((src_data[0] == 0xfe && src_data[1] == 0xff) ||
(src_data[0] == 0xff && src_data[1] == 0xfe))) {
bool bBE = src_data[0] == 0xfe;
@@ -455,16 +455,16 @@ CFX_WideString PDF_DecodeText(const uint8_t* src_data, uint32_t src_len) {
return result;
}
-CFX_WideString PDF_DecodeText(const CFX_ByteString& bstr) {
+WideString PDF_DecodeText(const ByteString& bstr) {
return PDF_DecodeText(reinterpret_cast<const uint8_t*>(bstr.c_str()),
bstr.GetLength());
}
-CFX_ByteString PDF_EncodeText(const wchar_t* pString, int len) {
+ByteString PDF_EncodeText(const wchar_t* pString, int len) {
if (len == -1)
len = FXSYS_wcslen(pString);
- CFX_ByteString result;
+ ByteString result;
char* dest_buf1 = result.GetBuffer(len);
int i;
for (i = 0; i < len; ++i) {
@@ -502,11 +502,11 @@ CFX_ByteString PDF_EncodeText(const wchar_t* pString, int len) {
return result;
}
-CFX_ByteString PDF_EncodeText(const CFX_WideString& str) {
+ByteString PDF_EncodeText(const WideString& str) {
return PDF_EncodeText(str.c_str(), str.GetLength());
}
-CFX_ByteString PDF_EncodeString(const CFX_ByteString& src, bool bHex) {
+ByteString PDF_EncodeString(const ByteString& src, bool bHex) {
std::ostringstream result;
int srclen = src.GetLength();
if (bHex) {
@@ -518,7 +518,7 @@ CFX_ByteString PDF_EncodeString(const CFX_ByteString& src, bool bHex) {
result << buf[1];
}
result << '>';
- return CFX_ByteString(result);
+ return ByteString(result);
}
result << '(';
for (int i = 0; i < srclen; ++i) {
@@ -536,7 +536,7 @@ CFX_ByteString PDF_EncodeString(const CFX_ByteString& src, bool bHex) {
result << static_cast<char>(ch);
}
result << ')';
- return CFX_ByteString(result);
+ return ByteString(result);
}
bool FlateEncode(const uint8_t* src_buf,
diff --git a/core/fpdfapi/parser/fpdf_parser_decode.h b/core/fpdfapi/parser/fpdf_parser_decode.h
index 23ca0a0fae..6650b68c06 100644
--- a/core/fpdfapi/parser/fpdf_parser_decode.h
+++ b/core/fpdfapi/parser/fpdf_parser_decode.h
@@ -17,14 +17,14 @@ class CPDF_Dictionary;
// Indexed by 8-bit char code, contains unicode code points.
extern const uint16_t PDFDocEncoding[256];
-CFX_ByteString PDF_NameDecode(const CFX_ByteStringC& orig);
-CFX_ByteString PDF_NameDecode(const CFX_ByteString& orig);
-CFX_ByteString PDF_NameEncode(const CFX_ByteString& orig);
-CFX_ByteString PDF_EncodeString(const CFX_ByteString& src, bool bHex);
-CFX_WideString PDF_DecodeText(const uint8_t* pData, uint32_t size);
-CFX_WideString PDF_DecodeText(const CFX_ByteString& bstr);
-CFX_ByteString PDF_EncodeText(const wchar_t* pString, int len);
-CFX_ByteString PDF_EncodeText(const CFX_WideString& str);
+ByteString PDF_NameDecode(const ByteStringView& orig);
+ByteString PDF_NameDecode(const ByteString& orig);
+ByteString PDF_NameEncode(const ByteString& orig);
+ByteString PDF_EncodeString(const ByteString& src, bool bHex);
+WideString PDF_DecodeText(const uint8_t* pData, uint32_t size);
+WideString PDF_DecodeText(const ByteString& bstr);
+ByteString PDF_EncodeText(const wchar_t* pString, int len);
+ByteString PDF_EncodeText(const WideString& str);
bool FlateEncode(const uint8_t* src_buf,
uint32_t src_size,
@@ -90,7 +90,7 @@ bool PDF_DataDecode(const uint8_t* src_buf,
bool bImageAcc,
uint8_t** dest_buf,
uint32_t* dest_size,
- CFX_ByteString* ImageEncoding,
+ ByteString* ImageEncoding,
CPDF_Dictionary** pImageParms);
#endif // CORE_FPDFAPI_PARSER_FPDF_PARSER_DECODE_H_
diff --git a/core/fpdfapi/parser/fpdf_parser_decode_unittest.cpp b/core/fpdfapi/parser/fpdf_parser_decode_unittest.cpp
index c8e0c7a0e1..ae30959013 100644
--- a/core/fpdfapi/parser/fpdf_parser_decode_unittest.cpp
+++ b/core/fpdfapi/parser/fpdf_parser_decode_unittest.cpp
@@ -99,7 +99,7 @@ TEST(fpdf_parser_decode, EncodeText) {
for (size_t i = 0; i < FX_ArraySize(test_data); ++i) {
const auto& test_case = test_data[i];
- CFX_ByteString output = PDF_EncodeText(test_case.input);
+ ByteString output = PDF_EncodeText(test_case.input);
ASSERT_EQ(test_case.expected_length, output.GetLength()) << "for case "
<< i;
const char* str_ptr = output.c_str();
diff --git a/core/fpdfapi/parser/fpdf_parser_utility.cpp b/core/fpdfapi/parser/fpdf_parser_utility.cpp
index c6487f55a0..82804528ab 100644
--- a/core/fpdfapi/parser/fpdf_parser_utility.cpp
+++ b/core/fpdfapi/parser/fpdf_parser_utility.cpp
@@ -84,17 +84,17 @@ int32_t GetHeaderOffset(const CFX_RetainPtr<IFX_SeekableReadStream>& pFile) {
return kInvalidHeaderOffset;
}
-int32_t GetDirectInteger(CPDF_Dictionary* pDict, const CFX_ByteString& key) {
+int32_t GetDirectInteger(CPDF_Dictionary* pDict, const ByteString& key) {
CPDF_Number* pObj = ToNumber(pDict->GetObjectFor(key));
return pObj ? pObj->GetInteger() : 0;
}
-CFX_ByteString PDF_NameDecode(const CFX_ByteStringC& bstr) {
+ByteString PDF_NameDecode(const ByteStringView& bstr) {
if (!bstr.Contains('#'))
- return CFX_ByteString(bstr);
+ return ByteString(bstr);
int size = bstr.GetLength();
- CFX_ByteString result;
+ ByteString result;
char* pDestStart = result.GetBuffer(size);
char* pDest = pDestStart;
for (int i = 0; i < size; i++) {
@@ -110,11 +110,11 @@ CFX_ByteString PDF_NameDecode(const CFX_ByteStringC& bstr) {
return result;
}
-CFX_ByteString PDF_NameDecode(const CFX_ByteString& orig) {
- return orig.Contains("#") ? PDF_NameDecode(orig.AsStringC()) : orig;
+ByteString PDF_NameDecode(const ByteString& orig) {
+ return orig.Contains("#") ? PDF_NameDecode(orig.AsStringView()) : orig;
}
-CFX_ByteString PDF_NameEncode(const CFX_ByteString& orig) {
+ByteString PDF_NameEncode(const ByteString& orig) {
uint8_t* src_buf = (uint8_t*)orig.c_str();
int src_len = orig.GetLength();
int dest_len = 0;
@@ -131,7 +131,7 @@ CFX_ByteString PDF_NameEncode(const CFX_ByteString& orig) {
if (dest_len == src_len)
return orig;
- CFX_ByteString res;
+ ByteString res;
char* dest_buf = res.GetBuffer(dest_len);
dest_len = 0;
for (i = 0; i < src_len; i++) {
@@ -167,7 +167,7 @@ std::ostream& operator<<(std::ostream& buf, const CPDF_Object* pObj) {
buf << PDF_EncodeString(pObj->GetString(), pObj->AsString()->IsHex());
break;
case CPDF_Object::NAME: {
- CFX_ByteString str = pObj->GetString();
+ ByteString str = pObj->GetString();
buf << "/" << PDF_NameEncode(str);
break;
}
@@ -193,7 +193,7 @@ std::ostream& operator<<(std::ostream& buf, const CPDF_Object* pObj) {
const CPDF_Dictionary* p = pObj->AsDictionary();
buf << "<<";
for (const auto& it : *p) {
- const CFX_ByteString& key = it.first;
+ const ByteString& key = it.first;
CPDF_Object* pValue = it.second.get();
buf << "/" << PDF_NameEncode(key);
if (pValue && !pValue->IsInline()) {
diff --git a/core/fpdfapi/parser/fpdf_parser_utility.h b/core/fpdfapi/parser/fpdf_parser_utility.h
index 94ee1fcfd3..5f85551a53 100644
--- a/core/fpdfapi/parser/fpdf_parser_utility.h
+++ b/core/fpdfapi/parser/fpdf_parser_utility.h
@@ -41,7 +41,7 @@ constexpr int32_t kInvalidHeaderOffset = -1;
// |kInvalidHeaderOffset|.
int32_t GetHeaderOffset(const CFX_RetainPtr<IFX_SeekableReadStream>& pFile);
-int32_t GetDirectInteger(CPDF_Dictionary* pDict, const CFX_ByteString& key);
+int32_t GetDirectInteger(CPDF_Dictionary* pDict, const ByteString& key);
std::ostream& operator<<(std::ostream& buf, const CPDF_Object* pObj);
diff --git a/core/fpdfapi/render/cpdf_charposlist.cpp b/core/fpdfapi/render/cpdf_charposlist.cpp
index f5882d9944..f286474dd8 100644
--- a/core/fpdfapi/render/cpdf_charposlist.cpp
+++ b/core/fpdfapi/render/cpdf_charposlist.cpp
@@ -37,7 +37,7 @@ void CPDF_CharPosList::Load(const std::vector<uint32_t>& charCodes,
FXTEXT_CHARPOS& charpos = m_pCharPos[m_nChars++];
if (pCIDFont)
charpos.m_bFontStyle = true;
- CFX_WideString unicode = pFont->UnicodeFromCharCode(CharCode);
+ WideString unicode = pFont->UnicodeFromCharCode(CharCode);
charpos.m_Unicode = !unicode.IsEmpty() ? unicode[0] : CharCode;
charpos.m_GlyphIndex = pFont->GlyphFromCharCode(CharCode, &bVert);
uint32_t GlyphID = charpos.m_GlyphIndex;
diff --git a/core/fpdfapi/render/cpdf_dibsource.cpp b/core/fpdfapi/render/cpdf_dibsource.cpp
index 08bde6ed8d..86a01c596c 100644
--- a/core/fpdfapi/render/cpdf_dibsource.cpp
+++ b/core/fpdfapi/render/cpdf_dibsource.cpp
@@ -317,7 +317,7 @@ int CPDF_DIBSource::StartLoadDIBSource(CPDF_Document* pDoc,
int CPDF_DIBSource::ContinueLoadDIBSource(IFX_PauseIndicator* pPause) {
FXCODEC_STATUS ret;
if (m_Status == 1) {
- const CFX_ByteString& decoder = m_pStreamAcc->GetImageDecoder();
+ const ByteString& decoder = m_pStreamAcc->GetImageDecoder();
if (decoder == "JPXDecode") {
return 0;
}
@@ -397,7 +397,7 @@ bool CPDF_DIBSource::LoadColorInfo(const CPDF_Dictionary* pFormResources,
if (!m_bImageMask) {
CPDF_Object* pFilter = m_pDict->GetDirectObjectFor("Filter");
if (pFilter) {
- CFX_ByteString filter;
+ ByteString filter;
if (pFilter->IsName()) {
filter = pFilter->GetString();
} else if (CPDF_Array* pArray = pFilter->AsArray()) {
@@ -432,7 +432,7 @@ bool CPDF_DIBSource::LoadColorInfo(const CPDF_Dictionary* pFormResources,
m_Family = m_pColorSpace->GetFamily();
m_nComponents = m_pColorSpace->CountComponents();
if (m_Family == PDFCS_ICCBASED && pCSObj->IsName()) {
- CFX_ByteString cs = pCSObj->GetString();
+ ByteString cs = pCSObj->GetString();
if (cs == "DeviceGray")
m_nComponents = 1;
else if (cs == "DeviceRGB")
@@ -500,7 +500,7 @@ DIB_COMP_DATA* CPDF_DIBSource::GetDecodeAndMaskArray(bool* bDefaultDecode,
}
int CPDF_DIBSource::CreateDecoder() {
- const CFX_ByteString& decoder = m_pStreamAcc->GetImageDecoder();
+ const ByteString& decoder = m_pStreamAcc->GetImageDecoder();
if (decoder.IsEmpty())
return 1;
@@ -841,7 +841,7 @@ void CPDF_DIBSource::ValidateDictParam() {
CPDF_Object* pFilter = m_pDict->GetDirectObjectFor("Filter");
if (pFilter) {
if (pFilter->IsName()) {
- CFX_ByteString filter = pFilter->GetString();
+ ByteString filter = pFilter->GetString();
if (filter == "CCITTFaxDecode" || filter == "JBIG2Decode") {
m_bpc = 1;
m_nComponents = 1;
@@ -853,7 +853,7 @@ void CPDF_DIBSource::ValidateDictParam() {
m_bpc = 8;
}
} else if (CPDF_Array* pArray = pFilter->AsArray()) {
- CFX_ByteString filter = pArray->GetStringAt(pArray->GetCount() - 1);
+ ByteString filter = pArray->GetStringAt(pArray->GetCount() - 1);
if (filter == "CCITTFaxDecode" || filter == "JBIG2Decode") {
m_bpc = 1;
m_nComponents = 1;
diff --git a/core/fpdfapi/render/cpdf_imagerenderer.cpp b/core/fpdfapi/render/cpdf_imagerenderer.cpp
index fafa18e5a4..75a381c8fc 100644
--- a/core/fpdfapi/render/cpdf_imagerenderer.cpp
+++ b/core/fpdfapi/render/cpdf_imagerenderer.cpp
@@ -556,7 +556,7 @@ void CPDF_ImageRenderer::HandleFilters() {
return;
if (pFilters->IsName()) {
- CFX_ByteString bsDecodeType = pFilters->GetString();
+ ByteString bsDecodeType = pFilters->GetString();
if (bsDecodeType == "DCTDecode" || bsDecodeType == "JPXDecode")
m_Flags |= FXRENDER_IMAGE_LOSSY;
return;
@@ -567,7 +567,7 @@ void CPDF_ImageRenderer::HandleFilters() {
return;
for (size_t i = 0; i < pArray->GetCount(); i++) {
- CFX_ByteString bsDecodeType = pArray->GetStringAt(i);
+ ByteString bsDecodeType = pArray->GetStringAt(i);
if (bsDecodeType == "DCTDecode" || bsDecodeType == "JPXDecode") {
m_Flags |= FXRENDER_IMAGE_LOSSY;
break;
diff --git a/core/fpdfapi/render/cpdf_textrenderer.cpp b/core/fpdfapi/render/cpdf_textrenderer.cpp
index 83e61478da..283d9946fa 100644
--- a/core/fpdfapi/render/cpdf_textrenderer.cpp
+++ b/core/fpdfapi/render/cpdf_textrenderer.cpp
@@ -76,7 +76,7 @@ void CPDF_TextRenderer::DrawTextString(CFX_RenderDevice* pDevice,
CPDF_Font* pFont,
float font_size,
const CFX_Matrix* pMatrix,
- const CFX_ByteString& str,
+ const ByteString& str,
FX_ARGB fill_argb,
const CFX_GraphStateData* pGraphState,
const CPDF_RenderOptions* pOptions) {
diff --git a/core/fpdfapi/render/cpdf_textrenderer.h b/core/fpdfapi/render/cpdf_textrenderer.h
index 31c44d9599..ac8c8c5568 100644
--- a/core/fpdfapi/render/cpdf_textrenderer.h
+++ b/core/fpdfapi/render/cpdf_textrenderer.h
@@ -28,7 +28,7 @@ class CPDF_TextRenderer {
CPDF_Font* pFont,
float font_size,
const CFX_Matrix* matrix,
- const CFX_ByteString& str,
+ const ByteString& str,
FX_ARGB fill_argb,
const CFX_GraphStateData* pGraphState,
const CPDF_RenderOptions* pOptions);
diff --git a/core/fpdfapi/render/cpdf_type3cache.cpp b/core/fpdfapi/render/cpdf_type3cache.cpp
index f113e7a862..b87b5ef74a 100644
--- a/core/fpdfapi/render/cpdf_type3cache.cpp
+++ b/core/fpdfapi/render/cpdf_type3cache.cpp
@@ -92,7 +92,7 @@ CFX_GlyphBitmap* CPDF_Type3Cache::LoadGlyph(uint32_t charcode,
keygen.Generate(
4, FXSYS_round(pMatrix->a * 10000), FXSYS_round(pMatrix->b * 10000),
FXSYS_round(pMatrix->c * 10000), FXSYS_round(pMatrix->d * 10000));
- CFX_ByteString FaceGlyphsKey(keygen.m_Key, keygen.m_KeyLen);
+ ByteString FaceGlyphsKey(keygen.m_Key, keygen.m_KeyLen);
CPDF_Type3Glyphs* pSizeCache;
auto it = m_SizeMap.find(FaceGlyphsKey);
if (it == m_SizeMap.end()) {
diff --git a/core/fpdfapi/render/cpdf_type3cache.h b/core/fpdfapi/render/cpdf_type3cache.h
index 36a1d6f98a..ab748ba989 100644
--- a/core/fpdfapi/render/cpdf_type3cache.h
+++ b/core/fpdfapi/render/cpdf_type3cache.h
@@ -39,7 +39,7 @@ class CPDF_Type3Cache : public CFX_Retainable {
float retinaScaleY);
CFX_UnownedPtr<CPDF_Type3Font> const m_pFont;
- std::map<CFX_ByteString, std::unique_ptr<CPDF_Type3Glyphs>> m_SizeMap;
+ std::map<ByteString, std::unique_ptr<CPDF_Type3Glyphs>> m_SizeMap;
};
#endif // CORE_FPDFAPI_RENDER_CPDF_TYPE3CACHE_H_
diff --git a/core/fpdfdoc/cpdf_action.cpp b/core/fpdfdoc/cpdf_action.cpp
index 4d9e630d97..9d28bc1f82 100644
--- a/core/fpdfdoc/cpdf_action.cpp
+++ b/core/fpdfdoc/cpdf_action.cpp
@@ -33,7 +33,7 @@ CPDF_Dest CPDF_Action::GetDest(CPDF_Document* pDoc) const {
if (!m_pDict)
return CPDF_Dest();
- CFX_ByteString type = m_pDict->GetStringFor("S");
+ ByteString type = m_pDict->GetStringFor("S");
if (type != "GoTo" && type != "GoToR")
return CPDF_Dest();
@@ -54,7 +54,7 @@ CPDF_Action::ActionType CPDF_Action::GetType() const {
if (!m_pDict)
return Unknown;
- CFX_ByteString csType = m_pDict->GetStringFor("S");
+ ByteString csType = m_pDict->GetStringFor("S");
if (csType.IsEmpty())
return Unknown;
@@ -65,11 +65,11 @@ CPDF_Action::ActionType CPDF_Action::GetType() const {
return Unknown;
}
-CFX_WideString CPDF_Action::GetFilePath() const {
- CFX_ByteString type = m_pDict->GetStringFor("S");
+WideString CPDF_Action::GetFilePath() const {
+ ByteString type = m_pDict->GetStringFor("S");
if (type != "GoToR" && type != "Launch" && type != "SubmitForm" &&
type != "ImportData") {
- return CFX_WideString();
+ return WideString();
}
CPDF_Object* pFile = m_pDict->GetDirectObjectFor("F");
@@ -79,14 +79,14 @@ CFX_WideString CPDF_Action::GetFilePath() const {
if (type == "Launch") {
CPDF_Dictionary* pWinDict = m_pDict->GetDictFor("Win");
if (pWinDict) {
- return CFX_WideString::FromLocal(pWinDict->GetStringFor("F").AsStringC());
+ return WideString::FromLocal(pWinDict->GetStringFor("F").AsStringView());
}
}
- return CFX_WideString();
+ return WideString();
}
-CFX_ByteString CPDF_Action::GetURI(const CPDF_Document* pDoc) const {
- CFX_ByteString csURI;
+ByteString CPDF_Action::GetURI(const CPDF_Document* pDoc) const {
+ ByteString csURI;
if (!m_pDict)
return csURI;
if (m_pDict->GetStringFor("S") != "URI")
@@ -103,8 +103,8 @@ CFX_ByteString CPDF_Action::GetURI(const CPDF_Document* pDoc) const {
return csURI;
}
-CFX_WideString CPDF_Action::GetJavaScript() const {
- CFX_WideString csJS;
+WideString CPDF_Action::GetJavaScript() const {
+ WideString csJS;
if (!m_pDict)
return csJS;
diff --git a/core/fpdfdoc/cpdf_action.h b/core/fpdfdoc/cpdf_action.h
index be4d461867..b405f226a5 100644
--- a/core/fpdfdoc/cpdf_action.h
+++ b/core/fpdfdoc/cpdf_action.h
@@ -45,12 +45,12 @@ class CPDF_Action {
CPDF_Dictionary* GetDict() const { return m_pDict.Get(); }
ActionType GetType() const;
CPDF_Dest GetDest(CPDF_Document* pDoc) const;
- CFX_WideString GetFilePath() const;
- CFX_ByteString GetURI(const CPDF_Document* pDoc) const;
+ WideString GetFilePath() const;
+ ByteString GetURI(const CPDF_Document* pDoc) const;
bool GetHideStatus() const { return m_pDict->GetBooleanFor("H", true); }
- CFX_ByteString GetNamedAction() const { return m_pDict->GetStringFor("N"); }
+ ByteString GetNamedAction() const { return m_pDict->GetStringFor("N"); }
uint32_t GetFlags() const { return m_pDict->GetIntegerFor("Flags"); }
- CFX_WideString GetJavaScript() const;
+ WideString GetJavaScript() const;
size_t GetSubActionsCount() const;
CPDF_Action GetSubAction(size_t iIndex) const;
diff --git a/core/fpdfdoc/cpdf_actionfields.cpp b/core/fpdfdoc/cpdf_actionfields.cpp
index f3c3f5ed25..cee256d3fb 100644
--- a/core/fpdfdoc/cpdf_actionfields.cpp
+++ b/core/fpdfdoc/cpdf_actionfields.cpp
@@ -23,7 +23,7 @@ size_t CPDF_ActionFields::GetFieldsCount() const {
if (!pDict)
return 0;
- CFX_ByteString csType = pDict->GetStringFor("S");
+ ByteString csType = pDict->GetStringFor("S");
CPDF_Object* pFields = nullptr;
if (csType == "Hide")
pFields = pDict->GetDirectObjectFor("T");
@@ -50,7 +50,7 @@ std::vector<CPDF_Object*> CPDF_ActionFields::GetAllFields() const {
if (!pDict)
return fields;
- CFX_ByteString csType = pDict->GetStringFor("S");
+ ByteString csType = pDict->GetStringFor("S");
CPDF_Object* pFields;
if (csType == "Hide")
pFields = pDict->GetDirectObjectFor("T");
@@ -80,7 +80,7 @@ CPDF_Object* CPDF_ActionFields::GetField(size_t iIndex) const {
if (!pDict)
return nullptr;
- CFX_ByteString csType = pDict->GetStringFor("S");
+ ByteString csType = pDict->GetStringFor("S");
CPDF_Object* pFields = nullptr;
if (csType == "Hide")
pFields = pDict->GetDirectObjectFor("T");
diff --git a/core/fpdfdoc/cpdf_annot.cpp b/core/fpdfdoc/cpdf_annot.cpp
index ea15436565..1a8538057c 100644
--- a/core/fpdfdoc/cpdf_annot.cpp
+++ b/core/fpdfdoc/cpdf_annot.cpp
@@ -179,12 +179,12 @@ CPDF_Stream* FPDFDOC_GetAnnotAP(const CPDF_Dictionary* pAnnotDict,
return pStream;
if (CPDF_Dictionary* pDict = psub->AsDictionary()) {
- CFX_ByteString as = pAnnotDict->GetStringFor("AS");
+ ByteString as = pAnnotDict->GetStringFor("AS");
if (as.IsEmpty()) {
- CFX_ByteString value = pAnnotDict->GetStringFor("V");
+ ByteString value = pAnnotDict->GetStringFor("V");
if (value.IsEmpty()) {
CPDF_Dictionary* pParentDict = pAnnotDict->GetDictFor("Parent");
- value = pParentDict ? pParentDict->GetStringFor("V") : CFX_ByteString();
+ value = pParentDict ? pParentDict->GetStringFor("V") : ByteString();
}
if (value.IsEmpty() || !pDict->KeyExist(value))
as = "Off";
@@ -241,7 +241,7 @@ bool CPDF_Annot::IsAnnotationHidden(CPDF_Dictionary* pAnnotDict) {
// Static.
CPDF_Annot::Subtype CPDF_Annot::StringToAnnotSubtype(
- const CFX_ByteString& sSubtype) {
+ const ByteString& sSubtype) {
if (sSubtype == "Text")
return CPDF_Annot::Subtype::TEXT;
if (sSubtype == "Link")
@@ -300,7 +300,7 @@ CPDF_Annot::Subtype CPDF_Annot::StringToAnnotSubtype(
}
// Static.
-CFX_ByteString CPDF_Annot::AnnotSubtypeToString(CPDF_Annot::Subtype nSubtype) {
+ByteString CPDF_Annot::AnnotSubtypeToString(CPDF_Annot::Subtype nSubtype) {
if (nSubtype == CPDF_Annot::Subtype::TEXT)
return "Text";
if (nSubtype == CPDF_Annot::Subtype::LINK)
@@ -456,7 +456,7 @@ void CPDF_Annot::DrawBorder(CFX_RenderDevice* pDevice,
width = 1;
}
} else {
- CFX_ByteString style = pBS->GetStringFor("S");
+ ByteString style = pBS->GetStringFor("S");
pDashArray = pBS->GetArrayFor("D");
style_char = style[1];
width = pBS->GetNumberFor("W");
diff --git a/core/fpdfdoc/cpdf_annot.h b/core/fpdfdoc/cpdf_annot.h
index 4ca1941819..cf1b304670 100644
--- a/core/fpdfdoc/cpdf_annot.h
+++ b/core/fpdfdoc/cpdf_annot.h
@@ -69,9 +69,8 @@ class CPDF_Annot {
};
static bool IsAnnotationHidden(CPDF_Dictionary* pAnnotDict);
- static CPDF_Annot::Subtype StringToAnnotSubtype(
- const CFX_ByteString& sSubtype);
- static CFX_ByteString AnnotSubtypeToString(CPDF_Annot::Subtype nSubtype);
+ static CPDF_Annot::Subtype StringToAnnotSubtype(const ByteString& sSubtype);
+ static ByteString AnnotSubtypeToString(CPDF_Annot::Subtype nSubtype);
static CFX_FloatRect RectFromQuadPoints(CPDF_Dictionary* pAnnotDict);
// The second constructor does not take ownership of the dictionary.
diff --git a/core/fpdfdoc/cpdf_annotlist.cpp b/core/fpdfdoc/cpdf_annotlist.cpp
index df3b631626..87e5ba7808 100644
--- a/core/fpdfdoc/cpdf_annotlist.cpp
+++ b/core/fpdfdoc/cpdf_annotlist.cpp
@@ -35,7 +35,7 @@ std::unique_ptr<CPDF_Annot> CreatePopupAnnot(CPDF_Annot* pAnnot,
// TODO(jaepark): We shouldn't strip BOM for some strings and not for others.
// See pdfium:593.
- CFX_WideString sContents = pParentDict->GetUnicodeTextFor("Contents");
+ WideString sContents = pParentDict->GetUnicodeTextFor("Contents");
if (sContents.IsEmpty())
return nullptr;
@@ -92,7 +92,7 @@ CPDF_AnnotList::CPDF_AnnotList(CPDF_Page* pPage)
CPDF_Dictionary* pDict = ToDictionary(pAnnots->GetDirectObjectAt(i));
if (!pDict)
continue;
- const CFX_ByteString subtype = pDict->GetStringFor("Subtype");
+ const ByteString subtype = pDict->GetStringFor("Subtype");
if (subtype == "Popup") {
// Skip creating Popup annotations in the PDF document since PDFium
// provides its own Popup annotations.
diff --git a/core/fpdfdoc/cpdf_apsettings.cpp b/core/fpdfdoc/cpdf_apsettings.cpp
index ee205e01dc..0fc9c202cb 100644
--- a/core/fpdfdoc/cpdf_apsettings.cpp
+++ b/core/fpdfdoc/cpdf_apsettings.cpp
@@ -18,7 +18,7 @@ CPDF_ApSettings::CPDF_ApSettings(const CPDF_ApSettings& that) = default;
CPDF_ApSettings::~CPDF_ApSettings() {}
-bool CPDF_ApSettings::HasMKEntry(const CFX_ByteString& csEntry) const {
+bool CPDF_ApSettings::HasMKEntry(const ByteString& csEntry) const {
return m_pDict && m_pDict->KeyExist(csEntry);
}
@@ -27,7 +27,7 @@ int CPDF_ApSettings::GetRotation() const {
}
FX_ARGB CPDF_ApSettings::GetColor(int& iColorType,
- const CFX_ByteString& csEntry) const {
+ const ByteString& csEntry) const {
iColorType = COLORTYPE_TRANSPARENT;
if (!m_pDict)
return 0;
@@ -65,7 +65,7 @@ FX_ARGB CPDF_ApSettings::GetColor(int& iColorType,
}
float CPDF_ApSettings::GetOriginalColor(int index,
- const CFX_ByteString& csEntry) const {
+ const ByteString& csEntry) const {
if (!m_pDict)
return 0;
@@ -75,7 +75,7 @@ float CPDF_ApSettings::GetOriginalColor(int index,
void CPDF_ApSettings::GetOriginalColor(int& iColorType,
float fc[4],
- const CFX_ByteString& csEntry) const {
+ const ByteString& csEntry) const {
iColorType = COLORTYPE_TRANSPARENT;
for (int i = 0; i < 4; i++)
fc[i] = 0;
@@ -105,12 +105,11 @@ void CPDF_ApSettings::GetOriginalColor(int& iColorType,
}
}
-CFX_WideString CPDF_ApSettings::GetCaption(
- const CFX_ByteString& csEntry) const {
- return m_pDict ? m_pDict->GetUnicodeTextFor(csEntry) : CFX_WideString();
+WideString CPDF_ApSettings::GetCaption(const ByteString& csEntry) const {
+ return m_pDict ? m_pDict->GetUnicodeTextFor(csEntry) : WideString();
}
-CPDF_Stream* CPDF_ApSettings::GetIcon(const CFX_ByteString& csEntry) const {
+CPDF_Stream* CPDF_ApSettings::GetIcon(const ByteString& csEntry) const {
return m_pDict ? m_pDict->GetStreamFor(csEntry) : nullptr;
}
diff --git a/core/fpdfdoc/cpdf_apsettings.h b/core/fpdfdoc/cpdf_apsettings.h
index 2f8f9e49d9..a2a1f91a33 100644
--- a/core/fpdfdoc/cpdf_apsettings.h
+++ b/core/fpdfdoc/cpdf_apsettings.h
@@ -23,7 +23,7 @@ class CPDF_ApSettings {
CPDF_ApSettings(const CPDF_ApSettings& that);
~CPDF_ApSettings();
- bool HasMKEntry(const CFX_ByteString& csEntry) const;
+ bool HasMKEntry(const ByteString& csEntry) const;
int GetRotation() const;
FX_ARGB GetBorderColor(int& iColorType) const {
@@ -50,9 +50,9 @@ class CPDF_ApSettings {
GetOriginalColor(iColorType, fc, "BG");
}
- CFX_WideString GetNormalCaption() const { return GetCaption("CA"); }
- CFX_WideString GetRolloverCaption() const { return GetCaption("RC"); }
- CFX_WideString GetDownCaption() const { return GetCaption("AC"); }
+ WideString GetNormalCaption() const { return GetCaption("CA"); }
+ WideString GetRolloverCaption() const { return GetCaption("RC"); }
+ WideString GetDownCaption() const { return GetCaption("AC"); }
CPDF_Stream* GetNormalIcon() const { return GetIcon("I"); }
CPDF_Stream* GetRolloverIcon() const { return GetIcon("RI"); }
CPDF_Stream* GetDownIcon() const { return GetIcon("IX"); }
@@ -62,14 +62,14 @@ class CPDF_ApSettings {
private:
friend class CPDF_FormControl;
- FX_ARGB GetColor(int& iColorType, const CFX_ByteString& csEntry) const;
- float GetOriginalColor(int index, const CFX_ByteString& csEntry) const;
+ FX_ARGB GetColor(int& iColorType, const ByteString& csEntry) const;
+ float GetOriginalColor(int index, const ByteString& csEntry) const;
void GetOriginalColor(int& iColorType,
float fc[4],
- const CFX_ByteString& csEntry) const;
+ const ByteString& csEntry) const;
- CFX_WideString GetCaption(const CFX_ByteString& csEntry) const;
- CPDF_Stream* GetIcon(const CFX_ByteString& csEntry) const;
+ WideString GetCaption(const ByteString& csEntry) const;
+ CPDF_Stream* GetIcon(const ByteString& csEntry) const;
CFX_UnownedPtr<CPDF_Dictionary> const m_pDict;
};
diff --git a/core/fpdfdoc/cpdf_bookmark.cpp b/core/fpdfdoc/cpdf_bookmark.cpp
index e84001f846..884c3cb0b8 100644
--- a/core/fpdfdoc/cpdf_bookmark.cpp
+++ b/core/fpdfdoc/cpdf_bookmark.cpp
@@ -40,25 +40,25 @@ uint32_t CPDF_Bookmark::GetFontStyle() const {
return m_pDict ? m_pDict->GetIntegerFor("F") : 0;
}
-CFX_WideString CPDF_Bookmark::GetTitle() const {
+WideString CPDF_Bookmark::GetTitle() const {
if (!m_pDict)
- return CFX_WideString();
+ return WideString();
CPDF_String* pString = ToString(m_pDict->GetDirectObjectFor("Title"));
if (!pString)
- return CFX_WideString();
+ return WideString();
- CFX_WideString title = pString->GetUnicodeText();
+ WideString title = pString->GetUnicodeText();
int len = title.GetLength();
if (!len)
- return CFX_WideString();
+ return WideString();
std::vector<wchar_t> buf(len);
for (int i = 0; i < len; i++) {
wchar_t w = title[i];
buf[i] = w > 0x20 ? w : 0x20;
}
- return CFX_WideString(buf.data(), len);
+ return WideString(buf.data(), len);
}
CPDF_Dest CPDF_Bookmark::GetDest(CPDF_Document* pDocument) const {
diff --git a/core/fpdfdoc/cpdf_bookmark.h b/core/fpdfdoc/cpdf_bookmark.h
index b9a1ac650e..88f47a9450 100644
--- a/core/fpdfdoc/cpdf_bookmark.h
+++ b/core/fpdfdoc/cpdf_bookmark.h
@@ -25,7 +25,7 @@ class CPDF_Bookmark {
CPDF_Dictionary* GetDict() const { return m_pDict.Get(); }
uint32_t GetColorRef() const;
uint32_t GetFontStyle() const;
- CFX_WideString GetTitle() const;
+ WideString GetTitle() const;
CPDF_Dest GetDest(CPDF_Document* pDocument) const;
CPDF_Action GetAction() const;
diff --git a/core/fpdfdoc/cpdf_defaultappearance.cpp b/core/fpdfdoc/cpdf_defaultappearance.cpp
index 28213aa33b..bd7ea1bc07 100644
--- a/core/fpdfdoc/cpdf_defaultappearance.cpp
+++ b/core/fpdfdoc/cpdf_defaultappearance.cpp
@@ -16,16 +16,16 @@ bool CPDF_DefaultAppearance::HasFont() {
if (m_csDA.IsEmpty())
return false;
- CPDF_SimpleParser syntax(m_csDA.AsStringC());
+ CPDF_SimpleParser syntax(m_csDA.AsStringView());
return syntax.FindTagParamFromStart("Tf", 2);
}
-CFX_ByteString CPDF_DefaultAppearance::GetFontString() {
- CFX_ByteString csFont;
+ByteString CPDF_DefaultAppearance::GetFontString() {
+ ByteString csFont;
if (m_csDA.IsEmpty())
return csFont;
- CPDF_SimpleParser syntax(m_csDA.AsStringC());
+ CPDF_SimpleParser syntax(m_csDA.AsStringView());
if (syntax.FindTagParamFromStart("Tf", 2)) {
csFont += syntax.GetWord();
csFont += " ";
@@ -36,15 +36,15 @@ CFX_ByteString CPDF_DefaultAppearance::GetFontString() {
return csFont;
}
-CFX_ByteString CPDF_DefaultAppearance::GetFont(float* fFontSize) {
+ByteString CPDF_DefaultAppearance::GetFont(float* fFontSize) {
*fFontSize = 0.0f;
if (m_csDA.IsEmpty())
- return CFX_ByteString();
+ return ByteString();
- CFX_ByteString csFontNameTag;
- CPDF_SimpleParser syntax(m_csDA.AsStringC());
+ ByteString csFontNameTag;
+ CPDF_SimpleParser syntax(m_csDA.AsStringView());
if (syntax.FindTagParamFromStart("Tf", 2)) {
- csFontNameTag = CFX_ByteString(syntax.GetWord());
+ csFontNameTag = ByteString(syntax.GetWord());
csFontNameTag.Delete(0, 1);
*fFontSize = FX_atof(syntax.GetWord());
}
@@ -55,7 +55,7 @@ bool CPDF_DefaultAppearance::HasColor(PaintOperation nOperation) {
if (m_csDA.IsEmpty())
return false;
- CPDF_SimpleParser syntax(m_csDA.AsStringC());
+ CPDF_SimpleParser syntax(m_csDA.AsStringView());
if (syntax.FindTagParamFromStart(
(nOperation == PaintOperation::STROKE ? "G" : "g"), 1)) {
return true;
@@ -68,13 +68,12 @@ bool CPDF_DefaultAppearance::HasColor(PaintOperation nOperation) {
(nOperation == PaintOperation::STROKE ? "K" : "k"), 4);
}
-CFX_ByteString CPDF_DefaultAppearance::GetColorString(
- PaintOperation nOperation) {
- CFX_ByteString csColor;
+ByteString CPDF_DefaultAppearance::GetColorString(PaintOperation nOperation) {
+ ByteString csColor;
if (m_csDA.IsEmpty())
return csColor;
- CPDF_SimpleParser syntax(m_csDA.AsStringC());
+ CPDF_SimpleParser syntax(m_csDA.AsStringView());
if (syntax.FindTagParamFromStart(
(nOperation == PaintOperation::STROKE ? "G" : "g"), 1)) {
csColor += syntax.GetWord();
@@ -118,7 +117,7 @@ void CPDF_DefaultAppearance::GetColor(int& iColorType,
if (m_csDA.IsEmpty())
return;
- CPDF_SimpleParser syntax(m_csDA.AsStringC());
+ CPDF_SimpleParser syntax(m_csDA.AsStringView());
if (syntax.FindTagParamFromStart(
(nOperation == PaintOperation::STROKE ? "G" : "g"), 1)) {
iColorType = COLORTYPE_GRAY;
@@ -151,7 +150,7 @@ void CPDF_DefaultAppearance::GetColor(FX_ARGB& color,
if (m_csDA.IsEmpty())
return;
- CPDF_SimpleParser syntax(m_csDA.AsStringC());
+ CPDF_SimpleParser syntax(m_csDA.AsStringView());
if (syntax.FindTagParamFromStart(
(nOperation == PaintOperation::STROKE ? "G" : "g"), 1)) {
iColorType = COLORTYPE_GRAY;
@@ -187,16 +186,16 @@ bool CPDF_DefaultAppearance::HasTextMatrix() {
if (m_csDA.IsEmpty())
return false;
- CPDF_SimpleParser syntax(m_csDA.AsStringC());
+ CPDF_SimpleParser syntax(m_csDA.AsStringView());
return syntax.FindTagParamFromStart("Tm", 6);
}
-CFX_ByteString CPDF_DefaultAppearance::GetTextMatrixString() {
- CFX_ByteString csTM;
+ByteString CPDF_DefaultAppearance::GetTextMatrixString() {
+ ByteString csTM;
if (m_csDA.IsEmpty())
return csTM;
- CPDF_SimpleParser syntax(m_csDA.AsStringC());
+ CPDF_SimpleParser syntax(m_csDA.AsStringView());
if (syntax.FindTagParamFromStart("Tm", 6)) {
for (int i = 0; i < 6; i++) {
csTM += syntax.GetWord();
@@ -211,7 +210,7 @@ CFX_Matrix CPDF_DefaultAppearance::GetTextMatrix() {
if (m_csDA.IsEmpty())
return CFX_Matrix();
- CPDF_SimpleParser syntax(m_csDA.AsStringC());
+ CPDF_SimpleParser syntax(m_csDA.AsStringView());
if (!syntax.FindTagParamFromStart("Tm", 6))
return CFX_Matrix();
diff --git a/core/fpdfdoc/cpdf_defaultappearance.h b/core/fpdfdoc/cpdf_defaultappearance.h
index 3be06e294d..33d4bfdd9d 100644
--- a/core/fpdfdoc/cpdf_defaultappearance.h
+++ b/core/fpdfdoc/cpdf_defaultappearance.h
@@ -19,21 +19,20 @@ enum class PaintOperation { STROKE, FILL };
class CPDF_DefaultAppearance {
public:
CPDF_DefaultAppearance() {}
- explicit CPDF_DefaultAppearance(const CFX_ByteString& csDA) : m_csDA(csDA) {}
+ explicit CPDF_DefaultAppearance(const ByteString& csDA) : m_csDA(csDA) {}
CPDF_DefaultAppearance(const CPDF_DefaultAppearance& cDA) {
m_csDA = cDA.GetStr();
}
- CFX_ByteString GetStr() const { return m_csDA; }
+ ByteString GetStr() const { return m_csDA; }
bool HasFont();
- CFX_ByteString GetFontString();
- CFX_ByteString GetFont(float* fFontSize);
+ ByteString GetFontString();
+ ByteString GetFont(float* fFontSize);
bool HasColor(PaintOperation nOperation = PaintOperation::FILL);
- CFX_ByteString GetColorString(
- PaintOperation nOperation = PaintOperation::FILL);
+ ByteString GetColorString(PaintOperation nOperation = PaintOperation::FILL);
void GetColor(int& iColorType,
float fc[4],
PaintOperation nOperation = PaintOperation::FILL);
@@ -42,11 +41,11 @@ class CPDF_DefaultAppearance {
PaintOperation nOperation = PaintOperation::FILL);
bool HasTextMatrix();
- CFX_ByteString GetTextMatrixString();
+ ByteString GetTextMatrixString();
CFX_Matrix GetTextMatrix();
private:
- CFX_ByteString m_csDA;
+ ByteString m_csDA;
};
#endif // CORE_FPDFDOC_CPDF_DEFAULTAPPEARANCE_H_
diff --git a/core/fpdfdoc/cpdf_dest.cpp b/core/fpdfdoc/cpdf_dest.cpp
index 3e1988dd5e..ebe3834e91 100644
--- a/core/fpdfdoc/cpdf_dest.cpp
+++ b/core/fpdfdoc/cpdf_dest.cpp
@@ -65,7 +65,7 @@ int CPDF_Dest::GetZoomMode() {
if (!pObj)
return 0;
- CFX_ByteString mode = pObj->GetString();
+ ByteString mode = pObj->GetString();
for (int i = 0; g_sZoomModes[i]; ++i) {
if (mode == g_sZoomModes[i])
return i + 1;
@@ -126,6 +126,6 @@ float CPDF_Dest::GetParam(int index) {
return pArray ? pArray->GetNumberAt(2 + index) : 0;
}
-CFX_ByteString CPDF_Dest::GetRemoteName() {
- return m_pObj ? m_pObj->GetString() : CFX_ByteString();
+ByteString CPDF_Dest::GetRemoteName() {
+ return m_pObj ? m_pObj->GetString() : ByteString();
}
diff --git a/core/fpdfdoc/cpdf_dest.h b/core/fpdfdoc/cpdf_dest.h
index f029d4c031..23964d7400 100644
--- a/core/fpdfdoc/cpdf_dest.h
+++ b/core/fpdfdoc/cpdf_dest.h
@@ -22,7 +22,7 @@ class CPDF_Dest {
~CPDF_Dest();
CPDF_Object* GetObject() const { return m_pObj.Get(); }
- CFX_ByteString GetRemoteName();
+ ByteString GetRemoteName();
int GetPageIndex(CPDF_Document* pDoc);
uint32_t GetPageObjNum();
int GetZoomMode();
diff --git a/core/fpdfdoc/cpdf_docjsactions.cpp b/core/fpdfdoc/cpdf_docjsactions.cpp
index 669ed7055c..974ca33b8b 100644
--- a/core/fpdfdoc/cpdf_docjsactions.cpp
+++ b/core/fpdfdoc/cpdf_docjsactions.cpp
@@ -18,9 +18,8 @@ int CPDF_DocJSActions::CountJSActions() const {
return name_tree.GetCount();
}
-CPDF_Action CPDF_DocJSActions::GetJSActionAndName(
- int index,
- CFX_WideString* csName) const {
+CPDF_Action CPDF_DocJSActions::GetJSActionAndName(int index,
+ WideString* csName) const {
ASSERT(m_pDocument);
CPDF_NameTree name_tree(m_pDocument.Get(), "JavaScript");
CPDF_Object* pAction = name_tree.LookupValueAndName(index, csName);
@@ -28,7 +27,7 @@ CPDF_Action CPDF_DocJSActions::GetJSActionAndName(
: CPDF_Action();
}
-CPDF_Action CPDF_DocJSActions::GetJSAction(const CFX_WideString& csName) const {
+CPDF_Action CPDF_DocJSActions::GetJSAction(const WideString& csName) const {
ASSERT(m_pDocument);
CPDF_NameTree name_tree(m_pDocument.Get(), "JavaScript");
CPDF_Object* pAction = name_tree.LookupValue(csName);
@@ -36,7 +35,7 @@ CPDF_Action CPDF_DocJSActions::GetJSAction(const CFX_WideString& csName) const {
: CPDF_Action();
}
-int CPDF_DocJSActions::FindJSAction(const CFX_WideString& csName) const {
+int CPDF_DocJSActions::FindJSAction(const WideString& csName) const {
ASSERT(m_pDocument);
CPDF_NameTree name_tree(m_pDocument.Get(), "JavaScript");
return name_tree.GetIndex(csName);
diff --git a/core/fpdfdoc/cpdf_docjsactions.h b/core/fpdfdoc/cpdf_docjsactions.h
index 73c0a1ef1c..c2652d7f6d 100644
--- a/core/fpdfdoc/cpdf_docjsactions.h
+++ b/core/fpdfdoc/cpdf_docjsactions.h
@@ -19,9 +19,9 @@ class CPDF_DocJSActions {
~CPDF_DocJSActions();
int CountJSActions() const;
- CPDF_Action GetJSActionAndName(int index, CFX_WideString* csName) const;
- CPDF_Action GetJSAction(const CFX_WideString& csName) const;
- int FindJSAction(const CFX_WideString& csName) const;
+ CPDF_Action GetJSActionAndName(int index, WideString* csName) const;
+ CPDF_Action GetJSAction(const WideString& csName) const;
+ int FindJSAction(const WideString& csName) const;
CPDF_Document* GetDocument() const { return m_pDocument.Get(); }
private:
diff --git a/core/fpdfdoc/cpdf_filespec.cpp b/core/fpdfdoc/cpdf_filespec.cpp
index e34f54e4e1..803c4148c7 100644
--- a/core/fpdfdoc/cpdf_filespec.cpp
+++ b/core/fpdfdoc/cpdf_filespec.cpp
@@ -20,8 +20,8 @@ namespace {
#if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ || \
_FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
-CFX_WideString ChangeSlashToPlatform(const wchar_t* str) {
- CFX_WideString result;
+WideString ChangeSlashToPlatform(const wchar_t* str) {
+ WideString result;
while (*str) {
if (*str == '/') {
#if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
@@ -37,8 +37,8 @@ CFX_WideString ChangeSlashToPlatform(const wchar_t* str) {
return result;
}
-CFX_WideString ChangeSlashToPDF(const wchar_t* str) {
- CFX_WideString result;
+WideString ChangeSlashToPDF(const wchar_t* str) {
+ WideString result;
while (*str) {
if (*str == '\\' || *str == ':')
result += L'/';
@@ -59,12 +59,12 @@ CPDF_FileSpec::CPDF_FileSpec(CPDF_Object* pObj) : m_pObj(pObj) {
CPDF_FileSpec::~CPDF_FileSpec() {}
-CFX_WideString CPDF_FileSpec::DecodeFileName(const CFX_WideString& filepath) {
+WideString CPDF_FileSpec::DecodeFileName(const WideString& filepath) {
if (filepath.GetLength() <= 1)
- return CFX_WideString();
+ return WideString();
#if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
- if (filepath.Left(sizeof("/Mac") - 1) == CFX_WideStringC(L"/Mac"))
+ if (filepath.Left(sizeof("/Mac") - 1) == WideStringView(L"/Mac"))
return ChangeSlashToPlatform(filepath.c_str() + 1);
return ChangeSlashToPlatform(filepath.c_str());
#elif _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
@@ -74,28 +74,28 @@ CFX_WideString CPDF_FileSpec::DecodeFileName(const CFX_WideString& filepath) {
if (filepath[1] == L'/')
return ChangeSlashToPlatform(filepath.c_str() + 1);
if (filepath[2] == L'/') {
- CFX_WideString result;
+ WideString result;
result += filepath[1];
result += L':';
result += ChangeSlashToPlatform(filepath.c_str() + 2);
return result;
}
- CFX_WideString result;
+ WideString result;
result += L'\\';
result += ChangeSlashToPlatform(filepath.c_str());
return result;
#else
- return CFX_WideString(filepath);
+ return WideString(filepath);
#endif
}
-CFX_WideString CPDF_FileSpec::GetFileName() const {
- CFX_WideString csFileName;
+WideString CPDF_FileSpec::GetFileName() const {
+ WideString csFileName;
if (CPDF_Dictionary* pDict = m_pObj->AsDictionary()) {
csFileName = pDict->GetUnicodeTextFor("UF");
if (csFileName.IsEmpty()) {
csFileName =
- CFX_WideString::FromLocal(pDict->GetStringFor("F").AsStringC());
+ WideString::FromLocal(pDict->GetStringFor("F").AsStringView());
}
if (pDict->GetStringFor("FS") == "URL")
return csFileName;
@@ -105,13 +105,13 @@ CFX_WideString CPDF_FileSpec::GetFileName() const {
for (const auto* key : keys) {
if (pDict->KeyExist(key)) {
csFileName =
- CFX_WideString::FromLocal(pDict->GetStringFor(key).AsStringC());
+ WideString::FromLocal(pDict->GetStringFor(key).AsStringView());
break;
}
}
}
} else if (m_pObj->IsString()) {
- csFileName = CFX_WideString::FromLocal(m_pObj->GetString().AsStringC());
+ csFileName = WideString::FromLocal(m_pObj->GetString().AsStringView());
}
return DecodeFileName(csFileName);
}
@@ -131,7 +131,7 @@ CPDF_Stream* CPDF_FileSpec::GetFileStream() const {
constexpr const char* keys[] = {"UF", "F", "DOS", "Mac", "Unix"};
size_t end = pDict->GetStringFor("FS") == "URL" ? 2 : FX_ArraySize(keys);
for (size_t i = 0; i < end; ++i) {
- const CFX_ByteString& key = keys[i];
+ const ByteString& key = keys[i];
if (!pDict->GetUnicodeTextFor(key).IsEmpty()) {
CPDF_Stream* pStream = pFiles->GetStreamFor(key);
if (pStream)
@@ -153,13 +153,13 @@ CPDF_Dictionary* CPDF_FileSpec::GetParamsDict() const {
return pDict->GetDictFor("Params");
}
-CFX_WideString CPDF_FileSpec::EncodeFileName(const CFX_WideString& filepath) {
+WideString CPDF_FileSpec::EncodeFileName(const WideString& filepath) {
if (filepath.GetLength() <= 1)
- return CFX_WideString();
+ return WideString();
#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
if (filepath[1] == L':') {
- CFX_WideString result(L'/');
+ WideString result(L'/');
result += filepath[0];
if (filepath[2] != L'\\')
result += L'/';
@@ -178,17 +178,16 @@ CFX_WideString CPDF_FileSpec::EncodeFileName(const CFX_WideString& filepath) {
return L'/' + ChangeSlashToPDF(filepath.c_str());
return ChangeSlashToPDF(filepath.c_str());
#else
- return CFX_WideString(filepath);
+ return WideString(filepath);
#endif
}
-void CPDF_FileSpec::SetFileName(const CFX_WideString& wsFileName) {
- CFX_WideString wsStr = EncodeFileName(wsFileName);
+void CPDF_FileSpec::SetFileName(const WideString& wsFileName) {
+ WideString wsStr = EncodeFileName(wsFileName);
if (m_pObj->IsString()) {
- m_pObj->SetString(CFX_ByteString::FromUnicode(wsStr));
+ m_pObj->SetString(ByteString::FromUnicode(wsStr));
} else if (CPDF_Dictionary* pDict = m_pObj->AsDictionary()) {
- pDict->SetNewFor<CPDF_String>("F", CFX_ByteString::FromUnicode(wsStr),
- false);
+ pDict->SetNewFor<CPDF_String>("F", ByteString::FromUnicode(wsStr), false);
pDict->SetNewFor<CPDF_String>("UF", PDF_EncodeText(wsStr), false);
}
}
diff --git a/core/fpdfdoc/cpdf_filespec.h b/core/fpdfdoc/cpdf_filespec.h
index 8640b2e4c6..2cbbc15977 100644
--- a/core/fpdfdoc/cpdf_filespec.h
+++ b/core/fpdfdoc/cpdf_filespec.h
@@ -22,18 +22,18 @@ class CPDF_FileSpec {
~CPDF_FileSpec();
// Convert a platform dependent file name into pdf format.
- static CFX_WideString EncodeFileName(const CFX_WideString& filepath);
+ static WideString EncodeFileName(const WideString& filepath);
// Convert a pdf file name into platform dependent format.
- static CFX_WideString DecodeFileName(const CFX_WideString& filepath);
+ static WideString DecodeFileName(const WideString& filepath);
CPDF_Object* GetObj() const { return m_pObj.Get(); }
- CFX_WideString GetFileName() const;
+ WideString GetFileName() const;
CPDF_Stream* GetFileStream() const;
CPDF_Dictionary* GetParamsDict() const;
// Set this file spec to refer to a file name (not a url).
- void SetFileName(const CFX_WideString& wsFileName);
+ void SetFileName(const WideString& wsFileName);
private:
CFX_UnownedPtr<CPDF_Object> const m_pObj;
diff --git a/core/fpdfdoc/cpdf_formcontrol.cpp b/core/fpdfdoc/cpdf_formcontrol.cpp
index 555d19660f..62302fe499 100644
--- a/core/fpdfdoc/cpdf_formcontrol.cpp
+++ b/core/fpdfdoc/cpdf_formcontrol.cpp
@@ -34,10 +34,10 @@ CPDF_FormControl::CPDF_FormControl(CPDF_FormField* pField,
CPDF_FormControl::~CPDF_FormControl() {}
-CFX_ByteString CPDF_FormControl::GetOnStateName() const {
+ByteString CPDF_FormControl::GetOnStateName() const {
ASSERT(GetType() == CPDF_FormField::CheckBox ||
GetType() == CPDF_FormField::RadioButton);
- CFX_ByteString csOn;
+ ByteString csOn;
CPDF_Dictionary* pAP = m_pWidgetDict->GetDictFor("AP");
if (!pAP)
return csOn;
@@ -50,19 +50,19 @@ CFX_ByteString CPDF_FormControl::GetOnStateName() const {
if (it.first != "Off")
return it.first;
}
- return CFX_ByteString();
+ return ByteString();
}
-void CPDF_FormControl::SetOnStateName(const CFX_ByteString& csOn) {
+void CPDF_FormControl::SetOnStateName(const ByteString& csOn) {
ASSERT(GetType() == CPDF_FormField::CheckBox ||
GetType() == CPDF_FormField::RadioButton);
- CFX_ByteString csValue = csOn;
+ ByteString csValue = csOn;
if (csValue.IsEmpty())
csValue = "Yes";
else if (csValue == "Off")
csValue = "Yes";
- CFX_ByteString csAS = m_pWidgetDict->GetStringFor("AS", "Off");
+ ByteString csAS = m_pWidgetDict->GetStringFor("AS", "Off");
if (csAS != "Off")
m_pWidgetDict->SetNewFor<CPDF_Name>("AS", csValue);
@@ -82,7 +82,7 @@ void CPDF_FormControl::SetOnStateName(const CFX_ByteString& csOn) {
auto subdict_it = pSubDict->begin();
while (subdict_it != pSubDict->end()) {
- const CFX_ByteString& csKey2 = subdict_it->first;
+ const ByteString& csKey2 = subdict_it->first;
CPDF_Object* pObj2 = subdict_it->second.get();
++subdict_it;
if (!pObj2)
@@ -95,10 +95,10 @@ void CPDF_FormControl::SetOnStateName(const CFX_ByteString& csOn) {
}
}
-CFX_ByteString CPDF_FormControl::GetCheckedAPState() {
+ByteString CPDF_FormControl::GetCheckedAPState() {
ASSERT(GetType() == CPDF_FormField::CheckBox ||
GetType() == CPDF_FormField::RadioButton);
- CFX_ByteString csOn = GetOnStateName();
+ ByteString csOn = GetOnStateName();
if (GetType() == CPDF_FormField::RadioButton ||
GetType() == CPDF_FormField::CheckBox) {
if (ToArray(FPDF_GetFieldAttr(m_pField->GetDict(), "Opt"))) {
@@ -111,10 +111,10 @@ CFX_ByteString CPDF_FormControl::GetCheckedAPState() {
return csOn;
}
-CFX_WideString CPDF_FormControl::GetExportValue() const {
+WideString CPDF_FormControl::GetExportValue() const {
ASSERT(GetType() == CPDF_FormField::CheckBox ||
GetType() == CPDF_FormField::RadioButton);
- CFX_ByteString csOn = GetOnStateName();
+ ByteString csOn = GetOnStateName();
if (GetType() == CPDF_FormField::RadioButton ||
GetType() == CPDF_FormField::CheckBox) {
if (CPDF_Array* pArray =
@@ -131,8 +131,8 @@ CFX_WideString CPDF_FormControl::GetExportValue() const {
bool CPDF_FormControl::IsChecked() const {
ASSERT(GetType() == CPDF_FormField::CheckBox ||
GetType() == CPDF_FormField::RadioButton);
- CFX_ByteString csOn = GetOnStateName();
- CFX_ByteString csAS = m_pWidgetDict->GetStringFor("AS");
+ ByteString csOn = GetOnStateName();
+ ByteString csAS = m_pWidgetDict->GetStringFor("AS");
return csAS == csOn;
}
@@ -143,17 +143,17 @@ bool CPDF_FormControl::IsDefaultChecked() const {
if (!pDV)
return false;
- CFX_ByteString csDV = pDV->GetString();
- CFX_ByteString csOn = GetOnStateName();
+ ByteString csDV = pDV->GetString();
+ ByteString csOn = GetOnStateName();
return (csDV == csOn);
}
void CPDF_FormControl::CheckControl(bool bChecked) {
ASSERT(GetType() == CPDF_FormField::CheckBox ||
GetType() == CPDF_FormField::RadioButton);
- CFX_ByteString csOn = GetOnStateName();
- CFX_ByteString csOldAS = m_pWidgetDict->GetStringFor("AS", "Off");
- CFX_ByteString csAS = "Off";
+ ByteString csOn = GetOnStateName();
+ ByteString csOldAS = m_pWidgetDict->GetStringFor("AS", "Off");
+ ByteString csAS = "Off";
if (bChecked)
csAS = csOn;
if (csOldAS == csAS)
@@ -192,7 +192,7 @@ CPDF_FormControl::HighlightingMode CPDF_FormControl::GetHighlightingMode() {
if (!m_pWidgetDict)
return Invert;
- CFX_ByteString csH = m_pWidgetDict->GetStringFor("H", "I");
+ ByteString csH = m_pWidgetDict->GetStringFor("H", "I");
for (size_t i = 0; i < FX_ArraySize(g_sHighlightingMode); ++i) {
if (csH == g_sHighlightingMode[i])
return static_cast<HighlightingMode>(i);
@@ -205,7 +205,7 @@ CPDF_ApSettings CPDF_FormControl::GetMK() const {
: nullptr);
}
-bool CPDF_FormControl::HasMKEntry(const CFX_ByteString& csEntry) const {
+bool CPDF_FormControl::HasMKEntry(const ByteString& csEntry) const {
return GetMK().HasMKEntry(csEntry);
}
@@ -213,27 +213,25 @@ int CPDF_FormControl::GetRotation() {
return GetMK().GetRotation();
}
-FX_ARGB CPDF_FormControl::GetColor(int& iColorType,
- const CFX_ByteString& csEntry) {
+FX_ARGB CPDF_FormControl::GetColor(int& iColorType, const ByteString& csEntry) {
return GetMK().GetColor(iColorType, csEntry);
}
-float CPDF_FormControl::GetOriginalColor(int index,
- const CFX_ByteString& csEntry) {
+float CPDF_FormControl::GetOriginalColor(int index, const ByteString& csEntry) {
return GetMK().GetOriginalColor(index, csEntry);
}
void CPDF_FormControl::GetOriginalColor(int& iColorType,
float fc[4],
- const CFX_ByteString& csEntry) {
+ const ByteString& csEntry) {
GetMK().GetOriginalColor(iColorType, fc, csEntry);
}
-CFX_WideString CPDF_FormControl::GetCaption(const CFX_ByteString& csEntry) {
+WideString CPDF_FormControl::GetCaption(const ByteString& csEntry) {
return GetMK().GetCaption(csEntry);
}
-CPDF_Stream* CPDF_FormControl::GetIcon(const CFX_ByteString& csEntry) {
+CPDF_Stream* CPDF_FormControl::GetIcon(const ByteString& csEntry) {
return GetMK().GetIcon(csEntry);
}
@@ -284,7 +282,7 @@ CPDF_DefaultAppearance CPDF_FormControl::GetDefaultAppearance() {
CPDF_Font* CPDF_FormControl::GetDefaultControlFont() {
float fFontSize;
CPDF_DefaultAppearance cDA = GetDefaultAppearance();
- CFX_ByteString csFontNameTag = cDA.GetFont(&fFontSize);
+ ByteString csFontNameTag = cDA.GetFont(&fFontSize);
if (csFontNameTag.IsEmpty())
return nullptr;
diff --git a/core/fpdfdoc/cpdf_formcontrol.h b/core/fpdfdoc/cpdf_formcontrol.h
index eb63b5b6f0..4f686f44ab 100644
--- a/core/fpdfdoc/cpdf_formcontrol.h
+++ b/core/fpdfdoc/cpdf_formcontrol.h
@@ -61,14 +61,14 @@ class CPDF_FormControl {
CPDF_Annot::AppearanceMode mode,
const CPDF_RenderOptions* pOptions = nullptr);
- CFX_ByteString GetCheckedAPState();
- CFX_WideString GetExportValue() const;
+ ByteString GetCheckedAPState();
+ WideString GetExportValue() const;
bool IsChecked() const;
bool IsDefaultChecked() const;
HighlightingMode GetHighlightingMode();
- bool HasMKEntry(const CFX_ByteString& csEntry) const;
+ bool HasMKEntry(const ByteString& csEntry) const;
int GetRotation();
FX_ARGB GetBorderColor(int& iColorType) { return GetColor(iColorType, "BC"); }
@@ -93,9 +93,9 @@ class CPDF_FormControl {
GetOriginalColor(iColorType, fc, "BG");
}
- CFX_WideString GetNormalCaption() { return GetCaption("CA"); }
- CFX_WideString GetRolloverCaption() { return GetCaption("RC"); }
- CFX_WideString GetDownCaption() { return GetCaption("AC"); }
+ WideString GetNormalCaption() { return GetCaption("CA"); }
+ WideString GetRolloverCaption() { return GetCaption("RC"); }
+ WideString GetDownCaption() { return GetCaption("AC"); }
CPDF_Stream* GetNormalIcon() { return GetIcon("I"); }
CPDF_Stream* GetRolloverIcon() { return GetIcon("RI"); }
@@ -114,17 +114,17 @@ class CPDF_FormControl {
friend class CPDF_InterForm;
friend class CPDF_FormField;
- CFX_ByteString GetOnStateName() const;
- void SetOnStateName(const CFX_ByteString& csOn);
+ ByteString GetOnStateName() const;
+ void SetOnStateName(const ByteString& csOn);
void CheckControl(bool bChecked);
- FX_ARGB GetColor(int& iColorType, const CFX_ByteString& csEntry);
- float GetOriginalColor(int index, const CFX_ByteString& csEntry);
+ FX_ARGB GetColor(int& iColorType, const ByteString& csEntry);
+ float GetOriginalColor(int index, const ByteString& csEntry);
void GetOriginalColor(int& iColorType,
float fc[4],
- const CFX_ByteString& csEntry);
+ const ByteString& csEntry);
- CFX_WideString GetCaption(const CFX_ByteString& csEntry);
- CPDF_Stream* GetIcon(const CFX_ByteString& csEntry);
+ WideString GetCaption(const ByteString& csEntry);
+ CPDF_Stream* GetIcon(const ByteString& csEntry);
CPDF_ApSettings GetMK() const;
CPDF_FormField* const m_pField;
diff --git a/core/fpdfdoc/cpdf_formfield.cpp b/core/fpdfdoc/cpdf_formfield.cpp
index acb46a5beb..fec1945956 100644
--- a/core/fpdfdoc/cpdf_formfield.cpp
+++ b/core/fpdfdoc/cpdf_formfield.cpp
@@ -65,13 +65,13 @@ CPDF_Object* FPDF_GetFieldAttr(const CPDF_Dictionary* pFieldDict,
return FPDF_GetFieldAttr(pParent, name, nLevel + 1);
}
-CFX_WideString FPDF_GetFullName(CPDF_Dictionary* pFieldDict) {
- CFX_WideString full_name;
+WideString FPDF_GetFullName(CPDF_Dictionary* pFieldDict) {
+ WideString full_name;
std::set<CPDF_Dictionary*> visited;
CPDF_Dictionary* pLevel = pFieldDict;
while (pLevel) {
visited.insert(pLevel);
- CFX_WideString short_name = pLevel->GetUnicodeTextFor("T");
+ WideString short_name = pLevel->GetUnicodeTextFor("T");
if (!short_name.IsEmpty()) {
if (full_name.IsEmpty())
full_name = short_name;
@@ -98,7 +98,7 @@ CPDF_FormField::~CPDF_FormField() {}
void CPDF_FormField::SyncFieldFlags() {
CPDF_Object* ft_attr = FPDF_GetFieldAttr(m_pDict.Get(), "FT");
- CFX_ByteString type_name = ft_attr ? ft_attr->GetString() : CFX_ByteString();
+ ByteString type_name = ft_attr ? ft_attr->GetString() : ByteString();
CPDF_Object* ff_attr = FPDF_GetFieldAttr(m_pDict.Get(), "Ff");
uint32_t flags = ff_attr ? ff_attr->GetInteger() : 0;
m_Flags = 0;
@@ -154,7 +154,7 @@ void CPDF_FormField::SyncFieldFlags() {
}
}
-CFX_WideString CPDF_FormField::GetFullName() const {
+WideString CPDF_FormField::GetFullName() const {
return FPDF_GetFullName(m_pDict.Get());
}
@@ -180,7 +180,7 @@ bool CPDF_FormField::ResetField(bool bNotify) {
}
case CPDF_FormField::ComboBox:
case CPDF_FormField::ListBox: {
- CFX_WideString csValue;
+ WideString csValue;
ClearSelection();
int iIndex = GetDefaultSelectedItem();
if (iIndex >= 0)
@@ -199,12 +199,12 @@ bool CPDF_FormField::ResetField(bool bNotify) {
case CPDF_FormField::File:
default: {
CPDF_Object* pDV = FPDF_GetFieldAttr(m_pDict.Get(), "DV");
- CFX_WideString csDValue;
+ WideString csDValue;
if (pDV)
csDValue = pDV->GetUnicodeText();
CPDF_Object* pV = FPDF_GetFieldAttr(m_pDict.Get(), "V");
- CFX_WideString csValue;
+ WideString csValue;
if (pV)
csValue = pV->GetUnicodeText();
@@ -272,12 +272,12 @@ CPDF_AAction CPDF_FormField::GetAdditionalAction() const {
return CPDF_AAction(pObj ? pObj->GetDict() : nullptr);
}
-CFX_WideString CPDF_FormField::GetAlternateName() const {
+WideString CPDF_FormField::GetAlternateName() const {
CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict.Get(), "TU");
return pObj ? pObj->GetUnicodeText() : L"";
}
-CFX_WideString CPDF_FormField::GetMappingName() const {
+WideString CPDF_FormField::GetMappingName() const {
CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict.Get(), "TM");
return pObj ? pObj->GetUnicodeText() : L"";
}
@@ -287,17 +287,17 @@ uint32_t CPDF_FormField::GetFieldFlags() const {
return pObj ? pObj->GetInteger() : 0;
}
-CFX_ByteString CPDF_FormField::GetDefaultStyle() const {
+ByteString CPDF_FormField::GetDefaultStyle() const {
CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict.Get(), "DS");
return pObj ? pObj->GetString() : "";
}
-CFX_WideString CPDF_FormField::GetRichTextString() const {
+WideString CPDF_FormField::GetRichTextString() const {
CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict.Get(), "RV");
return pObj ? pObj->GetUnicodeText() : L"";
}
-CFX_WideString CPDF_FormField::GetValue(bool bDefault) const {
+WideString CPDF_FormField::GetValue(bool bDefault) const {
if (GetType() == CheckBox || GetType() == RadioButton)
return GetCheckValue(bDefault);
@@ -310,7 +310,7 @@ CFX_WideString CPDF_FormField::GetValue(bool bDefault) const {
pValue = FPDF_GetFieldAttr(m_pDict.Get(), "DV");
}
if (!pValue)
- return CFX_WideString();
+ return WideString();
}
switch (pValue->GetType()) {
@@ -325,18 +325,18 @@ CFX_WideString CPDF_FormField::GetValue(bool bDefault) const {
default:
break;
}
- return CFX_WideString();
+ return WideString();
}
-CFX_WideString CPDF_FormField::GetValue() const {
+WideString CPDF_FormField::GetValue() const {
return GetValue(false);
}
-CFX_WideString CPDF_FormField::GetDefaultValue() const {
+WideString CPDF_FormField::GetDefaultValue() const {
return GetValue(true);
}
-bool CPDF_FormField::SetValue(const CFX_WideString& value,
+bool CPDF_FormField::SetValue(const WideString& value,
bool bDefault,
bool bNotify) {
switch (m_Type) {
@@ -349,14 +349,14 @@ bool CPDF_FormField::SetValue(const CFX_WideString& value,
case RichText:
case Text:
case ComboBox: {
- CFX_WideString csValue = value;
+ WideString csValue = value;
if (bNotify && !NotifyBeforeValueChange(csValue))
return false;
- CFX_ByteString key(bDefault ? "DV" : "V");
+ ByteString key(bDefault ? "DV" : "V");
int iIndex = FindOptionValue(csValue);
if (iIndex < 0) {
- CFX_ByteString bsEncodeText = PDF_EncodeText(csValue);
+ ByteString bsEncodeText = PDF_EncodeText(csValue);
m_pDict->SetNewFor<CPDF_String>(key, bsEncodeText, false);
if (m_Type == RichText && !bDefault)
m_pDict->SetNewFor<CPDF_String>("RV", bsEncodeText, false);
@@ -397,7 +397,7 @@ bool CPDF_FormField::SetValue(const CFX_WideString& value,
return true;
}
-bool CPDF_FormField::SetValue(const CFX_WideString& value, bool bNotify) {
+bool CPDF_FormField::SetValue(const WideString& value, bool bNotify) {
return SetValue(value, false, bNotify);
}
@@ -440,7 +440,7 @@ int CPDF_FormField::GetSelectedIndex(int index) const {
if (pValue->IsNumber())
return pValue->GetInteger();
- CFX_WideString sel_value;
+ WideString sel_value;
if (pValue->IsString()) {
if (index != 0)
return -1;
@@ -451,12 +451,11 @@ int CPDF_FormField::GetSelectedIndex(int index) const {
return -1;
CPDF_Object* elementValue = pArray->GetDirectObjectAt(index);
- sel_value =
- elementValue ? elementValue->GetUnicodeText() : CFX_WideString();
+ sel_value = elementValue ? elementValue->GetUnicodeText() : WideString();
}
if (index < CountSelectedOptions()) {
int iOptIndex = GetSelectedOptionIndex(index);
- CFX_WideString csOpt = GetOptionValue(iOptIndex);
+ WideString csOpt = GetOptionValue(iOptIndex);
if (csOpt == sel_value)
return iOptIndex;
}
@@ -469,7 +468,7 @@ int CPDF_FormField::GetSelectedIndex(int index) const {
bool CPDF_FormField::ClearSelection(bool bNotify) {
if (bNotify && m_pForm->m_pFormNotify) {
- CFX_WideString csValue;
+ WideString csValue;
int iIndex = GetSelectedIndex(0);
if (iIndex >= 0)
csValue = GetOptionLabel(iIndex);
@@ -491,7 +490,7 @@ bool CPDF_FormField::IsItemSelected(int index) const {
if (IsOptionSelected(index))
return true;
- CFX_WideString opt_value = GetOptionValue(index);
+ WideString opt_value = GetOptionValue(index);
CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict.Get(), "V");
if (!pValue) {
pValue = FPDF_GetFieldAttr(m_pDict.Get(), "I");
@@ -532,7 +531,7 @@ bool CPDF_FormField::SetItemSelection(int index, bool bSelected, bool bNotify) {
if (index < 0 || index >= CountOptions())
return false;
- CFX_WideString opt_value = GetOptionValue(index);
+ WideString opt_value = GetOptionValue(index);
if (bNotify && !NotifyListOrComboBoxBeforeChange(opt_value))
return false;
@@ -598,7 +597,7 @@ int CPDF_FormField::GetDefaultSelectedItem() const {
CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict.Get(), "DV");
if (!pValue)
return -1;
- CFX_WideString csDV = pValue->GetUnicodeText();
+ WideString csDV = pValue->GetUnicodeText();
if (csDV.IsEmpty())
return -1;
for (int i = 0; i < CountOptions(); i++) {
@@ -613,30 +612,30 @@ int CPDF_FormField::CountOptions() const {
return pArray ? pArray->GetCount() : 0;
}
-CFX_WideString CPDF_FormField::GetOptionText(int index, int sub_index) const {
+WideString CPDF_FormField::GetOptionText(int index, int sub_index) const {
CPDF_Array* pArray = ToArray(FPDF_GetFieldAttr(m_pDict.Get(), "Opt"));
if (!pArray)
- return CFX_WideString();
+ return WideString();
CPDF_Object* pOption = pArray->GetDirectObjectAt(index);
if (!pOption)
- return CFX_WideString();
+ return WideString();
if (CPDF_Array* pOptionArray = pOption->AsArray())
pOption = pOptionArray->GetDirectObjectAt(sub_index);
CPDF_String* pString = ToString(pOption);
- return pString ? pString->GetUnicodeText() : CFX_WideString();
+ return pString ? pString->GetUnicodeText() : WideString();
}
-CFX_WideString CPDF_FormField::GetOptionLabel(int index) const {
+WideString CPDF_FormField::GetOptionLabel(int index) const {
return GetOptionText(index, 1);
}
-CFX_WideString CPDF_FormField::GetOptionValue(int index) const {
+WideString CPDF_FormField::GetOptionValue(int index) const {
return GetOptionText(index, 0);
}
-int CPDF_FormField::FindOption(CFX_WideString csOptLabel) const {
+int CPDF_FormField::FindOption(WideString csOptLabel) const {
for (int i = 0; i < CountOptions(); i++) {
if (GetOptionValue(i) == csOptLabel)
return i;
@@ -644,7 +643,7 @@ int CPDF_FormField::FindOption(CFX_WideString csOptLabel) const {
return -1;
}
-int CPDF_FormField::FindOptionValue(const CFX_WideString& csOptValue) const {
+int CPDF_FormField::FindOptionValue(const WideString& csOptValue) const {
for (int i = 0; i < CountOptions(); i++) {
if (GetOptionValue(i) == csOptValue)
return i;
@@ -653,7 +652,7 @@ int CPDF_FormField::FindOptionValue(const CFX_WideString& csOptValue) const {
}
#ifdef PDF_ENABLE_XFA
-int CPDF_FormField::InsertOption(CFX_WideString csOptLabel,
+int CPDF_FormField::InsertOption(WideString csOptLabel,
int index,
bool bNotify) {
if (csOptLabel.IsEmpty())
@@ -662,7 +661,7 @@ int CPDF_FormField::InsertOption(CFX_WideString csOptLabel,
if (bNotify && !NotifyListOrComboBoxBeforeChange(csOptLabel))
return -1;
- CFX_ByteString csStr = PDF_EncodeText(csOptLabel);
+ ByteString csStr = PDF_EncodeText(csOptLabel);
CPDF_Array* pOpt = ToArray(FPDF_GetFieldAttr(m_pDict.Get(), "Opt"));
if (!pOpt)
pOpt = m_pDict->SetNewFor<CPDF_Array>("Opt");
@@ -682,7 +681,7 @@ int CPDF_FormField::InsertOption(CFX_WideString csOptLabel,
bool CPDF_FormField::ClearOptions(bool bNotify) {
if (bNotify && m_pForm->m_pFormNotify) {
- CFX_WideString csValue;
+ WideString csValue;
int iIndex = GetSelectedIndex(0);
if (iIndex >= 0)
csValue = GetOptionLabel(iIndex);
@@ -713,14 +712,14 @@ bool CPDF_FormField::CheckControl(int iControlIndex,
if (!bChecked && pControl->IsChecked() == bChecked)
return false;
- CFX_WideString csWExport = pControl->GetExportValue();
- CFX_ByteString csBExport = PDF_EncodeText(csWExport);
+ WideString csWExport = pControl->GetExportValue();
+ ByteString csBExport = PDF_EncodeText(csWExport);
int iCount = CountControls();
bool bUnison = IsUnison(this);
for (int i = 0; i < iCount; i++) {
CPDF_FormControl* pCtrl = GetControl(i);
if (bUnison) {
- CFX_WideString csEValue = pCtrl->GetExportValue();
+ WideString csEValue = pCtrl->GetExportValue();
if (csEValue == csWExport) {
if (pCtrl->GetOnStateName() == pControl->GetOnStateName())
pCtrl->CheckControl(bChecked);
@@ -742,7 +741,7 @@ bool CPDF_FormField::CheckControl(int iControlIndex,
if (bChecked) {
m_pDict->SetNewFor<CPDF_Name>("V", csBExport);
} else {
- CFX_ByteString csV;
+ ByteString csV;
CPDF_Object* pV = FPDF_GetFieldAttr(m_pDict.Get(), "V");
if (pV)
csV = pV->GetString();
@@ -750,7 +749,7 @@ bool CPDF_FormField::CheckControl(int iControlIndex,
m_pDict->SetNewFor<CPDF_Name>("V", "Off");
}
} else if (bChecked) {
- CFX_ByteString csIndex;
+ ByteString csIndex;
csIndex.Format("%d", iControlIndex);
m_pDict->SetNewFor<CPDF_Name>("V", csIndex);
}
@@ -759,9 +758,9 @@ bool CPDF_FormField::CheckControl(int iControlIndex,
return true;
}
-CFX_WideString CPDF_FormField::GetCheckValue(bool bDefault) const {
+WideString CPDF_FormField::GetCheckValue(bool bDefault) const {
ASSERT(GetType() == CheckBox || GetType() == RadioButton);
- CFX_WideString csExport = L"Off";
+ WideString csExport = L"Off";
int iCount = CountControls();
for (int i = 0; i < iCount; i++) {
CPDF_FormControl* pControl = GetControl(i);
@@ -775,14 +774,14 @@ CFX_WideString CPDF_FormField::GetCheckValue(bool bDefault) const {
return csExport;
}
-bool CPDF_FormField::SetCheckValue(const CFX_WideString& value,
+bool CPDF_FormField::SetCheckValue(const WideString& value,
bool bDefault,
bool bNotify) {
ASSERT(GetType() == CheckBox || GetType() == RadioButton);
int iCount = CountControls();
for (int i = 0; i < iCount; i++) {
CPDF_FormControl* pControl = GetControl(i);
- CFX_WideString csExport = pControl->GetExportValue();
+ WideString csExport = pControl->GetExportValue();
bool val = csExport == value;
if (!bDefault)
CheckControl(GetControlIndex(pControl), val);
@@ -844,7 +843,7 @@ bool CPDF_FormField::SelectOption(int iOptIndex, bool bSelected, bool bNotify) {
return true;
if (bNotify && m_pForm->m_pFormNotify) {
- CFX_WideString csValue = GetOptionLabel(iOptIndex);
+ WideString csValue = GetOptionLabel(iOptIndex);
if (!NotifyListOrComboBoxBeforeChange(csValue))
return false;
}
@@ -858,7 +857,7 @@ bool CPDF_FormField::SelectOption(int iOptIndex, bool bSelected, bool bNotify) {
continue;
if (bNotify && m_pForm->m_pFormNotify) {
- CFX_WideString csValue = GetOptionLabel(iOptIndex);
+ WideString csValue = GetOptionLabel(iOptIndex);
if (!NotifyListOrComboBoxBeforeChange(csValue))
return false;
}
@@ -882,7 +881,7 @@ bool CPDF_FormField::SelectOption(int iOptIndex, bool bSelected, bool bNotify) {
bool CPDF_FormField::ClearSelectedOptions(bool bNotify) {
if (bNotify && m_pForm->m_pFormNotify) {
- CFX_WideString csValue;
+ WideString csValue;
int iIndex = GetSelectedIndex(0);
if (iIndex >= 0)
csValue = GetOptionLabel(iIndex);
@@ -902,7 +901,7 @@ void CPDF_FormField::LoadDA() {
if (!pFormDict)
return;
- CFX_ByteString DA;
+ ByteString DA;
if (CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict.Get(), "DA"))
DA = pObj->GetString();
@@ -920,9 +919,9 @@ void CPDF_FormField::LoadDA() {
if (!pFont)
return;
- CPDF_SimpleParser syntax(DA.AsStringC());
+ CPDF_SimpleParser syntax(DA.AsStringView());
syntax.FindTagParamFromStart("Tf", 2);
- CFX_ByteString font_name(syntax.GetWord());
+ ByteString font_name(syntax.GetWord());
CPDF_Dictionary* pFontDict = pFont->GetDictFor(font_name);
if (!pFontDict)
return;
@@ -931,7 +930,7 @@ void CPDF_FormField::LoadDA() {
m_FontSize = FX_atof(syntax.GetWord());
}
-bool CPDF_FormField::NotifyBeforeSelectionChange(const CFX_WideString& value) {
+bool CPDF_FormField::NotifyBeforeSelectionChange(const WideString& value) {
if (!m_pForm->m_pFormNotify)
return true;
return m_pForm->m_pFormNotify->BeforeSelectionChange(this, value) >= 0;
@@ -943,7 +942,7 @@ void CPDF_FormField::NotifyAfterSelectionChange() {
m_pForm->m_pFormNotify->AfterSelectionChange(this);
}
-bool CPDF_FormField::NotifyBeforeValueChange(const CFX_WideString& value) {
+bool CPDF_FormField::NotifyBeforeValueChange(const WideString& value) {
if (!m_pForm->m_pFormNotify)
return true;
return m_pForm->m_pFormNotify->BeforeValueChange(this, value) >= 0;
@@ -955,8 +954,7 @@ void CPDF_FormField::NotifyAfterValueChange() {
m_pForm->m_pFormNotify->AfterValueChange(this);
}
-bool CPDF_FormField::NotifyListOrComboBoxBeforeChange(
- const CFX_WideString& value) {
+bool CPDF_FormField::NotifyListOrComboBoxBeforeChange(const WideString& value) {
switch (GetType()) {
case ListBox:
return NotifyBeforeSelectionChange(value);
diff --git a/core/fpdfdoc/cpdf_formfield.h b/core/fpdfdoc/cpdf_formfield.h
index 417f9d189f..6b4b7253e0 100644
--- a/core/fpdfdoc/cpdf_formfield.h
+++ b/core/fpdfdoc/cpdf_formfield.h
@@ -40,7 +40,7 @@ class CPDF_String;
CPDF_Object* FPDF_GetFieldAttr(const CPDF_Dictionary* pFieldDict,
const char* name,
int nLevel = 0);
-CFX_WideString FPDF_GetFullName(CPDF_Dictionary* pFieldDict);
+WideString FPDF_GetFullName(CPDF_Dictionary* pFieldDict);
class CPDF_FormField {
public:
@@ -60,7 +60,7 @@ class CPDF_FormField {
CPDF_FormField(CPDF_InterForm* pForm, CPDF_Dictionary* pDict);
~CPDF_FormField();
- CFX_WideString GetFullName() const;
+ WideString GetFullName() const;
Type GetType() const { return m_Type; }
uint32_t GetFlags() const { return m_Flags; }
@@ -82,16 +82,16 @@ class CPDF_FormField {
int GetFieldType() const;
CPDF_AAction GetAdditionalAction() const;
- CFX_WideString GetAlternateName() const;
- CFX_WideString GetMappingName() const;
+ WideString GetAlternateName() const;
+ WideString GetMappingName() const;
uint32_t GetFieldFlags() const;
- CFX_ByteString GetDefaultStyle() const;
- CFX_WideString GetRichTextString() const;
+ ByteString GetDefaultStyle() const;
+ WideString GetRichTextString() const;
- CFX_WideString GetValue() const;
- CFX_WideString GetDefaultValue() const;
- bool SetValue(const CFX_WideString& value, bool bNotify = false);
+ WideString GetValue() const;
+ WideString GetDefaultValue() const;
+ bool SetValue(const WideString& value, bool bNotify = false);
int GetMaxLen() const;
int CountSelectedItems() const;
@@ -106,11 +106,11 @@ class CPDF_FormField {
int GetDefaultSelectedItem() const;
int CountOptions() const;
- CFX_WideString GetOptionLabel(int index) const;
- CFX_WideString GetOptionValue(int index) const;
+ WideString GetOptionLabel(int index) const;
+ WideString GetOptionValue(int index) const;
- int FindOption(CFX_WideString csOptLabel) const;
- int FindOptionValue(const CFX_WideString& csOptValue) const;
+ int FindOption(WideString csOptLabel) const;
+ int FindOptionValue(const WideString& csOptValue) const;
bool CheckControl(int iControlIndex, bool bChecked, bool bNotify = false);
@@ -127,9 +127,7 @@ class CPDF_FormField {
#ifdef PDF_ENABLE_XFA
bool ClearOptions(bool bNotify = false);
- int InsertOption(CFX_WideString csOptLabel,
- int index = -1,
- bool bNotify = false);
+ int InsertOption(WideString csOptLabel, int index = -1, bool bNotify = false);
#endif // PDF_ENABLE_XFA
float GetFontSize() const { return m_FontSize; }
@@ -138,7 +136,7 @@ class CPDF_FormField {
const CPDF_Dictionary* GetDict() const { return m_pDict.Get(); }
const CPDF_InterForm* GetForm() const { return m_pForm.Get(); }
- CFX_WideString GetCheckValue(bool bDefault) const;
+ WideString GetCheckValue(bool bDefault) const;
void AddFormControl(CPDF_FormControl* pFormControl) {
m_ControlList.emplace_back(pFormControl);
@@ -149,23 +147,23 @@ class CPDF_FormField {
}
private:
- CFX_WideString GetValue(bool bDefault) const;
- bool SetValue(const CFX_WideString& value, bool bDefault, bool bNotify);
+ WideString GetValue(bool bDefault) const;
+ bool SetValue(const WideString& value, bool bDefault, bool bNotify);
void SyncFieldFlags();
int FindListSel(CPDF_String* str);
- CFX_WideString GetOptionText(int index, int sub_index) const;
+ WideString GetOptionText(int index, int sub_index) const;
void LoadDA();
- bool SetCheckValue(const CFX_WideString& value, bool bDefault, bool bNotify);
+ bool SetCheckValue(const WideString& value, bool bDefault, bool bNotify);
- bool NotifyBeforeSelectionChange(const CFX_WideString& value);
+ bool NotifyBeforeSelectionChange(const WideString& value);
void NotifyAfterSelectionChange();
- bool NotifyBeforeValueChange(const CFX_WideString& value);
+ bool NotifyBeforeValueChange(const WideString& value);
void NotifyAfterValueChange();
- bool NotifyListOrComboBoxBeforeChange(const CFX_WideString& value);
+ bool NotifyListOrComboBoxBeforeChange(const WideString& value);
void NotifyListOrComboBoxAfterChange();
CPDF_FormField::Type m_Type;
diff --git a/core/fpdfdoc/cpdf_formfield_unittest.cpp b/core/fpdfdoc/cpdf_formfield_unittest.cpp
index 4aeda84c88..af5d15dab3 100644
--- a/core/fpdfdoc/cpdf_formfield_unittest.cpp
+++ b/core/fpdfdoc/cpdf_formfield_unittest.cpp
@@ -10,7 +10,7 @@
#include "testing/gtest/include/gtest/gtest.h"
TEST(cpdf_formfield, FPDF_GetFullName) {
- CFX_WideString name = FPDF_GetFullName(nullptr);
+ WideString name = FPDF_GetFullName(nullptr);
EXPECT_TRUE(name.IsEmpty());
CPDF_IndirectObjectHolder obj_holder;
diff --git a/core/fpdfdoc/cpdf_iconfit.cpp b/core/fpdfdoc/cpdf_iconfit.cpp
index a28f3bc430..20ed963e92 100644
--- a/core/fpdfdoc/cpdf_iconfit.cpp
+++ b/core/fpdfdoc/cpdf_iconfit.cpp
@@ -20,7 +20,7 @@ CPDF_IconFit::ScaleMethod CPDF_IconFit::GetScaleMethod() {
if (!m_pDict)
return Always;
- CFX_ByteString csSW = m_pDict->GetStringFor("SW", "A");
+ ByteString csSW = m_pDict->GetStringFor("SW", "A");
if (csSW == "B")
return Bigger;
if (csSW == "S")
diff --git a/core/fpdfdoc/cpdf_interform.cpp b/core/fpdfdoc/cpdf_interform.cpp
index 7e73f7e5a5..3bbb50b9ec 100644
--- a/core/fpdfdoc/cpdf_interform.cpp
+++ b/core/fpdfdoc/cpdf_interform.cpp
@@ -40,24 +40,24 @@ const struct SupportFieldEncoding {
{"UHC", 949},
};
-CFX_WideString GetFieldValue(const CPDF_Dictionary& pFieldDict,
- const CFX_ByteString& bsEncoding) {
- const CFX_ByteString csBValue = pFieldDict.GetStringFor("V");
+WideString GetFieldValue(const CPDF_Dictionary& pFieldDict,
+ const ByteString& bsEncoding) {
+ const ByteString csBValue = pFieldDict.GetStringFor("V");
for (const auto& encoding : g_fieldEncoding) {
if (bsEncoding == encoding.m_name)
- return CFX_WideString::FromCodePage(csBValue.AsStringC(),
- encoding.m_codePage);
+ return WideString::FromCodePage(csBValue.AsStringView(),
+ encoding.m_codePage);
}
- CFX_ByteString csTemp = csBValue.Left(2);
+ ByteString csTemp = csBValue.Left(2);
if (csTemp == "\xFF\xFE" || csTemp == "\xFE\xFF")
return PDF_DecodeText(csBValue);
- return CFX_WideString::FromLocal(csBValue.AsStringC());
+ return WideString::FromLocal(csBValue.AsStringView());
}
void AddFont(CPDF_Dictionary*& pFormDict,
CPDF_Document* pDocument,
const CPDF_Font* pFont,
- CFX_ByteString* csNameTag);
+ ByteString* csNameTag);
void InitDict(CPDF_Dictionary*& pFormDict, CPDF_Document* pDocument) {
if (!pDocument)
@@ -69,17 +69,16 @@ void InitDict(CPDF_Dictionary*& pFormDict, CPDF_Document* pDocument) {
pFormDict->GetObjNum());
}
- CFX_ByteString csDA;
+ ByteString csDA;
if (!pFormDict->KeyExist("DR")) {
- CFX_ByteString csBaseName;
+ ByteString csBaseName;
uint8_t charSet = CPDF_InterForm::GetNativeCharSet();
CPDF_Font* pFont = CPDF_InterForm::AddStandardFont(pDocument, "Helvetica");
if (pFont)
AddFont(pFormDict, pDocument, pFont, &csBaseName);
if (charSet != FX_CHARSET_ANSI) {
- CFX_ByteString csFontName =
- CPDF_InterForm::GetNativeFont(charSet, nullptr);
+ ByteString csFontName = CPDF_InterForm::GetNativeFont(charSet, nullptr);
if (!pFont || csFontName != "Helvetica") {
pFont = CPDF_InterForm::AddNativeFont(pDocument);
if (pFont) {
@@ -101,8 +100,8 @@ void InitDict(CPDF_Dictionary*& pFormDict, CPDF_Document* pDocument) {
CPDF_Font* GetFont(CPDF_Dictionary* pFormDict,
CPDF_Document* pDocument,
- const CFX_ByteString& csNameTag) {
- CFX_ByteString csAlias = PDF_NameDecode(csNameTag);
+ const ByteString& csNameTag) {
+ ByteString csAlias = PDF_NameDecode(csNameTag);
if (!pFormDict || csAlias.IsEmpty())
return nullptr;
@@ -126,7 +125,7 @@ CPDF_Font* GetFont(CPDF_Dictionary* pFormDict,
CPDF_Font* GetNativeFont(CPDF_Dictionary* pFormDict,
CPDF_Document* pDocument,
uint8_t charSet,
- CFX_ByteString* csNameTag) {
+ ByteString* csNameTag) {
if (!pFormDict)
return nullptr;
@@ -139,7 +138,7 @@ CPDF_Font* GetNativeFont(CPDF_Dictionary* pFormDict,
return nullptr;
for (const auto& it : *pFonts) {
- const CFX_ByteString& csKey = it.first;
+ const ByteString& csKey = it.first;
if (!it.second)
continue;
@@ -166,7 +165,7 @@ CPDF_Font* GetNativeFont(CPDF_Dictionary* pFormDict,
bool FindFont(CPDF_Dictionary* pFormDict,
const CPDF_Font* pFont,
- CFX_ByteString* csNameTag) {
+ ByteString* csNameTag) {
if (!pFormDict || !pFont)
return false;
@@ -179,7 +178,7 @@ bool FindFont(CPDF_Dictionary* pFormDict,
return false;
for (const auto& it : *pFonts) {
- const CFX_ByteString& csKey = it.first;
+ const ByteString& csKey = it.first;
if (!it.second)
continue;
CPDF_Dictionary* pElement = ToDictionary(it.second->GetDirect());
@@ -197,9 +196,9 @@ bool FindFont(CPDF_Dictionary* pFormDict,
bool FindFont(CPDF_Dictionary* pFormDict,
CPDF_Document* pDocument,
- CFX_ByteString csFontName,
+ ByteString csFontName,
CPDF_Font*& pFont,
- CFX_ByteString* csNameTag) {
+ ByteString* csNameTag) {
if (!pFormDict)
return false;
@@ -215,7 +214,7 @@ bool FindFont(CPDF_Dictionary* pFormDict,
csFontName.Remove(' ');
for (const auto& it : *pFonts) {
- const CFX_ByteString& csKey = it.first;
+ const ByteString& csKey = it.first;
if (!it.second)
continue;
@@ -228,7 +227,7 @@ bool FindFont(CPDF_Dictionary* pFormDict,
if (!pFont)
continue;
- CFX_ByteString csBaseFont;
+ ByteString csBaseFont;
csBaseFont = pFont->GetBaseFont();
csBaseFont.Remove(' ');
if (csBaseFont == csFontName) {
@@ -242,13 +241,13 @@ bool FindFont(CPDF_Dictionary* pFormDict,
void AddFont(CPDF_Dictionary*& pFormDict,
CPDF_Document* pDocument,
const CPDF_Font* pFont,
- CFX_ByteString* csNameTag) {
+ ByteString* csNameTag) {
if (!pFont)
return;
if (!pFormDict)
InitDict(pFormDict, pDocument);
- CFX_ByteString csTag;
+ ByteString csTag;
if (FindFont(pFormDict, pFont, &csTag)) {
*csNameTag = csTag;
return;
@@ -277,17 +276,17 @@ void AddFont(CPDF_Dictionary*& pFormDict,
CPDF_Font* AddNativeFont(CPDF_Dictionary*& pFormDict,
CPDF_Document* pDocument,
uint8_t charSet,
- CFX_ByteString* csNameTag) {
+ ByteString* csNameTag) {
if (!pFormDict)
InitDict(pFormDict, pDocument);
- CFX_ByteString csTemp;
+ ByteString csTemp;
CPDF_Font* pFont = GetNativeFont(pFormDict, pDocument, charSet, &csTemp);
if (pFont) {
*csNameTag = csTemp;
return pFont;
}
- CFX_ByteString csFontName = CPDF_InterForm::GetNativeFont(charSet, nullptr);
+ ByteString csFontName = CPDF_InterForm::GetNativeFont(charSet, nullptr);
if (!csFontName.IsEmpty() &&
FindFont(pFormDict, pDocument, csFontName, pFont, csNameTag)) {
return pFont;
@@ -301,7 +300,7 @@ CPDF_Font* AddNativeFont(CPDF_Dictionary*& pFormDict,
class CFieldNameExtractor {
public:
- explicit CFieldNameExtractor(const CFX_WideString& full_name)
+ explicit CFieldNameExtractor(const WideString& full_name)
: m_FullName(full_name) {
m_pCur = m_FullName.c_str();
m_pEnd = m_pCur + m_FullName.GetLength();
@@ -318,7 +317,7 @@ class CFieldNameExtractor {
}
protected:
- CFX_WideString m_FullName;
+ WideString m_FullName;
const wchar_t* m_pCur;
const wchar_t* m_pEnd;
};
@@ -371,7 +370,7 @@ bool RetrieveSpecificFont(uint8_t charSet,
}
#endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
-int CompareFieldName(const CFX_WideString& name1, const CFX_WideString& name2) {
+int CompareFieldName(const WideString& name1, const WideString& name2) {
const wchar_t* ptr1 = name1.c_str();
const wchar_t* ptr2 = name2.c_str();
if (name1.GetLength() == name2.GetLength())
@@ -394,7 +393,7 @@ class CFieldTree {
class Node {
public:
Node() : m_pField(nullptr), m_level(0) {}
- Node(const CFX_WideString& short_name, int level)
+ Node(const WideString& short_name, int level)
: m_ShortName(short_name), m_level(level) {}
~Node() {}
@@ -420,7 +419,7 @@ class CFieldTree {
CPDF_FormField* GetField() const { return m_pField.get(); }
- const CFX_WideString& GetShortName() const { return m_ShortName; }
+ const WideString& GetShortName() const { return m_ShortName; }
int GetLevel() const { return m_level; }
@@ -451,7 +450,7 @@ class CFieldTree {
}
std::vector<std::unique_ptr<Node>> m_Children;
- CFX_WideString m_ShortName;
+ WideString m_ShortName;
std::unique_ptr<CPDF_FormField> m_pField;
const int m_level;
};
@@ -459,14 +458,14 @@ class CFieldTree {
CFieldTree();
~CFieldTree();
- bool SetField(const CFX_WideString& full_name,
+ bool SetField(const WideString& full_name,
std::unique_ptr<CPDF_FormField> pField);
- CPDF_FormField* GetField(const CFX_WideString& full_name);
+ CPDF_FormField* GetField(const WideString& full_name);
- Node* FindNode(const CFX_WideString& full_name);
- Node* AddChild(Node* pParent, const CFX_WideString& short_name);
+ Node* FindNode(const WideString& full_name);
+ Node* AddChild(Node* pParent, const WideString& short_name);
- Node* Lookup(Node* pParent, const CFX_WideString& short_name);
+ Node* Lookup(Node* pParent, const WideString& short_name);
Node m_Root;
};
@@ -476,7 +475,7 @@ CFieldTree::CFieldTree() {}
CFieldTree::~CFieldTree() {}
CFieldTree::Node* CFieldTree::AddChild(Node* pParent,
- const CFX_WideString& short_name) {
+ const WideString& short_name) {
if (!pParent)
return nullptr;
@@ -491,7 +490,7 @@ CFieldTree::Node* CFieldTree::AddChild(Node* pParent,
}
CFieldTree::Node* CFieldTree::Lookup(Node* pParent,
- const CFX_WideString& short_name) {
+ const WideString& short_name) {
if (!pParent)
return nullptr;
@@ -503,7 +502,7 @@ CFieldTree::Node* CFieldTree::Lookup(Node* pParent,
return nullptr;
}
-bool CFieldTree::SetField(const CFX_WideString& full_name,
+bool CFieldTree::SetField(const WideString& full_name,
std::unique_ptr<CPDF_FormField> pField) {
if (full_name.IsEmpty())
return false;
@@ -516,7 +515,7 @@ bool CFieldTree::SetField(const CFX_WideString& full_name,
Node* pLast = nullptr;
while (nLength > 0) {
pLast = pNode;
- CFX_WideString name = CFX_WideString(pName, nLength);
+ WideString name = WideString(pName, nLength);
pNode = Lookup(pLast, name);
if (!pNode)
pNode = AddChild(pLast, name);
@@ -532,7 +531,7 @@ bool CFieldTree::SetField(const CFX_WideString& full_name,
return true;
}
-CPDF_FormField* CFieldTree::GetField(const CFX_WideString& full_name) {
+CPDF_FormField* CFieldTree::GetField(const WideString& full_name) {
if (full_name.IsEmpty())
return nullptr;
@@ -544,14 +543,14 @@ CPDF_FormField* CFieldTree::GetField(const CFX_WideString& full_name) {
Node* pLast = nullptr;
while (nLength > 0 && pNode) {
pLast = pNode;
- CFX_WideString name = CFX_WideString(pName, nLength);
+ WideString name = WideString(pName, nLength);
pNode = Lookup(pLast, name);
name_extractor.GetNext(pName, nLength);
}
return pNode ? pNode->GetField() : nullptr;
}
-CFieldTree::Node* CFieldTree::FindNode(const CFX_WideString& full_name) {
+CFieldTree::Node* CFieldTree::FindNode(const WideString& full_name) {
if (full_name.IsEmpty())
return nullptr;
@@ -563,7 +562,7 @@ CFieldTree::Node* CFieldTree::FindNode(const CFX_WideString& full_name) {
Node* pLast = nullptr;
while (nLength > 0 && pNode) {
pLast = pNode;
- CFX_WideString name = CFX_WideString(pName, nLength);
+ WideString name = WideString(pName, nLength);
pNode = Lookup(pLast, name);
name_extractor.GetNext(pName, nLength);
}
@@ -572,7 +571,7 @@ CFieldTree::Node* CFieldTree::FindNode(const CFX_WideString& full_name) {
CPDF_Font* AddNativeInterFormFont(CPDF_Dictionary*& pFormDict,
CPDF_Document* pDocument,
- CFX_ByteString* csNameTag) {
+ ByteString* csNameTag) {
uint8_t charSet = CPDF_InterForm::GetNativeCharSet();
return AddNativeFont(pFormDict, pDocument, charSet, csNameTag);
}
@@ -671,13 +670,13 @@ void CPDF_InterForm::SetUpdateAP(bool bUpdateAP) {
s_bUpdateAP = bUpdateAP;
}
-CFX_ByteString CPDF_InterForm::GenerateNewResourceName(
+ByteString CPDF_InterForm::GenerateNewResourceName(
const CPDF_Dictionary* pResDict,
const char* csType,
int iMinLen,
const char* csPrefix) {
- CFX_ByteString csStr = csPrefix;
- CFX_ByteString csBType = csType;
+ ByteString csStr = csPrefix;
+ ByteString csBType = csType;
if (csStr.IsEmpty()) {
if (csBType == "ExtGState")
csStr = "GS";
@@ -688,7 +687,7 @@ CFX_ByteString CPDF_InterForm::GenerateNewResourceName(
else
csStr = "Res";
}
- CFX_ByteString csTmp = csStr;
+ ByteString csTmp = csStr;
int iCount = csStr.GetLength();
int m = 0;
if (iMinLen > 0) {
@@ -710,9 +709,9 @@ CFX_ByteString CPDF_InterForm::GenerateNewResourceName(
return csTmp;
int num = 0;
- CFX_ByteString bsNum;
+ ByteString bsNum;
while (true) {
- CFX_ByteString csKey = csTmp + bsNum;
+ ByteString csKey = csTmp + bsNum;
if (!pDict->KeyExist(csKey))
return csKey;
if (m < iCount)
@@ -726,7 +725,7 @@ CFX_ByteString CPDF_InterForm::GenerateNewResourceName(
}
CPDF_Font* CPDF_InterForm::AddStandardFont(CPDF_Document* pDocument,
- CFX_ByteString csFontName) {
+ ByteString csFontName) {
if (!pDocument || csFontName.IsEmpty())
return nullptr;
@@ -737,8 +736,8 @@ CPDF_Font* CPDF_InterForm::AddStandardFont(CPDF_Document* pDocument,
return pDocument->AddStandardFont(csFontName.c_str(), &encoding);
}
-CFX_ByteString CPDF_InterForm::GetNativeFont(uint8_t charSet, void* pLogFont) {
- CFX_ByteString csFontName;
+ByteString CPDF_InterForm::GetNativeFont(uint8_t charSet, void* pLogFont) {
+ ByteString csFontName;
#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
LOGFONTA lf = {};
if (charSet == FX_CHARSET_ANSI) {
@@ -786,7 +785,7 @@ CPDF_Font* CPDF_InterForm::AddNativeFont(uint8_t charSet,
#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
LOGFONTA lf;
- CFX_ByteString csFontName = GetNativeFont(charSet, &lf);
+ ByteString csFontName = GetNativeFont(charSet, &lf);
if (!csFontName.IsEmpty()) {
if (csFontName == "Helvetica")
return AddStandardFont(pDocument, csFontName);
@@ -801,7 +800,7 @@ CPDF_Font* CPDF_InterForm::AddNativeFont(CPDF_Document* pDocument) {
}
bool CPDF_InterForm::ValidateFieldName(
- CFX_WideString& csNewFieldName,
+ WideString& csNewFieldName,
int iType,
const CPDF_FormField* pExcludedField,
const CPDF_FormControl* pExcludedControl) const {
@@ -810,7 +809,7 @@ bool CPDF_InterForm::ValidateFieldName(
int iPos = 0;
int iLength = csNewFieldName.GetLength();
- CFX_WideString csSub;
+ WideString csSub;
while (true) {
while (iPos < iLength &&
(csNewFieldName[iPos] == L'.' || csNewFieldName[iPos] == L' ')) {
@@ -835,7 +834,7 @@ bool CPDF_InterForm::ValidateFieldName(
if (!pExcludedControl || pField->CountControls() < 2)
continue;
}
- CFX_WideString csFullName = pField->GetFullName();
+ WideString csFullName = pField->GetFullName();
int iRet = CompareFieldName(csSub, csFullName);
if (iRet == 1) {
if (pField->GetFieldType() != iType)
@@ -858,7 +857,7 @@ bool CPDF_InterForm::ValidateFieldName(
return true;
}
-size_t CPDF_InterForm::CountFields(const CFX_WideString& csFieldName) const {
+size_t CPDF_InterForm::CountFields(const WideString& csFieldName) const {
if (csFieldName.IsEmpty())
return m_pFieldTree->m_Root.CountFields();
@@ -866,9 +865,8 @@ size_t CPDF_InterForm::CountFields(const CFX_WideString& csFieldName) const {
return pNode ? pNode->CountFields() : 0;
}
-CPDF_FormField* CPDF_InterForm::GetField(
- uint32_t index,
- const CFX_WideString& csFieldName) const {
+CPDF_FormField* CPDF_InterForm::GetField(uint32_t index,
+ const WideString& csFieldName) const {
if (csFieldName.IsEmpty())
return m_pFieldTree->m_Root.GetFieldAtIndex(index);
@@ -881,7 +879,7 @@ CPDF_FormField* CPDF_InterForm::GetFieldByDict(
if (!pFieldDict)
return nullptr;
- CFX_WideString csWName = FPDF_GetFullName(pFieldDict);
+ WideString csWName = FPDF_GetFullName(pFieldDict);
return m_pFieldTree->GetField(csWName);
}
@@ -960,7 +958,7 @@ int CPDF_InterForm::FindFieldInCalculationOrder(const CPDF_FormField* pField) {
return -1;
}
-CPDF_Font* CPDF_InterForm::GetFormFont(CFX_ByteString csNameTag) const {
+CPDF_Font* CPDF_InterForm::GetFormFont(ByteString csNameTag) const {
return GetFont(m_pFormDict.Get(), m_pDocument.Get(), csNameTag);
}
@@ -1070,7 +1068,7 @@ void CPDF_InterForm::AddTerminalField(CPDF_Dictionary* pFieldDict) {
}
CPDF_Dictionary* pDict = pFieldDict;
- CFX_WideString csWName = FPDF_GetFullName(pFieldDict);
+ WideString csWName = FPDF_GetFullName(pFieldDict);
if (csWName.IsEmpty())
return;
@@ -1177,7 +1175,7 @@ bool CPDF_InterForm::CheckRequiredFields(
}
std::unique_ptr<CFDF_Document> CPDF_InterForm::ExportToFDF(
- const CFX_WideString& pdf_path,
+ const WideString& pdf_path,
bool bSimpleFileSpec) const {
std::vector<CPDF_FormField*> fields;
size_t nCount = m_pFieldTree->m_Root.CountFields();
@@ -1187,7 +1185,7 @@ std::unique_ptr<CFDF_Document> CPDF_InterForm::ExportToFDF(
}
std::unique_ptr<CFDF_Document> CPDF_InterForm::ExportToFDF(
- const CFX_WideString& pdf_path,
+ const WideString& pdf_path,
const std::vector<CPDF_FormField*>& fields,
bool bIncludeOrExclude,
bool bSimpleFileSpec) const {
@@ -1198,9 +1196,9 @@ std::unique_ptr<CFDF_Document> CPDF_InterForm::ExportToFDF(
CPDF_Dictionary* pMainDict = pDoc->GetRoot()->GetDictFor("FDF");
if (!pdf_path.IsEmpty()) {
if (bSimpleFileSpec) {
- CFX_WideString wsFilePath = CPDF_FileSpec::EncodeFileName(pdf_path);
+ WideString wsFilePath = CPDF_FileSpec::EncodeFileName(pdf_path);
pMainDict->SetNewFor<CPDF_String>(
- "F", CFX_ByteString::FromUnicode(wsFilePath), false);
+ "F", ByteString::FromUnicode(wsFilePath), false);
pMainDict->SetNewFor<CPDF_String>("UF", PDF_EncodeText(wsFilePath),
false);
} else {
@@ -1230,14 +1228,14 @@ std::unique_ptr<CFDF_Document> CPDF_InterForm::ExportToFDF(
continue;
}
- CFX_WideString fullname = FPDF_GetFullName(pField->GetFieldDict());
+ WideString fullname = FPDF_GetFullName(pField->GetFieldDict());
auto pFieldDict =
pdfium::MakeUnique<CPDF_Dictionary>(pDoc->GetByteStringPool());
pFieldDict->SetNewFor<CPDF_String>("T", fullname);
if (pField->GetType() == CPDF_FormField::CheckBox ||
pField->GetType() == CPDF_FormField::RadioButton) {
- CFX_WideString csExport = pField->GetCheckValue(false);
- CFX_ByteString csBExport = PDF_EncodeText(csExport);
+ WideString csExport = pField->GetCheckValue(false);
+ ByteString csBExport = PDF_EncodeText(csExport);
CPDF_Object* pOpt = FPDF_GetFieldAttr(pField->GetDict(), "Opt");
if (pOpt)
pFieldDict->SetNewFor<CPDF_String>("V", csBExport, false);
@@ -1255,10 +1253,10 @@ std::unique_ptr<CFDF_Document> CPDF_InterForm::ExportToFDF(
}
void CPDF_InterForm::FDF_ImportField(CPDF_Dictionary* pFieldDict,
- const CFX_WideString& parent_name,
+ const WideString& parent_name,
bool bNotify,
int nLevel) {
- CFX_WideString name;
+ WideString name;
if (!parent_name.IsEmpty())
name = parent_name + L".";
@@ -1281,7 +1279,7 @@ void CPDF_InterForm::FDF_ImportField(CPDF_Dictionary* pFieldDict,
if (!pField)
return;
- CFX_WideString csWValue = GetFieldValue(*pFieldDict, m_bsEncoding);
+ WideString csWValue = GetFieldValue(*pFieldDict, m_bsEncoding);
int iType = pField->GetFieldType();
if (bNotify && m_pFormNotify) {
if (iType == FIELDTYPE_LISTBOX) {
diff --git a/core/fpdfdoc/cpdf_interform.h b/core/fpdfdoc/cpdf_interform.h
index 9dc0532939..d3796e5752 100644
--- a/core/fpdfdoc/cpdf_interform.h
+++ b/core/fpdfdoc/cpdf_interform.h
@@ -30,7 +30,7 @@ class IPDF_FormNotify;
CPDF_Font* AddNativeInterFormFont(CPDF_Dictionary*& pFormDict,
CPDF_Document* pDocument,
- CFX_ByteString* csNameTag);
+ ByteString* csNameTag);
class CPDF_InterForm {
public:
@@ -39,20 +39,19 @@ class CPDF_InterForm {
static void SetUpdateAP(bool bUpdateAP);
static bool IsUpdateAPEnabled();
- static CFX_ByteString GenerateNewResourceName(const CPDF_Dictionary* pResDict,
- const char* csType,
- int iMinLen,
- const char* csPrefix);
+ static ByteString GenerateNewResourceName(const CPDF_Dictionary* pResDict,
+ const char* csType,
+ int iMinLen,
+ const char* csPrefix);
static CPDF_Font* AddStandardFont(CPDF_Document* pDocument,
- CFX_ByteString csFontName);
- static CFX_ByteString GetNativeFont(uint8_t iCharSet, void* pLogFont);
+ ByteString csFontName);
+ static ByteString GetNativeFont(uint8_t iCharSet, void* pLogFont);
static uint8_t GetNativeCharSet();
static CPDF_Font* AddNativeFont(uint8_t iCharSet, CPDF_Document* pDocument);
static CPDF_Font* AddNativeFont(CPDF_Document* pDocument);
- size_t CountFields(const CFX_WideString& csFieldName) const;
- CPDF_FormField* GetField(uint32_t index,
- const CFX_WideString& csFieldName) const;
+ size_t CountFields(const WideString& csFieldName) const;
+ CPDF_FormField* GetField(uint32_t index, const WideString& csFieldName) const;
CPDF_FormField* GetFieldByDict(CPDF_Dictionary* pFieldDict) const;
CPDF_FormControl* GetControlAtPoint(CPDF_Page* pPage,
@@ -65,18 +64,18 @@ class CPDF_InterForm {
CPDF_FormField* GetFieldInCalculationOrder(int index);
int FindFieldInCalculationOrder(const CPDF_FormField* pField);
- CPDF_Font* GetFormFont(CFX_ByteString csNameTag) const;
+ CPDF_Font* GetFormFont(ByteString csNameTag) const;
CPDF_DefaultAppearance GetDefaultAppearance() const;
int GetFormAlignment() const;
bool CheckRequiredFields(const std::vector<CPDF_FormField*>* fields,
bool bIncludeOrExclude) const;
- std::unique_ptr<CFDF_Document> ExportToFDF(const CFX_WideString& pdf_path,
+ std::unique_ptr<CFDF_Document> ExportToFDF(const WideString& pdf_path,
bool bSimpleFileSpec) const;
std::unique_ptr<CFDF_Document> ExportToFDF(
- const CFX_WideString& pdf_path,
+ const WideString& pdf_path,
const std::vector<CPDF_FormField*>& fields,
bool bIncludeOrExclude,
bool bSimpleFileSpec) const;
@@ -99,10 +98,10 @@ class CPDF_InterForm {
CPDF_FormControl* AddControl(CPDF_FormField* pField,
CPDF_Dictionary* pWidgetDict);
void FDF_ImportField(CPDF_Dictionary* pField,
- const CFX_WideString& parent_name,
+ const WideString& parent_name,
bool bNotify = false,
int nLevel = 0);
- bool ValidateFieldName(CFX_WideString& csNewFieldName,
+ bool ValidateFieldName(WideString& csNewFieldName,
int iType,
const CPDF_FormField* pExcludedField,
const CPDF_FormControl* pExcludedControl) const;
@@ -114,7 +113,7 @@ class CPDF_InterForm {
std::map<const CPDF_Dictionary*, std::unique_ptr<CPDF_FormControl>>
m_ControlMap;
std::unique_ptr<CFieldTree> m_pFieldTree;
- CFX_ByteString m_bsEncoding;
+ ByteString m_bsEncoding;
CFX_UnownedPtr<IPDF_FormNotify> m_pFormNotify;
};
diff --git a/core/fpdfdoc/cpdf_nametree.cpp b/core/fpdfdoc/cpdf_nametree.cpp
index d225d3f0bf..bdbf8b467e 100644
--- a/core/fpdfdoc/cpdf_nametree.cpp
+++ b/core/fpdfdoc/cpdf_nametree.cpp
@@ -19,11 +19,10 @@ namespace {
const int nMaxRecursion = 32;
-std::pair<CFX_WideString, CFX_WideString> GetNodeLimitsMaybeSwap(
- CPDF_Array* pLimits) {
+std::pair<WideString, WideString> GetNodeLimitsMaybeSwap(CPDF_Array* pLimits) {
ASSERT(pLimits);
- CFX_WideString csLeft = pLimits->GetUnicodeTextAt(0);
- CFX_WideString csRight = pLimits->GetUnicodeTextAt(1);
+ WideString csLeft = pLimits->GetUnicodeTextAt(0);
+ WideString csRight = pLimits->GetUnicodeTextAt(1);
// If the lower limit is greater than the upper limit, swap them.
if (csLeft.Compare(csRight) > 0) {
pLimits->SetNewAt<CPDF_String>(0, csRight);
@@ -71,14 +70,14 @@ bool GetNodeAncestorsLimits(const CPDF_Dictionary* pNode,
// if needed, and any ancestors that are now empty will be removed.
bool UpdateNodesAndLimitsUponDeletion(CPDF_Dictionary* pNode,
const CPDF_Array* pFind,
- const CFX_WideString& csName,
+ const WideString& csName,
int nLevel) {
if (nLevel > nMaxRecursion)
return false;
CPDF_Array* pLimits = pNode->GetArrayFor("Limits");
- CFX_WideString csLeft;
- CFX_WideString csRight;
+ WideString csLeft;
+ WideString csRight;
if (pLimits)
std::tie(csLeft, csRight) = GetNodeLimitsMaybeSwap(pLimits);
@@ -93,10 +92,10 @@ bool UpdateNodesAndLimitsUponDeletion(CPDF_Dictionary* pNode,
// Since |csName| defines |pNode|'s limits, we need to loop through the
// names to find the new lower and upper limits.
- CFX_WideString csNewLeft = csRight;
- CFX_WideString csNewRight = csLeft;
+ WideString csNewLeft = csRight;
+ WideString csNewRight = csLeft;
for (size_t i = 0; i < pNames->GetCount() / 2; ++i) {
- CFX_WideString wsName = pNames->GetUnicodeTextAt(i * 2);
+ WideString wsName = pNames->GetUnicodeTextAt(i * 2);
if (wsName.Compare(csNewLeft) < 0)
csNewLeft = wsName;
if (wsName.Compare(csNewRight) > 0)
@@ -131,8 +130,8 @@ bool UpdateNodesAndLimitsUponDeletion(CPDF_Dictionary* pNode,
// Since |csName| defines |pNode|'s limits, we need to loop through the
// kids to find the new lower and upper limits.
- CFX_WideString csNewLeft = csRight;
- CFX_WideString csNewRight = csLeft;
+ WideString csNewLeft = csRight;
+ WideString csNewRight = csLeft;
for (size_t j = 0; j < pKids->GetCount(); ++j) {
CPDF_Array* pKidLimits = pKids->GetDictAt(j)->GetArrayFor("Limits");
ASSERT(pKidLimits);
@@ -155,7 +154,7 @@ bool UpdateNodesAndLimitsUponDeletion(CPDF_Dictionary* pNode,
// will be the leaf array that |csName| should be added to, and |pFindIndex|
// will be the index that it should be added at.
CPDF_Object* SearchNameNode(CPDF_Dictionary* pNode,
- const CFX_WideString& csName,
+ const WideString& csName,
size_t& nIndex,
int nLevel,
CPDF_Array** ppFind,
@@ -166,8 +165,8 @@ CPDF_Object* SearchNameNode(CPDF_Dictionary* pNode,
CPDF_Array* pLimits = pNode->GetArrayFor("Limits");
CPDF_Array* pNames = pNode->GetArrayFor("Names");
if (pLimits) {
- CFX_WideString csLeft;
- CFX_WideString csRight;
+ WideString csLeft;
+ WideString csRight;
std::tie(csLeft, csRight) = GetNodeLimitsMaybeSwap(pLimits);
// Skip this node if the name to look for is smaller than its lower limit.
if (csName.Compare(csLeft) < 0)
@@ -189,7 +188,7 @@ CPDF_Object* SearchNameNode(CPDF_Dictionary* pNode,
if (pNames) {
size_t dwCount = pNames->GetCount() / 2;
for (size_t i = 0; i < dwCount; i++) {
- CFX_WideString csValue = pNames->GetUnicodeTextAt(i * 2);
+ WideString csValue = pNames->GetUnicodeTextAt(i * 2);
int32_t iCompare = csValue.Compare(csName);
if (iCompare > 0)
break;
@@ -233,7 +232,7 @@ CPDF_Object* SearchNameNode(CPDF_Dictionary* pNode,
size_t nIndex,
size_t& nCurIndex,
int nLevel,
- CFX_WideString* csName,
+ WideString* csName,
CPDF_Array** ppFind,
int* pFindIndex) {
if (nLevel > nMaxRecursion)
@@ -300,7 +299,7 @@ size_t CountNames(CPDF_Dictionary* pNode, int nLevel = 0) {
CPDF_NameTree::CPDF_NameTree(CPDF_Dictionary* pRoot) : m_pRoot(pRoot) {}
CPDF_NameTree::CPDF_NameTree(const CPDF_Document* pDoc,
- const CFX_ByteString& category)
+ const ByteString& category)
: m_pRoot(nullptr) {
const CPDF_Dictionary* pRoot = pDoc->GetRoot();
if (!pRoot)
@@ -319,7 +318,7 @@ size_t CPDF_NameTree::GetCount() const {
return m_pRoot ? ::CountNames(m_pRoot.Get()) : 0;
}
-int CPDF_NameTree::GetIndex(const CFX_WideString& csName) const {
+int CPDF_NameTree::GetIndex(const WideString& csName) const {
if (!m_pRoot)
return -1;
@@ -330,7 +329,7 @@ int CPDF_NameTree::GetIndex(const CFX_WideString& csName) const {
}
bool CPDF_NameTree::AddValueAndName(std::unique_ptr<CPDF_Object> pObj,
- const CFX_WideString& name) {
+ const WideString& name) {
if (!m_pRoot)
return false;
@@ -347,7 +346,7 @@ bool CPDF_NameTree::AddValueAndName(std::unique_ptr<CPDF_Object> pObj,
// |name| and |pObj|.
if (!pFind) {
size_t nCurIndex = 0;
- CFX_WideString csName;
+ WideString csName;
SearchNameNode(m_pRoot.Get(), 0, nCurIndex, 0, &csName, &pFind, nullptr);
}
ASSERT(pFind);
@@ -381,7 +380,7 @@ bool CPDF_NameTree::DeleteValueAndName(int nIndex) {
return false;
size_t nCurIndex = 0;
- CFX_WideString csName;
+ WideString csName;
CPDF_Array* pFind = nullptr;
int nFindIndex = -1;
// Fail if the tree does not contain |nIndex|.
@@ -400,7 +399,7 @@ bool CPDF_NameTree::DeleteValueAndName(int nIndex) {
}
CPDF_Object* CPDF_NameTree::LookupValueAndName(int nIndex,
- CFX_WideString* csName) const {
+ WideString* csName) const {
csName->clear();
if (!m_pRoot)
return nullptr;
@@ -410,7 +409,7 @@ CPDF_Object* CPDF_NameTree::LookupValueAndName(int nIndex,
nullptr);
}
-CPDF_Object* CPDF_NameTree::LookupValue(const CFX_WideString& csName) const {
+CPDF_Object* CPDF_NameTree::LookupValue(const WideString& csName) const {
if (!m_pRoot)
return nullptr;
@@ -419,7 +418,7 @@ CPDF_Object* CPDF_NameTree::LookupValue(const CFX_WideString& csName) const {
}
CPDF_Array* CPDF_NameTree::LookupNamedDest(CPDF_Document* pDoc,
- const CFX_WideString& sName) {
+ const WideString& sName) {
CPDF_Object* pValue = LookupValue(sName);
if (!pValue) {
CPDF_Dictionary* pDests = pDoc->GetRoot()->GetDictFor("Dests");
diff --git a/core/fpdfdoc/cpdf_nametree.h b/core/fpdfdoc/cpdf_nametree.h
index 4dc43fc3ac..add62f1767 100644
--- a/core/fpdfdoc/cpdf_nametree.h
+++ b/core/fpdfdoc/cpdf_nametree.h
@@ -20,18 +20,18 @@ class CPDF_Object;
class CPDF_NameTree {
public:
explicit CPDF_NameTree(CPDF_Dictionary* pRoot);
- CPDF_NameTree(const CPDF_Document* pDoc, const CFX_ByteString& category);
+ CPDF_NameTree(const CPDF_Document* pDoc, const ByteString& category);
~CPDF_NameTree();
bool AddValueAndName(std::unique_ptr<CPDF_Object> pObj,
- const CFX_WideString& name);
+ const WideString& name);
bool DeleteValueAndName(int nIndex);
- CPDF_Object* LookupValueAndName(int nIndex, CFX_WideString* csName) const;
- CPDF_Object* LookupValue(const CFX_WideString& csName) const;
- CPDF_Array* LookupNamedDest(CPDF_Document* pDoc, const CFX_WideString& sName);
+ CPDF_Object* LookupValueAndName(int nIndex, WideString* csName) const;
+ CPDF_Object* LookupValue(const WideString& csName) const;
+ CPDF_Array* LookupNamedDest(CPDF_Document* pDoc, const WideString& sName);
- int GetIndex(const CFX_WideString& csName) const;
+ int GetIndex(const WideString& csName) const;
size_t GetCount() const;
CPDF_Dictionary* GetRoot() const { return m_pRoot.Get(); }
diff --git a/core/fpdfdoc/cpdf_nametree_unittest.cpp b/core/fpdfdoc/cpdf_nametree_unittest.cpp
index e6e188a72c..38c3140b90 100644
--- a/core/fpdfdoc/cpdf_nametree_unittest.cpp
+++ b/core/fpdfdoc/cpdf_nametree_unittest.cpp
@@ -84,17 +84,17 @@ TEST(cpdf_nametree, GetUnicodeNameWithBOM) {
constexpr char kData[] = "\xFE\xFF\x00\x31";
for (size_t i = 0; i < sizeof(kData); ++i)
buf.put(kData[i]);
- pNames->AddNew<CPDF_String>(CFX_ByteString(buf), true);
+ pNames->AddNew<CPDF_String>(ByteString(buf), true);
pNames->AddNew<CPDF_Number>(100);
// Check that the key is as expected.
CPDF_NameTree nameTree(pRootDict.get());
- CFX_WideString storedName;
+ WideString storedName;
nameTree.LookupValueAndName(0, &storedName);
EXPECT_STREQ(L"1", storedName.c_str());
// Check that the correct value object can be obtained by looking up "1".
- CFX_WideString matchName = L"1";
+ WideString matchName = L"1";
CPDF_Object* pObj = nameTree.LookupValue(matchName);
ASSERT_TRUE(pObj->IsNumber());
EXPECT_EQ(100, pObj->AsNumber()->GetInteger());
@@ -232,7 +232,7 @@ TEST(cpdf_nametree, DeleteFromKids) {
// Delete the name "9.txt", and check that its node gets deleted and its
// parent node's limits get updated.
- CFX_WideString csName;
+ WideString csName;
ASSERT_TRUE(nameTree.LookupValue(L"9.txt"));
EXPECT_EQ(999, nameTree.LookupValue(L"9.txt")->GetInteger());
EXPECT_TRUE(nameTree.LookupValueAndName(4, &csName));
diff --git a/core/fpdfdoc/cpdf_occontext.cpp b/core/fpdfdoc/cpdf_occontext.cpp
index 7e746e0028..069292c65b 100644
--- a/core/fpdfdoc/cpdf_occontext.cpp
+++ b/core/fpdfdoc/cpdf_occontext.cpp
@@ -24,13 +24,13 @@ int32_t FindGroup(const CPDF_Array* pArray, const CPDF_Dictionary* pGroupDict) {
}
bool HasIntent(const CPDF_Dictionary* pDict,
- const CFX_ByteStringC& csElement,
- const CFX_ByteStringC& csDef) {
+ const ByteStringView& csElement,
+ const ByteStringView& csDef) {
CPDF_Object* pIntent = pDict->GetDirectObjectFor("Intent");
if (!pIntent)
return csElement == csDef;
- CFX_ByteString bsIntent;
+ ByteString bsIntent;
if (CPDF_Array* pArray = pIntent->AsArray()) {
for (size_t i = 0; i < pArray->GetCount(); i++) {
bsIntent = pArray->GetStringAt(i);
@@ -70,8 +70,8 @@ CPDF_Dictionary* GetConfig(CPDF_Document* pDoc,
return pConfig;
}
-CFX_ByteString GetUsageTypeString(CPDF_OCContext::UsageType eType) {
- CFX_ByteString csState;
+ByteString GetUsageTypeString(CPDF_OCContext::UsageType eType) {
+ ByteString csState;
switch (eType) {
case CPDF_OCContext::Design:
csState = "Design";
@@ -99,7 +99,7 @@ CPDF_OCContext::CPDF_OCContext(CPDF_Document* pDoc, UsageType eUsageType)
CPDF_OCContext::~CPDF_OCContext() {}
bool CPDF_OCContext::LoadOCGStateFromConfig(
- const CFX_ByteString& csConfig,
+ const ByteString& csConfig,
const CPDF_Dictionary* pOCGDict) const {
CPDF_Dictionary* pConfig = GetConfig(m_pDocument.Get(), pOCGDict);
if (!pConfig)
@@ -120,7 +120,7 @@ bool CPDF_OCContext::LoadOCGStateFromConfig(
if (!pArray)
return bState;
- CFX_ByteString csFind = csConfig + "State";
+ ByteString csFind = csConfig + "State";
for (size_t i = 0; i < pArray->GetCount(); i++) {
CPDF_Dictionary* pUsage = pArray->GetDictAt(i);
if (!pUsage)
@@ -149,12 +149,12 @@ bool CPDF_OCContext::LoadOCGState(const CPDF_Dictionary* pOCGDict) const {
if (!HasIntent(pOCGDict, "View", "View"))
return true;
- CFX_ByteString csState = GetUsageTypeString(m_eUsageType);
+ ByteString csState = GetUsageTypeString(m_eUsageType);
CPDF_Dictionary* pUsage = pOCGDict->GetDictFor("Usage");
if (pUsage) {
CPDF_Dictionary* pState = pUsage->GetDictFor(csState);
if (pState) {
- CFX_ByteString csFind = csState + "State";
+ ByteString csFind = csState + "State";
if (pState->KeyExist(csFind))
return pState->GetStringFor(csFind) != "OFF";
}
@@ -196,7 +196,7 @@ bool CPDF_OCContext::GetOCGVE(CPDF_Array* pExpression, int nLevel) {
if (nLevel > 32 || !pExpression)
return false;
- CFX_ByteString csOperator = pExpression->GetStringAt(0);
+ ByteString csOperator = pExpression->GetStringAt(0);
if (csOperator == "Not") {
CPDF_Object* pOCGObj = pExpression->GetDirectObjectAt(1);
if (!pOCGObj)
@@ -241,7 +241,7 @@ bool CPDF_OCContext::LoadOCMDState(const CPDF_Dictionary* pOCMDDict) {
if (pVE)
return GetOCGVE(pVE, 0);
- CFX_ByteString csP = pOCMDDict->GetStringFor("P", "AnyOn");
+ ByteString csP = pOCMDDict->GetStringFor("P", "AnyOn");
CPDF_Object* pOCGObj = pOCMDDict->GetDirectObjectFor("OCGs");
if (!pOCGObj)
return true;
@@ -279,7 +279,7 @@ bool CPDF_OCContext::CheckOCGVisible(const CPDF_Dictionary* pOCGDict) {
if (!pOCGDict)
return true;
- CFX_ByteString csType = pOCGDict->GetStringFor("Type", "OCG");
+ ByteString csType = pOCGDict->GetStringFor("Type", "OCG");
if (csType == "OCG")
return GetOCGVisible(pOCGDict);
return LoadOCMDState(pOCGDict);
diff --git a/core/fpdfdoc/cpdf_occontext.h b/core/fpdfdoc/cpdf_occontext.h
index ea8eea2489..3c93ef1d59 100644
--- a/core/fpdfdoc/cpdf_occontext.h
+++ b/core/fpdfdoc/cpdf_occontext.h
@@ -31,7 +31,7 @@ class CPDF_OCContext : public CFX_Retainable {
CPDF_OCContext(CPDF_Document* pDoc, UsageType eUsageType);
~CPDF_OCContext() override;
- bool LoadOCGStateFromConfig(const CFX_ByteString& csConfig,
+ bool LoadOCGStateFromConfig(const ByteString& csConfig,
const CPDF_Dictionary* pOCGDict) const;
bool LoadOCGState(const CPDF_Dictionary* pOCGDict) const;
bool GetOCGVisible(const CPDF_Dictionary* pOCGDict);
diff --git a/core/fpdfdoc/cpdf_pagelabel.cpp b/core/fpdfdoc/cpdf_pagelabel.cpp
index 7b5e66e585..5efb18ef3d 100644
--- a/core/fpdfdoc/cpdf_pagelabel.cpp
+++ b/core/fpdfdoc/cpdf_pagelabel.cpp
@@ -13,16 +13,15 @@
namespace {
-CFX_WideString MakeRoman(int num) {
+WideString MakeRoman(int num) {
const int kArabic[] = {1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1};
- const CFX_WideString kRoman[] = {L"m", L"cm", L"d", L"cd", L"c",
- L"xc", L"l", L"xl", L"x", L"ix",
- L"v", L"iv", L"i"};
+ const WideString kRoman[] = {L"m", L"cm", L"d", L"cd", L"c", L"xc", L"l",
+ L"xl", L"x", L"ix", L"v", L"iv", L"i"};
const int kMaxNum = 1000000;
num %= kMaxNum;
int i = 0;
- CFX_WideString wsRomanNumber;
+ WideString wsRomanNumber;
while (num > 0) {
while (num >= kArabic[i]) {
num = num - kArabic[i];
@@ -33,11 +32,11 @@ CFX_WideString MakeRoman(int num) {
return wsRomanNumber;
}
-CFX_WideString MakeLetters(int num) {
+WideString MakeLetters(int num) {
if (num == 0)
- return CFX_WideString();
+ return WideString();
- CFX_WideString wsLetters;
+ WideString wsLetters;
const int nMaxCount = 1000;
const int nLetterCount = 26;
--num;
@@ -50,8 +49,8 @@ CFX_WideString MakeLetters(int num) {
return wsLetters;
}
-CFX_WideString GetLabelNumPortion(int num, const CFX_ByteString& bsStyle) {
- CFX_WideString wsNumPortion;
+WideString GetLabelNumPortion(int num, const ByteString& bsStyle) {
+ WideString wsNumPortion;
if (bsStyle.IsEmpty())
return wsNumPortion;
if (bsStyle == "D") {
@@ -77,7 +76,7 @@ CPDF_PageLabel::CPDF_PageLabel(CPDF_Document* pDocument)
CPDF_PageLabel::~CPDF_PageLabel() {}
-bool CPDF_PageLabel::GetLabel(int nPage, CFX_WideString* wsLabel) const {
+bool CPDF_PageLabel::GetLabel(int nPage, WideString* wsLabel) const {
if (!m_pDocument)
return false;
@@ -108,10 +107,9 @@ bool CPDF_PageLabel::GetLabel(int nPage, CFX_WideString* wsLabel) const {
if (pLabel->KeyExist("P"))
*wsLabel += pLabel->GetUnicodeTextFor("P");
- CFX_ByteString bsNumberingStyle = pLabel->GetStringFor("S", "");
+ ByteString bsNumberingStyle = pLabel->GetStringFor("S", "");
int nLabelNum = nPage - n + pLabel->GetIntegerFor("St", 1);
- CFX_WideString wsNumPortion =
- GetLabelNumPortion(nLabelNum, bsNumberingStyle);
+ WideString wsNumPortion = GetLabelNumPortion(nLabelNum, bsNumberingStyle);
*wsLabel += wsNumPortion;
return true;
}
@@ -120,7 +118,7 @@ bool CPDF_PageLabel::GetLabel(int nPage, CFX_WideString* wsLabel) const {
return true;
}
-int32_t CPDF_PageLabel::GetPageByLabel(const CFX_ByteStringC& bsLabel) const {
+int32_t CPDF_PageLabel::GetPageByLabel(const ByteStringView& bsLabel) const {
if (!m_pDocument)
return -1;
@@ -130,19 +128,19 @@ int32_t CPDF_PageLabel::GetPageByLabel(const CFX_ByteStringC& bsLabel) const {
int nPages = m_pDocument->GetPageCount();
for (int i = 0; i < nPages; i++) {
- CFX_WideString str;
+ WideString str;
if (!GetLabel(i, &str))
continue;
if (PDF_EncodeText(str).Compare(bsLabel))
return i;
}
- int nPage = FXSYS_atoi(CFX_ByteString(bsLabel).c_str()); // NUL terminate.
+ int nPage = FXSYS_atoi(ByteString(bsLabel).c_str()); // NUL terminate.
return nPage > 0 && nPage <= nPages ? nPage : -1;
}
-int32_t CPDF_PageLabel::GetPageByLabel(const CFX_WideStringC& wsLabel) const {
+int32_t CPDF_PageLabel::GetPageByLabel(const WideStringView& wsLabel) const {
// TODO(tsepez): check usage of c_str() below.
return GetPageByLabel(
- PDF_EncodeText(wsLabel.unterminated_c_str()).AsStringC());
+ PDF_EncodeText(wsLabel.unterminated_c_str()).AsStringView());
}
diff --git a/core/fpdfdoc/cpdf_pagelabel.h b/core/fpdfdoc/cpdf_pagelabel.h
index 66324f87c6..1b21ca8bdb 100644
--- a/core/fpdfdoc/cpdf_pagelabel.h
+++ b/core/fpdfdoc/cpdf_pagelabel.h
@@ -16,9 +16,9 @@ class CPDF_PageLabel {
explicit CPDF_PageLabel(CPDF_Document* pDocument);
~CPDF_PageLabel();
- bool GetLabel(int nPage, CFX_WideString* wsLabel) const;
- int32_t GetPageByLabel(const CFX_ByteStringC& bsLabel) const;
- int32_t GetPageByLabel(const CFX_WideStringC& wsLabel) const;
+ bool GetLabel(int nPage, WideString* wsLabel) const;
+ int32_t GetPageByLabel(const ByteStringView& bsLabel) const;
+ int32_t GetPageByLabel(const WideStringView& wsLabel) const;
private:
CFX_UnownedPtr<CPDF_Document> const m_pDocument;
diff --git a/core/fpdfdoc/cpdf_structelement.cpp b/core/fpdfdoc/cpdf_structelement.cpp
index c5f2b6bd79..0b0b542852 100644
--- a/core/fpdfdoc/cpdf_structelement.cpp
+++ b/core/fpdfdoc/cpdf_structelement.cpp
@@ -36,7 +36,7 @@ CPDF_StructElement::CPDF_StructElement(CPDF_StructTree* pTree,
m_Type(pDict->GetStringFor("S")),
m_Title(pDict->GetStringFor("T")) {
if (pTree->GetRoleMap()) {
- CFX_ByteString mapped = pTree->GetRoleMap()->GetStringFor(m_Type);
+ ByteString mapped = pTree->GetRoleMap()->GetStringFor(m_Type);
if (!mapped.IsEmpty())
m_Type = mapped;
}
@@ -102,7 +102,7 @@ void CPDF_StructElement::LoadKid(uint32_t PageObjNum,
if (CPDF_Reference* pRef = ToReference(pKidDict->GetObjectFor("Pg")))
PageObjNum = pRef->GetRefObjNum();
- CFX_ByteString type = pKidDict->GetStringFor("Type");
+ ByteString type = pKidDict->GetStringFor("Type");
if ((type == "MCR" || type == "OBJR") && m_pTree->GetPage() &&
m_pTree->GetPage()->GetObjNum() != PageObjNum) {
return;
diff --git a/core/fpdfdoc/cpdf_structelement.h b/core/fpdfdoc/cpdf_structelement.h
index 8fe73e51c8..b54487e7f8 100644
--- a/core/fpdfdoc/cpdf_structelement.h
+++ b/core/fpdfdoc/cpdf_structelement.h
@@ -39,8 +39,8 @@ class CPDF_StructElement : public CFX_Retainable {
template <typename T, typename... Args>
friend CFX_RetainPtr<T> pdfium::MakeRetain(Args&&... args);
- const CFX_ByteString& GetType() const { return m_Type; }
- const CFX_ByteString& GetTitle() const { return m_Title; }
+ const ByteString& GetType() const { return m_Type; }
+ const ByteString& GetTitle() const { return m_Title; }
CPDF_Dictionary* GetDict() const { return m_pDict.Get(); }
int CountKids() const;
@@ -59,8 +59,8 @@ class CPDF_StructElement : public CFX_Retainable {
CFX_UnownedPtr<CPDF_StructTree> const m_pTree;
CFX_UnownedPtr<CPDF_StructElement> const m_pParent;
CFX_UnownedPtr<CPDF_Dictionary> const m_pDict;
- CFX_ByteString m_Type;
- CFX_ByteString m_Title;
+ ByteString m_Type;
+ ByteString m_Title;
std::vector<CPDF_StructKid> m_Kids;
};
diff --git a/core/fpdfdoc/cpdf_variabletext.cpp b/core/fpdfdoc/cpdf_variabletext.cpp
index 877f8ca01e..d3de6129f1 100644
--- a/core/fpdfdoc/cpdf_variabletext.cpp
+++ b/core/fpdfdoc/cpdf_variabletext.cpp
@@ -354,7 +354,7 @@ CPVT_WordPlace CPDF_VariableText::InsertSection(
CPVT_WordPlace CPDF_VariableText::InsertText(const CPVT_WordPlace& place,
const wchar_t* text) {
- CFX_WideString swText = text;
+ WideString swText = text;
CPVT_WordPlace wp = place;
for (int32_t i = 0, sz = swText.GetLength(); i < sz; i++) {
CPVT_WordPlace oldwp = wp;
@@ -412,7 +412,7 @@ CPVT_WordPlace CPDF_VariableText::BackSpaceWord(const CPVT_WordPlace& place) {
return ClearLeftWord(AdjustLineHeader(place, true));
}
-void CPDF_VariableText::SetText(const CFX_WideString& swText) {
+void CPDF_VariableText::SetText(const WideString& swText) {
DeleteWords(CPVT_WordRange(GetBeginWordPlace(), GetEndWordPlace()));
CPVT_WordPlace wp(0, 0, -1);
CPVT_SectionInfo secinfo;
diff --git a/core/fpdfdoc/cpdf_variabletext.h b/core/fpdfdoc/cpdf_variabletext.h
index a226350006..704408c5be 100644
--- a/core/fpdfdoc/cpdf_variabletext.h
+++ b/core/fpdfdoc/cpdf_variabletext.h
@@ -106,7 +106,7 @@ class CPDF_VariableText {
void RearrangeAll();
void RearrangePart(const CPVT_WordRange& PlaceRange);
void ResetAll();
- void SetText(const CFX_WideString& text);
+ void SetText(const WideString& text);
CPVT_WordPlace InsertWord(const CPVT_WordPlace& place,
uint16_t word,
int32_t charset,
diff --git a/core/fpdfdoc/cpdf_viewerpreferences.cpp b/core/fpdfdoc/cpdf_viewerpreferences.cpp
index e25316b6fb..e7fb1416a8 100644
--- a/core/fpdfdoc/cpdf_viewerpreferences.cpp
+++ b/core/fpdfdoc/cpdf_viewerpreferences.cpp
@@ -34,13 +34,13 @@ CPDF_Array* CPDF_ViewerPreferences::PrintPageRange() const {
return pDict ? pDict->GetArrayFor("PrintPageRange") : nullptr;
}
-CFX_ByteString CPDF_ViewerPreferences::Duplex() const {
+ByteString CPDF_ViewerPreferences::Duplex() const {
CPDF_Dictionary* pDict = GetViewerPreferences();
- return pDict ? pDict->GetStringFor("Duplex") : CFX_ByteString("None");
+ return pDict ? pDict->GetStringFor("Duplex") : ByteString("None");
}
-bool CPDF_ViewerPreferences::GenericName(const CFX_ByteString& bsKey,
- CFX_ByteString* bsVal) const {
+bool CPDF_ViewerPreferences::GenericName(const ByteString& bsKey,
+ ByteString* bsVal) const {
ASSERT(bsVal);
CPDF_Dictionary* pDict = GetViewerPreferences();
if (!pDict)
diff --git a/core/fpdfdoc/cpdf_viewerpreferences.h b/core/fpdfdoc/cpdf_viewerpreferences.h
index 46428a238c..bbe5d1a512 100644
--- a/core/fpdfdoc/cpdf_viewerpreferences.h
+++ b/core/fpdfdoc/cpdf_viewerpreferences.h
@@ -24,12 +24,12 @@ class CPDF_ViewerPreferences {
bool PrintScaling() const;
int32_t NumCopies() const;
CPDF_Array* PrintPageRange() const;
- CFX_ByteString Duplex() const;
+ ByteString Duplex() const;
// Gets the entry for |bsKey|. If the entry exists and it is of type name,
// then this method writes the value into |bsVal| and returns true. Otherwise
// returns false and |bsVal| is untouched. |bsVal| must not be NULL.
- bool GenericName(const CFX_ByteString& bsKey, CFX_ByteString* bsVal) const;
+ bool GenericName(const ByteString& bsKey, ByteString* bsVal) const;
private:
CPDF_Dictionary* GetViewerPreferences() const;
diff --git a/core/fpdfdoc/cpvt_color.cpp b/core/fpdfdoc/cpvt_color.cpp
index 584a85aaec..914e416dbd 100644
--- a/core/fpdfdoc/cpvt_color.cpp
+++ b/core/fpdfdoc/cpvt_color.cpp
@@ -9,8 +9,8 @@
#include "core/fpdfapi/parser/cpdf_simple_parser.h"
// Static.
-CPVT_Color CPVT_Color::ParseColor(const CFX_ByteString& str) {
- CPDF_SimpleParser syntax(str.AsStringC());
+CPVT_Color CPVT_Color::ParseColor(const ByteString& str) {
+ CPDF_SimpleParser syntax(str.AsStringView());
if (syntax.FindTagParamFromStart("g", 1))
return CPVT_Color(CPVT_Color::kGray, FX_atof(syntax.GetWord()));
diff --git a/core/fpdfdoc/cpvt_color.h b/core/fpdfdoc/cpvt_color.h
index 2db3b8310e..a7e925bf79 100644
--- a/core/fpdfdoc/cpvt_color.h
+++ b/core/fpdfdoc/cpvt_color.h
@@ -31,7 +31,7 @@ struct CPVT_Color {
float fColor3;
float fColor4;
- static CPVT_Color ParseColor(const CFX_ByteString& str);
+ static CPVT_Color ParseColor(const ByteString& str);
static CPVT_Color ParseColor(const CPDF_Array& array);
};
diff --git a/core/fpdfdoc/cpvt_fontmap.cpp b/core/fpdfdoc/cpvt_fontmap.cpp
index 0edabd1bc3..aaf8661f1e 100644
--- a/core/fpdfdoc/cpvt_fontmap.cpp
+++ b/core/fpdfdoc/cpvt_fontmap.cpp
@@ -17,7 +17,7 @@
CPVT_FontMap::CPVT_FontMap(CPDF_Document* pDoc,
CPDF_Dictionary* pResDict,
CPDF_Font* pDefFont,
- const CFX_ByteString& sDefFontAlias)
+ const ByteString& sDefFontAlias)
: m_pDocument(pDoc),
m_pResDict(pResDict),
m_pDefFont(pDefFont),
@@ -27,7 +27,7 @@ CPVT_FontMap::~CPVT_FontMap() {}
CPDF_Font* CPVT_FontMap::GetAnnotSysPDFFont(CPDF_Document* pDoc,
const CPDF_Dictionary* pResDict,
- CFX_ByteString* sSysFontAlias) {
+ ByteString* sSysFontAlias) {
if (!pDoc || !pResDict)
return nullptr;
@@ -59,7 +59,7 @@ CPDF_Font* CPVT_FontMap::GetPDFFont(int32_t nFontIndex) {
}
}
-CFX_ByteString CPVT_FontMap::GetPDFFontAlias(int32_t nFontIndex) {
+ByteString CPVT_FontMap::GetPDFFontAlias(int32_t nFontIndex) {
switch (nFontIndex) {
case 0:
return m_sDefFontAlias;
@@ -70,7 +70,7 @@ CFX_ByteString CPVT_FontMap::GetPDFFontAlias(int32_t nFontIndex) {
}
return m_sSysFontAlias;
default:
- return CFX_ByteString();
+ return ByteString();
}
}
diff --git a/core/fpdfdoc/cpvt_fontmap.h b/core/fpdfdoc/cpvt_fontmap.h
index da69463d95..feca454774 100644
--- a/core/fpdfdoc/cpvt_fontmap.h
+++ b/core/fpdfdoc/cpvt_fontmap.h
@@ -22,12 +22,12 @@ class CPVT_FontMap : public IPVT_FontMap {
CPVT_FontMap(CPDF_Document* pDoc,
CPDF_Dictionary* pResDict,
CPDF_Font* pDefFont,
- const CFX_ByteString& sDefFontAlias);
+ const ByteString& sDefFontAlias);
~CPVT_FontMap() override;
// IPVT_FontMap:
CPDF_Font* GetPDFFont(int32_t nFontIndex) override;
- CFX_ByteString GetPDFFontAlias(int32_t nFontIndex) override;
+ ByteString GetPDFFontAlias(int32_t nFontIndex) override;
int32_t GetWordFontIndex(uint16_t word,
int32_t charset,
int32_t nFontIndex) override;
@@ -36,15 +36,15 @@ class CPVT_FontMap : public IPVT_FontMap {
static CPDF_Font* GetAnnotSysPDFFont(CPDF_Document* pDoc,
const CPDF_Dictionary* pResDict,
- CFX_ByteString* sSysFontAlias);
+ ByteString* sSysFontAlias);
private:
CFX_UnownedPtr<CPDF_Document> const m_pDocument;
CFX_UnownedPtr<CPDF_Dictionary> const m_pResDict;
CFX_UnownedPtr<CPDF_Font> const m_pDefFont;
CFX_UnownedPtr<CPDF_Font> m_pSysFont;
- const CFX_ByteString m_sDefFontAlias;
- CFX_ByteString m_sSysFontAlias;
+ const ByteString m_sDefFontAlias;
+ ByteString m_sSysFontAlias;
};
#endif // CORE_FPDFDOC_CPVT_FONTMAP_H_
diff --git a/core/fpdfdoc/cpvt_generateap.cpp b/core/fpdfdoc/cpvt_generateap.cpp
index 132e771d47..634864c957 100644
--- a/core/fpdfdoc/cpvt_generateap.cpp
+++ b/core/fpdfdoc/cpvt_generateap.cpp
@@ -42,7 +42,7 @@ bool GenerateWidgetAP(CPDF_Document* pDoc,
if (!pFormDict)
return false;
- CFX_ByteString DA;
+ ByteString DA;
if (CPDF_Object* pDAObj = FPDF_GetFieldAttr(pAnnotDict, "DA"))
DA = pDAObj->GetString();
if (DA.IsEmpty())
@@ -50,9 +50,9 @@ bool GenerateWidgetAP(CPDF_Document* pDoc,
if (DA.IsEmpty())
return false;
- CPDF_SimpleParser syntax(DA.AsStringC());
+ CPDF_SimpleParser syntax(DA.AsStringView());
syntax.FindTagParamFromStart("Tf", 2);
- CFX_ByteString sFontName(syntax.GetWord());
+ ByteString sFontName(syntax.GetWord());
sFontName = PDF_NameDecode(sFontName);
if (sFontName.IsEmpty())
return false;
@@ -161,14 +161,13 @@ bool GenerateWidgetAP(CPDF_Document* pDoc,
crBG = CPVT_Color::ParseColor(*pArray);
}
std::ostringstream sAppStream;
- CFX_ByteString sBG =
- CPVT_GenerateAP::GenerateColorAP(crBG, PaintOperation::FILL);
+ ByteString sBG = CPVT_GenerateAP::GenerateColorAP(crBG, PaintOperation::FILL);
if (sBG.GetLength() > 0) {
sAppStream << "q\n" << sBG << rcBBox.left << " " << rcBBox.bottom << " "
<< rcBBox.Width() << " " << rcBBox.Height() << " re f\n"
<< "Q\n";
}
- CFX_ByteString sBorderStream = CPVT_GenerateAP::GenerateBorderAP(
+ ByteString sBorderStream = CPVT_GenerateAP::GenerateBorderAP(
rcBBox, fBorderWidth, crBorder, crLeftTop, crRightBottom, nBorderStyle,
dsBorder);
if (sBorderStream.GetLength() > 0)
@@ -208,10 +207,10 @@ bool GenerateWidgetAP(CPDF_Document* pDoc,
}
switch (nWidgetType) {
case 0: {
- CFX_WideString swValue =
+ WideString swValue =
FPDF_GetFieldAttr(pAnnotDict, "V")
? FPDF_GetFieldAttr(pAnnotDict, "V")->GetUnicodeText()
- : CFX_WideString();
+ : WideString();
int32_t nAlign = FPDF_GetFieldAttr(pAnnotDict, "Q")
? FPDF_GetFieldAttr(pAnnotDict, "Q")->GetInteger()
: 0;
@@ -260,7 +259,7 @@ bool GenerateWidgetAP(CPDF_Document* pDoc,
ptOffset =
CFX_PointF(0.0f, (rcContent.Height() - rcBody.Height()) / 2.0f);
}
- CFX_ByteString sBody = CPVT_GenerateAP::GenerateEditAP(
+ ByteString sBody = CPVT_GenerateAP::GenerateEditAP(
&map, vt.GetIterator(), ptOffset, !bCharArray, subWord);
if (sBody.GetLength() > 0) {
sAppStream << "/Tx BMC\n"
@@ -279,10 +278,10 @@ bool GenerateWidgetAP(CPDF_Document* pDoc,
}
} break;
case 1: {
- CFX_WideString swValue =
+ WideString swValue =
FPDF_GetFieldAttr(pAnnotDict, "V")
? FPDF_GetFieldAttr(pAnnotDict, "V")->GetUnicodeText()
- : CFX_WideString();
+ : WideString();
CPVT_FontMap map(
pDoc, pStreamDict ? pStreamDict->GetDictFor("Resources") : nullptr,
pDefFont, sFontName.Right(sFontName.GetLength() - 1));
@@ -307,8 +306,8 @@ bool GenerateWidgetAP(CPDF_Document* pDoc,
CFX_FloatRect rcContent = vt.GetContentRect();
CFX_PointF ptOffset =
CFX_PointF(0.0f, (rcContent.Height() - rcEdit.Height()) / 2.0f);
- CFX_ByteString sEdit = CPVT_GenerateAP::GenerateEditAP(
- &map, vt.GetIterator(), ptOffset, true, 0);
+ ByteString sEdit = CPVT_GenerateAP::GenerateEditAP(&map, vt.GetIterator(),
+ ptOffset, true, 0);
if (sEdit.GetLength() > 0) {
sAppStream << "/Tx BMC\n"
<< "q\n";
@@ -320,7 +319,7 @@ bool GenerateWidgetAP(CPDF_Document* pDoc,
<< sEdit << "ET\n"
<< "Q\nEMC\n";
}
- CFX_ByteString sButton = CPVT_GenerateAP::GenerateColorAP(
+ ByteString sButton = CPVT_GenerateAP::GenerateColorAP(
CPVT_Color(CPVT_Color::kRGB, 220.0f / 255.0f, 220.0f / 255.0f,
220.0f / 255.0f),
PaintOperation::FILL);
@@ -329,7 +328,7 @@ bool GenerateWidgetAP(CPDF_Document* pDoc,
sAppStream << rcButton.left << " " << rcButton.bottom << " "
<< rcButton.Width() << " " << rcButton.Height() << " re f\n";
sAppStream << "Q\n";
- CFX_ByteString sButtonBorder = CPVT_GenerateAP::GenerateBorderAP(
+ ByteString sButtonBorder = CPVT_GenerateAP::GenerateBorderAP(
rcButton, 2, CPVT_Color(CPVT_Color::kGray, 0),
CPVT_Color(CPVT_Color::kGray, 1),
CPVT_Color(CPVT_Color::kGray, 0.5), BorderStyle::BEVELED,
@@ -368,7 +367,7 @@ bool GenerateWidgetAP(CPDF_Document* pDoc,
break;
if (CPDF_Object* pOpt = pOpts->GetDirectObjectAt(i)) {
- CFX_WideString swItem;
+ WideString swItem;
if (pOpt->IsString())
swItem = pOpt->GetUnicodeText();
else if (CPDF_Array* pArray = pOpt->AsArray())
@@ -461,9 +460,9 @@ bool GenerateWidgetAP(CPDF_Document* pDoc,
return true;
}
-CFX_ByteString GetColorStringWithDefault(CPDF_Array* pColor,
- const CPVT_Color& crDefaultColor,
- PaintOperation nOperation) {
+ByteString GetColorStringWithDefault(CPDF_Array* pColor,
+ const CPVT_Color& crDefaultColor,
+ PaintOperation nOperation) {
if (pColor) {
CPVT_Color color = CPVT_Color::ParseColor(*pColor);
return CPVT_GenerateAP::GenerateColorAP(color, nOperation);
@@ -500,10 +499,10 @@ CPDF_Array* GetDashArray(const CPDF_Dictionary& pAnnotDict) {
return nullptr;
}
-CFX_ByteString GetDashPatternString(const CPDF_Dictionary& pAnnotDict) {
+ByteString GetDashPatternString(const CPDF_Dictionary& pAnnotDict) {
CPDF_Array* pDashArray = GetDashArray(pAnnotDict);
if (!pDashArray || pDashArray->IsEmpty())
- return CFX_ByteString();
+ return ByteString();
// Support maximum of ten elements in the dash array.
size_t pDashArrayCount = std::min<size_t>(pDashArray->GetCount(), 10);
@@ -514,14 +513,14 @@ CFX_ByteString GetDashPatternString(const CPDF_Dictionary& pAnnotDict) {
sDashStream << pDashArray->GetNumberAt(i) << " ";
sDashStream << "] 0 d\n";
- return CFX_ByteString(sDashStream);
+ return ByteString(sDashStream);
}
-CFX_ByteString GetPopupContentsString(CPDF_Document* pDoc,
- const CPDF_Dictionary& pAnnotDict,
- CPDF_Font* pDefFont,
- const CFX_ByteString& sFontName) {
- CFX_WideString swValue(pAnnotDict.GetUnicodeTextFor("T"));
+ByteString GetPopupContentsString(CPDF_Document* pDoc,
+ const CPDF_Dictionary& pAnnotDict,
+ CPDF_Font* pDefFont,
+ const ByteString& sFontName) {
+ WideString swValue(pAnnotDict.GetUnicodeTextFor("T"));
swValue += L'\n';
swValue += pAnnotDict.GetUnicodeTextFor("Contents");
CPVT_FontMap map(pDoc, nullptr, pDefFont, sFontName);
@@ -538,11 +537,11 @@ CFX_ByteString GetPopupContentsString(CPDF_Document* pDoc,
vt.SetText(swValue);
vt.RearrangeAll();
CFX_PointF ptOffset(3.0f, -3.0f);
- CFX_ByteString sContent = CPVT_GenerateAP::GenerateEditAP(
- &map, vt.GetIterator(), ptOffset, false, 0);
+ ByteString sContent = CPVT_GenerateAP::GenerateEditAP(&map, vt.GetIterator(),
+ ptOffset, false, 0);
if (sContent.IsEmpty())
- return CFX_ByteString();
+ return ByteString();
std::ostringstream sAppStream;
sAppStream << "BT\n"
@@ -550,12 +549,12 @@ CFX_ByteString GetPopupContentsString(CPDF_Document* pDoc,
CPVT_Color(CPVT_Color::kRGB, 0, 0, 0), PaintOperation::FILL)
<< sContent << "ET\n"
<< "Q\n";
- return CFX_ByteString(sAppStream);
+ return ByteString(sAppStream);
}
std::unique_ptr<CPDF_Dictionary> GenerateResourceFontDict(
CPDF_Document* pDoc,
- const CFX_ByteString& sFontDictName) {
+ const ByteString& sFontDictName) {
CPDF_Dictionary* pFontDict = pDoc->NewIndirect<CPDF_Dictionary>();
pFontDict->SetNewFor<CPDF_Name>("Type", "Font");
pFontDict->SetNewFor<CPDF_Name>("Subtype", "Type1");
@@ -569,13 +568,13 @@ std::unique_ptr<CPDF_Dictionary> GenerateResourceFontDict(
return pResourceFontDict;
}
-CFX_ByteString GetPaintOperatorString(bool bIsStrokeRect, bool bIsFillRect) {
+ByteString GetPaintOperatorString(bool bIsStrokeRect, bool bIsFillRect) {
if (bIsStrokeRect)
return bIsFillRect ? "b" : "s";
return bIsFillRect ? "f" : "n";
}
-CFX_ByteString GenerateTextSymbolAP(const CFX_FloatRect& rect) {
+ByteString GenerateTextSymbolAP(const CFX_FloatRect& rect) {
std::ostringstream sAppStream;
sAppStream << CPVT_GenerateAP::GenerateColorAP(
CPVT_Color(CPVT_Color::kRGB, 1, 1, 0), PaintOperation::FILL);
@@ -622,7 +621,7 @@ CFX_ByteString GenerateTextSymbolAP(const CFX_FloatRect& rect) {
}
sAppStream << "B*\n";
- return CFX_ByteString(sAppStream);
+ return ByteString(sAppStream);
}
} // namespace
@@ -635,7 +634,7 @@ bool FPDF_GenerateAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict) {
if (!pFieldTypeObj)
return false;
- CFX_ByteString field_type = pFieldTypeObj->GetString();
+ ByteString field_type = pFieldTypeObj->GetString();
if (field_type == "Tx")
return CPVT_GenerateAP::GenerateTextFieldAP(pDoc, pAnnotDict);
@@ -684,7 +683,7 @@ bool CPVT_GenerateAP::GenerateTextFieldAP(CPDF_Document* pDoc,
bool CPVT_GenerateAP::GenerateCircleAP(CPDF_Document* pDoc,
CPDF_Dictionary* pAnnotDict) {
std::ostringstream sAppStream;
- CFX_ByteString sExtGSDictName = "GS";
+ ByteString sExtGSDictName = "GS";
sAppStream << "/" << sExtGSDictName << " gs ";
CPDF_Array* pInteriorColor = pAnnotDict->GetArrayFor("IC");
@@ -758,7 +757,7 @@ bool CPVT_GenerateAP::GenerateCircleAP(CPDF_Document* pDoc,
bool CPVT_GenerateAP::GenerateHighlightAP(CPDF_Document* pDoc,
CPDF_Dictionary* pAnnotDict) {
std::ostringstream sAppStream;
- CFX_ByteString sExtGSDictName = "GS";
+ ByteString sExtGSDictName = "GS";
sAppStream << "/" << sExtGSDictName << " gs ";
sAppStream << GetColorStringWithDefault(pAnnotDict->GetArrayFor("C"),
@@ -796,7 +795,7 @@ bool CPVT_GenerateAP::GenerateInkAP(CPDF_Document* pDoc,
return false;
std::ostringstream sAppStream;
- CFX_ByteString sExtGSDictName = "GS";
+ ByteString sExtGSDictName = "GS";
sAppStream << "/" << sExtGSDictName << " gs ";
sAppStream << GetColorStringWithDefault(pAnnotDict->GetArrayFor("C"),
@@ -840,7 +839,7 @@ bool CPVT_GenerateAP::GenerateInkAP(CPDF_Document* pDoc,
bool CPVT_GenerateAP::GenerateTextAP(CPDF_Document* pDoc,
CPDF_Dictionary* pAnnotDict) {
std::ostringstream sAppStream;
- CFX_ByteString sExtGSDictName = "GS";
+ ByteString sExtGSDictName = "GS";
sAppStream << "/" << sExtGSDictName << " gs ";
CFX_FloatRect rect = pAnnotDict->GetRectFor("Rect");
@@ -863,7 +862,7 @@ bool CPVT_GenerateAP::GenerateTextAP(CPDF_Document* pDoc,
bool CPVT_GenerateAP::GenerateUnderlineAP(CPDF_Document* pDoc,
CPDF_Dictionary* pAnnotDict) {
std::ostringstream sAppStream;
- CFX_ByteString sExtGSDictName = "GS";
+ ByteString sExtGSDictName = "GS";
sAppStream << "/" << sExtGSDictName << " gs ";
sAppStream << GetColorStringWithDefault(pAnnotDict->GetArrayFor("C"),
@@ -890,7 +889,7 @@ bool CPVT_GenerateAP::GenerateUnderlineAP(CPDF_Document* pDoc,
bool CPVT_GenerateAP::GeneratePopupAP(CPDF_Document* pDoc,
CPDF_Dictionary* pAnnotDict) {
std::ostringstream sAppStream;
- CFX_ByteString sExtGSDictName = "GS";
+ ByteString sExtGSDictName = "GS";
sAppStream << "/" << sExtGSDictName << " gs\n";
sAppStream << GenerateColorAP(CPVT_Color(CPVT_Color::kRGB, 1, 1, 0),
@@ -908,7 +907,7 @@ bool CPVT_GenerateAP::GeneratePopupAP(CPDF_Document* pDoc,
sAppStream << rect.left << " " << rect.bottom << " " << rect.Width() << " "
<< rect.Height() << " re b\n";
- CFX_ByteString sFontName = "FONT";
+ ByteString sFontName = "FONT";
auto pResourceFontDict = GenerateResourceFontDict(pDoc, sFontName);
CPDF_Font* pDefFont = pDoc->LoadFont(pResourceFontDict.get());
if (!pDefFont)
@@ -928,7 +927,7 @@ bool CPVT_GenerateAP::GeneratePopupAP(CPDF_Document* pDoc,
bool CPVT_GenerateAP::GenerateSquareAP(CPDF_Document* pDoc,
CPDF_Dictionary* pAnnotDict) {
std::ostringstream sAppStream;
- CFX_ByteString sExtGSDictName = "GS";
+ ByteString sExtGSDictName = "GS";
sAppStream << "/" << sExtGSDictName << " gs ";
CPDF_Array* pInteriorColor = pAnnotDict->GetArrayFor("IC");
@@ -976,7 +975,7 @@ bool CPVT_GenerateAP::GenerateSquareAP(CPDF_Document* pDoc,
bool CPVT_GenerateAP::GenerateSquigglyAP(CPDF_Document* pDoc,
CPDF_Dictionary* pAnnotDict) {
std::ostringstream sAppStream;
- CFX_ByteString sExtGSDictName = "GS";
+ ByteString sExtGSDictName = "GS";
sAppStream << "/" << sExtGSDictName << " gs ";
sAppStream << GetColorStringWithDefault(pAnnotDict->GetArrayFor("C"),
@@ -1025,7 +1024,7 @@ bool CPVT_GenerateAP::GenerateSquigglyAP(CPDF_Document* pDoc,
bool CPVT_GenerateAP::GenerateStrikeOutAP(CPDF_Document* pDoc,
CPDF_Dictionary* pAnnotDict) {
std::ostringstream sAppStream;
- CFX_ByteString sExtGSDictName = "GS";
+ ByteString sExtGSDictName = "GS";
sAppStream << "/" << sExtGSDictName << " gs ";
sAppStream << GetColorStringWithDefault(pAnnotDict->GetArrayFor("C"),
@@ -1050,7 +1049,7 @@ bool CPVT_GenerateAP::GenerateStrikeOutAP(CPDF_Document* pDoc,
}
// Static.
-CFX_ByteString CPVT_GenerateAP::GenerateEditAP(
+ByteString CPVT_GenerateAP::GenerateEditAP(
IPVT_FontMap* pFontMap,
CPDF_VariableText::Iterator* pIterator,
const CFX_PointF& ptOffset,
@@ -1070,7 +1069,7 @@ CFX_ByteString CPVT_GenerateAP::GenerateEditAP(
if (bContinuous) {
if (place.LineCmp(oldplace) != 0) {
if (sWords.tellp() > 0) {
- sLineStream << GetWordRenderString(CFX_ByteString(sWords));
+ sLineStream << GetWordRenderString(ByteString(sWords));
sEditStream << sLineStream.str();
sLineStream.str("");
sWords.str("");
@@ -1095,7 +1094,7 @@ CFX_ByteString CPVT_GenerateAP::GenerateEditAP(
if (pIterator->GetWord(word)) {
if (word.nFontIndex != nCurFontIndex) {
if (sWords.tellp() > 0) {
- sLineStream << GetWordRenderString(CFX_ByteString(sWords));
+ sLineStream << GetWordRenderString(ByteString(sWords));
sWords.str("");
}
sLineStream << GetFontSetString(pFontMap, word.nFontIndex,
@@ -1126,24 +1125,23 @@ CFX_ByteString CPVT_GenerateAP::GenerateEditAP(
}
}
if (sWords.tellp() > 0) {
- sLineStream << GetWordRenderString(CFX_ByteString(sWords));
+ sLineStream << GetWordRenderString(ByteString(sWords));
sEditStream << sLineStream.str();
sWords.str("");
}
- return CFX_ByteString(sEditStream);
+ return ByteString(sEditStream);
}
// Static.
-CFX_ByteString CPVT_GenerateAP::GenerateBorderAP(
- const CFX_FloatRect& rect,
- float fWidth,
- const CPVT_Color& color,
- const CPVT_Color& crLeftTop,
- const CPVT_Color& crRightBottom,
- BorderStyle nStyle,
- const CPVT_Dash& dash) {
+ByteString CPVT_GenerateAP::GenerateBorderAP(const CFX_FloatRect& rect,
+ float fWidth,
+ const CPVT_Color& color,
+ const CPVT_Color& crLeftTop,
+ const CPVT_Color& crRightBottom,
+ BorderStyle nStyle,
+ const CPVT_Dash& dash) {
std::ostringstream sAppStream;
- CFX_ByteString sColor;
+ ByteString sColor;
float fLeft = rect.left;
float fRight = rect.right;
float fTop = rect.top;
@@ -1238,12 +1236,12 @@ CFX_ByteString CPVT_GenerateAP::GenerateBorderAP(
break;
}
}
- return CFX_ByteString(sAppStream);
+ return ByteString(sAppStream);
}
// Static.
-CFX_ByteString CPVT_GenerateAP::GenerateColorAP(const CPVT_Color& color,
- PaintOperation nOperation) {
+ByteString CPVT_GenerateAP::GenerateColorAP(const CPVT_Color& color,
+ PaintOperation nOperation) {
std::ostringstream sColorStream;
switch (color.nColorType) {
case CPVT_Color::kRGB:
@@ -1266,14 +1264,14 @@ CFX_ByteString CPVT_GenerateAP::GenerateColorAP(const CPVT_Color& color,
case CPVT_Color::kTransparent:
break;
}
- return CFX_ByteString(sColorStream);
+ return ByteString(sColorStream);
}
// Static.
std::unique_ptr<CPDF_Dictionary> CPVT_GenerateAP::GenerateExtGStateDict(
const CPDF_Dictionary& pAnnotDict,
- const CFX_ByteString& sExtGSDictName,
- const CFX_ByteString& sBlendMode) {
+ const ByteString& sExtGSDictName,
+ const ByteString& sBlendMode) {
auto pGSDict =
pdfium::MakeUnique<CPDF_Dictionary>(pAnnotDict.GetByteStringPool());
pGSDict->SetNewFor<CPDF_String>("Type", "ExtGState", false);
@@ -1334,11 +1332,11 @@ void CPVT_GenerateAP::GenerateAndSetAPDict(
}
// Static.
-CFX_ByteString CPVT_GenerateAP::GetPDFWordString(IPVT_FontMap* pFontMap,
- int32_t nFontIndex,
- uint16_t Word,
- uint16_t SubWord) {
- CFX_ByteString sWord;
+ByteString CPVT_GenerateAP::GetPDFWordString(IPVT_FontMap* pFontMap,
+ int32_t nFontIndex,
+ uint16_t Word,
+ uint16_t SubWord) {
+ ByteString sWord;
if (SubWord > 0) {
sWord.Format("%c", SubWord);
return sWord;
@@ -1361,22 +1359,21 @@ CFX_ByteString CPVT_GenerateAP::GetPDFWordString(IPVT_FontMap* pFontMap,
}
// Static.
-CFX_ByteString CPVT_GenerateAP::GetWordRenderString(
- const CFX_ByteString& strWords) {
+ByteString CPVT_GenerateAP::GetWordRenderString(const ByteString& strWords) {
if (strWords.GetLength() > 0)
return PDF_EncodeString(strWords, false) + " Tj\n";
return "";
}
// Static.
-CFX_ByteString CPVT_GenerateAP::GetFontSetString(IPVT_FontMap* pFontMap,
- int32_t nFontIndex,
- float fFontSize) {
+ByteString CPVT_GenerateAP::GetFontSetString(IPVT_FontMap* pFontMap,
+ int32_t nFontIndex,
+ float fFontSize) {
std::ostringstream sRet;
if (pFontMap) {
- CFX_ByteString sFontAlias = pFontMap->GetPDFFontAlias(nFontIndex);
+ ByteString sFontAlias = pFontMap->GetPDFFontAlias(nFontIndex);
if (sFontAlias.GetLength() > 0 && fFontSize > 0)
sRet << "/" << sFontAlias << " " << fFontSize << " Tf\n";
}
- return CFX_ByteString(sRet);
+ return ByteString(sRet);
}
diff --git a/core/fpdfdoc/cpvt_generateap.h b/core/fpdfdoc/cpvt_generateap.h
index cee96cda50..2812b29a47 100644
--- a/core/fpdfdoc/cpvt_generateap.h
+++ b/core/fpdfdoc/cpvt_generateap.h
@@ -7,6 +7,8 @@
#ifndef CORE_FPDFDOC_CPVT_GENERATEAP_H_
#define CORE_FPDFDOC_CPVT_GENERATEAP_H_
+#include <memory>
+
#include "core/fpdfdoc/cpdf_defaultappearance.h"
#include "core/fpdfdoc/cpdf_variabletext.h"
#include "core/fpdfdoc/cpvt_color.h"
@@ -46,24 +48,24 @@ class CPVT_GenerateAP {
CPDF_Dictionary* pAnnotDict);
static bool GenerateUnderlineAP(CPDF_Document* pDoc,
CPDF_Dictionary* pAnnotDict);
- static CFX_ByteString GenerateEditAP(IPVT_FontMap* pFontMap,
- CPDF_VariableText::Iterator* pIterator,
- const CFX_PointF& ptOffset,
- bool bContinuous,
- uint16_t SubWord);
- static CFX_ByteString GenerateBorderAP(const CFX_FloatRect& rect,
- float fWidth,
- const CPVT_Color& color,
- const CPVT_Color& crLeftTop,
- const CPVT_Color& crRightBottom,
- BorderStyle nStyle,
- const CPVT_Dash& dash);
- static CFX_ByteString GenerateColorAP(const CPVT_Color& color,
- PaintOperation nOperation);
+ static ByteString GenerateEditAP(IPVT_FontMap* pFontMap,
+ CPDF_VariableText::Iterator* pIterator,
+ const CFX_PointF& ptOffset,
+ bool bContinuous,
+ uint16_t SubWord);
+ static ByteString GenerateBorderAP(const CFX_FloatRect& rect,
+ float fWidth,
+ const CPVT_Color& color,
+ const CPVT_Color& crLeftTop,
+ const CPVT_Color& crRightBottom,
+ BorderStyle nStyle,
+ const CPVT_Dash& dash);
+ static ByteString GenerateColorAP(const CPVT_Color& color,
+ PaintOperation nOperation);
static std::unique_ptr<CPDF_Dictionary> GenerateExtGStateDict(
const CPDF_Dictionary& pAnnotDict,
- const CFX_ByteString& sExtGSDictName,
- const CFX_ByteString& sBlendMode);
+ const ByteString& sExtGSDictName,
+ const ByteString& sBlendMode);
static std::unique_ptr<CPDF_Dictionary> GenerateResourceDict(
CPDF_Document* pDoc,
std::unique_ptr<CPDF_Dictionary> pExtGStateDict,
@@ -75,14 +77,14 @@ class CPVT_GenerateAP {
std::unique_ptr<CPDF_Dictionary> pResourceDict,
bool bIsTextMarkupAnnotation);
- static CFX_ByteString GetPDFWordString(IPVT_FontMap* pFontMap,
- int32_t nFontIndex,
- uint16_t Word,
- uint16_t SubWord);
- static CFX_ByteString GetWordRenderString(const CFX_ByteString& strWords);
- static CFX_ByteString GetFontSetString(IPVT_FontMap* pFontMap,
- int32_t nFontIndex,
- float fFontSize);
+ static ByteString GetPDFWordString(IPVT_FontMap* pFontMap,
+ int32_t nFontIndex,
+ uint16_t Word,
+ uint16_t SubWord);
+ static ByteString GetWordRenderString(const ByteString& strWords);
+ static ByteString GetFontSetString(IPVT_FontMap* pFontMap,
+ int32_t nFontIndex,
+ float fFontSize);
};
#endif // CORE_FPDFDOC_CPVT_GENERATEAP_H_
diff --git a/core/fpdfdoc/ipdf_formnotify.h b/core/fpdfdoc/ipdf_formnotify.h
index bf6127dce2..52e5cc96aa 100644
--- a/core/fpdfdoc/ipdf_formnotify.h
+++ b/core/fpdfdoc/ipdf_formnotify.h
@@ -17,10 +17,10 @@ class IPDF_FormNotify {
virtual ~IPDF_FormNotify() {}
virtual int BeforeValueChange(CPDF_FormField* pField,
- const CFX_WideString& csValue) = 0;
+ const WideString& csValue) = 0;
virtual void AfterValueChange(CPDF_FormField* pField) = 0;
virtual int BeforeSelectionChange(CPDF_FormField* pField,
- const CFX_WideString& csValue) = 0;
+ const WideString& csValue) = 0;
virtual void AfterSelectionChange(CPDF_FormField* pField) = 0;
virtual void AfterCheckedStatusChange(CPDF_FormField* pField) = 0;
virtual int BeforeFormReset(CPDF_InterForm* pForm) = 0;
diff --git a/core/fpdfdoc/ipvt_fontmap.h b/core/fpdfdoc/ipvt_fontmap.h
index 740cb19eb8..31aa73b8a1 100644
--- a/core/fpdfdoc/ipvt_fontmap.h
+++ b/core/fpdfdoc/ipvt_fontmap.h
@@ -18,7 +18,7 @@ class IPVT_FontMap {
virtual ~IPVT_FontMap() {}
virtual CPDF_Font* GetPDFFont(int32_t nFontIndex) = 0;
- virtual CFX_ByteString GetPDFFontAlias(int32_t nFontIndex) = 0;
+ virtual ByteString GetPDFFontAlias(int32_t nFontIndex) = 0;
virtual int32_t GetWordFontIndex(uint16_t word,
int32_t charset,
int32_t nFontIndex) = 0;
diff --git a/core/fpdftext/cpdf_linkextract.cpp b/core/fpdftext/cpdf_linkextract.cpp
index a5eafe689a..91116711e6 100644
--- a/core/fpdftext/cpdf_linkextract.cpp
+++ b/core/fpdftext/cpdf_linkextract.cpp
@@ -19,7 +19,7 @@ namespace {
// |end|. The purpose of this function is to separate url from the surrounding
// context characters, we do not intend to fully validate the url. |str|
// contains lower case characters only.
-FX_STRSIZE FindWebLinkEnding(const CFX_WideString& str,
+FX_STRSIZE FindWebLinkEnding(const WideString& str,
FX_STRSIZE start,
FX_STRSIZE end) {
if (str.Contains(L'/', start)) {
@@ -67,7 +67,7 @@ FX_STRSIZE FindWebLinkEnding(const CFX_WideString& str,
// Remove characters from the end of |str|, delimited by |start| and |end|, up
// to and including |charToFind|. No-op if |charToFind| is not present. Updates
// |end| if characters were removed.
-void TrimBackwardsToChar(const CFX_WideString& str,
+void TrimBackwardsToChar(const WideString& str,
wchar_t charToFind,
FX_STRSIZE start,
FX_STRSIZE* end) {
@@ -83,7 +83,7 @@ void TrimBackwardsToChar(const CFX_WideString& str,
// |start| and |end| in |str|. Matches a closing bracket or quote for each
// opening character and, if present, removes everything afterwards. Returns the
// new end position for the string.
-FX_STRSIZE TrimExternalBracketsFromWebLink(const CFX_WideString& str,
+FX_STRSIZE TrimExternalBracketsFromWebLink(const WideString& str,
FX_STRSIZE start,
FX_STRSIZE end) {
for (FX_STRSIZE pos = 0; pos < start; pos++) {
@@ -144,7 +144,7 @@ void CPDF_LinkExtract::ParseLink() {
pos++;
continue;
}
- CFX_WideString strBeCheck;
+ WideString strBeCheck;
strBeCheck = m_pTextPage->GetPageText(start, nCount);
if (bLineBreak) {
strBeCheck.Remove(TEXT_LINEFEED_CHAR);
@@ -187,7 +187,7 @@ void CPDF_LinkExtract::ParseLink() {
}
}
-bool CPDF_LinkExtract::CheckWebLink(CFX_WideString* strBeCheck,
+bool CPDF_LinkExtract::CheckWebLink(WideString* strBeCheck,
int32_t* nStart,
int32_t* nCount) {
static const wchar_t kHttpScheme[] = L"http";
@@ -195,7 +195,7 @@ bool CPDF_LinkExtract::CheckWebLink(CFX_WideString* strBeCheck,
static const wchar_t kWWWAddrStart[] = L"www.";
static const FX_STRSIZE kWWWAddrStartLen = FXSYS_len(kWWWAddrStart);
- CFX_WideString str = *strBeCheck;
+ WideString str = *strBeCheck;
str.MakeLower();
FX_STRSIZE len = str.GetLength();
@@ -237,7 +237,7 @@ bool CPDF_LinkExtract::CheckWebLink(CFX_WideString* strBeCheck,
return false;
}
-bool CPDF_LinkExtract::CheckMailLink(CFX_WideString* str) {
+bool CPDF_LinkExtract::CheckMailLink(WideString* str) {
auto aPos = str->Find(L'@');
// Invalid when no '@' or when starts/ends with '@'.
if (!aPos.has_value() || aPos.value() == 0 || aPos == str->GetLength() - 1)
@@ -305,7 +305,7 @@ bool CPDF_LinkExtract::CheckMailLink(CFX_WideString* str) {
return true;
}
-CFX_WideString CPDF_LinkExtract::GetURL(size_t index) const {
+WideString CPDF_LinkExtract::GetURL(size_t index) const {
return index < m_LinkArray.size() ? m_LinkArray[index].m_strUrl : L"";
}
diff --git a/core/fpdftext/cpdf_linkextract.h b/core/fpdftext/cpdf_linkextract.h
index 5c022d3d78..db82deb684 100644
--- a/core/fpdftext/cpdf_linkextract.h
+++ b/core/fpdftext/cpdf_linkextract.h
@@ -22,23 +22,23 @@ class CPDF_LinkExtract {
void ExtractLinks();
size_t CountLinks() const { return m_LinkArray.size(); }
- CFX_WideString GetURL(size_t index) const;
+ WideString GetURL(size_t index) const;
std::vector<CFX_FloatRect> GetRects(size_t index) const;
protected:
void ParseLink();
- bool CheckWebLink(CFX_WideString* str, int32_t* nStart, int32_t* nCount);
- bool CheckMailLink(CFX_WideString* str);
+ bool CheckWebLink(WideString* str, int32_t* nStart, int32_t* nCount);
+ bool CheckMailLink(WideString* str);
private:
struct Link {
int m_Start;
int m_Count;
- CFX_WideString m_strUrl;
+ WideString m_strUrl;
};
CFX_UnownedPtr<const CPDF_TextPage> const m_pTextPage;
- CFX_WideString m_strPageText;
+ WideString m_strPageText;
std::vector<Link> m_LinkArray;
};
diff --git a/core/fpdftext/cpdf_linkextract_unittest.cpp b/core/fpdftext/cpdf_linkextract_unittest.cpp
index efeb53ebe2..30438e6c10 100644
--- a/core/fpdftext/cpdf_linkextract_unittest.cpp
+++ b/core/fpdftext/cpdf_linkextract_unittest.cpp
@@ -32,7 +32,7 @@ TEST(CPDF_LinkExtractTest, CheckMailLink) {
};
for (size_t i = 0; i < FX_ArraySize(invalid_strs); ++i) {
const wchar_t* const input = invalid_strs[i];
- CFX_WideString text_str(input);
+ WideString text_str(input);
EXPECT_FALSE(extractor.CheckMailLink(&text_str)) << input;
}
@@ -53,8 +53,8 @@ TEST(CPDF_LinkExtractTest, CheckMailLink) {
};
for (size_t i = 0; i < FX_ArraySize(valid_strs); ++i) {
const wchar_t* const input = valid_strs[i][0];
- CFX_WideString text_str(input);
- CFX_WideString expected_str(L"mailto:");
+ WideString text_str(input);
+ WideString expected_str(L"mailto:");
expected_str += valid_strs[i][1];
EXPECT_TRUE(extractor.CheckMailLink(&text_str)) << input;
EXPECT_STREQ(expected_str.c_str(), text_str.c_str());
@@ -80,7 +80,7 @@ TEST(CPDF_LinkExtractTest, CheckWebLink) {
const int32_t DEFAULT_VALUE = -42;
for (size_t i = 0; i < FX_ArraySize(invalid_cases); ++i) {
const wchar_t* const input = invalid_cases[i];
- CFX_WideString text_str(input);
+ WideString text_str(input);
int32_t start_offset = DEFAULT_VALUE;
int32_t count = DEFAULT_VALUE;
EXPECT_FALSE(extractor.CheckWebLink(&text_str, &start_offset, &count))
@@ -175,7 +175,7 @@ TEST(CPDF_LinkExtractTest, CheckWebLink) {
};
for (size_t i = 0; i < FX_ArraySize(valid_cases); ++i) {
const wchar_t* const input = valid_cases[i].input_string;
- CFX_WideString text_str(input);
+ WideString text_str(input);
int32_t start_offset = DEFAULT_VALUE;
int32_t count = DEFAULT_VALUE;
EXPECT_TRUE(extractor.CheckWebLink(&text_str, &start_offset, &count))
diff --git a/core/fpdftext/cpdf_textpage.cpp b/core/fpdftext/cpdf_textpage.cpp
index ee1d51bfd8..f73793cd72 100644
--- a/core/fpdftext/cpdf_textpage.cpp
+++ b/core/fpdftext/cpdf_textpage.cpp
@@ -348,14 +348,14 @@ int CPDF_TextPage::GetIndexAtPos(const CFX_PointF& point,
return pos < pdfium::CollectionSize<int>(m_CharList) ? pos : NearPos;
}
-CFX_WideString CPDF_TextPage::GetTextByRect(const CFX_FloatRect& rect) const {
+WideString CPDF_TextPage::GetTextByRect(const CFX_FloatRect& rect) const {
if (!m_bIsParsed)
- return CFX_WideString();
+ return WideString();
float posy = 0;
bool IsContainPreChar = false;
bool IsAddLineFeed = false;
- CFX_WideString strText;
+ WideString strText;
for (const auto& charinfo : m_CharList) {
if (IsRectIntersect(rect, charinfo.m_CharBox)) {
if (fabs(posy - charinfo.m_Origin.y) > 0 && !IsContainPreChar &&
@@ -436,7 +436,7 @@ void CPDF_TextPage::CheckMarkedContentObject(int32_t& start,
}
}
-CFX_WideString CPDF_TextPage::GetPageText(int start, int nCount) const {
+WideString CPDF_TextPage::GetPageText(int start, int nCount) const {
if (!m_bIsParsed || nCount == 0)
return L"";
@@ -445,8 +445,8 @@ CFX_WideString CPDF_TextPage::GetPageText(int start, int nCount) const {
if (nCount == -1) {
nCount = pdfium::CollectionSize<int>(m_CharList) - start;
- CFX_WideStringC wsTextBuf = m_TextBuf.AsStringC();
- return CFX_WideString(wsTextBuf.Right(wsTextBuf.GetLength() - start));
+ WideStringView wsTextBuf = m_TextBuf.AsStringView();
+ return WideString(wsTextBuf.Right(wsTextBuf.GetLength() - start));
}
if (nCount <= 0 || m_CharList.empty())
return L"";
@@ -478,7 +478,7 @@ CFX_WideString CPDF_TextPage::GetPageText(int start, int nCount) const {
nCount = start + nCount - nCountOffset - startindex;
if (nCount <= 0)
return L"";
- return CFX_WideString(m_TextBuf.AsStringC().Mid(startindex, nCount));
+ return WideString(m_TextBuf.AsStringView().Mid(startindex, nCount));
}
int CPDF_TextPage::CountRects(int start, int nCount) {
@@ -630,7 +630,7 @@ int CPDF_TextPage::GetCharWidth(uint32_t charCode, CPDF_Font* pFont) const {
if (int w = pFont->GetCharWidthF(charCode))
return w;
- CFX_ByteString str;
+ ByteString str;
pFont->AppendChar(&str, charCode);
if (int w = pFont->GetStringWidth(str.c_str(), 1))
return w;
@@ -702,7 +702,7 @@ void CPDF_TextPage::CloseTempLine() {
if (m_TempCharList.empty())
return;
- CFX_WideString str = m_TempTextBuf.MakeString();
+ WideString str = m_TempTextBuf.MakeString();
bool bPrevSpace = false;
for (FX_STRSIZE i = 0; i < str.GetLength(); i++) {
if (str[i] != ' ') {
@@ -814,7 +814,7 @@ FPDFText_MarkedContent CPDF_TextPage::PreMarkedContent(PDFTEXT_Obj Obj) {
if (nContentMark < 1)
return FPDFText_MarkedContent::Pass;
- CFX_WideString actText;
+ WideString actText;
bool bExist = false;
CPDF_Dictionary* pDict = nullptr;
int n = 0;
@@ -876,7 +876,7 @@ void CPDF_TextPage::ProcessMarkedContent(PDFTEXT_Obj Obj) {
if (nContentMark < 1)
return;
- CFX_WideString actText;
+ WideString actText;
for (int n = 0; n < nContentMark; n++) {
const CPDF_ContentMarkItem& item = pTextObj->m_ContentMark.GetItem(n);
CPDF_Dictionary* pDict = item.GetParam();
@@ -941,13 +941,13 @@ void CPDF_TextPage::SwapTempTextBuf(int32_t iCharListStartAppend,
bool CPDF_TextPage::IsRightToLeft(const CPDF_TextObject* pTextObj,
const CPDF_Font* pFont,
int nItems) const {
- CFX_WideString str;
+ WideString str;
for (int32_t i = 0; i < nItems; i++) {
CPDF_TextObjectItem item;
pTextObj->GetItemInfo(i, &item);
if (item.m_CharCode == static_cast<uint32_t>(-1))
continue;
- CFX_WideString wstrItem = pFont->UnicodeFromCharCode(item.m_CharCode);
+ WideString wstrItem = pFont->UnicodeFromCharCode(item.m_CharCode);
wchar_t wChar = !wstrItem.IsEmpty() ? wstrItem[0] : 0;
if (wChar == 0)
wChar = item.m_CharCode;
@@ -1004,7 +1004,7 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) {
if (pTextObj->CountChars() == 1) {
CPDF_TextObjectItem item;
pTextObj->GetCharInfo(0, &item);
- CFX_WideString wstrItem =
+ WideString wstrItem =
pTextObj->GetFont()->UnicodeFromCharCode(item.m_CharCode);
if (wstrItem.IsEmpty())
wstrItem += (wchar_t)item.m_CharCode;
@@ -1013,7 +1013,7 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) {
return;
}
while (m_TempTextBuf.GetSize() > 0 &&
- m_TempTextBuf.AsStringC()[m_TempTextBuf.GetLength() - 1] ==
+ m_TempTextBuf.AsStringView()[m_TempTextBuf.GetLength() - 1] ==
0x20) {
m_TempTextBuf.Delete(m_TempTextBuf.GetLength() - 1, 1);
m_TempCharList.pop_back();
@@ -1053,9 +1053,9 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) {
PAGECHAR_INFO charinfo;
pTextObj->GetItemInfo(i, &item);
if (item.m_CharCode == static_cast<uint32_t>(-1)) {
- CFX_WideString str = m_TempTextBuf.MakeString();
+ WideString str = m_TempTextBuf.MakeString();
if (str.IsEmpty())
- str = m_TextBuf.AsStringC();
+ str = m_TextBuf.AsStringView();
if (str.IsEmpty() || str[str.GetLength() - 1] == TEXT_SPACE_CHAR)
continue;
@@ -1106,7 +1106,7 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) {
continue;
}
spacing = 0;
- CFX_WideString wstrItem = pFont->UnicodeFromCharCode(item.m_CharCode);
+ WideString wstrItem = pFont->UnicodeFromCharCode(item.m_CharCode);
bool bNoUnicode = false;
if (wstrItem.IsEmpty() && item.m_CharCode) {
wstrItem += static_cast<wchar_t>(item.m_CharCode);
@@ -1177,7 +1177,7 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) {
m_TempCharList.push_back(charinfo);
}
} else if (i == 0) {
- CFX_WideString str = m_TempTextBuf.MakeString();
+ WideString str = m_TempTextBuf.MakeString();
if (!str.IsEmpty() && str[str.GetLength() - 1] == TEXT_SPACE_CHAR) {
m_TempTextBuf.Delete(m_TempTextBuf.GetLength() - 1, 1);
m_TempCharList.pop_back();
@@ -1220,11 +1220,11 @@ CPDF_TextPage::TextOrientation CPDF_TextPage::GetTextObjectWritingMode(
}
bool CPDF_TextPage::IsHyphen(wchar_t curChar) const {
- CFX_WideStringC curText;
+ WideStringView curText;
if (!m_TempTextBuf.IsEmpty())
- curText = m_TempTextBuf.AsStringC();
+ curText = m_TempTextBuf.AsStringView();
else if (!m_TextBuf.IsEmpty())
- curText = m_TextBuf.AsStringC();
+ curText = m_TextBuf.AsStringView();
else
return false;
@@ -1267,8 +1267,7 @@ CPDF_TextPage::GenerateCharacter CPDF_TextPage::ProcessInsertObject(
int nItem = m_pPreTextObj->CountItems();
m_pPreTextObj->GetItemInfo(nItem - 1, &PrevItem);
pObj->GetItemInfo(0, &item);
- CFX_WideString wstrItem =
- pObj->GetFont()->UnicodeFromCharCode(item.m_CharCode);
+ WideString wstrItem = pObj->GetFont()->UnicodeFromCharCode(item.m_CharCode);
if (wstrItem.IsEmpty())
wstrItem += static_cast<wchar_t>(item.m_CharCode);
wchar_t curChar = wstrItem[0];
@@ -1356,7 +1355,7 @@ CPDF_TextPage::GenerateCharacter CPDF_TextPage::ProcessInsertObject(
IsHyphen(curChar)) {
return GenerateCharacter::Hyphen;
}
- CFX_WideString PrevStr =
+ WideString PrevStr =
m_pPreTextObj->GetFont()->UnicodeFromCharCode(PrevItem.m_CharCode);
if (PrevStr.IsEmpty())
return GenerateCharacter::None;
diff --git a/core/fpdftext/cpdf_textpage.h b/core/fpdftext/cpdf_textpage.h
index 41892ea97c..ef55ad05cb 100644
--- a/core/fpdftext/cpdf_textpage.h
+++ b/core/fpdftext/cpdf_textpage.h
@@ -106,8 +106,8 @@ class CPDF_TextPage {
void GetCharInfo(int index, FPDF_CHAR_INFO* info) const;
std::vector<CFX_FloatRect> GetRectArray(int start, int nCount) const;
int GetIndexAtPos(const CFX_PointF& point, const CFX_SizeF& tolerance) const;
- CFX_WideString GetTextByRect(const CFX_FloatRect& rect) const;
- CFX_WideString GetPageText(int start = 0, int nCount = -1) const;
+ WideString GetTextByRect(const CFX_FloatRect& rect) const;
+ WideString GetPageText(int start = 0, int nCount = -1) const;
int CountRects(int start, int nCount);
void GetRect(int rectIndex,
float& left,
diff --git a/core/fpdftext/cpdf_textpagefind.cpp b/core/fpdftext/cpdf_textpagefind.cpp
index 3678e42515..f00b8a9f4d 100644
--- a/core/fpdftext/cpdf_textpagefind.cpp
+++ b/core/fpdftext/cpdf_textpagefind.cpp
@@ -79,14 +79,14 @@ int CPDF_TextPageFind::GetCharIndex(int index) const {
return m_pTextPage->CharIndexFromTextIndex(index);
}
-bool CPDF_TextPageFind::FindFirst(const CFX_WideString& findwhat,
+bool CPDF_TextPageFind::FindFirst(const WideString& findwhat,
int flags,
pdfium::Optional<FX_STRSIZE> startPos) {
if (!m_pTextPage)
return false;
if (m_strText.IsEmpty() || m_bMatchCase != (flags & FPDFTEXT_MATCHCASE))
m_strText = m_pTextPage->GetPageText();
- CFX_WideString findwhatStr = findwhat;
+ WideString findwhatStr = findwhat;
m_findWhat = findwhatStr;
m_flags = flags;
m_bMatchCase = flags & FPDFTEXT_MATCHCASE;
@@ -147,7 +147,7 @@ bool CPDF_TextPageFind::FindNext() {
FX_STRSIZE nStartPos = m_findNextStart.value();
bool bSpaceStart = false;
for (int iWord = 0; iWord < nCount; iWord++) {
- CFX_WideString csWord = m_csFindWhatArray[iWord];
+ WideString csWord = m_csFindWhatArray[iWord];
if (csWord.IsEmpty()) {
if (iWord == nCount - 1) {
wchar_t strInsert = m_strText[nStartPos];
@@ -175,7 +175,7 @@ bool CPDF_TextPageFind::FindNext() {
if (iWord != 0 && !bSpaceStart) {
FX_STRSIZE PreResEndPos = nStartPos;
int curChar = csWord[0];
- CFX_WideString lastWord = m_csFindWhatArray[iWord - 1];
+ WideString lastWord = m_csFindWhatArray[iWord - 1];
int lastChar = lastWord[lastWord.GetLength() - 1];
if (nStartPos == nResultPos.value() &&
!(IsIgnoreSpaceCharacter(lastChar) ||
@@ -275,12 +275,12 @@ bool CPDF_TextPageFind::FindPrev() {
return m_IsFind;
}
-void CPDF_TextPageFind::ExtractFindWhat(const CFX_WideString& findwhat) {
+void CPDF_TextPageFind::ExtractFindWhat(const WideString& findwhat) {
if (findwhat.IsEmpty())
return;
int index = 0;
while (1) {
- CFX_WideString csWord = TEXT_EMPTY;
+ WideString csWord = TEXT_EMPTY;
int ret =
ExtractSubString(csWord, findwhat.c_str(), index, TEXT_SPACE_CHAR);
if (csWord.IsEmpty()) {
@@ -294,7 +294,7 @@ void CPDF_TextPageFind::ExtractFindWhat(const CFX_WideString& findwhat) {
}
FX_STRSIZE pos = 0;
while (pos < csWord.GetLength()) {
- CFX_WideString curStr = csWord.Mid(pos, 1);
+ WideString curStr = csWord.Mid(pos, 1);
wchar_t curChar = csWord[pos];
if (IsIgnoreSpaceCharacter(curChar)) {
if (pos > 0 && curChar == 0x2019) {
@@ -320,7 +320,7 @@ void CPDF_TextPageFind::ExtractFindWhat(const CFX_WideString& findwhat) {
}
}
-bool CPDF_TextPageFind::IsMatchWholeWord(const CFX_WideString& csPageText,
+bool CPDF_TextPageFind::IsMatchWholeWord(const WideString& csPageText,
FX_STRSIZE startPos,
FX_STRSIZE endPos) {
if (startPos > endPos)
@@ -360,7 +360,7 @@ bool CPDF_TextPageFind::IsMatchWholeWord(const CFX_WideString& csPageText,
return true;
}
-bool CPDF_TextPageFind::ExtractSubString(CFX_WideString& rString,
+bool CPDF_TextPageFind::ExtractSubString(WideString& rString,
const wchar_t* lpszFullString,
int iSubString,
wchar_t chSep) {
diff --git a/core/fpdftext/cpdf_textpagefind.h b/core/fpdftext/cpdf_textpagefind.h
index cf8d3d1702..f9a28a0b0a 100644
--- a/core/fpdftext/cpdf_textpagefind.h
+++ b/core/fpdftext/cpdf_textpagefind.h
@@ -22,7 +22,7 @@ class CPDF_TextPageFind {
explicit CPDF_TextPageFind(const CPDF_TextPage* pTextPage);
~CPDF_TextPageFind();
- bool FindFirst(const CFX_WideString& findwhat,
+ bool FindFirst(const WideString& findwhat,
int flags,
pdfium::Optional<FX_STRSIZE> startPos);
bool FindNext();
@@ -31,11 +31,11 @@ class CPDF_TextPageFind {
int GetMatchedCount() const;
protected:
- void ExtractFindWhat(const CFX_WideString& findwhat);
- bool IsMatchWholeWord(const CFX_WideString& csPageText,
+ void ExtractFindWhat(const WideString& findwhat);
+ bool IsMatchWholeWord(const WideString& csPageText,
FX_STRSIZE startPos,
FX_STRSIZE endPos);
- bool ExtractSubString(CFX_WideString& rString,
+ bool ExtractSubString(WideString& rString,
const wchar_t* lpszFullString,
int iSubString,
wchar_t chSep);
@@ -44,10 +44,10 @@ class CPDF_TextPageFind {
private:
std::vector<uint16_t> m_CharIndex;
CFX_UnownedPtr<const CPDF_TextPage> m_pTextPage;
- CFX_WideString m_strText;
- CFX_WideString m_findWhat;
+ WideString m_strText;
+ WideString m_findWhat;
int m_flags;
- std::vector<CFX_WideString> m_csFindWhatArray;
+ std::vector<WideString> m_csFindWhatArray;
pdfium::Optional<FX_STRSIZE> m_findNextStart;
pdfium::Optional<FX_STRSIZE> m_findPreStart;
bool m_bMatchCase;
diff --git a/core/fxcodec/codec/ccodec_gifmodule.cpp b/core/fxcodec/codec/ccodec_gifmodule.cpp
index 757019314d..f7e3546a8f 100644
--- a/core/fxcodec/codec/ccodec_gifmodule.cpp
+++ b/core/fxcodec/codec/ccodec_gifmodule.cpp
@@ -71,7 +71,7 @@ GifDecodeStatus CCodec_GifModule::LoadFrame(Context* pContext,
if (len > 21) {
uint8_t size = *buf++;
if (size != 0)
- pAttribute->m_strAuthor = CFX_ByteString(buf, size);
+ pAttribute->m_strAuthor = ByteString(buf, size);
else
pAttribute->m_strAuthor.clear();
}
diff --git a/core/fxcodec/codec/ccodec_pngmodule.cpp b/core/fxcodec/codec/ccodec_pngmodule.cpp
index 8a3de3a154..ae70389ced 100644
--- a/core/fxcodec/codec/ccodec_pngmodule.cpp
+++ b/core/fxcodec/codec/ccodec_pngmodule.cpp
@@ -86,8 +86,8 @@ static void _png_load_bmp_attribute(png_structp png_ptr,
buf = "Author";
if (!memcmp(buf, text[i].key, std::min(len, FXSYS_strlen(buf)))) {
pAttribute->m_strAuthor =
- CFX_ByteString(reinterpret_cast<uint8_t*>(text[i].text),
- static_cast<FX_STRSIZE>(text[i].text_length));
+ ByteString(reinterpret_cast<uint8_t*>(text[i].text),
+ static_cast<FX_STRSIZE>(text[i].text_length));
}
}
}
diff --git a/core/fxcodec/fx_codec.h b/core/fxcodec/fx_codec.h
index 2e83319ef7..926a884efe 100644
--- a/core/fxcodec/fx_codec.h
+++ b/core/fxcodec/fx_codec.h
@@ -48,7 +48,7 @@ class CFX_DIBAttribute {
int32_t m_nYDPI;
float m_fAspectRatio;
uint16_t m_wDPIUnit;
- CFX_ByteString m_strAuthor;
+ ByteString m_strAuthor;
int32_t m_nGifLeft;
int32_t m_nGifTop;
uint32_t* m_pGifLocalPalette;
diff --git a/core/fxcodec/lgif/cgifcontext.h b/core/fxcodec/lgif/cgifcontext.h
index 1bd6d46d31..03976a7aad 100644
--- a/core/fxcodec/lgif/cgifcontext.h
+++ b/core/fxcodec/lgif/cgifcontext.h
@@ -46,7 +46,7 @@ class CGifContext : public CCodec_GifModule::Context {
uint32_t avail_in;
int32_t decode_status;
uint32_t skip_size;
- CFX_ByteString cmt_data;
+ ByteString cmt_data;
std::unique_ptr<GifGCE> m_GifGCE;
uint8_t* next_in;
std::vector<std::unique_ptr<GifImage>> m_Images;
diff --git a/core/fxcodec/lgif/fx_gif.cpp b/core/fxcodec/lgif/fx_gif.cpp
index cef4f9a9a5..18385c3bdd 100644
--- a/core/fxcodec/lgif/fx_gif.cpp
+++ b/core/fxcodec/lgif/fx_gif.cpp
@@ -61,7 +61,7 @@ GifDecodeStatus gif_decode_extension(CGifContext* context) {
context->skip_size = skip_size_org;
return GifDecodeStatus::Unfinished;
}
- context->cmt_data += CFX_ByteString(data_ptr, data_size);
+ context->cmt_data += ByteString(data_ptr, data_size);
}
break;
}
diff --git a/core/fxcrt/cfx_bytestring.cpp b/core/fxcrt/bytestring.cpp
index 073591a5ab..dd4dbd99e2 100644
--- a/core/fxcrt/cfx_bytestring.cpp
+++ b/core/fxcrt/bytestring.cpp
@@ -4,7 +4,7 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "core/fxcrt/cfx_bytestring.h"
+#include "core/fxcrt/bytestring.h"
#include <stddef.h>
@@ -21,9 +21,9 @@
#include "third_party/base/stl_util.h"
template class CFX_StringDataTemplate<char>;
-template class CFX_StringCTemplate<char>;
-template class CFX_StringPoolTemplate<CFX_ByteString>;
-template struct std::hash<CFX_ByteString>;
+template class fxcrt::StringViewTemplate<char>;
+template class CFX_StringPoolTemplate<ByteString>;
+template struct std::hash<ByteString>;
namespace {
@@ -66,7 +66,7 @@ bool IsValidCodePage(uint16_t codepage) {
}
#endif
-CFX_ByteString GetByteString(uint16_t codepage, const CFX_WideStringC& wstr) {
+ByteString GetByteString(uint16_t codepage, const WideStringView& wstr) {
ASSERT(IsValidCodePage(codepage));
int src_len = wstr.GetLength();
@@ -74,9 +74,9 @@ CFX_ByteString GetByteString(uint16_t codepage, const CFX_WideStringC& wstr) {
FXSYS_WideCharToMultiByte(codepage, 0, wstr.unterminated_c_str(), src_len,
nullptr, 0, nullptr, nullptr);
if (!dest_len)
- return CFX_ByteString();
+ return ByteString();
- CFX_ByteString bstr;
+ ByteString bstr;
char* dest_buf = bstr.GetBuffer(dest_len);
FXSYS_WideCharToMultiByte(codepage, 0, wstr.unterminated_c_str(), src_len,
dest_buf, dest_len, nullptr, nullptr);
@@ -86,45 +86,45 @@ CFX_ByteString GetByteString(uint16_t codepage, const CFX_WideStringC& wstr) {
} // namespace
-static_assert(sizeof(CFX_ByteString) <= sizeof(char*),
+namespace fxcrt {
+
+static_assert(sizeof(ByteString) <= sizeof(char*),
"Strings must not require more space than pointers");
-CFX_ByteString::CFX_ByteString(const char* pStr, FX_STRSIZE nLen) {
+ByteString::ByteString(const char* pStr, FX_STRSIZE nLen) {
if (nLen)
m_pData.Reset(StringData::Create(pStr, nLen));
}
-CFX_ByteString::CFX_ByteString(const uint8_t* pStr, FX_STRSIZE nLen) {
+ByteString::ByteString(const uint8_t* pStr, FX_STRSIZE nLen) {
if (nLen)
m_pData.Reset(
StringData::Create(reinterpret_cast<const char*>(pStr), nLen));
}
-CFX_ByteString::CFX_ByteString() {}
+ByteString::ByteString() {}
-CFX_ByteString::CFX_ByteString(const CFX_ByteString& other)
- : m_pData(other.m_pData) {}
+ByteString::ByteString(const ByteString& other) : m_pData(other.m_pData) {}
-CFX_ByteString::CFX_ByteString(CFX_ByteString&& other) noexcept {
+ByteString::ByteString(ByteString&& other) noexcept {
m_pData.Swap(other.m_pData);
}
-CFX_ByteString::CFX_ByteString(char ch) {
+ByteString::ByteString(char ch) {
m_pData.Reset(StringData::Create(1));
m_pData->m_String[0] = ch;
}
-CFX_ByteString::CFX_ByteString(const char* ptr)
- : CFX_ByteString(ptr, ptr ? FXSYS_strlen(ptr) : 0) {}
+ByteString::ByteString(const char* ptr)
+ : ByteString(ptr, ptr ? FXSYS_strlen(ptr) : 0) {}
-CFX_ByteString::CFX_ByteString(const CFX_ByteStringC& stringSrc) {
+ByteString::ByteString(const ByteStringView& stringSrc) {
if (!stringSrc.IsEmpty())
m_pData.Reset(StringData::Create(stringSrc.unterminated_c_str(),
stringSrc.GetLength()));
}
-CFX_ByteString::CFX_ByteString(const CFX_ByteStringC& str1,
- const CFX_ByteStringC& str2) {
+ByteString::ByteString(const ByteStringView& str1, const ByteStringView& str2) {
FX_SAFE_STRSIZE nSafeLen = str1.GetLength();
nSafeLen += str2.GetLength();
@@ -138,8 +138,7 @@ CFX_ByteString::CFX_ByteString(const CFX_ByteStringC& str1,
str2.GetLength());
}
-CFX_ByteString::CFX_ByteString(
- const std::initializer_list<CFX_ByteStringC>& list) {
+ByteString::ByteString(const std::initializer_list<ByteStringView>& list) {
FX_SAFE_STRSIZE nSafeLen = 0;
for (const auto& item : list)
nSafeLen += item.GetLength();
@@ -158,15 +157,15 @@ CFX_ByteString::CFX_ByteString(
}
}
-CFX_ByteString::CFX_ByteString(const std::ostringstream& outStream) {
+ByteString::ByteString(const std::ostringstream& outStream) {
std::string str = outStream.str();
if (str.length() > 0)
m_pData.Reset(StringData::Create(str.c_str(), str.length()));
}
-CFX_ByteString::~CFX_ByteString() {}
+ByteString::~ByteString() {}
-const CFX_ByteString& CFX_ByteString::operator=(const char* pStr) {
+const ByteString& ByteString::operator=(const char* pStr) {
if (!pStr || !pStr[0])
clear();
else
@@ -175,8 +174,7 @@ const CFX_ByteString& CFX_ByteString::operator=(const char* pStr) {
return *this;
}
-const CFX_ByteString& CFX_ByteString::operator=(
- const CFX_ByteStringC& stringSrc) {
+const ByteString& ByteString::operator=(const ByteStringView& stringSrc) {
if (stringSrc.IsEmpty())
clear();
else
@@ -185,41 +183,40 @@ const CFX_ByteString& CFX_ByteString::operator=(
return *this;
}
-const CFX_ByteString& CFX_ByteString::operator=(
- const CFX_ByteString& stringSrc) {
+const ByteString& ByteString::operator=(const ByteString& stringSrc) {
if (m_pData != stringSrc.m_pData)
m_pData = stringSrc.m_pData;
return *this;
}
-const CFX_ByteString& CFX_ByteString::operator+=(const char* pStr) {
+const ByteString& ByteString::operator+=(const char* pStr) {
if (pStr)
Concat(pStr, FXSYS_strlen(pStr));
return *this;
}
-const CFX_ByteString& CFX_ByteString::operator+=(char ch) {
+const ByteString& ByteString::operator+=(char ch) {
Concat(&ch, 1);
return *this;
}
-const CFX_ByteString& CFX_ByteString::operator+=(const CFX_ByteString& str) {
+const ByteString& ByteString::operator+=(const ByteString& str) {
if (str.m_pData)
Concat(str.m_pData->m_String, str.m_pData->m_nDataLength);
return *this;
}
-const CFX_ByteString& CFX_ByteString::operator+=(const CFX_ByteStringC& str) {
+const ByteString& ByteString::operator+=(const ByteStringView& str) {
if (!str.IsEmpty())
Concat(str.unterminated_c_str(), str.GetLength());
return *this;
}
-bool CFX_ByteString::operator==(const char* ptr) const {
+bool ByteString::operator==(const char* ptr) const {
if (!m_pData)
return !ptr || !ptr[0];
@@ -230,7 +227,7 @@ bool CFX_ByteString::operator==(const char* ptr) const {
memcmp(ptr, m_pData->m_String, m_pData->m_nDataLength) == 0;
}
-bool CFX_ByteString::operator==(const CFX_ByteStringC& str) const {
+bool ByteString::operator==(const ByteStringView& str) const {
if (!m_pData)
return str.IsEmpty();
@@ -239,7 +236,7 @@ bool CFX_ByteString::operator==(const CFX_ByteStringC& str) const {
0;
}
-bool CFX_ByteString::operator==(const CFX_ByteString& other) const {
+bool ByteString::operator==(const ByteString& other) const {
if (m_pData == other.m_pData)
return true;
@@ -254,7 +251,7 @@ bool CFX_ByteString::operator==(const CFX_ByteString& other) const {
m_pData->m_nDataLength) == 0;
}
-bool CFX_ByteString::operator<(const CFX_ByteString& str) const {
+bool ByteString::operator<(const ByteString& str) const {
if (m_pData == str.m_pData)
return false;
@@ -263,7 +260,7 @@ bool CFX_ByteString::operator<(const CFX_ByteString& str) const {
return result < 0 || (result == 0 && GetLength() < str.GetLength());
}
-bool CFX_ByteString::EqualNoCase(const CFX_ByteStringC& str) const {
+bool ByteString::EqualNoCase(const ByteStringView& str) const {
if (!m_pData)
return str.IsEmpty();
@@ -286,13 +283,13 @@ bool CFX_ByteString::EqualNoCase(const CFX_ByteStringC& str) const {
return true;
}
-void CFX_ByteString::AssignCopy(const char* pSrcData, FX_STRSIZE nSrcLen) {
+void ByteString::AssignCopy(const char* pSrcData, FX_STRSIZE nSrcLen) {
AllocBeforeWrite(nSrcLen);
m_pData->CopyContents(pSrcData, nSrcLen);
m_pData->m_nDataLength = nSrcLen;
}
-void CFX_ByteString::ReallocBeforeWrite(FX_STRSIZE nNewLength) {
+void ByteString::ReallocBeforeWrite(FX_STRSIZE nNewLength) {
if (m_pData && m_pData->CanOperateInPlace(nNewLength))
return;
@@ -313,7 +310,7 @@ void CFX_ByteString::ReallocBeforeWrite(FX_STRSIZE nNewLength) {
m_pData.Swap(pNewData);
}
-void CFX_ByteString::AllocBeforeWrite(FX_STRSIZE nNewLength) {
+void ByteString::AllocBeforeWrite(FX_STRSIZE nNewLength) {
if (m_pData && m_pData->CanOperateInPlace(nNewLength))
return;
@@ -325,7 +322,7 @@ void CFX_ByteString::AllocBeforeWrite(FX_STRSIZE nNewLength) {
m_pData.Reset(StringData::Create(nNewLength));
}
-void CFX_ByteString::ReleaseBuffer(FX_STRSIZE nNewLength) {
+void ByteString::ReleaseBuffer(FX_STRSIZE nNewLength) {
if (!m_pData)
return;
@@ -341,16 +338,16 @@ void CFX_ByteString::ReleaseBuffer(FX_STRSIZE nNewLength) {
if (m_pData->m_nAllocLength - nNewLength >= 32) {
// Over arbitrary threshold, so pay the price to relocate. Force copy to
// always occur by holding a second reference to the string.
- CFX_ByteString preserve(*this);
+ ByteString preserve(*this);
ReallocBeforeWrite(nNewLength);
}
}
-void CFX_ByteString::Reserve(FX_STRSIZE len) {
+void ByteString::Reserve(FX_STRSIZE len) {
GetBuffer(len);
}
-char* CFX_ByteString::GetBuffer(FX_STRSIZE nMinBufLength) {
+char* ByteString::GetBuffer(FX_STRSIZE nMinBufLength) {
if (!m_pData) {
if (nMinBufLength == 0)
return nullptr;
@@ -375,7 +372,7 @@ char* CFX_ByteString::GetBuffer(FX_STRSIZE nMinBufLength) {
return m_pData->m_String;
}
-FX_STRSIZE CFX_ByteString::Delete(FX_STRSIZE index, FX_STRSIZE count) {
+FX_STRSIZE ByteString::Delete(FX_STRSIZE index, FX_STRSIZE count) {
if (!m_pData)
return 0;
@@ -396,7 +393,7 @@ FX_STRSIZE CFX_ByteString::Delete(FX_STRSIZE index, FX_STRSIZE count) {
return m_pData->m_nDataLength;
}
-void CFX_ByteString::Concat(const char* pSrcData, FX_STRSIZE nSrcLen) {
+void ByteString::Concat(const char* pSrcData, FX_STRSIZE nSrcLen) {
if (!pSrcData || nSrcLen == 0)
return;
@@ -418,42 +415,42 @@ void CFX_ByteString::Concat(const char* pSrcData, FX_STRSIZE nSrcLen) {
m_pData.Swap(pNewData);
}
-CFX_ByteString CFX_ByteString::Mid(FX_STRSIZE first, FX_STRSIZE count) const {
+ByteString ByteString::Mid(FX_STRSIZE first, FX_STRSIZE count) const {
if (!m_pData)
- return CFX_ByteString();
+ return ByteString();
if (!IsValidIndex(first))
- return CFX_ByteString();
+ return ByteString();
if (count == 0 || !IsValidLength(count))
- return CFX_ByteString();
+ return ByteString();
if (!IsValidIndex(first + count - 1))
- return CFX_ByteString();
+ return ByteString();
if (first == 0 && count == m_pData->m_nDataLength)
return *this;
- CFX_ByteString dest;
+ ByteString dest;
AllocCopy(dest, count, first);
return dest;
}
-CFX_ByteString CFX_ByteString::Left(FX_STRSIZE count) const {
+ByteString ByteString::Left(FX_STRSIZE count) const {
if (count == 0 || !IsValidLength(count))
- return CFX_ByteString();
+ return ByteString();
return Mid(0, count);
}
-CFX_ByteString CFX_ByteString::Right(FX_STRSIZE count) const {
+ByteString ByteString::Right(FX_STRSIZE count) const {
if (count == 0 || !IsValidLength(count))
- return CFX_ByteString();
+ return ByteString();
return Mid(GetLength() - count, count);
}
-void CFX_ByteString::AllocCopy(CFX_ByteString& dest,
- FX_STRSIZE nCopyLen,
- FX_STRSIZE nCopyIndex) const {
+void ByteString::AllocCopy(ByteString& dest,
+ FX_STRSIZE nCopyLen,
+ FX_STRSIZE nCopyIndex) const {
if (nCopyLen == 0)
return;
@@ -466,13 +463,13 @@ void CFX_ByteString::AllocCopy(CFX_ByteString& dest,
#define FORCE_UNICODE 0x20000
#define FORCE_INT64 0x40000
-CFX_ByteString CFX_ByteString::FormatInteger(int i) {
+ByteString ByteString::FormatInteger(int i) {
char buf[32];
FXSYS_snprintf(buf, 32, "%d", i);
- return CFX_ByteString(buf);
+ return ByteString(buf);
}
-void CFX_ByteString::FormatV(const char* pFormat, va_list argList) {
+void ByteString::FormatV(const char* pFormat, va_list argList) {
va_list argListCopy;
va_copy(argListCopy, argList);
FX_STRSIZE nMaxLen = vsnprintf(nullptr, 0, pFormat, argListCopy);
@@ -491,20 +488,20 @@ void CFX_ByteString::FormatV(const char* pFormat, va_list argList) {
}
}
-void CFX_ByteString::Format(const char* pFormat, ...) {
+void ByteString::Format(const char* pFormat, ...) {
va_list argList;
va_start(argList, pFormat);
FormatV(pFormat, argList);
va_end(argList);
}
-void CFX_ByteString::SetAt(FX_STRSIZE index, char c) {
+void ByteString::SetAt(FX_STRSIZE index, char c) {
ASSERT(IsValidIndex(index));
ReallocBeforeWrite(m_pData->m_nDataLength);
m_pData->m_String[index] = c;
}
-FX_STRSIZE CFX_ByteString::Insert(FX_STRSIZE location, char ch) {
+FX_STRSIZE ByteString::Insert(FX_STRSIZE location, char ch) {
const FX_STRSIZE cur_length = m_pData ? m_pData->m_nDataLength : 0;
if (!IsValidLength(location))
return cur_length;
@@ -518,8 +515,7 @@ FX_STRSIZE CFX_ByteString::Insert(FX_STRSIZE location, char ch) {
return new_length;
}
-pdfium::Optional<FX_STRSIZE> CFX_ByteString::Find(char ch,
- FX_STRSIZE start) const {
+pdfium::Optional<FX_STRSIZE> ByteString::Find(char ch, FX_STRSIZE start) const {
if (!m_pData)
return pdfium::Optional<FX_STRSIZE>();
@@ -533,8 +529,8 @@ pdfium::Optional<FX_STRSIZE> CFX_ByteString::Find(char ch,
: pdfium::Optional<FX_STRSIZE>();
}
-pdfium::Optional<FX_STRSIZE> CFX_ByteString::Find(const CFX_ByteStringC& subStr,
- FX_STRSIZE start) const {
+pdfium::Optional<FX_STRSIZE> ByteString::Find(const ByteStringView& subStr,
+ FX_STRSIZE start) const {
if (!m_pData)
return pdfium::Optional<FX_STRSIZE>();
@@ -549,7 +545,7 @@ pdfium::Optional<FX_STRSIZE> CFX_ByteString::Find(const CFX_ByteStringC& subStr,
: pdfium::Optional<FX_STRSIZE>();
}
-pdfium::Optional<FX_STRSIZE> CFX_ByteString::ReverseFind(char ch) const {
+pdfium::Optional<FX_STRSIZE> ByteString::ReverseFind(char ch) const {
if (!m_pData)
return pdfium::Optional<FX_STRSIZE>();
@@ -561,7 +557,7 @@ pdfium::Optional<FX_STRSIZE> CFX_ByteString::ReverseFind(char ch) const {
return pdfium::Optional<FX_STRSIZE>();
}
-void CFX_ByteString::MakeLower() {
+void ByteString::MakeLower() {
if (!m_pData)
return;
@@ -569,7 +565,7 @@ void CFX_ByteString::MakeLower() {
FXSYS_strlwr(m_pData->m_String);
}
-void CFX_ByteString::MakeUpper() {
+void ByteString::MakeUpper() {
if (!m_pData)
return;
@@ -577,7 +573,7 @@ void CFX_ByteString::MakeUpper() {
FXSYS_strupr(m_pData->m_String);
}
-FX_STRSIZE CFX_ByteString::Remove(char chRemove) {
+FX_STRSIZE ByteString::Remove(char chRemove) {
if (!m_pData || m_pData->m_nDataLength < 1)
return 0;
@@ -611,8 +607,8 @@ FX_STRSIZE CFX_ByteString::Remove(char chRemove) {
return nCount;
}
-FX_STRSIZE CFX_ByteString::Replace(const CFX_ByteStringC& pOld,
- const CFX_ByteStringC& pNew) {
+FX_STRSIZE ByteString::Replace(const ByteStringView& pOld,
+ const ByteStringView& pNew) {
if (!m_pData || pOld.IsEmpty())
return 0;
@@ -658,20 +654,20 @@ FX_STRSIZE CFX_ByteString::Replace(const CFX_ByteStringC& pOld,
return nCount;
}
-CFX_WideString CFX_ByteString::UTF8Decode() const {
+WideString ByteString::UTF8Decode() const {
CFX_UTF8Decoder decoder;
for (FX_STRSIZE i = 0; i < GetLength(); i++) {
decoder.Input(static_cast<uint8_t>(m_pData->m_String[i]));
}
- return CFX_WideString(decoder.GetResult());
+ return WideString(decoder.GetResult());
}
// static
-CFX_ByteString CFX_ByteString::FromUnicode(const CFX_WideString& str) {
- return GetByteString(0, str.AsStringC());
+ByteString ByteString::FromUnicode(const WideString& str) {
+ return GetByteString(0, str.AsStringView());
}
-int CFX_ByteString::Compare(const CFX_ByteStringC& str) const {
+int ByteString::Compare(const ByteStringView& str) const {
if (!m_pData) {
return str.IsEmpty() ? 0 : -1;
}
@@ -695,7 +691,7 @@ int CFX_ByteString::Compare(const CFX_ByteStringC& str) const {
return 0;
}
-void CFX_ByteString::TrimRight(const CFX_ByteStringC& pTargets) {
+void ByteString::TrimRight(const ByteStringView& pTargets) {
if (!m_pData || pTargets.IsEmpty())
return;
@@ -721,15 +717,15 @@ void CFX_ByteString::TrimRight(const CFX_ByteStringC& pTargets) {
}
}
-void CFX_ByteString::TrimRight(char chTarget) {
- TrimRight(CFX_ByteStringC(chTarget));
+void ByteString::TrimRight(char chTarget) {
+ TrimRight(ByteStringView(chTarget));
}
-void CFX_ByteString::TrimRight() {
+void ByteString::TrimRight() {
TrimRight("\x09\x0a\x0b\x0c\x0d\x20");
}
-void CFX_ByteString::TrimLeft(const CFX_ByteStringC& pTargets) {
+void ByteString::TrimLeft(const ByteStringView& pTargets) {
if (!m_pData || pTargets.IsEmpty())
return;
@@ -757,24 +753,26 @@ void CFX_ByteString::TrimLeft(const CFX_ByteStringC& pTargets) {
}
}
-void CFX_ByteString::TrimLeft(char chTarget) {
- TrimLeft(CFX_ByteStringC(chTarget));
+void ByteString::TrimLeft(char chTarget) {
+ TrimLeft(ByteStringView(chTarget));
}
-void CFX_ByteString::TrimLeft() {
+void ByteString::TrimLeft() {
TrimLeft("\x09\x0a\x0b\x0c\x0d\x20");
}
-CFX_ByteString CFX_ByteString::FormatFloat(float d, int precision) {
+ByteString ByteString::FormatFloat(float d, int precision) {
char buf[32];
FX_STRSIZE len = FX_ftoa(d, buf);
- return CFX_ByteString(buf, len);
+ return ByteString(buf, len);
}
-std::ostream& operator<<(std::ostream& os, const CFX_ByteString& str) {
+std::ostream& operator<<(std::ostream& os, const ByteString& str) {
return os.write(str.c_str(), str.GetLength());
}
-std::ostream& operator<<(std::ostream& os, const CFX_ByteStringC& str) {
+std::ostream& operator<<(std::ostream& os, const ByteStringView& str) {
return os.write(str.unterminated_c_str(), str.GetLength());
}
+
+} // namespace fxcrt
diff --git a/core/fxcrt/bytestring.h b/core/fxcrt/bytestring.h
new file mode 100644
index 0000000000..0220e707cd
--- /dev/null
+++ b/core/fxcrt/bytestring.h
@@ -0,0 +1,279 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef CORE_FXCRT_BYTESTRING_H_
+#define CORE_FXCRT_BYTESTRING_H_
+
+#include <functional>
+#include <iterator>
+#include <sstream>
+#include <utility>
+
+#include "core/fxcrt/cfx_retain_ptr.h"
+#include "core/fxcrt/cfx_string_data_template.h"
+#include "core/fxcrt/fx_system.h"
+#include "core/fxcrt/string_view_template.h"
+#include "third_party/base/optional.h"
+
+class ByteString_Concat_Test;
+class fxcrt_ByteStringPool_Test;
+
+namespace fxcrt {
+
+class WideString;
+
+// A mutable string with shared buffers using copy-on-write semantics that
+// avoids the cost of std::string's iterator stability guarantees.
+class ByteString {
+ public:
+ using CharType = char;
+ using const_iterator = const CharType*;
+ using const_reverse_iterator = std::reverse_iterator<const_iterator>;
+
+ ByteString();
+ ByteString(const ByteString& other);
+ ByteString(ByteString&& other) noexcept;
+
+ // Deliberately implicit to avoid calling on every string literal.
+ // NOLINTNEXTLINE(runtime/explicit)
+ ByteString(char ch);
+ // NOLINTNEXTLINE(runtime/explicit)
+ ByteString(const char* ptr);
+
+ // No implicit conversions from wide strings.
+ // NOLINTNEXTLINE(runtime/explicit)
+ ByteString(wchar_t) = delete;
+
+ ByteString(const char* ptr, FX_STRSIZE len);
+ ByteString(const uint8_t* ptr, FX_STRSIZE len);
+
+ explicit ByteString(const ByteStringView& bstrc);
+ ByteString(const ByteStringView& bstrc1, const ByteStringView& bstrc2);
+ ByteString(const std::initializer_list<ByteStringView>& list);
+ explicit ByteString(const std::ostringstream& outStream);
+
+ ~ByteString();
+
+ void clear() { m_pData.Reset(); }
+
+ static ByteString FromUnicode(const WideString& str);
+
+ // Explicit conversion to C-style string.
+ // Note: Any subsequent modification of |this| will invalidate the result.
+ const char* c_str() const { return m_pData ? m_pData->m_String : ""; }
+
+ // Explicit conversion to uint8_t*.
+ // Note: Any subsequent modification of |this| will invalidate the result.
+ const uint8_t* raw_str() const {
+ return m_pData ? reinterpret_cast<const uint8_t*>(m_pData->m_String)
+ : nullptr;
+ }
+
+ // Explicit conversion to ByteStringView.
+ // Note: Any subsequent modification of |this| will invalidate the result.
+ ByteStringView AsStringView() const {
+ return ByteStringView(raw_str(), GetLength());
+ }
+
+ // Note: Any subsequent modification of |this| will invalidate iterators.
+ const_iterator begin() const { return m_pData ? m_pData->m_String : nullptr; }
+ const_iterator end() const {
+ return m_pData ? m_pData->m_String + m_pData->m_nDataLength : nullptr;
+ }
+
+ // Note: Any subsequent modification of |this| will invalidate iterators.
+ const_reverse_iterator rbegin() const {
+ return const_reverse_iterator(end());
+ }
+ const_reverse_iterator rend() const {
+ return const_reverse_iterator(begin());
+ }
+
+ FX_STRSIZE GetLength() const { return m_pData ? m_pData->m_nDataLength : 0; }
+ FX_STRSIZE GetStringLength() const {
+ return m_pData ? FXSYS_strlen(m_pData->m_String) : 0;
+ }
+ bool IsEmpty() const { return !GetLength(); }
+ bool IsValidIndex(FX_STRSIZE index) const { return index < GetLength(); }
+ bool IsValidLength(FX_STRSIZE length) const { return length <= GetLength(); }
+
+ int Compare(const ByteStringView& str) const;
+ bool EqualNoCase(const ByteStringView& str) const;
+
+ bool operator==(const char* ptr) const;
+ bool operator==(const ByteStringView& str) const;
+ bool operator==(const ByteString& other) const;
+
+ bool operator!=(const char* ptr) const { return !(*this == ptr); }
+ bool operator!=(const ByteStringView& str) const { return !(*this == str); }
+ bool operator!=(const ByteString& other) const { return !(*this == other); }
+
+ bool operator<(const ByteString& str) const;
+
+ const ByteString& operator=(const char* str);
+ const ByteString& operator=(const ByteStringView& bstrc);
+ const ByteString& operator=(const ByteString& stringSrc);
+
+ const ByteString& operator+=(char ch);
+ const ByteString& operator+=(const char* str);
+ const ByteString& operator+=(const ByteString& str);
+ const ByteString& operator+=(const ByteStringView& bstrc);
+
+ CharType operator[](const FX_STRSIZE index) const {
+ ASSERT(IsValidIndex(index));
+ return m_pData ? m_pData->m_String[index] : 0;
+ }
+
+ CharType First() const { return GetLength() ? (*this)[0] : 0; }
+ CharType Last() const { return GetLength() ? (*this)[GetLength() - 1] : 0; }
+
+ void SetAt(FX_STRSIZE index, char c);
+
+ FX_STRSIZE Insert(FX_STRSIZE index, char ch);
+ FX_STRSIZE InsertAtFront(char ch) { return Insert(0, ch); }
+ FX_STRSIZE InsertAtBack(char ch) { return Insert(GetLength(), ch); }
+ FX_STRSIZE Delete(FX_STRSIZE index, FX_STRSIZE count = 1);
+
+ void Format(const char* lpszFormat, ...);
+ void FormatV(const char* lpszFormat, va_list argList);
+
+ void Reserve(FX_STRSIZE len);
+ char* GetBuffer(FX_STRSIZE len);
+ void ReleaseBuffer(FX_STRSIZE len);
+
+ ByteString Mid(FX_STRSIZE first, FX_STRSIZE count) const;
+ ByteString Left(FX_STRSIZE count) const;
+ ByteString Right(FX_STRSIZE count) const;
+
+ pdfium::Optional<FX_STRSIZE> Find(const ByteStringView& lpszSub,
+ FX_STRSIZE start = 0) const;
+ pdfium::Optional<FX_STRSIZE> Find(char ch, FX_STRSIZE start = 0) const;
+ pdfium::Optional<FX_STRSIZE> ReverseFind(char ch) const;
+
+ bool Contains(const ByteStringView& lpszSub, FX_STRSIZE start = 0) const {
+ return Find(lpszSub, start).has_value();
+ }
+
+ bool Contains(char ch, FX_STRSIZE start = 0) const {
+ return Find(ch, start).has_value();
+ }
+
+ void MakeLower();
+ void MakeUpper();
+
+ void TrimRight();
+ void TrimRight(char chTarget);
+ void TrimRight(const ByteStringView& lpszTargets);
+
+ void TrimLeft();
+ void TrimLeft(char chTarget);
+ void TrimLeft(const ByteStringView& lpszTargets);
+
+ FX_STRSIZE Replace(const ByteStringView& lpszOld,
+ const ByteStringView& lpszNew);
+
+ FX_STRSIZE Remove(char ch);
+
+ WideString UTF8Decode() const;
+
+ uint32_t GetID() const { return AsStringView().GetID(); }
+
+ static ByteString FormatInteger(int i);
+ static ByteString FormatFloat(float f, int precision = 0);
+
+ protected:
+ using StringData = CFX_StringDataTemplate<char>;
+
+ void ReallocBeforeWrite(FX_STRSIZE nNewLen);
+ void AllocBeforeWrite(FX_STRSIZE nNewLen);
+ void AllocCopy(ByteString& dest,
+ FX_STRSIZE nCopyLen,
+ FX_STRSIZE nCopyIndex) const;
+ void AssignCopy(const char* pSrcData, FX_STRSIZE nSrcLen);
+ void Concat(const char* lpszSrcData, FX_STRSIZE nSrcLen);
+
+ CFX_RetainPtr<StringData> m_pData;
+
+ friend ByteString_Concat_Test;
+ friend fxcrt_ByteStringPool_Test;
+};
+
+inline bool operator==(const char* lhs, const ByteString& rhs) {
+ return rhs == lhs;
+}
+inline bool operator==(const ByteStringView& lhs, const ByteString& rhs) {
+ return rhs == lhs;
+}
+inline bool operator!=(const char* lhs, const ByteString& rhs) {
+ return rhs != lhs;
+}
+inline bool operator!=(const ByteStringView& lhs, const ByteString& rhs) {
+ return rhs != lhs;
+}
+
+inline ByteString operator+(const ByteStringView& str1,
+ const ByteStringView& str2) {
+ return ByteString(str1, str2);
+}
+inline ByteString operator+(const ByteStringView& str1, const char* str2) {
+ return ByteString(str1, str2);
+}
+inline ByteString operator+(const char* str1, const ByteStringView& str2) {
+ return ByteString(str1, str2);
+}
+inline ByteString operator+(const ByteStringView& str1, char ch) {
+ return ByteString(str1, ByteStringView(ch));
+}
+inline ByteString operator+(char ch, const ByteStringView& str2) {
+ return ByteString(ch, str2);
+}
+inline ByteString operator+(const ByteString& str1, const ByteString& str2) {
+ return ByteString(str1.AsStringView(), str2.AsStringView());
+}
+inline ByteString operator+(const ByteString& str1, char ch) {
+ return ByteString(str1.AsStringView(), ByteStringView(ch));
+}
+inline ByteString operator+(char ch, const ByteString& str2) {
+ return ByteString(ch, str2.AsStringView());
+}
+inline ByteString operator+(const ByteString& str1, const char* str2) {
+ return ByteString(str1.AsStringView(), str2);
+}
+inline ByteString operator+(const char* str1, const ByteString& str2) {
+ return ByteString(str1, str2.AsStringView());
+}
+inline ByteString operator+(const ByteString& str1,
+ const ByteStringView& str2) {
+ return ByteString(str1.AsStringView(), str2);
+}
+inline ByteString operator+(const ByteStringView& str1,
+ const ByteString& str2) {
+ return ByteString(str1, str2.AsStringView());
+}
+
+std::ostream& operator<<(std::ostream& os, const ByteString& str);
+std::ostream& operator<<(std::ostream& os, const ByteStringView& str);
+
+} // namespace fxcrt
+
+using ByteString = fxcrt::ByteString;
+
+uint32_t FX_HashCode_GetA(const ByteStringView& str, bool bIgnoreCase);
+
+namespace std {
+
+template <>
+struct hash<ByteString> {
+ std::size_t operator()(const ByteString& str) const {
+ return FX_HashCode_GetA(str.AsStringView(), false);
+ }
+};
+
+} // namespace std
+
+extern template struct std::hash<ByteString>;
+
+#endif // CORE_FXCRT_BYTESTRING_H_
diff --git a/core/fxcrt/cfx_bytestring_unittest.cpp b/core/fxcrt/bytestring_unittest.cpp
index 6bbe305268..06ba1f42fd 100644
--- a/core/fxcrt/cfx_bytestring_unittest.cpp
+++ b/core/fxcrt/bytestring_unittest.cpp
@@ -2,17 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "core/fxcrt/cfx_bytestring.h"
-#include "core/fxcrt/fx_string.h"
+#include "core/fxcrt/bytestring.h"
#include <algorithm>
#include <vector>
+#include "core/fxcrt/fx_string.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/base/stl_util.h"
-TEST(fxcrt, ByteStringElementAccess) {
- const CFX_ByteString abc("abc");
+TEST(ByteString, ElementAccess) {
+ const ByteString abc("abc");
EXPECT_EQ('a', abc[0]);
EXPECT_EQ('b', abc[1]);
EXPECT_EQ('c', abc[2]);
@@ -20,7 +20,7 @@ TEST(fxcrt, ByteStringElementAccess) {
EXPECT_DEATH({ abc[3]; }, ".*");
#endif
- CFX_ByteString mutable_abc = abc;
+ ByteString mutable_abc = abc;
EXPECT_EQ(abc.c_str(), mutable_abc.c_str());
EXPECT_EQ('a', mutable_abc[0]);
EXPECT_EQ('b', mutable_abc[1]);
@@ -48,11 +48,11 @@ TEST(fxcrt, ByteStringElementAccess) {
#endif
}
-TEST(fxcrt, ByteStringOperatorLT) {
- CFX_ByteString empty;
- CFX_ByteString a("a");
- CFX_ByteString abc("abc");
- CFX_ByteString def("def");
+TEST(ByteString, OperatorLT) {
+ ByteString empty;
+ ByteString a("a");
+ ByteString abc("abc");
+ ByteString def("def");
EXPECT_FALSE(empty < empty);
EXPECT_FALSE(a < a);
@@ -78,16 +78,16 @@ TEST(fxcrt, ByteStringOperatorLT) {
EXPECT_FALSE(def < abc);
}
-TEST(fxcrt, ByteStringOperatorEQ) {
- CFX_ByteString null_string;
+TEST(ByteString, OperatorEQ) {
+ ByteString null_string;
EXPECT_TRUE(null_string == null_string);
- CFX_ByteString empty_string("");
+ ByteString empty_string("");
EXPECT_TRUE(empty_string == empty_string);
EXPECT_TRUE(empty_string == null_string);
EXPECT_TRUE(null_string == empty_string);
- CFX_ByteString deleted_string("hello");
+ ByteString deleted_string("hello");
deleted_string.Delete(0, 5);
EXPECT_TRUE(deleted_string == deleted_string);
EXPECT_TRUE(deleted_string == null_string);
@@ -95,7 +95,7 @@ TEST(fxcrt, ByteStringOperatorEQ) {
EXPECT_TRUE(null_string == deleted_string);
EXPECT_TRUE(empty_string == deleted_string);
- CFX_ByteString byte_string("hello");
+ ByteString byte_string("hello");
EXPECT_TRUE(byte_string == byte_string);
EXPECT_FALSE(byte_string == null_string);
EXPECT_FALSE(byte_string == empty_string);
@@ -104,17 +104,17 @@ TEST(fxcrt, ByteStringOperatorEQ) {
EXPECT_FALSE(empty_string == byte_string);
EXPECT_FALSE(deleted_string == byte_string);
- CFX_ByteString byte_string_same1("hello");
+ ByteString byte_string_same1("hello");
EXPECT_TRUE(byte_string == byte_string_same1);
EXPECT_TRUE(byte_string_same1 == byte_string);
- CFX_ByteString byte_string_same2(byte_string);
+ ByteString byte_string_same2(byte_string);
EXPECT_TRUE(byte_string == byte_string_same2);
EXPECT_TRUE(byte_string_same2 == byte_string);
- CFX_ByteString byte_string1("he");
- CFX_ByteString byte_string2("hellp");
- CFX_ByteString byte_string3("hellod");
+ ByteString byte_string1("he");
+ ByteString byte_string2("hellp");
+ ByteString byte_string3("hellod");
EXPECT_FALSE(byte_string == byte_string1);
EXPECT_FALSE(byte_string == byte_string2);
EXPECT_FALSE(byte_string == byte_string3);
@@ -122,8 +122,8 @@ TEST(fxcrt, ByteStringOperatorEQ) {
EXPECT_FALSE(byte_string2 == byte_string);
EXPECT_FALSE(byte_string3 == byte_string);
- CFX_ByteStringC null_string_c;
- CFX_ByteStringC empty_string_c("");
+ ByteStringView null_string_c;
+ ByteStringView empty_string_c("");
EXPECT_TRUE(null_string == null_string_c);
EXPECT_TRUE(null_string == empty_string_c);
EXPECT_TRUE(empty_string == null_string_c);
@@ -137,13 +137,13 @@ TEST(fxcrt, ByteStringOperatorEQ) {
EXPECT_TRUE(null_string_c == deleted_string);
EXPECT_TRUE(empty_string_c == deleted_string);
- CFX_ByteStringC byte_string_c_same1("hello");
+ ByteStringView byte_string_c_same1("hello");
EXPECT_TRUE(byte_string == byte_string_c_same1);
EXPECT_TRUE(byte_string_c_same1 == byte_string);
- CFX_ByteStringC byte_string_c1("he");
- CFX_ByteStringC byte_string_c2("hellp");
- CFX_ByteStringC byte_string_c3("hellod");
+ ByteStringView byte_string_c1("he");
+ ByteStringView byte_string_c2("hellp");
+ ByteStringView byte_string_c3("hellod");
EXPECT_FALSE(byte_string == byte_string_c1);
EXPECT_FALSE(byte_string == byte_string_c2);
EXPECT_FALSE(byte_string == byte_string_c3);
@@ -181,16 +181,16 @@ TEST(fxcrt, ByteStringOperatorEQ) {
EXPECT_FALSE(c_string3 == byte_string);
}
-TEST(fxcrt, ByteStringOperatorNE) {
- CFX_ByteString null_string;
+TEST(ByteString, OperatorNE) {
+ ByteString null_string;
EXPECT_FALSE(null_string != null_string);
- CFX_ByteString empty_string("");
+ ByteString empty_string("");
EXPECT_FALSE(empty_string != empty_string);
EXPECT_FALSE(empty_string != null_string);
EXPECT_FALSE(null_string != empty_string);
- CFX_ByteString deleted_string("hello");
+ ByteString deleted_string("hello");
deleted_string.Delete(0, 5);
EXPECT_FALSE(deleted_string != deleted_string);
EXPECT_FALSE(deleted_string != null_string);
@@ -200,7 +200,7 @@ TEST(fxcrt, ByteStringOperatorNE) {
EXPECT_FALSE(empty_string != deleted_string);
EXPECT_FALSE(deleted_string != deleted_string);
- CFX_ByteString byte_string("hello");
+ ByteString byte_string("hello");
EXPECT_FALSE(byte_string != byte_string);
EXPECT_TRUE(byte_string != null_string);
EXPECT_TRUE(byte_string != empty_string);
@@ -209,17 +209,17 @@ TEST(fxcrt, ByteStringOperatorNE) {
EXPECT_TRUE(empty_string != byte_string);
EXPECT_TRUE(deleted_string != byte_string);
- CFX_ByteString byte_string_same1("hello");
+ ByteString byte_string_same1("hello");
EXPECT_FALSE(byte_string != byte_string_same1);
EXPECT_FALSE(byte_string_same1 != byte_string);
- CFX_ByteString byte_string_same2(byte_string);
+ ByteString byte_string_same2(byte_string);
EXPECT_FALSE(byte_string != byte_string_same2);
EXPECT_FALSE(byte_string_same2 != byte_string);
- CFX_ByteString byte_string1("he");
- CFX_ByteString byte_string2("hellp");
- CFX_ByteString byte_string3("hellod");
+ ByteString byte_string1("he");
+ ByteString byte_string2("hellp");
+ ByteString byte_string3("hellod");
EXPECT_TRUE(byte_string != byte_string1);
EXPECT_TRUE(byte_string != byte_string2);
EXPECT_TRUE(byte_string != byte_string3);
@@ -227,8 +227,8 @@ TEST(fxcrt, ByteStringOperatorNE) {
EXPECT_TRUE(byte_string2 != byte_string);
EXPECT_TRUE(byte_string3 != byte_string);
- CFX_ByteStringC null_string_c;
- CFX_ByteStringC empty_string_c("");
+ ByteStringView null_string_c;
+ ByteStringView empty_string_c("");
EXPECT_FALSE(null_string != null_string_c);
EXPECT_FALSE(null_string != empty_string_c);
EXPECT_FALSE(empty_string != null_string_c);
@@ -238,13 +238,13 @@ TEST(fxcrt, ByteStringOperatorNE) {
EXPECT_FALSE(null_string_c != empty_string);
EXPECT_FALSE(empty_string_c != empty_string);
- CFX_ByteStringC byte_string_c_same1("hello");
+ ByteStringView byte_string_c_same1("hello");
EXPECT_FALSE(byte_string != byte_string_c_same1);
EXPECT_FALSE(byte_string_c_same1 != byte_string);
- CFX_ByteStringC byte_string_c1("he");
- CFX_ByteStringC byte_string_c2("hellp");
- CFX_ByteStringC byte_string_c3("hellod");
+ ByteStringView byte_string_c1("he");
+ ByteStringView byte_string_c2("hellp");
+ ByteStringView byte_string_c3("hellod");
EXPECT_TRUE(byte_string != byte_string_c1);
EXPECT_TRUE(byte_string != byte_string_c2);
EXPECT_TRUE(byte_string != byte_string_c3);
@@ -282,47 +282,47 @@ TEST(fxcrt, ByteStringOperatorNE) {
EXPECT_TRUE(c_string3 != byte_string);
}
-TEST(fxcrt, ByteStringCNull) {
- CFX_ByteStringC null_string;
+TEST(ByteStringView, Null) {
+ ByteStringView null_string;
EXPECT_FALSE(null_string.raw_str());
EXPECT_EQ(0u, null_string.GetLength());
EXPECT_TRUE(null_string.IsEmpty());
- CFX_ByteStringC another_null_string;
+ ByteStringView another_null_string;
EXPECT_EQ(null_string, another_null_string);
- CFX_ByteStringC copied_null_string(null_string);
+ ByteStringView copied_null_string(null_string);
EXPECT_FALSE(copied_null_string.raw_str());
EXPECT_EQ(0u, copied_null_string.GetLength());
EXPECT_TRUE(copied_null_string.IsEmpty());
EXPECT_EQ(null_string, copied_null_string);
- CFX_ByteStringC empty_string(""); // Pointer to NUL, not NULL pointer.
+ ByteStringView empty_string(""); // Pointer to NUL, not NULL pointer.
EXPECT_TRUE(empty_string.raw_str());
EXPECT_EQ(0u, empty_string.GetLength());
EXPECT_TRUE(empty_string.IsEmpty());
EXPECT_EQ(null_string, empty_string);
- CFX_ByteStringC assigned_null_string("initially not nullptr");
+ ByteStringView assigned_null_string("initially not nullptr");
assigned_null_string = null_string;
EXPECT_FALSE(assigned_null_string.raw_str());
EXPECT_EQ(0u, assigned_null_string.GetLength());
EXPECT_TRUE(assigned_null_string.IsEmpty());
EXPECT_EQ(null_string, assigned_null_string);
- CFX_ByteStringC assigned_nullptr_string("initially not nullptr");
+ ByteStringView assigned_nullptr_string("initially not nullptr");
assigned_nullptr_string = nullptr;
EXPECT_FALSE(assigned_nullptr_string.raw_str());
EXPECT_EQ(0u, assigned_nullptr_string.GetLength());
EXPECT_TRUE(assigned_nullptr_string.IsEmpty());
EXPECT_EQ(null_string, assigned_nullptr_string);
- CFX_ByteStringC non_null_string("a");
+ ByteStringView non_null_string("a");
EXPECT_NE(null_string, non_null_string);
}
-TEST(fxcrt, ByteStringConcat) {
- CFX_ByteString fred;
+TEST(ByteString, Concat) {
+ ByteString fred;
fred.Concat("FRED", 4);
EXPECT_EQ("FRED", fred);
@@ -335,14 +335,14 @@ TEST(fxcrt, ByteStringConcat) {
fred.Concat("D", 1);
EXPECT_EQ("FRED", fred);
- CFX_ByteString copy = fred;
+ ByteString copy = fred;
fred.Concat("DY", 2);
EXPECT_EQ("FREDDY", fred);
EXPECT_EQ("FRED", copy);
}
-TEST(fxcrt, ByteStringRemove) {
- CFX_ByteString freed("FREED");
+TEST(ByteString, Remove) {
+ ByteString freed("FREED");
freed.Remove('E');
EXPECT_EQ("FRD", freed);
freed.Remove('F');
@@ -354,13 +354,13 @@ TEST(fxcrt, ByteStringRemove) {
freed.Remove('R');
EXPECT_EQ("", freed);
- CFX_ByteString empty;
+ ByteString empty;
empty.Remove('X');
EXPECT_EQ("", empty);
}
-TEST(fxcrt, ByteStringRemoveCopies) {
- CFX_ByteString freed("FREED");
+TEST(ByteString, RemoveCopies) {
+ ByteString freed("FREED");
const char* old_buffer = freed.c_str();
// No change with single reference - no copy.
@@ -374,7 +374,7 @@ TEST(fxcrt, ByteStringRemoveCopies) {
EXPECT_EQ(old_buffer, freed.c_str());
// No change with multiple references - no copy.
- CFX_ByteString shared(freed);
+ ByteString shared(freed);
freed.Remove('Q');
EXPECT_EQ("FRD", freed);
EXPECT_EQ(old_buffer, freed.c_str());
@@ -388,8 +388,8 @@ TEST(fxcrt, ByteStringRemoveCopies) {
EXPECT_EQ(old_buffer, shared.c_str());
}
-TEST(fxcrt, ByteStringReplace) {
- CFX_ByteString fred("FRED");
+TEST(ByteString, Replace) {
+ ByteString fred("FRED");
fred.Replace("FR", "BL");
EXPECT_EQ("BLED", fred);
fred.Replace("D", "DDY");
@@ -406,8 +406,8 @@ TEST(fxcrt, ByteStringReplace) {
EXPECT_EQ("", fred);
}
-TEST(fxcrt, ByteStringInsert) {
- CFX_ByteString fred("FRED");
+TEST(ByteString, Insert) {
+ ByteString fred("FRED");
EXPECT_EQ(5u, fred.Insert(0, 'S'));
EXPECT_EQ("SFRED", fred);
EXPECT_EQ(6u, fred.Insert(1, 'T'));
@@ -419,20 +419,20 @@ TEST(fxcrt, ByteStringInsert) {
EXPECT_EQ(8u, fred.Insert(12, 'P'));
EXPECT_EQ("STFRUEDV", fred);
{
- CFX_ByteString empty;
+ ByteString empty;
EXPECT_EQ(1u, empty.Insert(0, 'X'));
EXPECT_EQ("X", empty);
}
{
- CFX_ByteString empty;
+ ByteString empty;
EXPECT_EQ(0u, empty.Insert(5, 'X'));
EXPECT_NE("X", empty);
}
}
-TEST(fxcrt, ByteStringInsertAtFrontAndInsertAtBack) {
+TEST(ByteString, InsertAtFrontAndInsertAtBack) {
{
- CFX_ByteString empty;
+ ByteString empty;
EXPECT_EQ(1u, empty.InsertAtFront('D'));
EXPECT_EQ("D", empty);
EXPECT_EQ(2u, empty.InsertAtFront('E'));
@@ -443,7 +443,7 @@ TEST(fxcrt, ByteStringInsertAtFrontAndInsertAtBack) {
EXPECT_EQ("FRED", empty);
}
{
- CFX_ByteString empty;
+ ByteString empty;
EXPECT_EQ(1u, empty.InsertAtBack('F'));
EXPECT_EQ("F", empty);
EXPECT_EQ(2u, empty.InsertAtBack('R'));
@@ -454,7 +454,7 @@ TEST(fxcrt, ByteStringInsertAtFrontAndInsertAtBack) {
EXPECT_EQ("FRED", empty);
}
{
- CFX_ByteString empty;
+ ByteString empty;
EXPECT_EQ(1u, empty.InsertAtBack('E'));
EXPECT_EQ("E", empty);
EXPECT_EQ(2u, empty.InsertAtFront('R'));
@@ -466,8 +466,8 @@ TEST(fxcrt, ByteStringInsertAtFrontAndInsertAtBack) {
}
}
-TEST(fxcrt, ByteStringDelete) {
- CFX_ByteString fred("FRED");
+TEST(ByteString, Delete) {
+ ByteString fred("FRED");
EXPECT_EQ(4u, fred.Delete(0, 0));
EXPECT_EQ("FRED", fred);
EXPECT_EQ(2u, fred.Delete(0, 2));
@@ -479,15 +479,15 @@ TEST(fxcrt, ByteStringDelete) {
EXPECT_EQ(0u, fred.Delete(0));
EXPECT_EQ("", fred);
- CFX_ByteString empty;
+ ByteString empty;
EXPECT_EQ(0u, empty.Delete(0));
EXPECT_EQ("", empty);
EXPECT_EQ(0u, empty.Delete(1));
EXPECT_EQ("", empty);
}
-TEST(fxcrt, ByteStringMid) {
- CFX_ByteString fred("FRED");
+TEST(ByteString, Mid) {
+ ByteString fred("FRED");
EXPECT_EQ("", fred.Mid(0, 0));
EXPECT_EQ("", fred.Mid(3, 0));
EXPECT_EQ("FRED", fred.Mid(0, 4));
@@ -505,12 +505,12 @@ TEST(fxcrt, ByteStringMid) {
EXPECT_EQ("RED", fred.Mid(1, 3));
EXPECT_EQ("", fred.Mid(4, 1));
- CFX_ByteString empty;
+ ByteString empty;
EXPECT_EQ("", empty.Mid(0, 0));
}
-TEST(fxcrt, ByteStringLeft) {
- CFX_ByteString fred("FRED");
+TEST(ByteString, Left) {
+ ByteString fred("FRED");
EXPECT_EQ("", fred.Left(0));
EXPECT_EQ("F", fred.Left(1));
EXPECT_EQ("FR", fred.Left(2));
@@ -519,13 +519,13 @@ TEST(fxcrt, ByteStringLeft) {
EXPECT_EQ("", fred.Left(5));
- CFX_ByteString empty;
+ ByteString empty;
EXPECT_EQ("", empty.Left(0));
EXPECT_EQ("", empty.Left(1));
}
-TEST(fxcrt, ByteStringRight) {
- CFX_ByteString fred("FRED");
+TEST(ByteString, Right) {
+ ByteString fred("FRED");
EXPECT_EQ("", fred.Right(0));
EXPECT_EQ("D", fred.Right(1));
EXPECT_EQ("ED", fred.Right(2));
@@ -534,29 +534,29 @@ TEST(fxcrt, ByteStringRight) {
EXPECT_EQ("", fred.Right(5));
- CFX_ByteString empty;
+ ByteString empty;
EXPECT_EQ("", empty.Right(0));
EXPECT_EQ("", empty.Right(1));
}
-TEST(fxcrt, ByteStringFind) {
- CFX_ByteString null_string;
+TEST(ByteString, Find) {
+ ByteString null_string;
EXPECT_FALSE(null_string.Find('a').has_value());
EXPECT_FALSE(null_string.Find('\0').has_value());
- CFX_ByteString empty_string("");
+ ByteString empty_string("");
EXPECT_FALSE(empty_string.Find('a').has_value());
EXPECT_FALSE(empty_string.Find('\0').has_value());
pdfium::Optional<FX_STRSIZE> result;
- CFX_ByteString single_string("a");
+ ByteString single_string("a");
result = single_string.Find('a');
ASSERT_TRUE(result.has_value());
EXPECT_EQ(0u, result.value());
EXPECT_FALSE(single_string.Find('b').has_value());
EXPECT_FALSE(single_string.Find('\0').has_value());
- CFX_ByteString longer_string("abccc");
+ ByteString longer_string("abccc");
result = longer_string.Find('a');
ASSERT_TRUE(result.has_value());
EXPECT_EQ(0u, result.value());
@@ -580,7 +580,7 @@ TEST(fxcrt, ByteStringFind) {
EXPECT_EQ(3u, result.value());
EXPECT_FALSE(longer_string.Find("d").has_value());
- CFX_ByteString hibyte_string(
+ ByteString hibyte_string(
"ab\x8c"
"def");
result = hibyte_string.Find('\x8c');
@@ -588,24 +588,24 @@ TEST(fxcrt, ByteStringFind) {
EXPECT_EQ(2u, result.value());
}
-TEST(fxcrt, ByteStringReverseFind) {
- CFX_ByteString null_string;
+TEST(ByteString, ReverseFind) {
+ ByteString null_string;
EXPECT_FALSE(null_string.ReverseFind('a').has_value());
EXPECT_FALSE(null_string.ReverseFind('\0').has_value());
- CFX_ByteString empty_string("");
+ ByteString empty_string("");
EXPECT_FALSE(empty_string.ReverseFind('a').has_value());
EXPECT_FALSE(empty_string.ReverseFind('\0').has_value());
pdfium::Optional<FX_STRSIZE> result;
- CFX_ByteString single_string("a");
+ ByteString single_string("a");
result = single_string.ReverseFind('a');
ASSERT_TRUE(result.has_value());
EXPECT_EQ(0u, result.value());
EXPECT_FALSE(single_string.ReverseFind('b').has_value());
EXPECT_FALSE(single_string.ReverseFind('\0').has_value());
- CFX_ByteString longer_string("abccc");
+ ByteString longer_string("abccc");
result = longer_string.ReverseFind('a');
ASSERT_TRUE(result.has_value());
EXPECT_EQ(0u, result.value());
@@ -614,7 +614,7 @@ TEST(fxcrt, ByteStringReverseFind) {
EXPECT_EQ(4u, result.value());
EXPECT_FALSE(longer_string.ReverseFind('\0').has_value());
- CFX_ByteString hibyte_string(
+ ByteString hibyte_string(
"ab\x8c"
"def");
result = hibyte_string.ReverseFind('\x8c');
@@ -622,22 +622,22 @@ TEST(fxcrt, ByteStringReverseFind) {
EXPECT_EQ(2u, result.value());
}
-TEST(fxcrt, ByteStringUpperLower) {
- CFX_ByteString fred("F-Re.42D");
+TEST(ByteString, UpperLower) {
+ ByteString fred("F-Re.42D");
fred.MakeLower();
EXPECT_EQ("f-re.42d", fred);
fred.MakeUpper();
EXPECT_EQ("F-RE.42D", fred);
- CFX_ByteString empty;
+ ByteString empty;
empty.MakeLower();
EXPECT_EQ("", empty);
empty.MakeUpper();
EXPECT_EQ("", empty);
}
-TEST(fxcrt, ByteStringTrimRight) {
- CFX_ByteString fred(" FRED ");
+TEST(ByteString, TrimRight) {
+ ByteString fred(" FRED ");
fred.TrimRight();
EXPECT_EQ(" FRED", fred);
fred.TrimRight('E');
@@ -647,7 +647,7 @@ TEST(fxcrt, ByteStringTrimRight) {
fred.TrimRight("ERP");
EXPECT_EQ(" F", fred);
- CFX_ByteString blank(" ");
+ ByteString blank(" ");
blank.TrimRight("ERP");
EXPECT_EQ(" ", blank);
blank.TrimRight('E');
@@ -655,7 +655,7 @@ TEST(fxcrt, ByteStringTrimRight) {
blank.TrimRight();
EXPECT_EQ("", blank);
- CFX_ByteString empty;
+ ByteString empty;
empty.TrimRight("ERP");
EXPECT_EQ("", empty);
empty.TrimRight('E');
@@ -664,10 +664,10 @@ TEST(fxcrt, ByteStringTrimRight) {
EXPECT_EQ("", empty);
}
-TEST(fxcrt, ByteStringTrimRightCopies) {
+TEST(ByteString, TrimRightCopies) {
{
// With a single reference, no copy takes place.
- CFX_ByteString fred(" FRED ");
+ ByteString fred(" FRED ");
const char* old_buffer = fred.c_str();
fred.TrimRight();
EXPECT_EQ(" FRED", fred);
@@ -675,8 +675,8 @@ TEST(fxcrt, ByteStringTrimRightCopies) {
}
{
// With multiple references, we must copy.
- CFX_ByteString fred(" FRED ");
- CFX_ByteString other_fred = fred;
+ ByteString fred(" FRED ");
+ ByteString other_fred = fred;
const char* old_buffer = fred.c_str();
fred.TrimRight();
EXPECT_EQ(" FRED", fred);
@@ -685,8 +685,8 @@ TEST(fxcrt, ByteStringTrimRightCopies) {
}
{
// With multiple references, but no modifications, no copy.
- CFX_ByteString fred("FRED");
- CFX_ByteString other_fred = fred;
+ ByteString fred("FRED");
+ ByteString other_fred = fred;
const char* old_buffer = fred.c_str();
fred.TrimRight();
EXPECT_EQ("FRED", fred);
@@ -695,8 +695,8 @@ TEST(fxcrt, ByteStringTrimRightCopies) {
}
}
-TEST(fxcrt, ByteStringTrimLeft) {
- CFX_ByteString fred(" FRED ");
+TEST(ByteString, TrimLeft) {
+ ByteString fred(" FRED ");
fred.TrimLeft();
EXPECT_EQ("FRED ", fred);
fred.TrimLeft('E');
@@ -706,7 +706,7 @@ TEST(fxcrt, ByteStringTrimLeft) {
fred.TrimLeft("ERP");
EXPECT_EQ("D ", fred);
- CFX_ByteString blank(" ");
+ ByteString blank(" ");
blank.TrimLeft("ERP");
EXPECT_EQ(" ", blank);
blank.TrimLeft('E');
@@ -714,7 +714,7 @@ TEST(fxcrt, ByteStringTrimLeft) {
blank.TrimLeft();
EXPECT_EQ("", blank);
- CFX_ByteString empty;
+ ByteString empty;
empty.TrimLeft("ERP");
EXPECT_EQ("", empty);
empty.TrimLeft('E');
@@ -723,10 +723,10 @@ TEST(fxcrt, ByteStringTrimLeft) {
EXPECT_EQ("", empty);
}
-TEST(fxcrt, ByteStringTrimLeftCopies) {
+TEST(ByteString, TrimLeftCopies) {
{
// With a single reference, no copy takes place.
- CFX_ByteString fred(" FRED ");
+ ByteString fred(" FRED ");
const char* old_buffer = fred.c_str();
fred.TrimLeft();
EXPECT_EQ("FRED ", fred);
@@ -734,8 +734,8 @@ TEST(fxcrt, ByteStringTrimLeftCopies) {
}
{
// With multiple references, we must copy.
- CFX_ByteString fred(" FRED ");
- CFX_ByteString other_fred = fred;
+ ByteString fred(" FRED ");
+ ByteString other_fred = fred;
const char* old_buffer = fred.c_str();
fred.TrimLeft();
EXPECT_EQ("FRED ", fred);
@@ -744,8 +744,8 @@ TEST(fxcrt, ByteStringTrimLeftCopies) {
}
{
// With multiple references, but no modifications, no copy.
- CFX_ByteString fred("FRED");
- CFX_ByteString other_fred = fred;
+ ByteString fred("FRED");
+ ByteString other_fred = fred;
const char* old_buffer = fred.c_str();
fred.TrimLeft();
EXPECT_EQ("FRED", fred);
@@ -754,9 +754,9 @@ TEST(fxcrt, ByteStringTrimLeftCopies) {
}
}
-TEST(fxcrt, ByteStringReserve) {
+TEST(ByteString, Reserve) {
{
- CFX_ByteString str;
+ ByteString str;
str.Reserve(6);
const char* old_buffer = str.c_str();
str += "ABCDEF";
@@ -765,7 +765,7 @@ TEST(fxcrt, ByteStringReserve) {
EXPECT_NE(old_buffer, str.c_str());
}
{
- CFX_ByteString str("A");
+ ByteString str("A");
str.Reserve(6);
const char* old_buffer = str.c_str();
str += "BCDEF";
@@ -775,9 +775,9 @@ TEST(fxcrt, ByteStringReserve) {
}
}
-TEST(fxcrt, ByteStringGetBuffer) {
+TEST(ByteString, GetBuffer) {
{
- CFX_ByteString str;
+ ByteString str;
char* buffer = str.GetBuffer(12);
// NOLINTNEXTLINE(runtime/printf)
strcpy(buffer, "clams");
@@ -785,7 +785,7 @@ TEST(fxcrt, ByteStringGetBuffer) {
EXPECT_EQ("clams", str);
}
{
- CFX_ByteString str("cl");
+ ByteString str("cl");
char* buffer = str.GetBuffer(12);
// NOLINTNEXTLINE(runtime/printf)
strcpy(buffer + 2, "ams");
@@ -794,9 +794,9 @@ TEST(fxcrt, ByteStringGetBuffer) {
}
}
-TEST(fxcrt, ByteStringReleaseBuffer) {
+TEST(ByteString, ReleaseBuffer) {
{
- CFX_ByteString str;
+ ByteString str;
str.Reserve(12);
str += "clams";
const char* old_buffer = str.c_str();
@@ -805,7 +805,7 @@ TEST(fxcrt, ByteStringReleaseBuffer) {
EXPECT_EQ("clam", str);
}
{
- CFX_ByteString str("c");
+ ByteString str("c");
str.Reserve(12);
str += "lams";
const char* old_buffer = str.c_str();
@@ -814,7 +814,7 @@ TEST(fxcrt, ByteStringReleaseBuffer) {
EXPECT_EQ("clam", str);
}
{
- CFX_ByteString str;
+ ByteString str;
str.Reserve(200);
str += "clams";
const char* old_buffer = str.c_str();
@@ -823,7 +823,7 @@ TEST(fxcrt, ByteStringReleaseBuffer) {
EXPECT_EQ("clam", str);
}
{
- CFX_ByteString str("c");
+ ByteString str("c");
str.Reserve(200);
str += "lams";
const char* old_buffer = str.c_str();
@@ -833,16 +833,16 @@ TEST(fxcrt, ByteStringReleaseBuffer) {
}
}
-TEST(fxcrt, ByteStringEmptyReverseIterator) {
- CFX_ByteString empty;
+TEST(ByteString, EmptyReverseIterator) {
+ ByteString empty;
auto iter = empty.rbegin();
EXPECT_TRUE(iter == empty.rend());
EXPECT_FALSE(iter != empty.rend());
EXPECT_FALSE(iter < empty.rend());
}
-TEST(fxcrt, ByteStringOneCharReverseIterator) {
- CFX_ByteString one_str("a");
+TEST(ByteString, OneCharReverseIterator) {
+ ByteString one_str("a");
auto iter = one_str.rbegin();
EXPECT_FALSE(iter == one_str.rend());
EXPECT_TRUE(iter != one_str.rend());
@@ -855,8 +855,8 @@ TEST(fxcrt, ByteStringOneCharReverseIterator) {
EXPECT_FALSE(iter < one_str.rend());
}
-TEST(fxcrt, ByteStringMultiCharReverseIterator) {
- CFX_ByteString multi_str("abcd");
+TEST(ByteString, MultiCharReverseIterator) {
+ ByteString multi_str("abcd");
auto iter = multi_str.rbegin();
EXPECT_FALSE(iter == multi_str.rend());
@@ -900,12 +900,12 @@ TEST(fxcrt, ByteStringMultiCharReverseIterator) {
EXPECT_TRUE(iter == multi_str.rbegin());
}
-TEST(fxcrt, ByteStringCNotNull) {
- CFX_ByteStringC string3("abc");
- CFX_ByteStringC string6("abcdef");
- CFX_ByteStringC alternate_string3("abcdef", 3);
- CFX_ByteStringC embedded_nul_string7("abc\0def", 7);
- CFX_ByteStringC illegal_string7("abcdef", 7);
+TEST(ByteStringView, NotNull) {
+ ByteStringView string3("abc");
+ ByteStringView string6("abcdef");
+ ByteStringView alternate_string3("abcdef", 3);
+ ByteStringView embedded_nul_string7("abc\0def", 7);
+ ByteStringView illegal_string7("abcdef", 7);
EXPECT_EQ(3u, string3.GetLength());
EXPECT_EQ(6u, string6.GetLength());
@@ -924,18 +924,18 @@ TEST(fxcrt, ByteStringCNotNull) {
EXPECT_NE(alternate_string3, illegal_string7);
EXPECT_NE(embedded_nul_string7, illegal_string7);
- CFX_ByteStringC copied_string3(string3);
- CFX_ByteStringC copied_alternate_string3(alternate_string3);
- CFX_ByteStringC copied_embedded_nul_string7(embedded_nul_string7);
+ ByteStringView copied_string3(string3);
+ ByteStringView copied_alternate_string3(alternate_string3);
+ ByteStringView copied_embedded_nul_string7(embedded_nul_string7);
EXPECT_EQ(string3, copied_string3);
EXPECT_EQ(alternate_string3, copied_alternate_string3);
EXPECT_EQ(embedded_nul_string7, copied_embedded_nul_string7);
- CFX_ByteStringC assigned_string3("intially something else");
- CFX_ByteStringC assigned_alternate_string3("initally something else");
- CFX_ByteStringC assigned_ptr_string3("initially something else");
- CFX_ByteStringC assigned_embedded_nul_string7("initially something else");
+ ByteStringView assigned_string3("intially something else");
+ ByteStringView assigned_alternate_string3("initally something else");
+ ByteStringView assigned_ptr_string3("initially something else");
+ ByteStringView assigned_embedded_nul_string7("initially something else");
assigned_string3 = string3;
assigned_alternate_string3 = alternate_string3;
@@ -947,15 +947,15 @@ TEST(fxcrt, ByteStringCNotNull) {
EXPECT_EQ(embedded_nul_string7, assigned_embedded_nul_string7);
}
-TEST(fxcrt, ByteStringCFromChar) {
- CFX_ByteStringC null_string;
- CFX_ByteStringC lower_a_string("a");
+TEST(ByteStringView, FromChar) {
+ ByteStringView null_string;
+ ByteStringView lower_a_string("a");
// Must have lvalues that outlive the corresponding ByteStringC.
char nul = '\0';
char lower_a = 'a';
- CFX_ByteStringC nul_string_from_char(nul);
- CFX_ByteStringC lower_a_string_from_char(lower_a);
+ ByteStringView nul_string_from_char(nul);
+ ByteStringView lower_a_string_from_char(lower_a);
// Pointer to nul, not nullptr ptr, hence length 1 ...
EXPECT_EQ(1u, nul_string_from_char.GetLength());
@@ -965,60 +965,60 @@ TEST(fxcrt, ByteStringCFromChar) {
EXPECT_EQ(lower_a_string, lower_a_string_from_char);
EXPECT_NE(nul_string_from_char, lower_a_string_from_char);
- CFX_ByteStringC longer_string("ab");
+ ByteStringView longer_string("ab");
EXPECT_NE(longer_string, lower_a_string_from_char);
}
-TEST(fxcrt, ByteStringCFromVector) {
+TEST(ByteStringView, FromVector) {
std::vector<uint8_t> null_vec;
- CFX_ByteStringC null_string(null_vec);
+ ByteStringView null_string(null_vec);
EXPECT_EQ(0u, null_string.GetLength());
std::vector<uint8_t> lower_a_vec(10, static_cast<uint8_t>('a'));
- CFX_ByteStringC lower_a_string(lower_a_vec);
+ ByteStringView lower_a_string(lower_a_vec);
EXPECT_EQ(static_cast<FX_STRSIZE>(10), lower_a_string.GetLength());
EXPECT_EQ("aaaaaaaaaa", lower_a_string);
std::vector<uint8_t> cleared_vec;
cleared_vec.push_back(42);
cleared_vec.pop_back();
- CFX_ByteStringC cleared_string(cleared_vec);
+ ByteStringView cleared_string(cleared_vec);
EXPECT_EQ(0u, cleared_string.GetLength());
EXPECT_EQ(nullptr, cleared_string.raw_str());
}
-TEST(fxcrt, ByteStringCGetID) {
- CFX_ByteStringC null_string;
+TEST(ByteStringView, GetID) {
+ ByteStringView null_string;
EXPECT_EQ(0u, null_string.GetID());
- CFX_ByteStringC empty_string("");
+ ByteStringView empty_string("");
EXPECT_EQ(0u, empty_string.GetID());
- CFX_ByteStringC short_string("ab");
+ ByteStringView short_string("ab");
EXPECT_EQ(FXBSTR_ID('a', 'b', 0, 0), short_string.GetID());
- CFX_ByteStringC longer_string("abcdef");
+ ByteStringView longer_string("abcdef");
EXPECT_EQ(FXBSTR_ID('a', 'b', 'c', 'd'), longer_string.GetID());
}
-TEST(fxcrt, ByteStringCFind) {
- CFX_ByteStringC null_string;
+TEST(ByteStringView, Find) {
+ ByteStringView null_string;
EXPECT_FALSE(null_string.Find('a').has_value());
EXPECT_FALSE(null_string.Find('\0').has_value());
- CFX_ByteStringC empty_string("");
+ ByteStringView empty_string("");
EXPECT_FALSE(empty_string.Find('a').has_value());
EXPECT_FALSE(empty_string.Find('\0').has_value());
pdfium::Optional<FX_STRSIZE> result;
- CFX_ByteStringC single_string("a");
+ ByteStringView single_string("a");
result = single_string.Find('a');
ASSERT_TRUE(result.has_value());
EXPECT_EQ(0u, result.value());
EXPECT_FALSE(single_string.Find('b').has_value());
EXPECT_FALSE(single_string.Find('\0').has_value());
- CFX_ByteStringC longer_string("abccc");
+ ByteStringView longer_string("abccc");
result = longer_string.Find('a');
ASSERT_TRUE(result.has_value());
EXPECT_EQ(0u, result.value());
@@ -1028,7 +1028,7 @@ TEST(fxcrt, ByteStringCFind) {
EXPECT_FALSE(longer_string.Find('d').has_value());
EXPECT_FALSE(longer_string.Find('\0').has_value());
- CFX_ByteStringC hibyte_string(
+ ByteStringView hibyte_string(
"ab\x8c"
"def");
result = hibyte_string.Find('\x8c');
@@ -1036,47 +1036,47 @@ TEST(fxcrt, ByteStringCFind) {
EXPECT_EQ(2u, result.value());
}
-TEST(fxcrt, ByteStringCMid) {
- CFX_ByteStringC null_string;
+TEST(ByteStringView, Mid) {
+ ByteStringView null_string;
EXPECT_EQ(null_string, null_string.Mid(0, 1));
EXPECT_EQ(null_string, null_string.Mid(1, 1));
- CFX_ByteStringC empty_string("");
+ ByteStringView empty_string("");
EXPECT_EQ("", empty_string.Mid(0, 1));
EXPECT_EQ("", empty_string.Mid(1, 1));
- CFX_ByteStringC single_character("a");
+ ByteStringView single_character("a");
EXPECT_EQ("", single_character.Mid(0, 0));
EXPECT_EQ(single_character, single_character.Mid(0, 1));
EXPECT_EQ("", single_character.Mid(1, 0));
EXPECT_EQ("", single_character.Mid(1, 1));
- CFX_ByteStringC longer_string("abcdef");
+ ByteStringView longer_string("abcdef");
EXPECT_EQ(longer_string, longer_string.Mid(0, 6));
EXPECT_EQ("", longer_string.Mid(0, 187));
- CFX_ByteStringC leading_substring("ab");
+ ByteStringView leading_substring("ab");
EXPECT_EQ(leading_substring, longer_string.Mid(0, 2));
- CFX_ByteStringC middle_substring("bcde");
+ ByteStringView middle_substring("bcde");
EXPECT_EQ(middle_substring, longer_string.Mid(1, 4));
- CFX_ByteStringC trailing_substring("ef");
+ ByteStringView trailing_substring("ef");
EXPECT_EQ(trailing_substring, longer_string.Mid(4, 2));
EXPECT_EQ("", longer_string.Mid(4, 3));
}
-TEST(fxcrt, ByteStringCTrimmedRight) {
- CFX_ByteStringC fred("FRED");
+TEST(ByteStringView, TrimmedRight) {
+ ByteStringView fred("FRED");
EXPECT_EQ("FRED", fred.TrimmedRight('E'));
EXPECT_EQ("FRE", fred.TrimmedRight('D'));
- CFX_ByteStringC fredd("FREDD");
+ ByteStringView fredd("FREDD");
EXPECT_EQ("FRE", fred.TrimmedRight('D'));
}
-TEST(fxcrt, ByteStringCElementAccess) {
- // CFX_ByteStringC includes the NUL terminator for non-empty strings.
- CFX_ByteStringC abc("abc");
+TEST(ByteStringView, ElementAccess) {
+ // ByteStringView includes the NUL terminator for non-empty strings.
+ ByteStringView abc("abc");
EXPECT_EQ('a', static_cast<char>(abc[0]));
EXPECT_EQ('b', static_cast<char>(abc[1]));
EXPECT_EQ('c', static_cast<char>(abc[2]));
@@ -1085,11 +1085,11 @@ TEST(fxcrt, ByteStringCElementAccess) {
#endif
}
-TEST(fxcrt, ByteStringCOperatorLT) {
- CFX_ByteStringC empty;
- CFX_ByteStringC a("a");
- CFX_ByteStringC abc("abc");
- CFX_ByteStringC def("def");
+TEST(ByteStringView, OperatorLT) {
+ ByteStringView empty;
+ ByteStringView a("a");
+ ByteStringView abc("abc");
+ ByteStringView def("def");
EXPECT_FALSE(empty < empty);
EXPECT_FALSE(a < a);
@@ -1115,21 +1115,21 @@ TEST(fxcrt, ByteStringCOperatorLT) {
EXPECT_FALSE(def < abc);
}
-TEST(fxcrt, ByteStringCOperatorEQ) {
- CFX_ByteStringC byte_string_c("hello");
+TEST(ByteStringView, OperatorEQ) {
+ ByteStringView byte_string_c("hello");
EXPECT_TRUE(byte_string_c == byte_string_c);
- CFX_ByteStringC byte_string_c_same1("hello");
+ ByteStringView byte_string_c_same1("hello");
EXPECT_TRUE(byte_string_c == byte_string_c_same1);
EXPECT_TRUE(byte_string_c_same1 == byte_string_c);
- CFX_ByteStringC byte_string_c_same2(byte_string_c);
+ ByteStringView byte_string_c_same2(byte_string_c);
EXPECT_TRUE(byte_string_c == byte_string_c_same2);
EXPECT_TRUE(byte_string_c_same2 == byte_string_c);
- CFX_ByteStringC byte_string_c1("he");
- CFX_ByteStringC byte_string_c2("hellp");
- CFX_ByteStringC byte_string_c3("hellod");
+ ByteStringView byte_string_c1("he");
+ ByteStringView byte_string_c2("hellp");
+ ByteStringView byte_string_c3("hellod");
EXPECT_FALSE(byte_string_c == byte_string_c1);
EXPECT_FALSE(byte_string_c == byte_string_c2);
EXPECT_FALSE(byte_string_c == byte_string_c3);
@@ -1137,13 +1137,13 @@ TEST(fxcrt, ByteStringCOperatorEQ) {
EXPECT_FALSE(byte_string_c2 == byte_string_c);
EXPECT_FALSE(byte_string_c3 == byte_string_c);
- CFX_ByteString byte_string_same1("hello");
+ ByteString byte_string_same1("hello");
EXPECT_TRUE(byte_string_c == byte_string_same1);
EXPECT_TRUE(byte_string_same1 == byte_string_c);
- CFX_ByteString byte_string1("he");
- CFX_ByteString byte_string2("hellp");
- CFX_ByteString byte_string3("hellod");
+ ByteString byte_string1("he");
+ ByteString byte_string2("hellp");
+ ByteString byte_string3("hellod");
EXPECT_FALSE(byte_string_c == byte_string1);
EXPECT_FALSE(byte_string_c == byte_string2);
EXPECT_FALSE(byte_string_c == byte_string3);
@@ -1167,21 +1167,21 @@ TEST(fxcrt, ByteStringCOperatorEQ) {
EXPECT_FALSE(c_string3 == byte_string_c);
}
-TEST(fxcrt, ByteStringCOperatorNE) {
- CFX_ByteStringC byte_string_c("hello");
+TEST(ByteStringView, OperatorNE) {
+ ByteStringView byte_string_c("hello");
EXPECT_FALSE(byte_string_c != byte_string_c);
- CFX_ByteStringC byte_string_c_same1("hello");
+ ByteStringView byte_string_c_same1("hello");
EXPECT_FALSE(byte_string_c != byte_string_c_same1);
EXPECT_FALSE(byte_string_c_same1 != byte_string_c);
- CFX_ByteStringC byte_string_c_same2(byte_string_c);
+ ByteStringView byte_string_c_same2(byte_string_c);
EXPECT_FALSE(byte_string_c != byte_string_c_same2);
EXPECT_FALSE(byte_string_c_same2 != byte_string_c);
- CFX_ByteStringC byte_string_c1("he");
- CFX_ByteStringC byte_string_c2("hellp");
- CFX_ByteStringC byte_string_c3("hellod");
+ ByteStringView byte_string_c1("he");
+ ByteStringView byte_string_c2("hellp");
+ ByteStringView byte_string_c3("hellod");
EXPECT_TRUE(byte_string_c != byte_string_c1);
EXPECT_TRUE(byte_string_c != byte_string_c2);
EXPECT_TRUE(byte_string_c != byte_string_c3);
@@ -1189,13 +1189,13 @@ TEST(fxcrt, ByteStringCOperatorNE) {
EXPECT_TRUE(byte_string_c2 != byte_string_c);
EXPECT_TRUE(byte_string_c3 != byte_string_c);
- CFX_ByteString byte_string_same1("hello");
+ ByteString byte_string_same1("hello");
EXPECT_FALSE(byte_string_c != byte_string_same1);
EXPECT_FALSE(byte_string_same1 != byte_string_c);
- CFX_ByteString byte_string1("he");
- CFX_ByteString byte_string2("hellp");
- CFX_ByteString byte_string3("hellod");
+ ByteString byte_string1("he");
+ ByteString byte_string2("hellp");
+ ByteString byte_string3("hellod");
EXPECT_TRUE(byte_string_c != byte_string1);
EXPECT_TRUE(byte_string_c != byte_string2);
EXPECT_TRUE(byte_string_c != byte_string3);
@@ -1219,8 +1219,8 @@ TEST(fxcrt, ByteStringCOperatorNE) {
EXPECT_TRUE(c_string3 != byte_string_c);
}
-TEST(fxcrt, ByteStringCNullIterator) {
- CFX_ByteStringC null_str;
+TEST(ByteStringView, NullIterator) {
+ ByteStringView null_str;
int32_t sum = 0;
bool any_present = false;
for (const auto& c : null_str) {
@@ -1231,8 +1231,8 @@ TEST(fxcrt, ByteStringCNullIterator) {
EXPECT_EQ(0, sum);
}
-TEST(fxcrt, ByteStringCEmptyIterator) {
- CFX_ByteStringC empty_str("");
+TEST(ByteStringView, EmptyIterator) {
+ ByteStringView empty_str("");
int32_t sum = 0;
bool any_present = false;
for (const auto& c : empty_str) {
@@ -1243,8 +1243,8 @@ TEST(fxcrt, ByteStringCEmptyIterator) {
EXPECT_EQ(0, sum);
}
-TEST(fxcrt, ByteStringCOneCharIterator) {
- CFX_ByteStringC one_str("a");
+TEST(ByteStringView, OneCharIterator) {
+ ByteStringView one_str("a");
int32_t sum = 0;
bool any_present = false;
for (const auto& c : one_str) {
@@ -1255,8 +1255,8 @@ TEST(fxcrt, ByteStringCOneCharIterator) {
EXPECT_EQ('a', sum);
}
-TEST(fxcrt, ByteStringCMultiCharIterator) {
- CFX_ByteStringC one_str("abc");
+TEST(ByteStringView, MultiCharIterator) {
+ ByteStringView one_str("abc");
int32_t sum = 0;
bool any_present = false;
for (const auto& c : one_str) {
@@ -1267,16 +1267,16 @@ TEST(fxcrt, ByteStringCMultiCharIterator) {
EXPECT_EQ('a' + 'b' + 'c', sum);
}
-TEST(fxcrt, ByteStringCEmptyReverseIterator) {
- CFX_ByteStringC empty;
+TEST(ByteStringView, EmptyReverseIterator) {
+ ByteStringView empty;
auto iter = empty.rbegin();
EXPECT_TRUE(iter == empty.rend());
EXPECT_FALSE(iter != empty.rend());
EXPECT_FALSE(iter < empty.rend());
}
-TEST(fxcrt, ByteStringCOneCharReverseIterator) {
- CFX_ByteStringC one_str("a");
+TEST(ByteStringView, OneCharReverseIterator) {
+ ByteStringView one_str("a");
auto iter = one_str.rbegin();
EXPECT_FALSE(iter == one_str.rend());
EXPECT_TRUE(iter != one_str.rend());
@@ -1289,8 +1289,8 @@ TEST(fxcrt, ByteStringCOneCharReverseIterator) {
EXPECT_FALSE(iter < one_str.rend());
}
-TEST(fxcrt, ByteStringCMultiCharReverseIterator) {
- CFX_ByteStringC multi_str("abcd");
+TEST(ByteStringView, MultiCharReverseIterator) {
+ ByteStringView multi_str("abcd");
auto iter = multi_str.rbegin();
EXPECT_FALSE(iter == multi_str.rend());
@@ -1334,8 +1334,8 @@ TEST(fxcrt, ByteStringCMultiCharReverseIterator) {
EXPECT_TRUE(iter == multi_str.rbegin());
}
-TEST(fxcrt, ByteStringCAnyAllNoneOf) {
- CFX_ByteStringC str("aaaaaaaaaaaaaaaaab");
+TEST(ByteStringView, AnyAllNoneOf) {
+ ByteStringView str("aaaaaaaaaaaaaaaaab");
EXPECT_FALSE(std::all_of(str.begin(), str.end(),
[](const char& c) { return c == 'a'; }));
@@ -1350,87 +1350,87 @@ TEST(fxcrt, ByteStringCAnyAllNoneOf) {
EXPECT_FALSE(pdfium::ContainsValue(str, 'z'));
}
-TEST(fxcrt, ByteStringFormatWidth) {
+TEST(ByteString, FormatWidth) {
{
- CFX_ByteString str;
+ ByteString str;
str.Format("%5d", 1);
EXPECT_EQ(" 1", str);
}
{
- CFX_ByteString str;
+ ByteString str;
str.Format("%d", 1);
EXPECT_EQ("1", str);
}
{
- CFX_ByteString str;
+ ByteString str;
str.Format("%*d", 5, 1);
EXPECT_EQ(" 1", str);
}
{
- CFX_ByteString str;
+ ByteString str;
str.Format("%-1d", 1);
EXPECT_EQ("1", str);
}
{
- CFX_ByteString str;
+ ByteString str;
str.Format("%0d", 1);
EXPECT_EQ("1", str);
}
}
-TEST(fxcrt, ByteStringFormatPrecision) {
+TEST(ByteString, FormatPrecision) {
{
- CFX_ByteString str;
+ ByteString str;
str.Format("%.2f", 1.12345);
EXPECT_EQ("1.12", str);
}
{
- CFX_ByteString str;
+ ByteString str;
str.Format("%.*f", 3, 1.12345);
EXPECT_EQ("1.123", str);
}
{
- CFX_ByteString str;
+ ByteString str;
str.Format("%f", 1.12345);
EXPECT_EQ("1.123450", str);
}
{
- CFX_ByteString str;
+ ByteString str;
str.Format("%-1f", 1.12345);
EXPECT_EQ("1.123450", str);
}
{
- CFX_ByteString str;
+ ByteString str;
str.Format("%0f", 1.12345);
EXPECT_EQ("1.123450", str);
}
}
-TEST(fxcrt, EmptyByteString) {
- CFX_ByteString empty_str;
+TEST(ByteString, Empty) {
+ ByteString empty_str;
EXPECT_TRUE(empty_str.IsEmpty());
EXPECT_EQ(0u, empty_str.GetLength());
const char* cstr = empty_str.c_str();
EXPECT_EQ(0u, FXSYS_strlen(cstr));
}
-TEST(fxcrt, ByteStringInitializerList) {
- CFX_ByteString many_str({"clams", " and ", "oysters"});
+TEST(ByteString, InitializerList) {
+ ByteString many_str({"clams", " and ", "oysters"});
EXPECT_EQ("clams and oysters", many_str);
many_str = {"fish", " and ", "chips", " and ", "soda"};
EXPECT_EQ("fish and chips and soda", many_str);
}
-TEST(fxcrt, ByteStringNullIterator) {
- CFX_ByteString null_str;
+TEST(ByteString, NullIterator) {
+ ByteString null_str;
int32_t sum = 0;
bool any_present = false;
for (const auto& c : null_str) {
@@ -1441,8 +1441,8 @@ TEST(fxcrt, ByteStringNullIterator) {
EXPECT_EQ(0, sum);
}
-TEST(fxcrt, ByteStringEmptyIterator) {
- CFX_ByteString empty_str("");
+TEST(ByteString, EmptyIterator) {
+ ByteString empty_str("");
int32_t sum = 0;
bool any_present = false;
for (const auto& c : empty_str) {
@@ -1453,8 +1453,8 @@ TEST(fxcrt, ByteStringEmptyIterator) {
EXPECT_EQ(0, sum);
}
-TEST(fxcrt, ByteStringOneCharIterator) {
- CFX_ByteString one_str("a");
+TEST(ByteString, OneCharIterator) {
+ ByteString one_str("a");
int32_t sum = 0;
bool any_present = false;
for (const auto& c : one_str) {
@@ -1465,8 +1465,8 @@ TEST(fxcrt, ByteStringOneCharIterator) {
EXPECT_EQ('a', sum);
}
-TEST(fxcrt, ByteStringMultiCharIterator) {
- CFX_ByteString one_str("abc");
+TEST(ByteString, MultiCharIterator) {
+ ByteString one_str("abc");
int32_t sum = 0;
bool any_present = false;
for (const auto& c : one_str) {
@@ -1477,8 +1477,8 @@ TEST(fxcrt, ByteStringMultiCharIterator) {
EXPECT_EQ('a' + 'b' + 'c', sum);
}
-TEST(fxcrt, ByteStringAnyAllNoneOf) {
- CFX_ByteString str("aaaaaaaaaaaaaaaaab");
+TEST(ByteString, AnyAllNoneOf) {
+ ByteString str("aaaaaaaaaaaaaaaaab");
EXPECT_FALSE(std::all_of(str.begin(), str.end(),
[](const char& c) { return c == 'a'; }));
@@ -1493,8 +1493,8 @@ TEST(fxcrt, ByteStringAnyAllNoneOf) {
EXPECT_FALSE(pdfium::ContainsValue(str, 'z'));
}
-TEST(fxcrt, EqualNoCase) {
- CFX_ByteString str("aaa");
+TEST(CFX_BytrString, EqualNoCase) {
+ ByteString str("aaa");
EXPECT_TRUE(str.EqualNoCase("aaa"));
EXPECT_TRUE(str.EqualNoCase("AAA"));
EXPECT_TRUE(str.EqualNoCase("aaA"));
@@ -1506,11 +1506,11 @@ TEST(fxcrt, EqualNoCase) {
EXPECT_FALSE(str.EqualNoCase(""));
}
-TEST(fxcrt, OStreamByteStringOverload) {
+TEST(ByteString, OStreamOverload) {
std::ostringstream stream;
// Basic case, empty string
- CFX_ByteString str;
+ ByteString str;
stream << str;
EXPECT_EQ("", stream.str());
@@ -1520,7 +1520,7 @@ TEST(fxcrt, OStreamByteStringOverload) {
stream << "abc" << str << "ghi";
EXPECT_EQ("abcdefghi", stream.str());
- // Changing the CFX_ByteString does not change the stream it was written to.
+ // Changing the ByteString does not change the stream it was written to.
str = "123";
EXPECT_EQ("abcdefghi", stream.str());
@@ -1531,35 +1531,35 @@ TEST(fxcrt, OStreamByteStringOverload) {
char stringWithNulls[]{'x', 'y', '\0', 'z'};
- // Writing a CFX_ByteString with nulls and no specified length treats it as
+ // Writing a ByteString with nulls and no specified length treats it as
// a C-style null-terminated string.
- str = CFX_ByteString(stringWithNulls);
+ str = ByteString(stringWithNulls);
EXPECT_EQ(2u, str.GetLength());
stream.str("");
stream << str;
EXPECT_EQ(2u, stream.tellp());
- // Writing a CFX_ByteString with nulls but specifying its length treats it as
+ // Writing a ByteString with nulls but specifying its length treats it as
// a C++-style string.
- str = CFX_ByteString(stringWithNulls, 4);
+ str = ByteString(stringWithNulls, 4);
EXPECT_EQ(4u, str.GetLength());
stream.str("");
stream << str;
EXPECT_EQ(4u, stream.tellp());
// << operators can be chained.
- CFX_ByteString str1("abc");
- CFX_ByteString str2("def");
+ ByteString str1("abc");
+ ByteString str2("def");
stream.str("");
stream << str1 << str2;
EXPECT_EQ("abcdef", stream.str());
}
-TEST(fxcrt, OStreamByteStringCOverload) {
+TEST(ByteStringView, OStreamOverload) {
// Basic case, empty string
{
std::ostringstream stream;
- CFX_ByteStringC str;
+ ByteStringView str;
stream << str;
EXPECT_EQ("", stream.str());
}
@@ -1567,15 +1567,15 @@ TEST(fxcrt, OStreamByteStringCOverload) {
// Basic case, non-empty string
{
std::ostringstream stream;
- CFX_ByteStringC str("def");
+ ByteStringView str("def");
stream << "abc" << str << "ghi";
EXPECT_EQ("abcdefghi", stream.str());
}
- // Changing the CFX_ByteStringC does not change the stream it was written to.
+ // Changing the ByteStringView does not change the stream it was written to.
{
std::ostringstream stream;
- CFX_ByteStringC str("abc");
+ ByteStringView str("abc");
stream << str;
str = "123";
EXPECT_EQ("abc", stream.str());
@@ -1584,7 +1584,7 @@ TEST(fxcrt, OStreamByteStringCOverload) {
// Writing it again to the stream will use the latest value.
{
std::ostringstream stream;
- CFX_ByteStringC str("abc");
+ ByteStringView str("abc");
stream << str;
stream.str("");
str = "123";
@@ -1592,24 +1592,24 @@ TEST(fxcrt, OStreamByteStringCOverload) {
EXPECT_EQ("123", stream.str());
}
- // Writing a CFX_ByteStringC with nulls and no specified length treats it as
+ // Writing a ByteStringView with nulls and no specified length treats it as
// a C-style null-terminated string.
{
std::ostringstream stream;
char stringWithNulls[]{'x', 'y', '\0', 'z'};
- CFX_ByteStringC str(stringWithNulls);
+ ByteStringView str(stringWithNulls);
EXPECT_EQ(2u, str.GetLength());
stream << str;
EXPECT_EQ(2u, stream.tellp());
str = "";
}
- // Writing a CFX_ByteStringC with nulls but specifying its length treats it as
+ // Writing a ByteStringView with nulls but specifying its length treats it as
// a C++-style string.
{
std::ostringstream stream;
char stringWithNulls[]{'x', 'y', '\0', 'z'};
- CFX_ByteStringC str(stringWithNulls, 4);
+ ByteStringView str(stringWithNulls, 4);
EXPECT_EQ(4u, str.GetLength());
stream << str;
EXPECT_EQ(4u, stream.tellp());
@@ -1619,24 +1619,24 @@ TEST(fxcrt, OStreamByteStringCOverload) {
// << operators can be chained.
{
std::ostringstream stream;
- CFX_ByteStringC str1("abc");
- CFX_ByteStringC str2("def");
+ ByteStringView str1("abc");
+ ByteStringView str2("def");
stream << str1 << str2;
EXPECT_EQ("abcdef", stream.str());
}
}
-TEST(fxcrt, ByteStringFormatInteger) {
+TEST(ByteString, FormatInteger) {
// Base case of 0.
- EXPECT_EQ("0", CFX_ByteString::FormatInteger(0));
+ EXPECT_EQ("0", ByteString::FormatInteger(0));
// Positive ordinary number.
- EXPECT_EQ("123456", CFX_ByteString::FormatInteger(123456));
+ EXPECT_EQ("123456", ByteString::FormatInteger(123456));
// Negative ordinary number.
- EXPECT_EQ("-123456", CFX_ByteString::FormatInteger(-123456));
+ EXPECT_EQ("-123456", ByteString::FormatInteger(-123456));
// int limits.
- EXPECT_EQ("2147483647", CFX_ByteString::FormatInteger(INT_MAX));
- EXPECT_EQ("-2147483648", CFX_ByteString::FormatInteger(INT_MIN));
+ EXPECT_EQ("2147483647", ByteString::FormatInteger(INT_MAX));
+ EXPECT_EQ("-2147483648", ByteString::FormatInteger(INT_MIN));
}
diff --git a/core/fxcrt/cfx_binarybuf.h b/core/fxcrt/cfx_binarybuf.h
index 4c795eda0b..186d8d1b88 100644
--- a/core/fxcrt/cfx_binarybuf.h
+++ b/core/fxcrt/cfx_binarybuf.h
@@ -27,7 +27,7 @@ class CFX_BinaryBuf {
void Clear();
void EstimateSize(FX_STRSIZE size, FX_STRSIZE alloc_step = 0);
void AppendBlock(const void* pBuf, FX_STRSIZE size);
- void AppendString(const CFX_ByteString& str) {
+ void AppendString(const ByteString& str) {
AppendBlock(str.c_str(), str.GetLength());
}
diff --git a/core/fxcrt/cfx_blockbuffer.cpp b/core/fxcrt/cfx_blockbuffer.cpp
index aeef5653e8..13134f0e7b 100644
--- a/core/fxcrt/cfx_blockbuffer.cpp
+++ b/core/fxcrt/cfx_blockbuffer.cpp
@@ -70,19 +70,19 @@ void CFX_BlockBuffer::DeleteTextChars(size_t count) {
m_DataLength -= count;
}
-CFX_WideString CFX_BlockBuffer::GetTextData(size_t start, size_t length) const {
+WideString CFX_BlockBuffer::GetTextData(size_t start, size_t length) const {
if (m_BufferSize <= m_StartPosition + 1 || length == 0)
- return CFX_WideString();
+ return WideString();
size_t maybeDataLength = m_BufferSize - 1 - m_StartPosition;
if (start > maybeDataLength)
- return CFX_WideString();
+ return WideString();
length = std::min(length, maybeDataLength);
- CFX_WideString wsTextData;
+ WideString wsTextData;
wchar_t* pBuf = wsTextData.GetBuffer(length);
if (!pBuf)
- return CFX_WideString();
+ return WideString();
size_t startBlock = 0;
size_t startInner = 0;
diff --git a/core/fxcrt/cfx_blockbuffer.h b/core/fxcrt/cfx_blockbuffer.h
index 867449074d..423aa6820b 100644
--- a/core/fxcrt/cfx_blockbuffer.h
+++ b/core/fxcrt/cfx_blockbuffer.h
@@ -37,7 +37,7 @@ class CFX_BlockBuffer {
void SetTextChar(size_t iIndex, wchar_t ch);
void DeleteTextChars(size_t iCount);
- CFX_WideString GetTextData(size_t iStart, size_t iLength) const;
+ WideString GetTextData(size_t iStart, size_t iLength) const;
private:
std::pair<size_t, size_t> TextDataIndex2BufIndex(const size_t iIndex) const;
diff --git a/core/fxcrt/cfx_bytestring.h b/core/fxcrt/cfx_bytestring.h
deleted file mode 100644
index b976287617..0000000000
--- a/core/fxcrt/cfx_bytestring.h
+++ /dev/null
@@ -1,273 +0,0 @@
-// Copyright 2017 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef CORE_FXCRT_CFX_BYTESTRING_H_
-#define CORE_FXCRT_CFX_BYTESTRING_H_
-
-#include <functional>
-#include <iterator>
-#include <sstream>
-#include <utility>
-
-#include "core/fxcrt/cfx_retain_ptr.h"
-#include "core/fxcrt/cfx_string_c_template.h"
-#include "core/fxcrt/cfx_string_data_template.h"
-#include "core/fxcrt/fx_system.h"
-#include "third_party/base/optional.h"
-
-class CFX_WideString;
-
-// A mutable string with shared buffers using copy-on-write semantics that
-// avoids the cost of std::string's iterator stability guarantees.
-class CFX_ByteString {
- public:
- using CharType = char;
- using const_iterator = const CharType*;
- using const_reverse_iterator = std::reverse_iterator<const_iterator>;
-
- CFX_ByteString();
- CFX_ByteString(const CFX_ByteString& other);
- CFX_ByteString(CFX_ByteString&& other) noexcept;
-
- // Deliberately implicit to avoid calling on every string literal.
- // NOLINTNEXTLINE(runtime/explicit)
- CFX_ByteString(char ch);
- // NOLINTNEXTLINE(runtime/explicit)
- CFX_ByteString(const char* ptr);
-
- // No implicit conversions from wide strings.
- // NOLINTNEXTLINE(runtime/explicit)
- CFX_ByteString(wchar_t) = delete;
-
- CFX_ByteString(const char* ptr, FX_STRSIZE len);
- CFX_ByteString(const uint8_t* ptr, FX_STRSIZE len);
-
- explicit CFX_ByteString(const CFX_ByteStringC& bstrc);
- CFX_ByteString(const CFX_ByteStringC& bstrc1, const CFX_ByteStringC& bstrc2);
- CFX_ByteString(const std::initializer_list<CFX_ByteStringC>& list);
- explicit CFX_ByteString(const std::ostringstream& outStream);
-
- ~CFX_ByteString();
-
- void clear() { m_pData.Reset(); }
-
- static CFX_ByteString FromUnicode(const CFX_WideString& str);
-
- // Explicit conversion to C-style string.
- // Note: Any subsequent modification of |this| will invalidate the result.
- const char* c_str() const { return m_pData ? m_pData->m_String : ""; }
-
- // Explicit conversion to uint8_t*.
- // Note: Any subsequent modification of |this| will invalidate the result.
- const uint8_t* raw_str() const {
- return m_pData ? reinterpret_cast<const uint8_t*>(m_pData->m_String)
- : nullptr;
- }
-
- // Explicit conversion to CFX_ByteStringC.
- // Note: Any subsequent modification of |this| will invalidate the result.
- CFX_ByteStringC AsStringC() const {
- return CFX_ByteStringC(raw_str(), GetLength());
- }
-
- // Note: Any subsequent modification of |this| will invalidate iterators.
- const_iterator begin() const { return m_pData ? m_pData->m_String : nullptr; }
- const_iterator end() const {
- return m_pData ? m_pData->m_String + m_pData->m_nDataLength : nullptr;
- }
-
- // Note: Any subsequent modification of |this| will invalidate iterators.
- const_reverse_iterator rbegin() const {
- return const_reverse_iterator(end());
- }
- const_reverse_iterator rend() const {
- return const_reverse_iterator(begin());
- }
-
- FX_STRSIZE GetLength() const { return m_pData ? m_pData->m_nDataLength : 0; }
- FX_STRSIZE GetStringLength() const {
- return m_pData ? FXSYS_strlen(m_pData->m_String) : 0;
- }
- bool IsEmpty() const { return !GetLength(); }
- bool IsValidIndex(FX_STRSIZE index) const { return index < GetLength(); }
- bool IsValidLength(FX_STRSIZE length) const { return length <= GetLength(); }
-
- int Compare(const CFX_ByteStringC& str) const;
- bool EqualNoCase(const CFX_ByteStringC& str) const;
-
- bool operator==(const char* ptr) const;
- bool operator==(const CFX_ByteStringC& str) const;
- bool operator==(const CFX_ByteString& other) const;
-
- bool operator!=(const char* ptr) const { return !(*this == ptr); }
- bool operator!=(const CFX_ByteStringC& str) const { return !(*this == str); }
- bool operator!=(const CFX_ByteString& other) const {
- return !(*this == other);
- }
-
- bool operator<(const CFX_ByteString& str) const;
-
- const CFX_ByteString& operator=(const char* str);
- const CFX_ByteString& operator=(const CFX_ByteStringC& bstrc);
- const CFX_ByteString& operator=(const CFX_ByteString& stringSrc);
-
- const CFX_ByteString& operator+=(char ch);
- const CFX_ByteString& operator+=(const char* str);
- const CFX_ByteString& operator+=(const CFX_ByteString& str);
- const CFX_ByteString& operator+=(const CFX_ByteStringC& bstrc);
-
- CharType operator[](const FX_STRSIZE index) const {
- ASSERT(IsValidIndex(index));
- return m_pData ? m_pData->m_String[index] : 0;
- }
-
- CharType First() const { return GetLength() ? (*this)[0] : 0; }
- CharType Last() const { return GetLength() ? (*this)[GetLength() - 1] : 0; }
-
- void SetAt(FX_STRSIZE index, char c);
-
- FX_STRSIZE Insert(FX_STRSIZE index, char ch);
- FX_STRSIZE InsertAtFront(char ch) { return Insert(0, ch); }
- FX_STRSIZE InsertAtBack(char ch) { return Insert(GetLength(), ch); }
- FX_STRSIZE Delete(FX_STRSIZE index, FX_STRSIZE count = 1);
-
- void Format(const char* lpszFormat, ...);
- void FormatV(const char* lpszFormat, va_list argList);
-
- void Reserve(FX_STRSIZE len);
- char* GetBuffer(FX_STRSIZE len);
- void ReleaseBuffer(FX_STRSIZE len);
-
- CFX_ByteString Mid(FX_STRSIZE first, FX_STRSIZE count) const;
- CFX_ByteString Left(FX_STRSIZE count) const;
- CFX_ByteString Right(FX_STRSIZE count) const;
-
- pdfium::Optional<FX_STRSIZE> Find(const CFX_ByteStringC& lpszSub,
- FX_STRSIZE start = 0) const;
- pdfium::Optional<FX_STRSIZE> Find(char ch, FX_STRSIZE start = 0) const;
- pdfium::Optional<FX_STRSIZE> ReverseFind(char ch) const;
-
- bool Contains(const CFX_ByteStringC& lpszSub, FX_STRSIZE start = 0) const {
- return Find(lpszSub, start).has_value();
- }
-
- bool Contains(char ch, FX_STRSIZE start = 0) const {
- return Find(ch, start).has_value();
- }
-
- void MakeLower();
- void MakeUpper();
-
- void TrimRight();
- void TrimRight(char chTarget);
- void TrimRight(const CFX_ByteStringC& lpszTargets);
-
- void TrimLeft();
- void TrimLeft(char chTarget);
- void TrimLeft(const CFX_ByteStringC& lpszTargets);
-
- FX_STRSIZE Replace(const CFX_ByteStringC& lpszOld,
- const CFX_ByteStringC& lpszNew);
-
- FX_STRSIZE Remove(char ch);
-
- CFX_WideString UTF8Decode() const;
-
- uint32_t GetID() const { return AsStringC().GetID(); }
-
- static CFX_ByteString FormatInteger(int i);
- static CFX_ByteString FormatFloat(float f, int precision = 0);
-
- protected:
- using StringData = CFX_StringDataTemplate<char>;
-
- void ReallocBeforeWrite(FX_STRSIZE nNewLen);
- void AllocBeforeWrite(FX_STRSIZE nNewLen);
- void AllocCopy(CFX_ByteString& dest,
- FX_STRSIZE nCopyLen,
- FX_STRSIZE nCopyIndex) const;
- void AssignCopy(const char* pSrcData, FX_STRSIZE nSrcLen);
- void Concat(const char* lpszSrcData, FX_STRSIZE nSrcLen);
-
- CFX_RetainPtr<StringData> m_pData;
-
- friend class fxcrt_ByteStringConcat_Test;
- friend class fxcrt_ByteStringPool_Test;
-};
-
-inline bool operator==(const char* lhs, const CFX_ByteString& rhs) {
- return rhs == lhs;
-}
-inline bool operator==(const CFX_ByteStringC& lhs, const CFX_ByteString& rhs) {
- return rhs == lhs;
-}
-inline bool operator!=(const char* lhs, const CFX_ByteString& rhs) {
- return rhs != lhs;
-}
-inline bool operator!=(const CFX_ByteStringC& lhs, const CFX_ByteString& rhs) {
- return rhs != lhs;
-}
-
-inline CFX_ByteString operator+(const CFX_ByteStringC& str1,
- const CFX_ByteStringC& str2) {
- return CFX_ByteString(str1, str2);
-}
-inline CFX_ByteString operator+(const CFX_ByteStringC& str1, const char* str2) {
- return CFX_ByteString(str1, str2);
-}
-inline CFX_ByteString operator+(const char* str1, const CFX_ByteStringC& str2) {
- return CFX_ByteString(str1, str2);
-}
-inline CFX_ByteString operator+(const CFX_ByteStringC& str1, char ch) {
- return CFX_ByteString(str1, CFX_ByteStringC(ch));
-}
-inline CFX_ByteString operator+(char ch, const CFX_ByteStringC& str2) {
- return CFX_ByteString(ch, str2);
-}
-inline CFX_ByteString operator+(const CFX_ByteString& str1,
- const CFX_ByteString& str2) {
- return CFX_ByteString(str1.AsStringC(), str2.AsStringC());
-}
-inline CFX_ByteString operator+(const CFX_ByteString& str1, char ch) {
- return CFX_ByteString(str1.AsStringC(), CFX_ByteStringC(ch));
-}
-inline CFX_ByteString operator+(char ch, const CFX_ByteString& str2) {
- return CFX_ByteString(ch, str2.AsStringC());
-}
-inline CFX_ByteString operator+(const CFX_ByteString& str1, const char* str2) {
- return CFX_ByteString(str1.AsStringC(), str2);
-}
-inline CFX_ByteString operator+(const char* str1, const CFX_ByteString& str2) {
- return CFX_ByteString(str1, str2.AsStringC());
-}
-inline CFX_ByteString operator+(const CFX_ByteString& str1,
- const CFX_ByteStringC& str2) {
- return CFX_ByteString(str1.AsStringC(), str2);
-}
-inline CFX_ByteString operator+(const CFX_ByteStringC& str1,
- const CFX_ByteString& str2) {
- return CFX_ByteString(str1, str2.AsStringC());
-}
-
-uint32_t FX_HashCode_GetA(const CFX_ByteStringC& str, bool bIgnoreCase);
-
-std::ostream& operator<<(std::ostream& os, const CFX_ByteString& str);
-std::ostream& operator<<(std::ostream& os, const CFX_ByteStringC& str);
-
-namespace std {
-
-template <>
-struct hash<CFX_ByteString> {
- std::size_t operator()(const CFX_ByteString& str) const {
- return FX_HashCode_GetA(str.AsStringC(), false);
- }
-};
-
-} // namespace std
-
-extern template struct std::hash<CFX_ByteString>;
-
-#endif // CORE_FXCRT_CFX_BYTESTRING_H_
diff --git a/core/fxcrt/cfx_checksumcontext.cpp b/core/fxcrt/cfx_checksumcontext.cpp
index 31140169b4..c75e440231 100644
--- a/core/fxcrt/cfx_checksumcontext.cpp
+++ b/core/fxcrt/cfx_checksumcontext.cpp
@@ -140,11 +140,11 @@ void CFX_ChecksumContext::FinishChecksum() {
}
}
-CFX_ByteString CFX_ChecksumContext::GetChecksum() const {
+ByteString CFX_ChecksumContext::GetChecksum() const {
return m_bsChecksum;
}
-void CFX_ChecksumContext::Update(const CFX_ByteStringC& bsText) {
+void CFX_ChecksumContext::Update(const ByteStringView& bsText) {
if (!m_pByteContext)
return;
diff --git a/core/fxcrt/cfx_checksumcontext.h b/core/fxcrt/cfx_checksumcontext.h
index 8869c540fb..4231e09a83 100644
--- a/core/fxcrt/cfx_checksumcontext.h
+++ b/core/fxcrt/cfx_checksumcontext.h
@@ -18,17 +18,17 @@ class CFX_ChecksumContext {
~CFX_ChecksumContext();
void StartChecksum();
- void Update(const CFX_ByteStringC& bsText);
+ void Update(const ByteStringView& bsText);
bool UpdateChecksum(const CFX_RetainPtr<IFX_SeekableReadStream>& pSrcFile,
FX_FILESIZE offset = 0,
size_t size = 0);
void FinishChecksum();
- CFX_ByteString GetChecksum() const;
+ ByteString GetChecksum() const;
private:
std::unique_ptr<CFX_SAXReader> m_pSAXReader;
std::unique_ptr<CRYPT_sha1_context> m_pByteContext;
- CFX_ByteString m_bsChecksum;
+ ByteString m_bsChecksum;
};
#endif // CORE_FXCRT_CFX_CHECKSUMCONTEXT_H_
diff --git a/core/fxcrt/cfx_crtfileaccess.cpp b/core/fxcrt/cfx_crtfileaccess.cpp
index ddca68e144..2479c95654 100644
--- a/core/fxcrt/cfx_crtfileaccess.cpp
+++ b/core/fxcrt/cfx_crtfileaccess.cpp
@@ -6,7 +6,7 @@
#include "core/fxcrt/cfx_crtfileaccess.h"
-CFX_CRTFileAccess::CFX_CRTFileAccess(const CFX_WideStringC& wsPath)
+CFX_CRTFileAccess::CFX_CRTFileAccess(const WideStringView& wsPath)
: m_path(wsPath) {}
CFX_CRTFileAccess::~CFX_CRTFileAccess() {}
diff --git a/core/fxcrt/cfx_crtfileaccess.h b/core/fxcrt/cfx_crtfileaccess.h
index cb2a034f20..3c63aa30c3 100644
--- a/core/fxcrt/cfx_crtfileaccess.h
+++ b/core/fxcrt/cfx_crtfileaccess.h
@@ -19,10 +19,10 @@ class CFX_CRTFileAccess : public CFX_Retainable {
CFX_RetainPtr<IFX_SeekableStream> CreateFileStream(uint32_t dwModes);
private:
- explicit CFX_CRTFileAccess(const CFX_WideStringC& wsPath);
+ explicit CFX_CRTFileAccess(const WideStringView& wsPath);
~CFX_CRTFileAccess() override;
- CFX_WideString m_path;
+ WideString m_path;
};
#endif // CORE_FXCRT_CFX_CRTFILEACCESS_H_
diff --git a/core/fxcrt/cfx_decimal.cpp b/core/fxcrt/cfx_decimal.cpp
index b900e069a7..45980db6ee 100644
--- a/core/fxcrt/cfx_decimal.cpp
+++ b/core/fxcrt/cfx_decimal.cpp
@@ -294,7 +294,7 @@ CFX_Decimal::CFX_Decimal(float val, uint8_t scale) {
m_uFlags = FXMATH_DECIMAL_MAKEFLAGS(val < 0 && IsNotZero(), scale);
}
-CFX_Decimal::CFX_Decimal(const CFX_WideStringC& strObj) {
+CFX_Decimal::CFX_Decimal(const WideStringView& strObj) {
const wchar_t* str = strObj.unterminated_c_str();
const wchar_t* strBound = str + strObj.GetLength();
bool pointmet = false;
@@ -329,9 +329,9 @@ CFX_Decimal::CFX_Decimal(const CFX_WideStringC& strObj) {
m_uFlags = FXMATH_DECIMAL_MAKEFLAGS(negmet && IsNotZero(), scale);
}
-CFX_Decimal::operator CFX_WideString() const {
- CFX_WideString retString;
- CFX_WideString tmpbuf;
+CFX_Decimal::operator WideString() const {
+ WideString retString;
+ WideString tmpbuf;
uint64_t phi = m_uHi;
uint64_t pmid = m_uMid;
uint64_t plo = m_uLo;
diff --git a/core/fxcrt/cfx_decimal.h b/core/fxcrt/cfx_decimal.h
index 544280444a..de6e3de5e5 100644
--- a/core/fxcrt/cfx_decimal.h
+++ b/core/fxcrt/cfx_decimal.h
@@ -16,9 +16,9 @@ class CFX_Decimal {
explicit CFX_Decimal(uint64_t val);
explicit CFX_Decimal(int32_t val);
CFX_Decimal(float val, uint8_t scale);
- explicit CFX_Decimal(const CFX_WideStringC& str);
+ explicit CFX_Decimal(const WideStringView& str);
- operator CFX_WideString() const;
+ operator WideString() const;
operator double() const;
CFX_Decimal operator*(const CFX_Decimal& val) const;
diff --git a/core/fxcrt/cfx_fileaccess_posix.cpp b/core/fxcrt/cfx_fileaccess_posix.cpp
index 345b6641ef..d98e58dbe9 100644
--- a/core/fxcrt/cfx_fileaccess_posix.cpp
+++ b/core/fxcrt/cfx_fileaccess_posix.cpp
@@ -51,7 +51,7 @@ CFX_FileAccess_Posix::~CFX_FileAccess_Posix() {
Close();
}
-bool CFX_FileAccess_Posix::Open(const CFX_ByteStringC& fileName,
+bool CFX_FileAccess_Posix::Open(const ByteStringView& fileName,
uint32_t dwMode) {
if (m_nFD > -1)
return false;
@@ -65,9 +65,9 @@ bool CFX_FileAccess_Posix::Open(const CFX_ByteStringC& fileName,
return m_nFD > -1;
}
-bool CFX_FileAccess_Posix::Open(const CFX_WideStringC& fileName,
+bool CFX_FileAccess_Posix::Open(const WideStringView& fileName,
uint32_t dwMode) {
- return Open(FX_UTF8Encode(fileName).AsStringC(), dwMode);
+ return Open(FX_UTF8Encode(fileName).AsStringView(), dwMode);
}
void CFX_FileAccess_Posix::Close() {
diff --git a/core/fxcrt/cfx_fileaccess_posix.h b/core/fxcrt/cfx_fileaccess_posix.h
index c299f6cc34..0b739e72d8 100644
--- a/core/fxcrt/cfx_fileaccess_posix.h
+++ b/core/fxcrt/cfx_fileaccess_posix.h
@@ -18,8 +18,8 @@ class CFX_FileAccess_Posix : public IFX_FileAccess {
~CFX_FileAccess_Posix() override;
// IFX_FileAccess:
- bool Open(const CFX_ByteStringC& fileName, uint32_t dwMode) override;
- bool Open(const CFX_WideStringC& fileName, uint32_t dwMode) override;
+ bool Open(const ByteStringView& fileName, uint32_t dwMode) override;
+ bool Open(const WideStringView& fileName, uint32_t dwMode) override;
void Close() override;
FX_FILESIZE GetSize() const override;
FX_FILESIZE GetPosition() const override;
diff --git a/core/fxcrt/cfx_fileaccess_windows.cpp b/core/fxcrt/cfx_fileaccess_windows.cpp
index b39a4d6efc..105ad788f7 100644
--- a/core/fxcrt/cfx_fileaccess_windows.cpp
+++ b/core/fxcrt/cfx_fileaccess_windows.cpp
@@ -54,7 +54,7 @@ CFX_FileAccess_Windows::~CFX_FileAccess_Windows() {
Close();
}
-bool CFX_FileAccess_Windows::Open(const CFX_ByteStringC& fileName,
+bool CFX_FileAccess_Windows::Open(const ByteStringView& fileName,
uint32_t dwMode) {
if (m_hFile)
return false;
@@ -69,7 +69,7 @@ bool CFX_FileAccess_Windows::Open(const CFX_ByteStringC& fileName,
return !!m_hFile;
}
-bool CFX_FileAccess_Windows::Open(const CFX_WideStringC& fileName,
+bool CFX_FileAccess_Windows::Open(const WideStringView& fileName,
uint32_t dwMode) {
if (m_hFile)
return false;
diff --git a/core/fxcrt/cfx_fileaccess_windows.h b/core/fxcrt/cfx_fileaccess_windows.h
index 692a537a82..f05ab39d6e 100644
--- a/core/fxcrt/cfx_fileaccess_windows.h
+++ b/core/fxcrt/cfx_fileaccess_windows.h
@@ -16,8 +16,8 @@ class CFX_FileAccess_Windows : public IFX_FileAccess {
~CFX_FileAccess_Windows() override;
// IFX_FileAccess
- bool Open(const CFX_ByteStringC& fileName, uint32_t dwMode) override;
- bool Open(const CFX_WideStringC& fileName, uint32_t dwMode) override;
+ bool Open(const ByteStringView& fileName, uint32_t dwMode) override;
+ bool Open(const WideStringView& fileName, uint32_t dwMode) override;
void Close() override;
FX_FILESIZE GetSize() const override;
FX_FILESIZE GetPosition() const override;
diff --git a/core/fxcrt/cfx_seekablestreamproxy.cpp b/core/fxcrt/cfx_seekablestreamproxy.cpp
index d3516e1794..6a6c6e6c3e 100644
--- a/core/fxcrt/cfx_seekablestreamproxy.cpp
+++ b/core/fxcrt/cfx_seekablestreamproxy.cpp
@@ -269,7 +269,7 @@ FX_STRSIZE CFX_SeekableStreamProxy::ReadString(wchar_t* pStr,
return iMaxLength;
}
-void CFX_SeekableStreamProxy::WriteString(const CFX_WideStringC& str) {
+void CFX_SeekableStreamProxy::WriteString(const WideStringView& str) {
if (!m_IsWriteStream || str.GetLength() == 0 ||
m_wCodePage != FX_CODEPAGE_UTF8) {
return;
diff --git a/core/fxcrt/cfx_seekablestreamproxy.h b/core/fxcrt/cfx_seekablestreamproxy.h
index 0e427fc79b..fc041b49b5 100644
--- a/core/fxcrt/cfx_seekablestreamproxy.h
+++ b/core/fxcrt/cfx_seekablestreamproxy.h
@@ -31,7 +31,7 @@ class CFX_SeekableStreamProxy : public CFX_Retainable {
void Seek(From eSeek, FX_FILESIZE iOffset);
FX_STRSIZE ReadString(wchar_t* pStr, FX_STRSIZE iMaxLength, bool* bEOS);
- void WriteString(const CFX_WideStringC& str);
+ void WriteString(const WideStringView& str);
uint16_t GetCodePage() const { return m_wCodePage; }
void SetCodePage(uint16_t wCodePage);
diff --git a/core/fxcrt/cfx_string_pool_template.h b/core/fxcrt/cfx_string_pool_template.h
index bfc1ce4bfb..b170a84127 100644
--- a/core/fxcrt/cfx_string_pool_template.h
+++ b/core/fxcrt/cfx_string_pool_template.h
@@ -21,10 +21,10 @@ class CFX_StringPoolTemplate {
std::unordered_set<StringType> m_Pool;
};
-using CFX_ByteStringPool = CFX_StringPoolTemplate<CFX_ByteString>;
-using CFX_WideStringPool = CFX_StringPoolTemplate<CFX_WideString>;
+using ByteStringPool = CFX_StringPoolTemplate<ByteString>;
+using WideStringPool = CFX_StringPoolTemplate<WideString>;
-extern template class CFX_StringPoolTemplate<CFX_ByteString>;
-extern template class CFX_StringPoolTemplate<CFX_WideString>;
+extern template class CFX_StringPoolTemplate<ByteString>;
+extern template class CFX_StringPoolTemplate<WideString>;
#endif // CORE_FXCRT_CFX_STRING_POOL_TEMPLATE_H_
diff --git a/core/fxcrt/cfx_string_pool_template_unittest.cpp b/core/fxcrt/cfx_string_pool_template_unittest.cpp
index a4e603c8fa..9a5ac5d3ed 100644
--- a/core/fxcrt/cfx_string_pool_template_unittest.cpp
+++ b/core/fxcrt/cfx_string_pool_template_unittest.cpp
@@ -7,22 +7,22 @@
#include "testing/gtest/include/gtest/gtest.h"
TEST(fxcrt, ByteStringPool) {
- CFX_ByteStringPool pool;
+ ByteStringPool pool;
- CFX_ByteString null1;
- CFX_ByteString null2;
- CFX_ByteString goats1("goats");
- CFX_ByteString goats2("goats");
+ ByteString null1;
+ ByteString null2;
+ ByteString goats1("goats");
+ ByteString goats2("goats");
// Underlying storage, if non-null, is not shared.
EXPECT_EQ(nullptr, null1.m_pData.Get());
EXPECT_EQ(nullptr, null2.m_pData.Get());
EXPECT_NE(goats1.m_pData, goats2.m_pData);
- CFX_ByteString interned_null1 = pool.Intern(null1);
- CFX_ByteString interned_null2 = pool.Intern(null2);
- CFX_ByteString interned_goats1 = pool.Intern(goats1);
- CFX_ByteString interned_goats2 = pool.Intern(goats2);
+ ByteString interned_null1 = pool.Intern(null1);
+ ByteString interned_null2 = pool.Intern(null2);
+ ByteString interned_goats1 = pool.Intern(goats1);
+ ByteString interned_goats2 = pool.Intern(goats2);
// Strings are logically equal after being interned.
EXPECT_EQ(null1, interned_null1);
@@ -37,10 +37,10 @@ TEST(fxcrt, ByteStringPool) {
EXPECT_EQ(goats1.m_pData, interned_goats2.m_pData);
pool.Clear();
- CFX_ByteString reinterned_null2 = pool.Intern(null2);
- CFX_ByteString reinterned_null1 = pool.Intern(null2);
- CFX_ByteString reinterned_goats2 = pool.Intern(goats2);
- CFX_ByteString reinterned_goats1 = pool.Intern(goats2);
+ ByteString reinterned_null2 = pool.Intern(null2);
+ ByteString reinterned_null1 = pool.Intern(null2);
+ ByteString reinterned_goats2 = pool.Intern(goats2);
+ ByteString reinterned_goats1 = pool.Intern(goats2);
// After clearing pool, storage was re-interned using second strings.
EXPECT_EQ(nullptr, interned_null1.m_pData.Get());
@@ -50,22 +50,22 @@ TEST(fxcrt, ByteStringPool) {
}
TEST(fxcrt, WideStringPool) {
- CFX_WideStringPool pool;
+ WideStringPool pool;
- CFX_WideString null1;
- CFX_WideString null2;
- CFX_WideString goats1(L"goats");
- CFX_WideString goats2(L"goats");
+ WideString null1;
+ WideString null2;
+ WideString goats1(L"goats");
+ WideString goats2(L"goats");
// Underlying storage, if non-null, is not shared.
EXPECT_EQ(nullptr, null1.m_pData.Get());
EXPECT_EQ(nullptr, null2.m_pData.Get());
EXPECT_NE(goats1.m_pData, goats2.m_pData);
- CFX_WideString interned_null1 = pool.Intern(null1);
- CFX_WideString interned_null2 = pool.Intern(null2);
- CFX_WideString interned_goats1 = pool.Intern(goats1);
- CFX_WideString interned_goats2 = pool.Intern(goats2);
+ WideString interned_null1 = pool.Intern(null1);
+ WideString interned_null2 = pool.Intern(null2);
+ WideString interned_goats1 = pool.Intern(goats1);
+ WideString interned_goats2 = pool.Intern(goats2);
// Strings are logically equal after being interned.
EXPECT_EQ(null1, interned_null1);
@@ -80,10 +80,10 @@ TEST(fxcrt, WideStringPool) {
EXPECT_EQ(goats1.m_pData, interned_goats2.m_pData);
pool.Clear();
- CFX_WideString reinterned_null2 = pool.Intern(null2);
- CFX_WideString reinterned_null1 = pool.Intern(null2);
- CFX_WideString reinterned_goats2 = pool.Intern(goats2);
- CFX_WideString reinterned_goats1 = pool.Intern(goats2);
+ WideString reinterned_null2 = pool.Intern(null2);
+ WideString reinterned_null1 = pool.Intern(null2);
+ WideString reinterned_goats2 = pool.Intern(goats2);
+ WideString reinterned_goats1 = pool.Intern(goats2);
// After clearing pool, storage was re-interned using second strings.
EXPECT_EQ(nullptr, interned_null1.m_pData.Get());
diff --git a/core/fxcrt/cfx_utf8decoder.h b/core/fxcrt/cfx_utf8decoder.h
index dcf5ef796a..1cafbe4472 100644
--- a/core/fxcrt/cfx_utf8decoder.h
+++ b/core/fxcrt/cfx_utf8decoder.h
@@ -17,7 +17,7 @@ class CFX_UTF8Decoder {
void Input(uint8_t byte);
void AppendCodePoint(uint32_t ch);
void ClearStatus() { m_PendingBytes = 0; }
- CFX_WideStringC GetResult() const { return m_Buffer.AsStringC(); }
+ WideStringView GetResult() const { return m_Buffer.AsStringView(); }
private:
int m_PendingBytes;
diff --git a/core/fxcrt/cfx_widestring.h b/core/fxcrt/cfx_widestring.h
deleted file mode 100644
index 595615a0b2..0000000000
--- a/core/fxcrt/cfx_widestring.h
+++ /dev/null
@@ -1,276 +0,0 @@
-// Copyright 2017 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef CORE_FXCRT_CFX_WIDESTRING_H_
-#define CORE_FXCRT_CFX_WIDESTRING_H_
-
-#include <functional>
-#include <iterator>
-#include <utility>
-
-#include "core/fxcrt/cfx_retain_ptr.h"
-#include "core/fxcrt/cfx_string_c_template.h"
-#include "core/fxcrt/cfx_string_data_template.h"
-#include "core/fxcrt/fx_memory.h"
-#include "core/fxcrt/fx_system.h"
-#include "third_party/base/optional.h"
-
-class CFX_ByteString;
-
-// A mutable string with shared buffers using copy-on-write semantics that
-// avoids the cost of std::string's iterator stability guarantees.
-class CFX_WideString {
- public:
- using CharType = wchar_t;
- using const_iterator = const CharType*;
- using const_reverse_iterator = std::reverse_iterator<const_iterator>;
-
- CFX_WideString();
- CFX_WideString(const CFX_WideString& other);
- CFX_WideString(CFX_WideString&& other) noexcept;
-
- // Deliberately implicit to avoid calling on every string literal.
- // NOLINTNEXTLINE(runtime/explicit)
- CFX_WideString(wchar_t ch);
- // NOLINTNEXTLINE(runtime/explicit)
- CFX_WideString(const wchar_t* ptr);
-
- // No implicit conversions from byte strings.
- // NOLINTNEXTLINE(runtime/explicit)
- CFX_WideString(char) = delete;
-
- CFX_WideString(const wchar_t* ptr, FX_STRSIZE len);
-
- explicit CFX_WideString(const CFX_WideStringC& str);
- CFX_WideString(const CFX_WideStringC& str1, const CFX_WideStringC& str2);
- CFX_WideString(const std::initializer_list<CFX_WideStringC>& list);
-
- ~CFX_WideString();
-
- static CFX_WideString FromLocal(const CFX_ByteStringC& str);
- static CFX_WideString FromCodePage(const CFX_ByteStringC& str,
- uint16_t codepage);
-
- static CFX_WideString FromUTF8(const CFX_ByteStringC& str);
- static CFX_WideString FromUTF16LE(const unsigned short* str, FX_STRSIZE len);
-
- static FX_STRSIZE WStringLength(const unsigned short* str);
-
- // Explicit conversion to C-style wide string.
- // Note: Any subsequent modification of |this| will invalidate the result.
- const wchar_t* c_str() const { return m_pData ? m_pData->m_String : L""; }
-
- // Explicit conversion to CFX_WideStringC.
- // Note: Any subsequent modification of |this| will invalidate the result.
- CFX_WideStringC AsStringC() const {
- return CFX_WideStringC(c_str(), GetLength());
- }
-
- // Note: Any subsequent modification of |this| will invalidate iterators.
- const_iterator begin() const { return m_pData ? m_pData->m_String : nullptr; }
- const_iterator end() const {
- return m_pData ? m_pData->m_String + m_pData->m_nDataLength : nullptr;
- }
-
- // Note: Any subsequent modification of |this| will invalidate iterators.
- const_reverse_iterator rbegin() const {
- return const_reverse_iterator(end());
- }
- const_reverse_iterator rend() const {
- return const_reverse_iterator(begin());
- }
-
- void clear() { m_pData.Reset(); }
-
- FX_STRSIZE GetLength() const { return m_pData ? m_pData->m_nDataLength : 0; }
- FX_STRSIZE GetStringLength() const {
- return m_pData ? FXSYS_wcslen(m_pData->m_String) : 0;
- }
- bool IsEmpty() const { return !GetLength(); }
- bool IsValidIndex(FX_STRSIZE index) const { return index < GetLength(); }
- bool IsValidLength(FX_STRSIZE length) const { return length <= GetLength(); }
-
- const CFX_WideString& operator=(const wchar_t* str);
- const CFX_WideString& operator=(const CFX_WideString& stringSrc);
- const CFX_WideString& operator=(const CFX_WideStringC& stringSrc);
-
- const CFX_WideString& operator+=(const wchar_t* str);
- const CFX_WideString& operator+=(wchar_t ch);
- const CFX_WideString& operator+=(const CFX_WideString& str);
- const CFX_WideString& operator+=(const CFX_WideStringC& str);
-
- bool operator==(const wchar_t* ptr) const;
- bool operator==(const CFX_WideStringC& str) const;
- bool operator==(const CFX_WideString& other) const;
-
- bool operator!=(const wchar_t* ptr) const { return !(*this == ptr); }
- bool operator!=(const CFX_WideStringC& str) const { return !(*this == str); }
- bool operator!=(const CFX_WideString& other) const {
- return !(*this == other);
- }
-
- bool operator<(const CFX_WideString& str) const;
-
- CharType operator[](const FX_STRSIZE index) const {
- ASSERT(IsValidIndex(index));
- return m_pData ? m_pData->m_String[index] : 0;
- }
-
- CharType First() const { return GetLength() ? (*this)[0] : 0; }
- CharType Last() const { return GetLength() ? (*this)[GetLength() - 1] : 0; }
-
- void SetAt(FX_STRSIZE index, wchar_t c);
-
- int Compare(const wchar_t* str) const;
- int Compare(const CFX_WideString& str) const;
- int CompareNoCase(const wchar_t* str) const;
-
- CFX_WideString Mid(FX_STRSIZE first, FX_STRSIZE count) const;
- CFX_WideString Left(FX_STRSIZE count) const;
- CFX_WideString Right(FX_STRSIZE count) const;
-
- FX_STRSIZE Insert(FX_STRSIZE index, wchar_t ch);
- FX_STRSIZE InsertAtFront(wchar_t ch) { return Insert(0, ch); }
- FX_STRSIZE InsertAtBack(wchar_t ch) { return Insert(GetLength(), ch); }
- FX_STRSIZE Delete(FX_STRSIZE index, FX_STRSIZE count = 1);
-
- void Format(const wchar_t* lpszFormat, ...);
- void FormatV(const wchar_t* lpszFormat, va_list argList);
-
- void MakeLower();
- void MakeUpper();
-
- void TrimRight();
- void TrimRight(wchar_t chTarget);
- void TrimRight(const CFX_WideStringC& pTargets);
-
- void TrimLeft();
- void TrimLeft(wchar_t chTarget);
- void TrimLeft(const CFX_WideStringC& pTargets);
-
- void Reserve(FX_STRSIZE len);
- wchar_t* GetBuffer(FX_STRSIZE len);
- void ReleaseBuffer(FX_STRSIZE len);
-
- int GetInteger() const;
- float GetFloat() const;
-
- pdfium::Optional<FX_STRSIZE> Find(const CFX_WideStringC& pSub,
- FX_STRSIZE start = 0) const;
- pdfium::Optional<FX_STRSIZE> Find(wchar_t ch, FX_STRSIZE start = 0) const;
-
- bool Contains(const CFX_WideStringC& lpszSub, FX_STRSIZE start = 0) const {
- return Find(lpszSub, start).has_value();
- }
-
- bool Contains(char ch, FX_STRSIZE start = 0) const {
- return Find(ch, start).has_value();
- }
-
- FX_STRSIZE Replace(const CFX_WideStringC& pOld, const CFX_WideStringC& pNew);
- FX_STRSIZE Remove(wchar_t ch);
-
- CFX_ByteString UTF8Encode() const;
- CFX_ByteString UTF16LE_Encode() const;
-
- protected:
- using StringData = CFX_StringDataTemplate<wchar_t>;
-
- void ReallocBeforeWrite(FX_STRSIZE nLen);
- void AllocBeforeWrite(FX_STRSIZE nLen);
- void AllocCopy(CFX_WideString& dest,
- FX_STRSIZE nCopyLen,
- FX_STRSIZE nCopyIndex) const;
- void AssignCopy(const wchar_t* pSrcData, FX_STRSIZE nSrcLen);
- void Concat(const wchar_t* lpszSrcData, FX_STRSIZE nSrcLen);
-
- // Returns true unless we ran out of space.
- bool TryVSWPrintf(FX_STRSIZE size, const wchar_t* format, va_list argList);
-
- CFX_RetainPtr<StringData> m_pData;
-
- friend class fxcrt_WideStringConcatInPlace_Test;
- friend class fxcrt_WideStringPool_Test;
-};
-
-inline CFX_WideString operator+(const CFX_WideStringC& str1,
- const CFX_WideStringC& str2) {
- return CFX_WideString(str1, str2);
-}
-inline CFX_WideString operator+(const CFX_WideStringC& str1,
- const wchar_t* str2) {
- return CFX_WideString(str1, str2);
-}
-inline CFX_WideString operator+(const wchar_t* str1,
- const CFX_WideStringC& str2) {
- return CFX_WideString(str1, str2);
-}
-inline CFX_WideString operator+(const CFX_WideStringC& str1, wchar_t ch) {
- return CFX_WideString(str1, CFX_WideStringC(ch));
-}
-inline CFX_WideString operator+(wchar_t ch, const CFX_WideStringC& str2) {
- return CFX_WideString(ch, str2);
-}
-inline CFX_WideString operator+(const CFX_WideString& str1,
- const CFX_WideString& str2) {
- return CFX_WideString(str1.AsStringC(), str2.AsStringC());
-}
-inline CFX_WideString operator+(const CFX_WideString& str1, wchar_t ch) {
- return CFX_WideString(str1.AsStringC(), CFX_WideStringC(ch));
-}
-inline CFX_WideString operator+(wchar_t ch, const CFX_WideString& str2) {
- return CFX_WideString(ch, str2.AsStringC());
-}
-inline CFX_WideString operator+(const CFX_WideString& str1,
- const wchar_t* str2) {
- return CFX_WideString(str1.AsStringC(), str2);
-}
-inline CFX_WideString operator+(const wchar_t* str1,
- const CFX_WideString& str2) {
- return CFX_WideString(str1, str2.AsStringC());
-}
-inline CFX_WideString operator+(const CFX_WideString& str1,
- const CFX_WideStringC& str2) {
- return CFX_WideString(str1.AsStringC(), str2);
-}
-inline CFX_WideString operator+(const CFX_WideStringC& str1,
- const CFX_WideString& str2) {
- return CFX_WideString(str1, str2.AsStringC());
-}
-inline bool operator==(const wchar_t* lhs, const CFX_WideString& rhs) {
- return rhs == lhs;
-}
-inline bool operator==(const CFX_WideStringC& lhs, const CFX_WideString& rhs) {
- return rhs == lhs;
-}
-inline bool operator!=(const wchar_t* lhs, const CFX_WideString& rhs) {
- return rhs != lhs;
-}
-inline bool operator!=(const CFX_WideStringC& lhs, const CFX_WideString& rhs) {
- return rhs != lhs;
-}
-
-uint32_t FX_HashCode_GetW(const CFX_WideStringC& str, bool bIgnoreCase);
-
-std::wostream& operator<<(std::wostream& os, const CFX_WideString& str);
-std::ostream& operator<<(std::ostream& os, const CFX_WideString& str);
-std::wostream& operator<<(std::wostream& os, const CFX_WideStringC& str);
-std::ostream& operator<<(std::ostream& os, const CFX_WideStringC& str);
-
-namespace std {
-
-template <>
-struct hash<CFX_WideString> {
- std::size_t operator()(const CFX_WideString& str) const {
- return FX_HashCode_GetW(str.AsStringC(), false);
- }
-};
-
-} // namespace std
-
-extern template struct std::hash<CFX_WideString>;
-
-#endif // CORE_FXCRT_CFX_WIDESTRING_H_
diff --git a/core/fxcrt/cfx_widetextbuf.cpp b/core/fxcrt/cfx_widetextbuf.cpp
index 81b5fd4b05..d51e5ea314 100644
--- a/core/fxcrt/cfx_widetextbuf.cpp
+++ b/core/fxcrt/cfx_widetextbuf.cpp
@@ -16,12 +16,12 @@ void CFX_WideTextBuf::AppendChar(wchar_t ch) {
m_DataSize += sizeof(wchar_t);
}
-CFX_WideTextBuf& CFX_WideTextBuf::operator<<(const CFX_WideStringC& str) {
+CFX_WideTextBuf& CFX_WideTextBuf::operator<<(const WideStringView& str) {
AppendBlock(str.unterminated_c_str(), str.GetLength() * sizeof(wchar_t));
return *this;
}
-CFX_WideTextBuf& CFX_WideTextBuf::operator<<(const CFX_WideString& str) {
+CFX_WideTextBuf& CFX_WideTextBuf::operator<<(const WideString& str) {
AppendBlock(str.c_str(), str.GetLength() * sizeof(wchar_t));
return *this;
}
diff --git a/core/fxcrt/cfx_widetextbuf.h b/core/fxcrt/cfx_widetextbuf.h
index 389f2e52a3..77fe4141f9 100644
--- a/core/fxcrt/cfx_widetextbuf.h
+++ b/core/fxcrt/cfx_widetextbuf.h
@@ -19,14 +19,14 @@ class CFX_WideTextBuf : public CFX_BinaryBuf {
return reinterpret_cast<wchar_t*>(m_pBuffer.get());
}
- CFX_WideStringC AsStringC() const {
- return CFX_WideStringC(reinterpret_cast<const wchar_t*>(m_pBuffer.get()),
- m_DataSize / sizeof(wchar_t));
- }
- CFX_WideString MakeString() const {
- return CFX_WideString(reinterpret_cast<const wchar_t*>(m_pBuffer.get()),
+ WideStringView AsStringView() const {
+ return WideStringView(reinterpret_cast<const wchar_t*>(m_pBuffer.get()),
m_DataSize / sizeof(wchar_t));
}
+ WideString MakeString() const {
+ return WideString(reinterpret_cast<const wchar_t*>(m_pBuffer.get()),
+ m_DataSize / sizeof(wchar_t));
+ }
void Delete(int start_index, int count) {
CFX_BinaryBuf::Delete(start_index * sizeof(wchar_t),
@@ -36,8 +36,8 @@ class CFX_WideTextBuf : public CFX_BinaryBuf {
CFX_WideTextBuf& operator<<(int i);
CFX_WideTextBuf& operator<<(double f);
CFX_WideTextBuf& operator<<(const wchar_t* lpsz);
- CFX_WideTextBuf& operator<<(const CFX_WideStringC& str);
- CFX_WideTextBuf& operator<<(const CFX_WideString& str);
+ CFX_WideTextBuf& operator<<(const WideStringView& str);
+ CFX_WideTextBuf& operator<<(const WideString& str);
CFX_WideTextBuf& operator<<(const CFX_WideTextBuf& buf);
};
diff --git a/core/fxcrt/css/cfx_csscomputedstyle.cpp b/core/fxcrt/css/cfx_csscomputedstyle.cpp
index 953c107ec3..aae88a364a 100644
--- a/core/fxcrt/css/cfx_csscomputedstyle.cpp
+++ b/core/fxcrt/css/cfx_csscomputedstyle.cpp
@@ -14,8 +14,8 @@ CFX_CSSComputedStyle::CFX_CSSComputedStyle() {}
CFX_CSSComputedStyle::~CFX_CSSComputedStyle() {}
-bool CFX_CSSComputedStyle::GetCustomStyle(const CFX_WideString& wsName,
- CFX_WideString& wsValue) const {
+bool CFX_CSSComputedStyle::GetCustomStyle(const WideString& wsName,
+ WideString& wsValue) const {
for (auto iter = m_CustomProperties.rbegin();
iter != m_CustomProperties.rend(); iter++) {
if (wsName == iter->name()) {
@@ -32,7 +32,7 @@ int32_t CFX_CSSComputedStyle::CountFontFamilies() const {
: 0;
}
-const CFX_WideString CFX_CSSComputedStyle::GetFontFamily(int32_t index) const {
+const WideString CFX_CSSComputedStyle::GetFontFamily(int32_t index) const {
return m_InheritedData.m_pFontFamily->GetValue(index)
.As<CFX_CSSStringValue>()
->Value();
diff --git a/core/fxcrt/css/cfx_csscomputedstyle.h b/core/fxcrt/css/cfx_csscomputedstyle.h
index bb4b62bc2b..b05339ac02 100644
--- a/core/fxcrt/css/cfx_csscomputedstyle.h
+++ b/core/fxcrt/css/cfx_csscomputedstyle.h
@@ -56,7 +56,7 @@ class CFX_CSSComputedStyle : public CFX_Retainable {
};
int32_t CountFontFamilies() const;
- const CFX_WideString GetFontFamily(int32_t index) const;
+ const WideString GetFontFamily(int32_t index) const;
uint16_t GetFontWeight() const;
CFX_CSSFontVariant GetFontVariant() const;
CFX_CSSFontStyle GetFontStyle() const;
@@ -91,8 +91,7 @@ class CFX_CSSComputedStyle : public CFX_Retainable {
void SetLetterSpacing(const CFX_CSSLength& letterSpacing);
void AddCustomStyle(const CFX_CSSCustomProperty& prop);
- bool GetCustomStyle(const CFX_WideString& wsName,
- CFX_WideString& wsValue) const;
+ bool GetCustomStyle(const WideString& wsName, WideString& wsValue) const;
InheritedData m_InheritedData;
NonInheritedData m_NonInheritedData;
diff --git a/core/fxcrt/css/cfx_csscustomproperty.cpp b/core/fxcrt/css/cfx_csscustomproperty.cpp
index 8bfb9d961e..353facd5f0 100644
--- a/core/fxcrt/css/cfx_csscustomproperty.cpp
+++ b/core/fxcrt/css/cfx_csscustomproperty.cpp
@@ -4,8 +4,8 @@
#include "core/fxcrt/css/cfx_csscustomproperty.h"
-CFX_CSSCustomProperty::CFX_CSSCustomProperty(const CFX_WideString& name,
- const CFX_WideString& value)
+CFX_CSSCustomProperty::CFX_CSSCustomProperty(const WideString& name,
+ const WideString& value)
: name_(name), value_(value) {}
CFX_CSSCustomProperty::CFX_CSSCustomProperty(const CFX_CSSCustomProperty& prop)
diff --git a/core/fxcrt/css/cfx_csscustomproperty.h b/core/fxcrt/css/cfx_csscustomproperty.h
index e062c3e953..15c3eca124 100644
--- a/core/fxcrt/css/cfx_csscustomproperty.h
+++ b/core/fxcrt/css/cfx_csscustomproperty.h
@@ -11,17 +11,16 @@
class CFX_CSSCustomProperty {
public:
- CFX_CSSCustomProperty(const CFX_WideString& name,
- const CFX_WideString& value);
+ CFX_CSSCustomProperty(const WideString& name, const WideString& value);
CFX_CSSCustomProperty(const CFX_CSSCustomProperty& prop);
~CFX_CSSCustomProperty();
- CFX_WideString name() const { return name_; }
- CFX_WideString value() const { return value_; }
+ WideString name() const { return name_; }
+ WideString value() const { return value_; }
private:
- CFX_WideString name_;
- CFX_WideString value_;
+ WideString name_;
+ WideString value_;
};
#endif // CORE_FXCRT_CSS_CFX_CSSCUSTOMPROPERTY_H_
diff --git a/core/fxcrt/css/cfx_cssdatatable.cpp b/core/fxcrt/css/cfx_cssdatatable.cpp
index 833b81b93b..53617b6a48 100644
--- a/core/fxcrt/css/cfx_cssdatatable.cpp
+++ b/core/fxcrt/css/cfx_cssdatatable.cpp
@@ -122,7 +122,7 @@ static_assert(g_iCSSPropertyCount ==
"Property table differs in size from property enum");
const CFX_CSSPropertyTable* CFX_GetCSSPropertyByName(
- const CFX_WideStringC& wsName) {
+ const WideStringView& wsName) {
ASSERT(!wsName.IsEmpty());
uint32_t dwHash = FX_HashCode_GetW(wsName, true);
int32_t iEnd = g_iCSSPropertyCount;
diff --git a/core/fxcrt/css/cfx_cssdatatable.h b/core/fxcrt/css/cfx_cssdatatable.h
index 43310c7d5c..63c303488e 100644
--- a/core/fxcrt/css/cfx_cssdatatable.h
+++ b/core/fxcrt/css/cfx_cssdatatable.h
@@ -23,7 +23,7 @@ struct CFX_CSSPropertyTable {
};
const CFX_CSSPropertyTable* CFX_GetCSSPropertyByName(
- const CFX_WideStringC& wsName);
+ const WideStringView& wsName);
const CFX_CSSPropertyTable* CFX_GetCSSPropertyByEnum(CFX_CSSProperty eName);
#endif // CORE_FXCRT_CSS_CFX_CSSDATATABLE_H_
diff --git a/core/fxcrt/css/cfx_cssdeclaration.cpp b/core/fxcrt/css/cfx_cssdeclaration.cpp
index 344fc842c4..f2c7d3930b 100644
--- a/core/fxcrt/css/cfx_cssdeclaration.cpp
+++ b/core/fxcrt/css/cfx_cssdeclaration.cpp
@@ -113,7 +113,7 @@ const CFX_CSSColorTable g_CFX_CSSColors[] = {
};
const CFX_CSSPropertyValueTable* GetCSSPropertyValueByName(
- const CFX_WideStringC& wsName) {
+ const WideStringView& wsName) {
ASSERT(!wsName.IsEmpty());
uint32_t dwHash = FX_HashCode_GetW(wsName, true);
int32_t iEnd = g_iCSSPropertyValueCount;
@@ -134,7 +134,7 @@ const CFX_CSSPropertyValueTable* GetCSSPropertyValueByName(
}
const CFX_CSSLengthUnitTable* GetCSSLengthUnitByName(
- const CFX_WideStringC& wsName) {
+ const WideStringView& wsName) {
ASSERT(!wsName.IsEmpty());
uint16_t wHash = FX_HashCode_GetW(wsName, true);
int32_t iEnd =
@@ -155,7 +155,7 @@ const CFX_CSSLengthUnitTable* GetCSSLengthUnitByName(
return nullptr;
}
-const CFX_CSSColorTable* GetCSSColorByName(const CFX_WideStringC& wsName) {
+const CFX_CSSColorTable* GetCSSColorByName(const WideStringView& wsName) {
ASSERT(!wsName.IsEmpty());
uint32_t dwHash = FX_HashCode_GetW(wsName, true);
int32_t iEnd = sizeof(g_CFX_CSSColors) / sizeof(CFX_CSSColorTable) - 1;
@@ -192,7 +192,7 @@ bool ParseCSSNumber(const wchar_t* pszValue,
eUnit = CFX_CSSNumberType::Percent;
} else if (iValueLen == 2) {
const CFX_CSSLengthUnitTable* pUnit =
- GetCSSLengthUnitByName(CFX_WideStringC(pszValue, 2));
+ GetCSSLengthUnitByName(WideStringView(pszValue, 2));
if (pUnit)
eUnit = pUnit->wValue;
}
@@ -273,7 +273,7 @@ bool CFX_CSSDeclaration::ParseCSSColor(const wchar_t* pszValue,
}
const CFX_CSSColorTable* pColor =
- GetCSSColorByName(CFX_WideStringC(pszValue, iValueLen));
+ GetCSSColorByName(WideStringView(pszValue, iValueLen));
if (!pColor)
return false;
@@ -308,7 +308,7 @@ void CFX_CSSDeclaration::AddPropertyHolder(CFX_CSSProperty eProperty,
}
void CFX_CSSDeclaration::AddProperty(const CFX_CSSPropertyTable* pTable,
- const CFX_WideStringC& value) {
+ const WideStringView& value) {
ASSERT(!value.IsEmpty());
const wchar_t* pszValue = value.unterminated_c_str();
@@ -422,8 +422,8 @@ void CFX_CSSDeclaration::AddProperty(const CFX_CSSPropertyTable* pTable,
}
}
-void CFX_CSSDeclaration::AddProperty(const CFX_WideString& prop,
- const CFX_WideString& value) {
+void CFX_CSSDeclaration::AddProperty(const WideString& prop,
+ const WideString& value) {
custom_properties_.push_back(
pdfium::MakeUnique<CFX_CSSCustomProperty>(prop, value));
}
@@ -442,7 +442,7 @@ CFX_RetainPtr<CFX_CSSValue> CFX_CSSDeclaration::ParseEnum(
const wchar_t* pszValue,
int32_t iValueLen) {
const CFX_CSSPropertyValueTable* pValue =
- GetCSSPropertyValueByName(CFX_WideStringC(pszValue, iValueLen));
+ GetCSSPropertyValueByName(WideStringView(pszValue, iValueLen));
return pValue ? pdfium::MakeRetain<CFX_CSSEnumValue>(pValue->eName) : nullptr;
}
@@ -466,7 +466,7 @@ CFX_RetainPtr<CFX_CSSValue> CFX_CSSDeclaration::ParseString(
return nullptr;
return pdfium::MakeRetain<CFX_CSSStringValue>(
- CFX_WideString(pszValue + iOffset, iValueLen));
+ WideString(pszValue + iOffset, iValueLen));
}
void CFX_CSSDeclaration::ParseValueListProperty(
@@ -502,7 +502,7 @@ void CFX_CSSDeclaration::ParseValueListProperty(
}
if (dwType & CFX_CSSVALUETYPE_MaybeEnum) {
const CFX_CSSPropertyValueTable* pValue =
- GetCSSPropertyValueByName(CFX_WideStringC(pszValue, iValueLen));
+ GetCSSPropertyValueByName(WideStringView(pszValue, iValueLen));
if (pValue) {
list.push_back(pdfium::MakeRetain<CFX_CSSEnumValue>(pValue->eName));
continue;
@@ -510,7 +510,7 @@ void CFX_CSSDeclaration::ParseValueListProperty(
}
if (dwType & CFX_CSSVALUETYPE_MaybeString) {
list.push_back(pdfium::MakeRetain<CFX_CSSStringValue>(
- CFX_WideString(pszValue, iValueLen)));
+ WideString(pszValue, iValueLen)));
}
break;
case CFX_CSSPrimitiveType::RGB:
@@ -614,12 +614,12 @@ bool CFX_CSSDeclaration::ParseBorderProperty(
}
case CFX_CSSPrimitiveType::String: {
const CFX_CSSColorTable* pColorItem =
- GetCSSColorByName(CFX_WideStringC(pszValue, iValueLen));
+ GetCSSColorByName(WideStringView(pszValue, iValueLen));
if (pColorItem)
continue;
const CFX_CSSPropertyValueTable* pValue =
- GetCSSPropertyValueByName(CFX_WideStringC(pszValue, iValueLen));
+ GetCSSPropertyValueByName(WideStringView(pszValue, iValueLen));
if (!pValue)
continue;
@@ -661,7 +661,7 @@ void CFX_CSSDeclaration::ParseFontProperty(const wchar_t* pszValue,
switch (eType) {
case CFX_CSSPrimitiveType::String: {
const CFX_CSSPropertyValueTable* pValue =
- GetCSSPropertyValueByName(CFX_WideStringC(pszValue, iValueLen));
+ GetCSSPropertyValueByName(WideStringView(pszValue, iValueLen));
if (pValue) {
switch (pValue->eName) {
case CFX_CSSPropertyValue::XxSmall:
@@ -710,7 +710,7 @@ void CFX_CSSDeclaration::ParseFontProperty(const wchar_t* pszValue,
}
if (pFontSize) {
familyList.push_back(pdfium::MakeRetain<CFX_CSSStringValue>(
- CFX_WideString(pszValue, iValueLen)));
+ WideString(pszValue, iValueLen)));
}
parser.m_Separator = ',';
break;
diff --git a/core/fxcrt/css/cfx_cssdeclaration.h b/core/fxcrt/css/cfx_cssdeclaration.h
index 7b39daef7e..dba1d44fc7 100644
--- a/core/fxcrt/css/cfx_cssdeclaration.h
+++ b/core/fxcrt/css/cfx_cssdeclaration.h
@@ -48,8 +48,8 @@ class CFX_CSSDeclaration {
bool empty() const { return properties_.empty(); }
void AddProperty(const CFX_CSSPropertyTable* pTable,
- const CFX_WideStringC& value);
- void AddProperty(const CFX_WideString& prop, const CFX_WideString& value);
+ const WideStringView& value);
+ void AddProperty(const WideString& prop, const WideString& value);
size_t PropertyCountForTesting() const;
diff --git a/core/fxcrt/css/cfx_cssrulecollection.cpp b/core/fxcrt/css/cfx_cssrulecollection.cpp
index 635ca91c72..2030518b69 100644
--- a/core/fxcrt/css/cfx_cssrulecollection.cpp
+++ b/core/fxcrt/css/cfx_cssrulecollection.cpp
@@ -28,7 +28,7 @@ void CFX_CSSRuleCollection::Clear() {
}
const std::vector<std::unique_ptr<CFX_CSSRuleCollection::Data>>*
-CFX_CSSRuleCollection::GetTagRuleData(const CFX_WideString& tagname) const {
+CFX_CSSRuleCollection::GetTagRuleData(const WideString& tagname) const {
auto it = m_TagRules.find(FX_HashCode_GetW(tagname.c_str(), true));
return it != m_TagRules.end() ? &it->second : nullptr;
}
diff --git a/core/fxcrt/css/cfx_cssrulecollection.h b/core/fxcrt/css/cfx_cssrulecollection.h
index 6b91c6bcd5..72ae58c55f 100644
--- a/core/fxcrt/css/cfx_cssrulecollection.h
+++ b/core/fxcrt/css/cfx_cssrulecollection.h
@@ -36,7 +36,7 @@ class CFX_CSSRuleCollection {
int32_t CountSelectors() const { return m_iSelectors; }
const std::vector<std::unique_ptr<Data>>* GetTagRuleData(
- const CFX_WideString& tagname) const;
+ const WideString& tagname) const;
private:
void AddRulesFrom(const CFX_CSSStyleSheet* pStyleSheet,
diff --git a/core/fxcrt/css/cfx_cssselector.cpp b/core/fxcrt/css/cfx_cssselector.cpp
index 6ee81f5610..3993dcae5c 100644
--- a/core/fxcrt/css/cfx_cssselector.cpp
+++ b/core/fxcrt/css/cfx_cssselector.cpp
@@ -31,7 +31,7 @@ CFX_CSSSelector::CFX_CSSSelector(CFX_CSSSelectorType eType,
int32_t iLen,
bool bIgnoreCase)
: m_eType(eType),
- m_dwHash(FX_HashCode_GetW(CFX_WideStringC(psz, iLen), bIgnoreCase)) {}
+ m_dwHash(FX_HashCode_GetW(WideStringView(psz, iLen), bIgnoreCase)) {}
CFX_CSSSelector::~CFX_CSSSelector() {}
@@ -49,7 +49,7 @@ CFX_CSSSelector* CFX_CSSSelector::GetNextSelector() const {
// static.
std::unique_ptr<CFX_CSSSelector> CFX_CSSSelector::FromString(
- const CFX_WideStringC& str) {
+ const WideStringView& str) {
ASSERT(!str.IsEmpty());
const wchar_t* psz = str.unterminated_c_str();
diff --git a/core/fxcrt/css/cfx_cssselector.h b/core/fxcrt/css/cfx_cssselector.h
index 9fff42a850..62f8b166cc 100644
--- a/core/fxcrt/css/cfx_cssselector.h
+++ b/core/fxcrt/css/cfx_cssselector.h
@@ -15,8 +15,7 @@
class CFX_CSSSelector {
public:
- static std::unique_ptr<CFX_CSSSelector> FromString(
- const CFX_WideStringC& str);
+ static std::unique_ptr<CFX_CSSSelector> FromString(const WideStringView& str);
CFX_CSSSelector(CFX_CSSSelectorType eType,
const wchar_t* psz,
diff --git a/core/fxcrt/css/cfx_cssstringvalue.cpp b/core/fxcrt/css/cfx_cssstringvalue.cpp
index b66c54505f..6ff2a33c9b 100644
--- a/core/fxcrt/css/cfx_cssstringvalue.cpp
+++ b/core/fxcrt/css/cfx_cssstringvalue.cpp
@@ -6,7 +6,7 @@
#include "core/fxcrt/css/cfx_cssstringvalue.h"
-CFX_CSSStringValue::CFX_CSSStringValue(const CFX_WideString& value)
+CFX_CSSStringValue::CFX_CSSStringValue(const WideString& value)
: CFX_CSSValue(CFX_CSSPrimitiveType::String), value_(value) {}
CFX_CSSStringValue::~CFX_CSSStringValue() {}
diff --git a/core/fxcrt/css/cfx_cssstringvalue.h b/core/fxcrt/css/cfx_cssstringvalue.h
index 7680360973..d72078a630 100644
--- a/core/fxcrt/css/cfx_cssstringvalue.h
+++ b/core/fxcrt/css/cfx_cssstringvalue.h
@@ -11,13 +11,13 @@
class CFX_CSSStringValue : public CFX_CSSValue {
public:
- explicit CFX_CSSStringValue(const CFX_WideString& value);
+ explicit CFX_CSSStringValue(const WideString& value);
~CFX_CSSStringValue() override;
- const CFX_WideString Value() const { return value_; }
+ const WideString Value() const { return value_; }
private:
- const CFX_WideString value_;
+ const WideString value_;
};
#endif // CORE_FXCRT_CSS_CFX_CSSSTRINGVALUE_H_
diff --git a/core/fxcrt/css/cfx_cssstyleselector.cpp b/core/fxcrt/css/cfx_cssstyleselector.cpp
index 9a2bc8c498..9ae2b876f7 100644
--- a/core/fxcrt/css/cfx_cssstyleselector.cpp
+++ b/core/fxcrt/css/cfx_cssstyleselector.cpp
@@ -50,7 +50,7 @@ void CFX_CSSStyleSelector::UpdateStyleIndex() {
}
std::vector<const CFX_CSSDeclaration*> CFX_CSSStyleSelector::MatchDeclarations(
- const CFX_WideString& tagname) {
+ const WideString& tagname) {
std::vector<const CFX_CSSDeclaration*> matchedDecls;
if (m_UARules.CountSelectors() == 0 || tagname.IsEmpty())
return matchedDecls;
@@ -66,7 +66,7 @@ std::vector<const CFX_CSSDeclaration*> CFX_CSSStyleSelector::MatchDeclarations(
return matchedDecls;
}
-bool CFX_CSSStyleSelector::MatchSelector(const CFX_WideString& tagname,
+bool CFX_CSSStyleSelector::MatchSelector(const WideString& tagname,
CFX_CSSSelector* pSel) {
// TODO(dsinclair): The code only supports a single level of selector at this
// point. None of the code using selectors required the complexity so lets
@@ -80,8 +80,8 @@ bool CFX_CSSStyleSelector::MatchSelector(const CFX_WideString& tagname,
void CFX_CSSStyleSelector::ComputeStyle(
const std::vector<const CFX_CSSDeclaration*>& declArray,
- const CFX_WideString& styleString,
- const CFX_WideString& alignString,
+ const WideString& styleString,
+ const WideString& alignString,
CFX_CSSComputedStyle* pDest) {
std::unique_ptr<CFX_CSSDeclaration> pDecl;
if (!styleString.IsEmpty() || !alignString.IsEmpty()) {
@@ -91,7 +91,7 @@ void CFX_CSSStyleSelector::ComputeStyle(
AppendInlineStyle(pDecl.get(), styleString);
if (!alignString.IsEmpty()) {
pDecl->AddProperty(CFX_GetCSSPropertyByEnum(CFX_CSSProperty::TextAlign),
- alignString.AsStringC());
+ alignString.AsStringView());
}
}
ApplyDeclarations(declArray, pDecl.get(), pDest);
@@ -137,29 +137,29 @@ void CFX_CSSStyleSelector::ExtractValues(
}
void CFX_CSSStyleSelector::AppendInlineStyle(CFX_CSSDeclaration* pDecl,
- const CFX_WideString& style) {
+ const WideString& style) {
ASSERT(pDecl && !style.IsEmpty());
auto pSyntax = pdfium::MakeUnique<CFX_CSSSyntaxParser>(
style.c_str(), style.GetLength(), 32, true);
int32_t iLen2 = 0;
const CFX_CSSPropertyTable* table = nullptr;
- CFX_WideString wsName;
+ WideString wsName;
while (1) {
CFX_CSSSyntaxStatus eStatus = pSyntax->DoSyntaxParse();
if (eStatus == CFX_CSSSyntaxStatus::PropertyName) {
- CFX_WideStringC strValue = pSyntax->GetCurrentString();
+ WideStringView strValue = pSyntax->GetCurrentString();
table = CFX_GetCSSPropertyByName(strValue);
if (!table)
- wsName = CFX_WideString(strValue);
+ wsName = WideString(strValue);
} else if (eStatus == CFX_CSSSyntaxStatus::PropertyValue) {
if (table || iLen2 > 0) {
- CFX_WideStringC strValue = pSyntax->GetCurrentString();
+ WideStringView strValue = pSyntax->GetCurrentString();
if (!strValue.IsEmpty()) {
if (table)
pDecl->AddProperty(table, strValue);
else if (iLen2 > 0)
- pDecl->AddProperty(wsName, CFX_WideString(strValue));
+ pDecl->AddProperty(wsName, WideString(strValue));
}
}
} else {
diff --git a/core/fxcrt/css/cfx_cssstyleselector.h b/core/fxcrt/css/cfx_cssstyleselector.h
index 143e51ee68..b59e3048d6 100644
--- a/core/fxcrt/css/cfx_cssstyleselector.h
+++ b/core/fxcrt/css/cfx_cssstyleselector.h
@@ -39,18 +39,17 @@ class CFX_CSSStyleSelector {
// adds non-inherited data from the parent style. Attempting to copy
// internally will fail as you'll lose the non-inherited data.
void ComputeStyle(const std::vector<const CFX_CSSDeclaration*>& declArray,
- const CFX_WideString& styleString,
- const CFX_WideString& alignString,
+ const WideString& styleString,
+ const WideString& alignString,
CFX_CSSComputedStyle* pDestStyle);
std::vector<const CFX_CSSDeclaration*> MatchDeclarations(
- const CFX_WideString& tagname);
+ const WideString& tagname);
private:
- bool MatchSelector(const CFX_WideString& tagname, CFX_CSSSelector* pSel);
+ bool MatchSelector(const WideString& tagname, CFX_CSSSelector* pSel);
- void AppendInlineStyle(CFX_CSSDeclaration* pDecl,
- const CFX_WideString& style);
+ void AppendInlineStyle(CFX_CSSDeclaration* pDecl, const WideString& style);
void ApplyDeclarations(
const std::vector<const CFX_CSSDeclaration*>& declArray,
const CFX_CSSDeclaration* extraDecl,
diff --git a/core/fxcrt/css/cfx_cssstylesheet.cpp b/core/fxcrt/css/cfx_cssstylesheet.cpp
index 9bd25c044f..183765f3b0 100644
--- a/core/fxcrt/css/cfx_cssstylesheet.cpp
+++ b/core/fxcrt/css/cfx_cssstylesheet.cpp
@@ -63,32 +63,32 @@ CFX_CSSSyntaxStatus CFX_CSSStyleSheet::LoadStyleRule(
CFX_CSSStyleRule* pStyleRule = nullptr;
int32_t iValueLen = 0;
const CFX_CSSPropertyTable* propertyTable = nullptr;
- CFX_WideString wsName;
+ WideString wsName;
while (1) {
switch (pSyntax->DoSyntaxParse()) {
case CFX_CSSSyntaxStatus::Selector: {
- CFX_WideStringC strValue = pSyntax->GetCurrentString();
+ WideStringView strValue = pSyntax->GetCurrentString();
auto pSelector = CFX_CSSSelector::FromString(strValue);
if (pSelector)
selectors.push_back(std::move(pSelector));
break;
}
case CFX_CSSSyntaxStatus::PropertyName: {
- CFX_WideStringC strValue = pSyntax->GetCurrentString();
+ WideStringView strValue = pSyntax->GetCurrentString();
propertyTable = CFX_GetCSSPropertyByName(strValue);
if (!propertyTable)
- wsName = CFX_WideString(strValue);
+ wsName = WideString(strValue);
break;
}
case CFX_CSSSyntaxStatus::PropertyValue: {
if (propertyTable || iValueLen > 0) {
- CFX_WideStringC strValue = pSyntax->GetCurrentString();
+ WideStringView strValue = pSyntax->GetCurrentString();
auto* decl = pStyleRule->GetDeclaration();
if (!strValue.IsEmpty()) {
if (propertyTable) {
decl->AddProperty(propertyTable, strValue);
} else {
- decl->AddProperty(wsName, CFX_WideString(strValue));
+ decl->AddProperty(wsName, WideString(strValue));
}
}
}
diff --git a/core/fxcrt/css/cfx_cssstylesheet_unittest.cpp b/core/fxcrt/css/cfx_cssstylesheet_unittest.cpp
index 4194a70490..abcd2f6972 100644
--- a/core/fxcrt/css/cfx_cssstylesheet_unittest.cpp
+++ b/core/fxcrt/css/cfx_cssstylesheet_unittest.cpp
@@ -28,7 +28,7 @@ class CFX_CSSStyleSheetTest : public testing::Test {
void TearDown() override { decl_ = nullptr; }
void LoadAndVerifyDecl(const wchar_t* buf,
- const std::vector<CFX_WideString>& selectors,
+ const std::vector<WideString>& selectors,
size_t decl_count) {
ASSERT(sheet_);
@@ -39,7 +39,7 @@ class CFX_CSSStyleSheetTest : public testing::Test {
EXPECT_EQ(selectors.size(), style->CountSelectorLists());
for (size_t i = 0; i < selectors.size(); i++) {
- uint32_t hash = FX_HashCode_GetW(selectors[i].AsStringC(), true);
+ uint32_t hash = FX_HashCode_GetW(selectors[i].AsStringView(), true);
EXPECT_EQ(hash, style->GetSelectorList(i)->GetNameHash());
}
diff --git a/core/fxcrt/css/cfx_csssyntaxparser.cpp b/core/fxcrt/css/cfx_csssyntaxparser.cpp
index c8082e87fb..066b82b5d6 100644
--- a/core/fxcrt/css/cfx_csssyntaxparser.cpp
+++ b/core/fxcrt/css/cfx_csssyntaxparser.cpp
@@ -223,6 +223,6 @@ bool CFX_CSSSyntaxParser::RestoreMode() {
return true;
}
-CFX_WideStringC CFX_CSSSyntaxParser::GetCurrentString() const {
- return CFX_WideStringC(m_TextData.GetBuffer(), m_iTextDataLen);
+WideStringView CFX_CSSSyntaxParser::GetCurrentString() const {
+ return WideStringView(m_TextData.GetBuffer(), m_iTextDataLen);
}
diff --git a/core/fxcrt/css/cfx_csssyntaxparser.h b/core/fxcrt/css/cfx_csssyntaxparser.h
index 9ddedfe4a7..778f9a3272 100644
--- a/core/fxcrt/css/cfx_csssyntaxparser.h
+++ b/core/fxcrt/css/cfx_csssyntaxparser.h
@@ -47,7 +47,7 @@ class CFX_CSSSyntaxParser {
~CFX_CSSSyntaxParser();
CFX_CSSSyntaxStatus DoSyntaxParse();
- CFX_WideStringC GetCurrentString() const;
+ WideStringView GetCurrentString() const;
protected:
void SwitchMode(CFX_CSSSyntaxMode eMode);
diff --git a/core/fxcrt/css/cfx_cssvaluelistparser_unittest.cpp b/core/fxcrt/css/cfx_cssvaluelistparser_unittest.cpp
index 510c96251d..62a542bc52 100644
--- a/core/fxcrt/css/cfx_cssvaluelistparser_unittest.cpp
+++ b/core/fxcrt/css/cfx_cssvaluelistparser_unittest.cpp
@@ -18,25 +18,25 @@ TEST(CFX_CSSValueListParserTest, rgb_short) {
auto parser = pdfium::MakeUnique<CFX_CSSValueListParser>(L"#abc", 4, L' ');
EXPECT_TRUE(parser->NextValue(type, start, len));
EXPECT_EQ(CFX_CSSPrimitiveType::RGB, type);
- EXPECT_EQ(L"#abc", CFX_WideString(start, len));
+ EXPECT_EQ(L"#abc", WideString(start, len));
EXPECT_FALSE(parser->NextValue(type, start, len));
parser = pdfium::MakeUnique<CFX_CSSValueListParser>(L"#abcdef", 7, L' ');
EXPECT_TRUE(parser->NextValue(type, start, len));
EXPECT_EQ(CFX_CSSPrimitiveType::RGB, type);
- EXPECT_EQ(L"#abcdef", CFX_WideString(start, len));
+ EXPECT_EQ(L"#abcdef", WideString(start, len));
EXPECT_FALSE(parser->NextValue(type, start, len));
parser =
pdfium::MakeUnique<CFX_CSSValueListParser>(L"rgb(1, 255, 4)", 14, L' ');
EXPECT_TRUE(parser->NextValue(type, start, len));
EXPECT_EQ(CFX_CSSPrimitiveType::RGB, type);
- EXPECT_EQ(L"rgb(1, 255, 4)", CFX_WideString(start, len));
+ EXPECT_EQ(L"rgb(1, 255, 4)", WideString(start, len));
parser = pdfium::MakeUnique<CFX_CSSValueListParser>(L"#abcdefghij", 11, L' ');
EXPECT_TRUE(parser->NextValue(type, start, len));
EXPECT_EQ(CFX_CSSPrimitiveType::Unknown, type);
- EXPECT_EQ(L"#abcdefghij", CFX_WideString(start, len));
+ EXPECT_EQ(L"#abcdefghij", WideString(start, len));
EXPECT_FALSE(parser->NextValue(type, start, len));
}
@@ -48,38 +48,38 @@ TEST(CFX_CSSValueListParserTest, number_parsing) {
auto parser = pdfium::MakeUnique<CFX_CSSValueListParser>(L"1234", 4, L' ');
EXPECT_TRUE(parser->NextValue(type, start, len));
EXPECT_EQ(CFX_CSSPrimitiveType::Number, type);
- EXPECT_EQ(L"1234", CFX_WideString(start, len));
+ EXPECT_EQ(L"1234", WideString(start, len));
parser = pdfium::MakeUnique<CFX_CSSValueListParser>(L"-1234", 5, L' ');
EXPECT_TRUE(parser->NextValue(type, start, len));
EXPECT_EQ(CFX_CSSPrimitiveType::Number, type);
- EXPECT_EQ(L"-1234", CFX_WideString(start, len));
+ EXPECT_EQ(L"-1234", WideString(start, len));
parser = pdfium::MakeUnique<CFX_CSSValueListParser>(L"+1234", 5, L' ');
EXPECT_TRUE(parser->NextValue(type, start, len));
EXPECT_EQ(CFX_CSSPrimitiveType::Number, type);
- EXPECT_EQ(L"+1234", CFX_WideString(start, len));
+ EXPECT_EQ(L"+1234", WideString(start, len));
parser = pdfium::MakeUnique<CFX_CSSValueListParser>(L".1234", 5, L' ');
EXPECT_TRUE(parser->NextValue(type, start, len));
EXPECT_EQ(CFX_CSSPrimitiveType::Number, type);
- EXPECT_EQ(L".1234", CFX_WideString(start, len));
+ EXPECT_EQ(L".1234", WideString(start, len));
parser = pdfium::MakeUnique<CFX_CSSValueListParser>(L"4321.1234", 9, L' ');
EXPECT_TRUE(parser->NextValue(type, start, len));
EXPECT_EQ(CFX_CSSPrimitiveType::Number, type);
- EXPECT_EQ(L"4321.1234", CFX_WideString(start, len));
+ EXPECT_EQ(L"4321.1234", WideString(start, len));
// TODO(dsinclair): These should probably fail but currently don't.
parser = pdfium::MakeUnique<CFX_CSSValueListParser>(L"4321.12.34", 10, L' ');
EXPECT_TRUE(parser->NextValue(type, start, len));
EXPECT_EQ(CFX_CSSPrimitiveType::Number, type);
- EXPECT_EQ(L"4321.12.34", CFX_WideString(start, len));
+ EXPECT_EQ(L"4321.12.34", WideString(start, len));
parser = pdfium::MakeUnique<CFX_CSSValueListParser>(L"43a1.12.34", 10, L' ');
EXPECT_TRUE(parser->NextValue(type, start, len));
EXPECT_EQ(CFX_CSSPrimitiveType::Number, type);
- EXPECT_EQ(L"43a1.12.34", CFX_WideString(start, len));
+ EXPECT_EQ(L"43a1.12.34", WideString(start, len));
}
TEST(CFX_CSSValueListParserTest, string_parsing) {
@@ -91,18 +91,18 @@ TEST(CFX_CSSValueListParserTest, string_parsing) {
pdfium::MakeUnique<CFX_CSSValueListParser>(L"'string'", 8, L' ');
EXPECT_TRUE(parser->NextValue(type, start, len));
EXPECT_EQ(CFX_CSSPrimitiveType::String, type);
- EXPECT_EQ(L"string", CFX_WideString(start, len));
+ EXPECT_EQ(L"string", WideString(start, len));
parser = pdfium::MakeUnique<CFX_CSSValueListParser>(L"\"another string\"", 16,
L' ');
EXPECT_TRUE(parser->NextValue(type, start, len));
EXPECT_EQ(CFX_CSSPrimitiveType::String, type);
- EXPECT_EQ(L"another string", CFX_WideString(start, len));
+ EXPECT_EQ(L"another string", WideString(start, len));
parser = pdfium::MakeUnique<CFX_CSSValueListParser>(L"standalone", 10, L' ');
EXPECT_TRUE(parser->NextValue(type, start, len));
EXPECT_EQ(CFX_CSSPrimitiveType::String, type);
- EXPECT_EQ(L"standalone", CFX_WideString(start, len));
+ EXPECT_EQ(L"standalone", WideString(start, len));
}
TEST(CFX_CSSValueListParserTest, multiparsing) {
@@ -113,15 +113,15 @@ TEST(CFX_CSSValueListParserTest, multiparsing) {
auto parser = pdfium::MakeUnique<CFX_CSSValueListParser>(L"1, 2, 3", 7, L',');
EXPECT_TRUE(parser->NextValue(type, start, len));
EXPECT_EQ(CFX_CSSPrimitiveType::Number, type);
- EXPECT_EQ(L"1", CFX_WideString(start, len));
+ EXPECT_EQ(L"1", WideString(start, len));
EXPECT_TRUE(parser->NextValue(type, start, len));
EXPECT_EQ(CFX_CSSPrimitiveType::Number, type);
- EXPECT_EQ(L"2", CFX_WideString(start, len));
+ EXPECT_EQ(L"2", WideString(start, len));
EXPECT_TRUE(parser->NextValue(type, start, len));
EXPECT_EQ(CFX_CSSPrimitiveType::Number, type);
- EXPECT_EQ(L"3", CFX_WideString(start, len));
+ EXPECT_EQ(L"3", WideString(start, len));
EXPECT_FALSE(parser->NextValue(type, start, len));
@@ -129,13 +129,13 @@ TEST(CFX_CSSValueListParserTest, multiparsing) {
22, L',');
EXPECT_TRUE(parser->NextValue(type, start, len));
EXPECT_EQ(CFX_CSSPrimitiveType::String, type);
- EXPECT_EQ(L"str", CFX_WideString(start, len));
+ EXPECT_EQ(L"str", WideString(start, len));
EXPECT_TRUE(parser->NextValue(type, start, len));
EXPECT_EQ(CFX_CSSPrimitiveType::RGB, type);
- EXPECT_EQ(L"rgb(1, 2, 3)", CFX_WideString(start, len));
+ EXPECT_EQ(L"rgb(1, 2, 3)", WideString(start, len));
EXPECT_TRUE(parser->NextValue(type, start, len));
EXPECT_EQ(CFX_CSSPrimitiveType::Number, type);
- EXPECT_EQ(L"4", CFX_WideString(start, len));
+ EXPECT_EQ(L"4", WideString(start, len));
}
diff --git a/core/fxcrt/fx_bidi.cpp b/core/fxcrt/fx_bidi.cpp
index b7c7cacad8..cae0942550 100644
--- a/core/fxcrt/fx_bidi.cpp
+++ b/core/fxcrt/fx_bidi.cpp
@@ -581,7 +581,7 @@ void CFX_BidiChar::StartNewSegment(CFX_BidiChar::Direction direction) {
m_CurrentSegment.direction = direction;
}
-CFX_BidiString::CFX_BidiString(const CFX_WideString& str)
+CFX_BidiString::CFX_BidiString(const WideString& str)
: m_Str(str),
m_pBidiChar(pdfium::MakeUnique<CFX_BidiChar>()),
m_eOverallDirection(CFX_BidiChar::LEFT) {
diff --git a/core/fxcrt/fx_bidi.h b/core/fxcrt/fx_bidi.h
index 0dc426b57a..23f5d02dfd 100644
--- a/core/fxcrt/fx_bidi.h
+++ b/core/fxcrt/fx_bidi.h
@@ -54,7 +54,7 @@ class CFX_BidiString {
public:
using const_iterator = std::vector<CFX_BidiChar::Segment>::const_iterator;
- explicit CFX_BidiString(const CFX_WideString& str);
+ explicit CFX_BidiString(const WideString& str);
~CFX_BidiString();
// Overall direction is always LEFT or RIGHT, never NEUTRAL.
@@ -70,7 +70,7 @@ class CFX_BidiString {
const_iterator end() const { return m_Order.end(); }
private:
- const CFX_WideString m_Str;
+ const WideString m_Str;
std::unique_ptr<CFX_BidiChar> m_pBidiChar;
std::vector<CFX_BidiChar::Segment> m_Order;
CFX_BidiChar::Direction m_eOverallDirection;
diff --git a/core/fxcrt/fx_extension.cpp b/core/fxcrt/fx_extension.cpp
index 7f73a4ccad..4d0adb86ca 100644
--- a/core/fxcrt/fx_extension.cpp
+++ b/core/fxcrt/fx_extension.cpp
@@ -73,7 +73,7 @@ int32_t FXSYS_wcsnicmp(const wchar_t* s1, const wchar_t* s2, size_t count) {
return wch1 - wch2;
}
-uint32_t FX_HashCode_GetA(const CFX_ByteStringC& str, bool bIgnoreCase) {
+uint32_t FX_HashCode_GetA(const ByteStringView& str, bool bIgnoreCase) {
uint32_t dwHashCode = 0;
if (bIgnoreCase) {
for (const auto& c : str)
@@ -85,7 +85,7 @@ uint32_t FX_HashCode_GetA(const CFX_ByteStringC& str, bool bIgnoreCase) {
return dwHashCode;
}
-uint32_t FX_HashCode_GetW(const CFX_WideStringC& str, bool bIgnoreCase) {
+uint32_t FX_HashCode_GetW(const WideStringView& str, bool bIgnoreCase) {
uint32_t dwHashCode = 0;
if (bIgnoreCase) {
for (const auto& c : str)
diff --git a/core/fxcrt/fx_stream.cpp b/core/fxcrt/fx_stream.cpp
index c269ec91ed..a04e781d0d 100644
--- a/core/fxcrt/fx_stream.cpp
+++ b/core/fxcrt/fx_stream.cpp
@@ -95,16 +95,16 @@ bool IFX_SeekableStream::WriteBlock(const void* buffer, size_t size) {
return WriteBlock(buffer, GetSize(), size);
}
-bool IFX_SeekableStream::WriteString(const CFX_ByteStringC& str) {
+bool IFX_SeekableStream::WriteString(const ByteStringView& str) {
return WriteBlock(str.unterminated_c_str(), str.GetLength());
}
FX_FileHandle* FX_OpenFolder(const char* path) {
#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
auto pData = pdfium::MakeUnique<CFindFileDataA>();
- pData->m_Handle = FindFirstFileExA((CFX_ByteString(path) + "/*.*").c_str(),
- FindExInfoStandard, &pData->m_FindData,
- FindExSearchNameMatch, nullptr, 0);
+ pData->m_Handle =
+ FindFirstFileExA((ByteString(path) + "/*.*").c_str(), FindExInfoStandard,
+ &pData->m_FindData, FindExSearchNameMatch, nullptr, 0);
if (pData->m_Handle == INVALID_HANDLE_VALUE)
return nullptr;
@@ -116,7 +116,7 @@ FX_FileHandle* FX_OpenFolder(const char* path) {
}
bool FX_GetNextFile(FX_FileHandle* handle,
- CFX_ByteString* filename,
+ ByteString* filename,
bool* bFolder) {
if (!handle)
return false;
diff --git a/core/fxcrt/fx_stream.h b/core/fxcrt/fx_stream.h
index abf031dade..08331e9bf0 100644
--- a/core/fxcrt/fx_stream.h
+++ b/core/fxcrt/fx_stream.h
@@ -29,9 +29,7 @@ typedef DIR FX_FileHandle;
#endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
FX_FileHandle* FX_OpenFolder(const char* path);
-bool FX_GetNextFile(FX_FileHandle* handle,
- CFX_ByteString* filename,
- bool* bFolder);
+bool FX_GetNextFile(FX_FileHandle* handle, ByteString* filename, bool* bFolder);
void FX_CloseFolder(FX_FileHandle* handle);
#define FX_FILEMODE_Write 0
@@ -41,7 +39,7 @@ void FX_CloseFolder(FX_FileHandle* handle);
class IFX_WriteStream : virtual public CFX_Retainable {
public:
virtual bool WriteBlock(const void* pData, size_t size) = 0;
- virtual bool WriteString(const CFX_ByteStringC& str) = 0;
+ virtual bool WriteString(const ByteStringView& str) = 0;
};
class IFX_ArchiveStream : public IFX_WriteStream {
@@ -107,7 +105,7 @@ class IFX_SeekableStream : public IFX_SeekableReadStream,
FX_FILESIZE offset,
size_t size) override = 0;
bool WriteBlock(const void* buffer, size_t size) override;
- bool WriteString(const CFX_ByteStringC& str) override;
+ bool WriteString(const ByteStringView& str) override;
bool Flush() override = 0;
};
diff --git a/core/fxcrt/fx_string.cpp b/core/fxcrt/fx_string.cpp
index 075f29e538..ce4e187837 100644
--- a/core/fxcrt/fx_string.cpp
+++ b/core/fxcrt/fx_string.cpp
@@ -51,8 +51,8 @@ class CFX_UTF8Encoder {
// The data returned by GetResult() is invalidated when this is modified by
// appending any data.
- CFX_ByteStringC GetResult() const {
- return CFX_ByteStringC(m_Buffer.data(), m_Buffer.size());
+ ByteStringView GetResult() const {
+ return ByteStringView(m_Buffer.data(), m_Buffer.size());
}
private:
@@ -61,14 +61,14 @@ class CFX_UTF8Encoder {
} // namespace
-CFX_ByteString FX_UTF8Encode(const CFX_WideStringC& wsStr) {
+ByteString FX_UTF8Encode(const WideStringView& wsStr) {
FX_STRSIZE len = wsStr.GetLength();
const wchar_t* pStr = wsStr.unterminated_c_str();
CFX_UTF8Encoder encoder;
while (len-- > 0)
encoder.Input(*pStr++);
- return CFX_ByteString(encoder.GetResult());
+ return ByteString(encoder.GetResult());
}
namespace {
@@ -84,7 +84,7 @@ float FractionalScale(size_t scale_factor, int value) {
} // namespace
-bool FX_atonum(const CFX_ByteStringC& strc, void* pData) {
+bool FX_atonum(const ByteStringView& strc, void* pData) {
if (strc.Contains('.')) {
float* pFloat = static_cast<float*>(pData);
*pFloat = FX_atof(strc);
@@ -141,7 +141,7 @@ bool FX_atonum(const CFX_ByteStringC& strc, void* pData) {
return true;
}
-float FX_atof(const CFX_ByteStringC& strc) {
+float FX_atof(const ByteStringView& strc) {
if (strc.IsEmpty())
return 0.0;
@@ -180,7 +180,7 @@ float FX_atof(const CFX_ByteStringC& strc) {
return bNegative ? -value : value;
}
-float FX_atof(const CFX_WideStringC& wsStr) {
+float FX_atof(const WideStringView& wsStr) {
return FX_atof(FX_UTF8Encode(wsStr).c_str());
}
diff --git a/core/fxcrt/fx_string.h b/core/fxcrt/fx_string.h
index 9cc0b251eb..0481a15d34 100644
--- a/core/fxcrt/fx_string.h
+++ b/core/fxcrt/fx_string.h
@@ -7,17 +7,17 @@
#ifndef CORE_FXCRT_FX_STRING_H_
#define CORE_FXCRT_FX_STRING_H_
-#include "core/fxcrt/cfx_bytestring.h"
-#include "core/fxcrt/cfx_widestring.h"
+#include "core/fxcrt/bytestring.h"
+#include "core/fxcrt/widestring.h"
#define FXBSTR_ID(c1, c2, c3, c4) \
(((uint32_t)c1 << 24) | ((uint32_t)c2 << 16) | ((uint32_t)c3 << 8) | \
((uint32_t)c4))
-CFX_ByteString FX_UTF8Encode(const CFX_WideStringC& wsStr);
-float FX_atof(const CFX_ByteStringC& str);
-float FX_atof(const CFX_WideStringC& wsStr);
-bool FX_atonum(const CFX_ByteStringC& str, void* pData);
+ByteString FX_UTF8Encode(const WideStringView& wsStr);
+float FX_atof(const ByteStringView& str);
+float FX_atof(const WideStringView& wsStr);
+bool FX_atonum(const ByteStringView& str, void* pData);
FX_STRSIZE FX_ftoa(float f, char* buf);
#endif // CORE_FXCRT_FX_STRING_H_
diff --git a/core/fxcrt/ifx_fileaccess.h b/core/fxcrt/ifx_fileaccess.h
index e818303d85..9bfe2b4e63 100644
--- a/core/fxcrt/ifx_fileaccess.h
+++ b/core/fxcrt/ifx_fileaccess.h
@@ -19,8 +19,8 @@ class IFX_FileAccess {
static std::unique_ptr<IFX_FileAccess> Create();
virtual ~IFX_FileAccess() {}
- virtual bool Open(const CFX_ByteStringC& fileName, uint32_t dwMode) = 0;
- virtual bool Open(const CFX_WideStringC& fileName, uint32_t dwMode) = 0;
+ virtual bool Open(const ByteStringView& fileName, uint32_t dwMode) = 0;
+ virtual bool Open(const WideStringView& fileName, uint32_t dwMode) = 0;
virtual void Close() = 0;
virtual FX_FILESIZE GetSize() const = 0;
virtual FX_FILESIZE GetPosition() const = 0;
diff --git a/core/fxcrt/ifx_locale.h b/core/fxcrt/ifx_locale.h
index 5039aec6f0..5918e7a183 100644
--- a/core/fxcrt/ifx_locale.h
+++ b/core/fxcrt/ifx_locale.h
@@ -58,19 +58,19 @@ class IFX_Locale {
public:
virtual ~IFX_Locale() {}
- virtual CFX_WideString GetName() const = 0;
- virtual CFX_WideString GetNumbericSymbol(FX_LOCALENUMSYMBOL eType) const = 0;
- virtual CFX_WideString GetDateTimeSymbols() const = 0;
- virtual CFX_WideString GetMonthName(int32_t nMonth, bool bAbbr) const = 0;
- virtual CFX_WideString GetDayName(int32_t nWeek, bool bAbbr) const = 0;
- virtual CFX_WideString GetMeridiemName(bool bAM) const = 0;
+ virtual WideString GetName() const = 0;
+ virtual WideString GetNumbericSymbol(FX_LOCALENUMSYMBOL eType) const = 0;
+ virtual WideString GetDateTimeSymbols() const = 0;
+ virtual WideString GetMonthName(int32_t nMonth, bool bAbbr) const = 0;
+ virtual WideString GetDayName(int32_t nWeek, bool bAbbr) const = 0;
+ virtual WideString GetMeridiemName(bool bAM) const = 0;
virtual FX_TIMEZONE GetTimeZone() const = 0;
- virtual CFX_WideString GetEraName(bool bAD) const = 0;
- virtual CFX_WideString GetDatePattern(
+ virtual WideString GetEraName(bool bAD) const = 0;
+ virtual WideString GetDatePattern(
FX_LOCALEDATETIMESUBCATEGORY eType) const = 0;
- virtual CFX_WideString GetTimePattern(
+ virtual WideString GetTimePattern(
FX_LOCALEDATETIMESUBCATEGORY eType) const = 0;
- virtual CFX_WideString GetNumPattern(FX_LOCALENUMSUBCATEGORY eType) const = 0;
+ virtual WideString GetNumPattern(FX_LOCALENUMSUBCATEGORY eType) const = 0;
};
#endif // CORE_FXCRT_IFX_LOCALE_H_
diff --git a/core/fxcrt/cfx_string_c_template.h b/core/fxcrt/string_view_template.h
index 9123fc234b..21426acaeb 100644
--- a/core/fxcrt/cfx_string_c_template.h
+++ b/core/fxcrt/string_view_template.h
@@ -4,8 +4,8 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef CORE_FXCRT_CFX_STRING_C_TEMPLATE_H_
-#define CORE_FXCRT_CFX_STRING_C_TEMPLATE_H_
+#ifndef CORE_FXCRT_STRING_VIEW_TEMPLATE_H_
+#define CORE_FXCRT_STRING_VIEW_TEMPLATE_H_
#include <algorithm>
#include <iterator>
@@ -18,61 +18,63 @@
#include "third_party/base/optional.h"
#include "third_party/base/stl_util.h"
+namespace fxcrt {
+
// An immutable string with caller-provided storage which must outlive the
// string itself. These are not necessarily nul-terminated, so that substring
// extraction (via the Mid(), Left(), and Right() methods) is copy-free.
template <typename T>
-class CFX_StringCTemplate {
+class StringViewTemplate {
public:
using CharType = T;
using UnsignedType = typename std::make_unsigned<CharType>::type;
using const_iterator = const CharType*;
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
- CFX_StringCTemplate() : m_Ptr(nullptr), m_Length(0) {}
+ StringViewTemplate() : m_Ptr(nullptr), m_Length(0) {}
// Deliberately implicit to avoid calling on every string literal.
// NOLINTNEXTLINE(runtime/explicit)
- CFX_StringCTemplate(const CharType* ptr)
+ StringViewTemplate(const CharType* ptr)
: m_Ptr(reinterpret_cast<const UnsignedType*>(ptr)),
m_Length(ptr ? FXSYS_len(ptr) : 0) {}
- CFX_StringCTemplate(const CharType* ptr, FX_STRSIZE len)
+ StringViewTemplate(const CharType* ptr, FX_STRSIZE len)
: m_Ptr(reinterpret_cast<const UnsignedType*>(ptr)), m_Length(len) {}
template <typename U = UnsignedType>
- CFX_StringCTemplate(
+ StringViewTemplate(
const UnsignedType* ptr,
FX_STRSIZE size,
typename std::enable_if<!std::is_same<U, CharType>::value>::type* = 0)
: m_Ptr(ptr), m_Length(size) {}
// Deliberately implicit to avoid calling on every string literal.
- // |ch| must be an lvalue that outlives the the CFX_StringCTemplate.
+ // |ch| must be an lvalue that outlives the the StringViewTemplate.
// NOLINTNEXTLINE(runtime/explicit)
- CFX_StringCTemplate(CharType& ch) {
+ StringViewTemplate(CharType& ch) {
m_Ptr = reinterpret_cast<const UnsignedType*>(&ch);
m_Length = 1;
}
- CFX_StringCTemplate(const CFX_StringCTemplate& src) {
+ StringViewTemplate(const StringViewTemplate& src) {
m_Ptr = src.m_Ptr;
m_Length = src.m_Length;
}
// Any changes to |vec| invalidate the string.
- explicit CFX_StringCTemplate(const std::vector<UnsignedType>& vec) {
+ explicit StringViewTemplate(const std::vector<UnsignedType>& vec) {
m_Length = pdfium::CollectionSize<FX_STRSIZE>(vec);
m_Ptr = m_Length ? vec.data() : nullptr;
}
- CFX_StringCTemplate& operator=(const CharType* src) {
+ StringViewTemplate& operator=(const CharType* src) {
m_Ptr = reinterpret_cast<const UnsignedType*>(src);
m_Length = src ? FXSYS_len(src) : 0;
return *this;
}
- CFX_StringCTemplate& operator=(const CFX_StringCTemplate& src) {
+ StringViewTemplate& operator=(const StringViewTemplate& src) {
m_Ptr = src.m_Ptr;
m_Length = src.m_Length;
return *this;
@@ -98,14 +100,14 @@ class CFX_StringCTemplate {
FXSYS_cmp(ptr, reinterpret_cast<const CharType*>(m_Ptr.Get()),
m_Length) == 0;
}
- bool operator==(const CFX_StringCTemplate& other) const {
+ bool operator==(const StringViewTemplate& other) const {
return other.m_Length == m_Length &&
FXSYS_cmp(reinterpret_cast<const CharType*>(other.m_Ptr.Get()),
reinterpret_cast<const CharType*>(m_Ptr.Get()),
m_Length) == 0;
}
bool operator!=(const CharType* ptr) const { return !(*this == ptr); }
- bool operator!=(const CFX_StringCTemplate& other) const {
+ bool operator!=(const StringViewTemplate& other) const {
return !(*this == other);
}
@@ -157,56 +159,56 @@ class CFX_StringCTemplate {
bool Contains(CharType ch) const { return Find(ch).has_value(); }
- CFX_StringCTemplate Mid(FX_STRSIZE first, FX_STRSIZE count) const {
+ StringViewTemplate Mid(FX_STRSIZE first, FX_STRSIZE count) const {
if (!m_Ptr.Get())
- return CFX_StringCTemplate();
+ return StringViewTemplate();
if (!IsValidIndex(first))
- return CFX_StringCTemplate();
+ return StringViewTemplate();
if (count == 0 || !IsValidLength(count))
- return CFX_StringCTemplate();
+ return StringViewTemplate();
if (!IsValidIndex(first + count - 1))
- return CFX_StringCTemplate();
+ return StringViewTemplate();
- return CFX_StringCTemplate(m_Ptr.Get() + first, count);
+ return StringViewTemplate(m_Ptr.Get() + first, count);
}
- CFX_StringCTemplate Left(FX_STRSIZE count) const {
+ StringViewTemplate Left(FX_STRSIZE count) const {
if (count == 0 || !IsValidLength(count))
- return CFX_StringCTemplate();
+ return StringViewTemplate();
return Mid(0, count);
}
- CFX_StringCTemplate Right(FX_STRSIZE count) const {
+ StringViewTemplate Right(FX_STRSIZE count) const {
if (count == 0 || !IsValidLength(count))
- return CFX_StringCTemplate();
+ return StringViewTemplate();
return Mid(GetLength() - count, count);
}
- CFX_StringCTemplate TrimmedRight(CharType ch) const {
+ StringViewTemplate TrimmedRight(CharType ch) const {
if (IsEmpty())
- return CFX_StringCTemplate();
+ return StringViewTemplate();
FX_STRSIZE pos = GetLength();
while (pos && CharAt(pos - 1) == ch)
pos--;
if (pos == 0)
- return CFX_StringCTemplate();
+ return StringViewTemplate();
- return CFX_StringCTemplate(m_Ptr.Get(), pos);
+ return StringViewTemplate(m_Ptr.Get(), pos);
}
- bool operator<(const CFX_StringCTemplate& that) const {
+ bool operator<(const StringViewTemplate& that) const {
int result = FXSYS_cmp(reinterpret_cast<const CharType*>(m_Ptr.Get()),
reinterpret_cast<const CharType*>(that.m_Ptr.Get()),
std::min(m_Length, that.m_Length));
return result < 0 || (result == 0 && m_Length < that.m_Length);
}
- bool operator>(const CFX_StringCTemplate& that) const {
+ bool operator>(const StringViewTemplate& that) const {
int result = FXSYS_cmp(reinterpret_cast<const CharType*>(m_Ptr.Get()),
reinterpret_cast<const CharType*>(that.m_Ptr.Get()),
std::min(m_Length, that.m_Length));
@@ -222,19 +224,24 @@ class CFX_StringCTemplate {
};
template <typename T>
-inline bool operator==(const T* lhs, const CFX_StringCTemplate<T>& rhs) {
+inline bool operator==(const T* lhs, const StringViewTemplate<T>& rhs) {
return rhs == lhs;
}
template <typename T>
-inline bool operator!=(const T* lhs, const CFX_StringCTemplate<T>& rhs) {
+inline bool operator!=(const T* lhs, const StringViewTemplate<T>& rhs) {
return rhs != lhs;
}
-extern template class CFX_StringCTemplate<char>;
-extern template class CFX_StringCTemplate<wchar_t>;
+extern template class StringViewTemplate<char>;
+extern template class StringViewTemplate<wchar_t>;
+
+using ByteStringView = StringViewTemplate<char>;
+using WideStringView = StringViewTemplate<wchar_t>;
+
+} // namespace fxcrt
-using CFX_ByteStringC = CFX_StringCTemplate<char>;
-using CFX_WideStringC = CFX_StringCTemplate<wchar_t>;
+using ByteStringView = fxcrt::ByteStringView;
+using WideStringView = fxcrt::WideStringView;
-#endif // CORE_FXCRT_CFX_STRING_C_TEMPLATE_H_
+#endif // CORE_FXCRT_STRING_VIEW_TEMPLATE_H_
diff --git a/core/fxcrt/cfx_widestring.cpp b/core/fxcrt/widestring.cpp
index aadd1a29ed..fa5c80130d 100644
--- a/core/fxcrt/cfx_widestring.cpp
+++ b/core/fxcrt/widestring.cpp
@@ -4,7 +4,7 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "core/fxcrt/cfx_widestring.h"
+#include "core/fxcrt/widestring.h"
#include <stddef.h>
@@ -21,9 +21,9 @@
#include "third_party/base/stl_util.h"
template class CFX_StringDataTemplate<wchar_t>;
-template class CFX_StringCTemplate<wchar_t>;
-template class CFX_StringPoolTemplate<CFX_WideString>;
-template struct std::hash<CFX_WideString>;
+template class fxcrt::StringViewTemplate<wchar_t>;
+template class CFX_StringPoolTemplate<WideString>;
+template struct std::hash<WideString>;
#define FORCE_ANSI 0x10000
#define FORCE_UNICODE 0x20000
@@ -261,16 +261,16 @@ bool IsValidCodePage(uint16_t codepage) {
}
#endif
-CFX_WideString GetWideString(uint16_t codepage, const CFX_ByteStringC& bstr) {
+WideString GetWideString(uint16_t codepage, const ByteStringView& bstr) {
ASSERT(IsValidCodePage(codepage));
int src_len = bstr.GetLength();
int dest_len = FXSYS_MultiByteToWideChar(
codepage, 0, bstr.unterminated_c_str(), src_len, nullptr, 0);
if (!dest_len)
- return CFX_WideString();
+ return WideString();
- CFX_WideString wstr;
+ WideString wstr;
wchar_t* dest_buf = wstr.GetBuffer(dest_len);
FXSYS_MultiByteToWideChar(codepage, 0, bstr.unterminated_c_str(), src_len,
dest_buf, dest_len);
@@ -280,40 +280,40 @@ CFX_WideString GetWideString(uint16_t codepage, const CFX_ByteStringC& bstr) {
} // namespace
-static_assert(sizeof(CFX_WideString) <= sizeof(wchar_t*),
+namespace fxcrt {
+
+static_assert(sizeof(WideString) <= sizeof(wchar_t*),
"Strings must not require more space than pointers");
-CFX_WideString::CFX_WideString() {}
+WideString::WideString() {}
-CFX_WideString::CFX_WideString(const CFX_WideString& other)
- : m_pData(other.m_pData) {}
+WideString::WideString(const WideString& other) : m_pData(other.m_pData) {}
-CFX_WideString::CFX_WideString(CFX_WideString&& other) noexcept {
+WideString::WideString(WideString&& other) noexcept {
m_pData.Swap(other.m_pData);
}
-CFX_WideString::CFX_WideString(const wchar_t* pStr, FX_STRSIZE nLen) {
+WideString::WideString(const wchar_t* pStr, FX_STRSIZE nLen) {
if (nLen)
m_pData.Reset(StringData::Create(pStr, nLen));
}
-CFX_WideString::CFX_WideString(wchar_t ch) {
+WideString::WideString(wchar_t ch) {
m_pData.Reset(StringData::Create(1));
m_pData->m_String[0] = ch;
}
-CFX_WideString::CFX_WideString(const wchar_t* ptr)
- : CFX_WideString(ptr, ptr ? FXSYS_wcslen(ptr) : 0) {}
+WideString::WideString(const wchar_t* ptr)
+ : WideString(ptr, ptr ? FXSYS_wcslen(ptr) : 0) {}
-CFX_WideString::CFX_WideString(const CFX_WideStringC& stringSrc) {
+WideString::WideString(const WideStringView& stringSrc) {
if (!stringSrc.IsEmpty()) {
m_pData.Reset(StringData::Create(stringSrc.unterminated_c_str(),
stringSrc.GetLength()));
}
}
-CFX_WideString::CFX_WideString(const CFX_WideStringC& str1,
- const CFX_WideStringC& str2) {
+WideString::WideString(const WideStringView& str1, const WideStringView& str2) {
FX_SAFE_STRSIZE nSafeLen = str1.GetLength();
nSafeLen += str2.GetLength();
@@ -327,8 +327,7 @@ CFX_WideString::CFX_WideString(const CFX_WideStringC& str1,
str2.GetLength());
}
-CFX_WideString::CFX_WideString(
- const std::initializer_list<CFX_WideStringC>& list) {
+WideString::WideString(const std::initializer_list<WideStringView>& list) {
FX_SAFE_STRSIZE nSafeLen = 0;
for (const auto& item : list)
nSafeLen += item.GetLength();
@@ -347,9 +346,9 @@ CFX_WideString::CFX_WideString(
}
}
-CFX_WideString::~CFX_WideString() {}
+WideString::~WideString() {}
-const CFX_WideString& CFX_WideString::operator=(const wchar_t* pStr) {
+const WideString& WideString::operator=(const wchar_t* pStr) {
if (!pStr || !pStr[0])
clear();
else
@@ -358,8 +357,7 @@ const CFX_WideString& CFX_WideString::operator=(const wchar_t* pStr) {
return *this;
}
-const CFX_WideString& CFX_WideString::operator=(
- const CFX_WideStringC& stringSrc) {
+const WideString& WideString::operator=(const WideStringView& stringSrc) {
if (stringSrc.IsEmpty())
clear();
else
@@ -368,41 +366,40 @@ const CFX_WideString& CFX_WideString::operator=(
return *this;
}
-const CFX_WideString& CFX_WideString::operator=(
- const CFX_WideString& stringSrc) {
+const WideString& WideString::operator=(const WideString& stringSrc) {
if (m_pData != stringSrc.m_pData)
m_pData = stringSrc.m_pData;
return *this;
}
-const CFX_WideString& CFX_WideString::operator+=(const wchar_t* pStr) {
+const WideString& WideString::operator+=(const wchar_t* pStr) {
if (pStr)
Concat(pStr, FXSYS_wcslen(pStr));
return *this;
}
-const CFX_WideString& CFX_WideString::operator+=(wchar_t ch) {
+const WideString& WideString::operator+=(wchar_t ch) {
Concat(&ch, 1);
return *this;
}
-const CFX_WideString& CFX_WideString::operator+=(const CFX_WideString& str) {
+const WideString& WideString::operator+=(const WideString& str) {
if (str.m_pData)
Concat(str.m_pData->m_String, str.m_pData->m_nDataLength);
return *this;
}
-const CFX_WideString& CFX_WideString::operator+=(const CFX_WideStringC& str) {
+const WideString& WideString::operator+=(const WideStringView& str) {
if (!str.IsEmpty())
Concat(str.unterminated_c_str(), str.GetLength());
return *this;
}
-bool CFX_WideString::operator==(const wchar_t* ptr) const {
+bool WideString::operator==(const wchar_t* ptr) const {
if (!m_pData)
return !ptr || !ptr[0];
@@ -413,7 +410,7 @@ bool CFX_WideString::operator==(const wchar_t* ptr) const {
wmemcmp(ptr, m_pData->m_String, m_pData->m_nDataLength) == 0;
}
-bool CFX_WideString::operator==(const CFX_WideStringC& str) const {
+bool WideString::operator==(const WideStringView& str) const {
if (!m_pData)
return str.IsEmpty();
@@ -422,7 +419,7 @@ bool CFX_WideString::operator==(const CFX_WideStringC& str) const {
str.GetLength()) == 0;
}
-bool CFX_WideString::operator==(const CFX_WideString& other) const {
+bool WideString::operator==(const WideString& other) const {
if (m_pData == other.m_pData)
return true;
@@ -437,7 +434,7 @@ bool CFX_WideString::operator==(const CFX_WideString& other) const {
m_pData->m_nDataLength) == 0;
}
-bool CFX_WideString::operator<(const CFX_WideString& str) const {
+bool WideString::operator<(const WideString& str) const {
if (m_pData == str.m_pData)
return false;
@@ -446,13 +443,13 @@ bool CFX_WideString::operator<(const CFX_WideString& str) const {
return result < 0 || (result == 0 && GetLength() < str.GetLength());
}
-void CFX_WideString::AssignCopy(const wchar_t* pSrcData, FX_STRSIZE nSrcLen) {
+void WideString::AssignCopy(const wchar_t* pSrcData, FX_STRSIZE nSrcLen) {
AllocBeforeWrite(nSrcLen);
m_pData->CopyContents(pSrcData, nSrcLen);
m_pData->m_nDataLength = nSrcLen;
}
-void CFX_WideString::ReallocBeforeWrite(FX_STRSIZE nNewLength) {
+void WideString::ReallocBeforeWrite(FX_STRSIZE nNewLength) {
if (m_pData && m_pData->CanOperateInPlace(nNewLength))
return;
@@ -473,7 +470,7 @@ void CFX_WideString::ReallocBeforeWrite(FX_STRSIZE nNewLength) {
m_pData.Swap(pNewData);
}
-void CFX_WideString::AllocBeforeWrite(FX_STRSIZE nNewLength) {
+void WideString::AllocBeforeWrite(FX_STRSIZE nNewLength) {
if (m_pData && m_pData->CanOperateInPlace(nNewLength))
return;
@@ -485,7 +482,7 @@ void CFX_WideString::AllocBeforeWrite(FX_STRSIZE nNewLength) {
m_pData.Reset(StringData::Create(nNewLength));
}
-void CFX_WideString::ReleaseBuffer(FX_STRSIZE nNewLength) {
+void WideString::ReleaseBuffer(FX_STRSIZE nNewLength) {
if (!m_pData)
return;
@@ -501,16 +498,16 @@ void CFX_WideString::ReleaseBuffer(FX_STRSIZE nNewLength) {
if (m_pData->m_nAllocLength - nNewLength >= 32) {
// Over arbitrary threshold, so pay the price to relocate. Force copy to
// always occur by holding a second reference to the string.
- CFX_WideString preserve(*this);
+ WideString preserve(*this);
ReallocBeforeWrite(nNewLength);
}
}
-void CFX_WideString::Reserve(FX_STRSIZE len) {
+void WideString::Reserve(FX_STRSIZE len) {
GetBuffer(len);
}
-wchar_t* CFX_WideString::GetBuffer(FX_STRSIZE nMinBufLength) {
+wchar_t* WideString::GetBuffer(FX_STRSIZE nMinBufLength) {
if (!m_pData) {
if (nMinBufLength == 0)
return nullptr;
@@ -535,7 +532,7 @@ wchar_t* CFX_WideString::GetBuffer(FX_STRSIZE nMinBufLength) {
return m_pData->m_String;
}
-FX_STRSIZE CFX_WideString::Delete(FX_STRSIZE index, FX_STRSIZE count) {
+FX_STRSIZE WideString::Delete(FX_STRSIZE index, FX_STRSIZE count) {
if (!m_pData)
return 0;
@@ -556,7 +553,7 @@ FX_STRSIZE CFX_WideString::Delete(FX_STRSIZE index, FX_STRSIZE count) {
return m_pData->m_nDataLength;
}
-void CFX_WideString::Concat(const wchar_t* pSrcData, FX_STRSIZE nSrcLen) {
+void WideString::Concat(const wchar_t* pSrcData, FX_STRSIZE nSrcLen) {
if (!pSrcData || nSrcLen == 0)
return;
@@ -578,16 +575,16 @@ void CFX_WideString::Concat(const wchar_t* pSrcData, FX_STRSIZE nSrcLen) {
m_pData.Swap(pNewData);
}
-CFX_ByteString CFX_WideString::UTF8Encode() const {
- return FX_UTF8Encode(AsStringC());
+ByteString WideString::UTF8Encode() const {
+ return FX_UTF8Encode(AsStringView());
}
-CFX_ByteString CFX_WideString::UTF16LE_Encode() const {
+ByteString WideString::UTF16LE_Encode() const {
if (!m_pData) {
- return CFX_ByteString("\0\0", 2);
+ return ByteString("\0\0", 2);
}
int len = m_pData->m_nDataLength;
- CFX_ByteString result;
+ ByteString result;
char* buffer = result.GetBuffer(len * 2 + 2);
for (int i = 0; i < len; i++) {
buffer[i * 2] = m_pData->m_String[i] & 0xff;
@@ -599,42 +596,42 @@ CFX_ByteString CFX_WideString::UTF16LE_Encode() const {
return result;
}
-CFX_WideString CFX_WideString::Mid(FX_STRSIZE first, FX_STRSIZE count) const {
+WideString WideString::Mid(FX_STRSIZE first, FX_STRSIZE count) const {
if (!m_pData)
- return CFX_WideString();
+ return WideString();
if (!IsValidIndex(first))
- return CFX_WideString();
+ return WideString();
if (count == 0 || !IsValidLength(count))
- return CFX_WideString();
+ return WideString();
if (!IsValidIndex(first + count - 1))
- return CFX_WideString();
+ return WideString();
if (first == 0 && count == GetLength())
return *this;
- CFX_WideString dest;
+ WideString dest;
AllocCopy(dest, count, first);
return dest;
}
-CFX_WideString CFX_WideString::Left(FX_STRSIZE count) const {
+WideString WideString::Left(FX_STRSIZE count) const {
if (count == 0 || !IsValidLength(count))
- return CFX_WideString();
+ return WideString();
return Mid(0, count);
}
-CFX_WideString CFX_WideString::Right(FX_STRSIZE count) const {
+WideString WideString::Right(FX_STRSIZE count) const {
if (count == 0 || !IsValidLength(count))
- return CFX_WideString();
+ return WideString();
return Mid(GetLength() - count, count);
}
-void CFX_WideString::AllocCopy(CFX_WideString& dest,
- FX_STRSIZE nCopyLen,
- FX_STRSIZE nCopyIndex) const {
+void WideString::AllocCopy(WideString& dest,
+ FX_STRSIZE nCopyLen,
+ FX_STRSIZE nCopyIndex) const {
if (nCopyLen == 0)
return;
@@ -643,9 +640,9 @@ void CFX_WideString::AllocCopy(CFX_WideString& dest,
dest.m_pData.Swap(pNewData);
}
-bool CFX_WideString::TryVSWPrintf(FX_STRSIZE size,
- const wchar_t* pFormat,
- va_list argList) {
+bool WideString::TryVSWPrintf(FX_STRSIZE size,
+ const wchar_t* pFormat,
+ va_list argList) {
GetBuffer(size);
if (!m_pData)
return true;
@@ -663,7 +660,7 @@ bool CFX_WideString::TryVSWPrintf(FX_STRSIZE size,
return bSufficientBuffer;
}
-void CFX_WideString::FormatV(const wchar_t* format, va_list argList) {
+void WideString::FormatV(const wchar_t* format, va_list argList) {
va_list argListCopy;
va_copy(argListCopy, argList);
int maxLen = vswprintf(nullptr, 0, format, argListCopy);
@@ -687,14 +684,14 @@ void CFX_WideString::FormatV(const wchar_t* format, va_list argList) {
}
}
-void CFX_WideString::Format(const wchar_t* pFormat, ...) {
+void WideString::Format(const wchar_t* pFormat, ...) {
va_list argList;
va_start(argList, pFormat);
FormatV(pFormat, argList);
va_end(argList);
}
-FX_STRSIZE CFX_WideString::Insert(FX_STRSIZE location, wchar_t ch) {
+FX_STRSIZE WideString::Insert(FX_STRSIZE location, wchar_t ch) {
const FX_STRSIZE cur_length = m_pData ? m_pData->m_nDataLength : 0;
if (!IsValidLength(location))
return cur_length;
@@ -708,8 +705,8 @@ FX_STRSIZE CFX_WideString::Insert(FX_STRSIZE location, wchar_t ch) {
return new_length;
}
-pdfium::Optional<FX_STRSIZE> CFX_WideString::Find(wchar_t ch,
- FX_STRSIZE start) const {
+pdfium::Optional<FX_STRSIZE> WideString::Find(wchar_t ch,
+ FX_STRSIZE start) const {
if (!m_pData)
return pdfium::Optional<FX_STRSIZE>();
@@ -723,8 +720,8 @@ pdfium::Optional<FX_STRSIZE> CFX_WideString::Find(wchar_t ch,
: pdfium::Optional<FX_STRSIZE>();
}
-pdfium::Optional<FX_STRSIZE> CFX_WideString::Find(const CFX_WideStringC& subStr,
- FX_STRSIZE start) const {
+pdfium::Optional<FX_STRSIZE> WideString::Find(const WideStringView& subStr,
+ FX_STRSIZE start) const {
if (!m_pData)
return pdfium::Optional<FX_STRSIZE>();
@@ -739,7 +736,7 @@ pdfium::Optional<FX_STRSIZE> CFX_WideString::Find(const CFX_WideStringC& subStr,
: pdfium::Optional<FX_STRSIZE>();
}
-void CFX_WideString::MakeLower() {
+void WideString::MakeLower() {
if (!m_pData)
return;
@@ -747,7 +744,7 @@ void CFX_WideString::MakeLower() {
FXSYS_wcslwr(m_pData->m_String);
}
-void CFX_WideString::MakeUpper() {
+void WideString::MakeUpper() {
if (!m_pData)
return;
@@ -755,7 +752,7 @@ void CFX_WideString::MakeUpper() {
FXSYS_wcsupr(m_pData->m_String);
}
-FX_STRSIZE CFX_WideString::Remove(wchar_t chRemove) {
+FX_STRSIZE WideString::Remove(wchar_t chRemove) {
if (!m_pData || m_pData->m_nDataLength < 1)
return 0;
@@ -789,8 +786,8 @@ FX_STRSIZE CFX_WideString::Remove(wchar_t chRemove) {
return count;
}
-FX_STRSIZE CFX_WideString::Replace(const CFX_WideStringC& pOld,
- const CFX_WideStringC& pNew) {
+FX_STRSIZE WideString::Replace(const WideStringView& pOld,
+ const WideStringView& pNew) {
if (!m_pData || pOld.IsEmpty())
return 0;
@@ -837,36 +834,36 @@ FX_STRSIZE CFX_WideString::Replace(const CFX_WideStringC& pOld,
}
// static
-CFX_WideString CFX_WideString::FromLocal(const CFX_ByteStringC& str) {
+WideString WideString::FromLocal(const ByteStringView& str) {
return FromCodePage(str, 0);
}
// static
-CFX_WideString CFX_WideString::FromCodePage(const CFX_ByteStringC& str,
- uint16_t codepage) {
+WideString WideString::FromCodePage(const ByteStringView& str,
+ uint16_t codepage) {
return GetWideString(codepage, str);
}
// static
-CFX_WideString CFX_WideString::FromUTF8(const CFX_ByteStringC& str) {
+WideString WideString::FromUTF8(const ByteStringView& str) {
if (str.IsEmpty())
- return CFX_WideString();
+ return WideString();
CFX_UTF8Decoder decoder;
for (FX_STRSIZE i = 0; i < str.GetLength(); i++)
decoder.Input(str[i]);
- return CFX_WideString(decoder.GetResult());
+ return WideString(decoder.GetResult());
}
// static
-CFX_WideString CFX_WideString::FromUTF16LE(const unsigned short* wstr,
- FX_STRSIZE wlen) {
+WideString WideString::FromUTF16LE(const unsigned short* wstr,
+ FX_STRSIZE wlen) {
if (!wstr || wlen == 0) {
- return CFX_WideString();
+ return WideString();
}
- CFX_WideString result;
+ WideString result;
wchar_t* buf = result.GetBuffer(wlen);
for (FX_STRSIZE i = 0; i < wlen; i++) {
buf[i] = wstr[i];
@@ -875,19 +872,19 @@ CFX_WideString CFX_WideString::FromUTF16LE(const unsigned short* wstr,
return result;
}
-void CFX_WideString::SetAt(FX_STRSIZE index, wchar_t c) {
+void WideString::SetAt(FX_STRSIZE index, wchar_t c) {
ASSERT(IsValidIndex(index));
ReallocBeforeWrite(m_pData->m_nDataLength);
m_pData->m_String[index] = c;
}
-int CFX_WideString::Compare(const wchar_t* lpsz) const {
+int WideString::Compare(const wchar_t* lpsz) const {
if (m_pData)
return wcscmp(m_pData->m_String, lpsz);
return (!lpsz || lpsz[0] == 0) ? 0 : -1;
}
-int CFX_WideString::Compare(const CFX_WideString& str) const {
+int WideString::Compare(const WideString& str) const {
if (!m_pData) {
if (!str.m_pData) {
return 0;
@@ -917,14 +914,14 @@ int CFX_WideString::Compare(const CFX_WideString& str) const {
return 0;
}
-int CFX_WideString::CompareNoCase(const wchar_t* lpsz) const {
+int WideString::CompareNoCase(const wchar_t* lpsz) const {
if (!m_pData) {
return (!lpsz || lpsz[0] == 0) ? 0 : -1;
}
return FXSYS_wcsicmp(m_pData->m_String, lpsz);
}
-FX_STRSIZE CFX_WideString::WStringLength(const unsigned short* str) {
+FX_STRSIZE WideString::WStringLength(const unsigned short* str) {
FX_STRSIZE len = 0;
if (str)
while (str[len])
@@ -932,7 +929,7 @@ FX_STRSIZE CFX_WideString::WStringLength(const unsigned short* str) {
return len;
}
-void CFX_WideString::TrimRight(const CFX_WideStringC& pTargets) {
+void WideString::TrimRight(const WideStringView& pTargets) {
if (IsEmpty() || pTargets.IsEmpty())
return;
@@ -947,16 +944,16 @@ void CFX_WideString::TrimRight(const CFX_WideStringC& pTargets) {
}
}
-void CFX_WideString::TrimRight(wchar_t chTarget) {
+void WideString::TrimRight(wchar_t chTarget) {
wchar_t str[2] = {chTarget, 0};
TrimRight(str);
}
-void CFX_WideString::TrimRight() {
+void WideString::TrimRight() {
TrimRight(L"\x09\x0a\x0b\x0c\x0d\x20");
}
-void CFX_WideString::TrimLeft(const CFX_WideStringC& pTargets) {
+void WideString::TrimLeft(const WideStringView& pTargets) {
if (!m_pData || pTargets.IsEmpty())
return;
@@ -986,12 +983,12 @@ void CFX_WideString::TrimLeft(const CFX_WideStringC& pTargets) {
m_pData->m_nDataLength = nDataLength;
}
-void CFX_WideString::TrimLeft(wchar_t chTarget) {
+void WideString::TrimLeft(wchar_t chTarget) {
wchar_t str[2] = {chTarget, 0};
TrimLeft(str);
}
-void CFX_WideString::TrimLeft() {
+void WideString::TrimLeft() {
TrimLeft(L"\x09\x0a\x0b\x0c\x0d\x20");
}
float FX_wtof(const wchar_t* str, int len) {
@@ -1028,28 +1025,30 @@ float FX_wtof(const wchar_t* str, int len) {
return bNegative ? -fraction : fraction;
}
-int CFX_WideString::GetInteger() const {
+int WideString::GetInteger() const {
return m_pData ? FXSYS_wtoi(m_pData->m_String) : 0;
}
-float CFX_WideString::GetFloat() const {
+float WideString::GetFloat() const {
return m_pData ? FX_wtof(m_pData->m_String, m_pData->m_nDataLength) : 0.0f;
}
-std::wostream& operator<<(std::wostream& os, const CFX_WideString& str) {
+std::wostream& operator<<(std::wostream& os, const WideString& str) {
return os.write(str.c_str(), str.GetLength());
}
-std::ostream& operator<<(std::ostream& os, const CFX_WideString& str) {
+std::ostream& operator<<(std::ostream& os, const WideString& str) {
os << str.UTF8Encode();
return os;
}
-std::wostream& operator<<(std::wostream& os, const CFX_WideStringC& str) {
+std::wostream& operator<<(std::wostream& os, const WideStringView& str) {
return os.write(str.unterminated_c_str(), str.GetLength());
}
-std::ostream& operator<<(std::ostream& os, const CFX_WideStringC& str) {
+std::ostream& operator<<(std::ostream& os, const WideStringView& str) {
os << FX_UTF8Encode(str);
return os;
}
+
+} // namespace fxcrt
diff --git a/core/fxcrt/widestring.h b/core/fxcrt/widestring.h
new file mode 100644
index 0000000000..8841c84093
--- /dev/null
+++ b/core/fxcrt/widestring.h
@@ -0,0 +1,277 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef CORE_FXCRT_WIDESTRING_H_
+#define CORE_FXCRT_WIDESTRING_H_
+
+#include <functional>
+#include <iterator>
+#include <utility>
+
+#include "core/fxcrt/cfx_retain_ptr.h"
+#include "core/fxcrt/cfx_string_data_template.h"
+#include "core/fxcrt/fx_memory.h"
+#include "core/fxcrt/fx_system.h"
+#include "core/fxcrt/string_view_template.h"
+#include "third_party/base/optional.h"
+
+class WideString_ConcatInPlace_Test;
+class fxcrt_WideStringPool_Test;
+
+namespace fxcrt {
+
+class ByteString;
+
+// A mutable string with shared buffers using copy-on-write semantics that
+// avoids the cost of std::string's iterator stability guarantees.
+class WideString {
+ public:
+ using CharType = wchar_t;
+ using const_iterator = const CharType*;
+ using const_reverse_iterator = std::reverse_iterator<const_iterator>;
+
+ WideString();
+ WideString(const WideString& other);
+ WideString(WideString&& other) noexcept;
+
+ // Deliberately implicit to avoid calling on every string literal.
+ // NOLINTNEXTLINE(runtime/explicit)
+ WideString(wchar_t ch);
+ // NOLINTNEXTLINE(runtime/explicit)
+ WideString(const wchar_t* ptr);
+
+ // No implicit conversions from byte strings.
+ // NOLINTNEXTLINE(runtime/explicit)
+ WideString(char) = delete;
+
+ WideString(const wchar_t* ptr, FX_STRSIZE len);
+
+ explicit WideString(const WideStringView& str);
+ WideString(const WideStringView& str1, const WideStringView& str2);
+ WideString(const std::initializer_list<WideStringView>& list);
+
+ ~WideString();
+
+ static WideString FromLocal(const ByteStringView& str);
+ static WideString FromCodePage(const ByteStringView& str, uint16_t codepage);
+
+ static WideString FromUTF8(const ByteStringView& str);
+ static WideString FromUTF16LE(const unsigned short* str, FX_STRSIZE len);
+
+ static FX_STRSIZE WStringLength(const unsigned short* str);
+
+ // Explicit conversion to C-style wide string.
+ // Note: Any subsequent modification of |this| will invalidate the result.
+ const wchar_t* c_str() const { return m_pData ? m_pData->m_String : L""; }
+
+ // Explicit conversion to WideStringView.
+ // Note: Any subsequent modification of |this| will invalidate the result.
+ WideStringView AsStringView() const {
+ return WideStringView(c_str(), GetLength());
+ }
+
+ // Note: Any subsequent modification of |this| will invalidate iterators.
+ const_iterator begin() const { return m_pData ? m_pData->m_String : nullptr; }
+ const_iterator end() const {
+ return m_pData ? m_pData->m_String + m_pData->m_nDataLength : nullptr;
+ }
+
+ // Note: Any subsequent modification of |this| will invalidate iterators.
+ const_reverse_iterator rbegin() const {
+ return const_reverse_iterator(end());
+ }
+ const_reverse_iterator rend() const {
+ return const_reverse_iterator(begin());
+ }
+
+ void clear() { m_pData.Reset(); }
+
+ FX_STRSIZE GetLength() const { return m_pData ? m_pData->m_nDataLength : 0; }
+ FX_STRSIZE GetStringLength() const {
+ return m_pData ? FXSYS_wcslen(m_pData->m_String) : 0;
+ }
+ bool IsEmpty() const { return !GetLength(); }
+ bool IsValidIndex(FX_STRSIZE index) const { return index < GetLength(); }
+ bool IsValidLength(FX_STRSIZE length) const { return length <= GetLength(); }
+
+ const WideString& operator=(const wchar_t* str);
+ const WideString& operator=(const WideString& stringSrc);
+ const WideString& operator=(const WideStringView& stringSrc);
+
+ const WideString& operator+=(const wchar_t* str);
+ const WideString& operator+=(wchar_t ch);
+ const WideString& operator+=(const WideString& str);
+ const WideString& operator+=(const WideStringView& str);
+
+ bool operator==(const wchar_t* ptr) const;
+ bool operator==(const WideStringView& str) const;
+ bool operator==(const WideString& other) const;
+
+ bool operator!=(const wchar_t* ptr) const { return !(*this == ptr); }
+ bool operator!=(const WideStringView& str) const { return !(*this == str); }
+ bool operator!=(const WideString& other) const { return !(*this == other); }
+
+ bool operator<(const WideString& str) const;
+
+ CharType operator[](const FX_STRSIZE index) const {
+ ASSERT(IsValidIndex(index));
+ return m_pData ? m_pData->m_String[index] : 0;
+ }
+
+ CharType First() const { return GetLength() ? (*this)[0] : 0; }
+ CharType Last() const { return GetLength() ? (*this)[GetLength() - 1] : 0; }
+
+ void SetAt(FX_STRSIZE index, wchar_t c);
+
+ int Compare(const wchar_t* str) const;
+ int Compare(const WideString& str) const;
+ int CompareNoCase(const wchar_t* str) const;
+
+ WideString Mid(FX_STRSIZE first, FX_STRSIZE count) const;
+ WideString Left(FX_STRSIZE count) const;
+ WideString Right(FX_STRSIZE count) const;
+
+ FX_STRSIZE Insert(FX_STRSIZE index, wchar_t ch);
+ FX_STRSIZE InsertAtFront(wchar_t ch) { return Insert(0, ch); }
+ FX_STRSIZE InsertAtBack(wchar_t ch) { return Insert(GetLength(), ch); }
+ FX_STRSIZE Delete(FX_STRSIZE index, FX_STRSIZE count = 1);
+
+ void Format(const wchar_t* lpszFormat, ...);
+ void FormatV(const wchar_t* lpszFormat, va_list argList);
+
+ void MakeLower();
+ void MakeUpper();
+
+ void TrimRight();
+ void TrimRight(wchar_t chTarget);
+ void TrimRight(const WideStringView& pTargets);
+
+ void TrimLeft();
+ void TrimLeft(wchar_t chTarget);
+ void TrimLeft(const WideStringView& pTargets);
+
+ void Reserve(FX_STRSIZE len);
+ wchar_t* GetBuffer(FX_STRSIZE len);
+ void ReleaseBuffer(FX_STRSIZE len);
+
+ int GetInteger() const;
+ float GetFloat() const;
+
+ pdfium::Optional<FX_STRSIZE> Find(const WideStringView& pSub,
+ FX_STRSIZE start = 0) const;
+ pdfium::Optional<FX_STRSIZE> Find(wchar_t ch, FX_STRSIZE start = 0) const;
+
+ bool Contains(const WideStringView& lpszSub, FX_STRSIZE start = 0) const {
+ return Find(lpszSub, start).has_value();
+ }
+
+ bool Contains(char ch, FX_STRSIZE start = 0) const {
+ return Find(ch, start).has_value();
+ }
+
+ FX_STRSIZE Replace(const WideStringView& pOld, const WideStringView& pNew);
+ FX_STRSIZE Remove(wchar_t ch);
+
+ ByteString UTF8Encode() const;
+ ByteString UTF16LE_Encode() const;
+
+ protected:
+ using StringData = CFX_StringDataTemplate<wchar_t>;
+
+ void ReallocBeforeWrite(FX_STRSIZE nLen);
+ void AllocBeforeWrite(FX_STRSIZE nLen);
+ void AllocCopy(WideString& dest,
+ FX_STRSIZE nCopyLen,
+ FX_STRSIZE nCopyIndex) const;
+ void AssignCopy(const wchar_t* pSrcData, FX_STRSIZE nSrcLen);
+ void Concat(const wchar_t* lpszSrcData, FX_STRSIZE nSrcLen);
+
+ // Returns true unless we ran out of space.
+ bool TryVSWPrintf(FX_STRSIZE size, const wchar_t* format, va_list argList);
+
+ CFX_RetainPtr<StringData> m_pData;
+
+ friend WideString_ConcatInPlace_Test;
+ friend fxcrt_WideStringPool_Test;
+};
+
+inline WideString operator+(const WideStringView& str1,
+ const WideStringView& str2) {
+ return WideString(str1, str2);
+}
+inline WideString operator+(const WideStringView& str1, const wchar_t* str2) {
+ return WideString(str1, str2);
+}
+inline WideString operator+(const wchar_t* str1, const WideStringView& str2) {
+ return WideString(str1, str2);
+}
+inline WideString operator+(const WideStringView& str1, wchar_t ch) {
+ return WideString(str1, WideStringView(ch));
+}
+inline WideString operator+(wchar_t ch, const WideStringView& str2) {
+ return WideString(ch, str2);
+}
+inline WideString operator+(const WideString& str1, const WideString& str2) {
+ return WideString(str1.AsStringView(), str2.AsStringView());
+}
+inline WideString operator+(const WideString& str1, wchar_t ch) {
+ return WideString(str1.AsStringView(), WideStringView(ch));
+}
+inline WideString operator+(wchar_t ch, const WideString& str2) {
+ return WideString(ch, str2.AsStringView());
+}
+inline WideString operator+(const WideString& str1, const wchar_t* str2) {
+ return WideString(str1.AsStringView(), str2);
+}
+inline WideString operator+(const wchar_t* str1, const WideString& str2) {
+ return WideString(str1, str2.AsStringView());
+}
+inline WideString operator+(const WideString& str1,
+ const WideStringView& str2) {
+ return WideString(str1.AsStringView(), str2);
+}
+inline WideString operator+(const WideStringView& str1,
+ const WideString& str2) {
+ return WideString(str1, str2.AsStringView());
+}
+inline bool operator==(const wchar_t* lhs, const WideString& rhs) {
+ return rhs == lhs;
+}
+inline bool operator==(const WideStringView& lhs, const WideString& rhs) {
+ return rhs == lhs;
+}
+inline bool operator!=(const wchar_t* lhs, const WideString& rhs) {
+ return rhs != lhs;
+}
+inline bool operator!=(const WideStringView& lhs, const WideString& rhs) {
+ return rhs != lhs;
+}
+
+std::wostream& operator<<(std::wostream& os, const WideString& str);
+std::ostream& operator<<(std::ostream& os, const WideString& str);
+std::wostream& operator<<(std::wostream& os, const WideStringView& str);
+std::ostream& operator<<(std::ostream& os, const WideStringView& str);
+
+} // namespace fxcrt
+
+using WideString = fxcrt::WideString;
+
+uint32_t FX_HashCode_GetW(const WideStringView& str, bool bIgnoreCase);
+
+namespace std {
+
+template <>
+struct hash<WideString> {
+ std::size_t operator()(const WideString& str) const {
+ return FX_HashCode_GetW(str.AsStringView(), false);
+ }
+};
+
+} // namespace std
+
+extern template struct std::hash<WideString>;
+
+#endif // CORE_FXCRT_WIDESTRING_H_
diff --git a/core/fxcrt/cfx_widestring_unittest.cpp b/core/fxcrt/widestring_unittest.cpp
index 6f3bc0837f..949827f6f1 100644
--- a/core/fxcrt/cfx_widestring_unittest.cpp
+++ b/core/fxcrt/widestring_unittest.cpp
@@ -2,16 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "core/fxcrt/cfx_widestring.h"
-#include "core/fxcrt/fx_string.h"
+#include "core/fxcrt/widestring.h"
#include <algorithm>
#include <vector>
+#include "core/fxcrt/fx_string.h"
#include "testing/gtest/include/gtest/gtest.h"
-TEST(fxcrt, WideStringElementAccess) {
- const CFX_WideString abc(L"abc");
+TEST(WideString, ElementAccess) {
+ const WideString abc(L"abc");
EXPECT_EQ(L'a', abc[0]);
EXPECT_EQ(L'b', abc[1]);
EXPECT_EQ(L'c', abc[2]);
@@ -19,7 +19,7 @@ TEST(fxcrt, WideStringElementAccess) {
EXPECT_DEATH({ abc[4]; }, ".*");
#endif
- CFX_WideString mutable_abc = abc;
+ WideString mutable_abc = abc;
EXPECT_EQ(abc.c_str(), mutable_abc.c_str());
EXPECT_EQ(L'a', mutable_abc[0]);
EXPECT_EQ(L'b', mutable_abc[1]);
@@ -47,11 +47,11 @@ TEST(fxcrt, WideStringElementAccess) {
#endif
}
-TEST(fxcrt, WideStringOperatorLT) {
- CFX_WideString empty;
- CFX_WideString a(L"a");
- CFX_WideString abc(L"\x0110qq"); // Comes before despite endianness.
- CFX_WideString def(L"\x1001qq"); // Comes after despite endianness.
+TEST(WideString, OperatorLT) {
+ WideString empty;
+ WideString a(L"a");
+ WideString abc(L"\x0110qq"); // Comes before despite endianness.
+ WideString def(L"\x1001qq"); // Comes after despite endianness.
EXPECT_FALSE(empty < empty);
EXPECT_FALSE(a < a);
@@ -77,16 +77,16 @@ TEST(fxcrt, WideStringOperatorLT) {
EXPECT_FALSE(def < abc);
}
-TEST(fxcrt, WideStringOperatorEQ) {
- CFX_WideString null_string;
+TEST(WideString, OperatorEQ) {
+ WideString null_string;
EXPECT_TRUE(null_string == null_string);
- CFX_WideString empty_string(L"");
+ WideString empty_string(L"");
EXPECT_TRUE(empty_string == empty_string);
EXPECT_TRUE(empty_string == null_string);
EXPECT_TRUE(null_string == empty_string);
- CFX_WideString deleted_string(L"hello");
+ WideString deleted_string(L"hello");
deleted_string.Delete(0, 5);
EXPECT_TRUE(deleted_string == deleted_string);
EXPECT_TRUE(deleted_string == null_string);
@@ -94,7 +94,7 @@ TEST(fxcrt, WideStringOperatorEQ) {
EXPECT_TRUE(null_string == deleted_string);
EXPECT_TRUE(null_string == empty_string);
- CFX_WideString wide_string(L"hello");
+ WideString wide_string(L"hello");
EXPECT_TRUE(wide_string == wide_string);
EXPECT_FALSE(wide_string == null_string);
EXPECT_FALSE(wide_string == empty_string);
@@ -103,17 +103,17 @@ TEST(fxcrt, WideStringOperatorEQ) {
EXPECT_FALSE(empty_string == wide_string);
EXPECT_FALSE(deleted_string == wide_string);
- CFX_WideString wide_string_same1(L"hello");
+ WideString wide_string_same1(L"hello");
EXPECT_TRUE(wide_string == wide_string_same1);
EXPECT_TRUE(wide_string_same1 == wide_string);
- CFX_WideString wide_string_same2(wide_string);
+ WideString wide_string_same2(wide_string);
EXPECT_TRUE(wide_string == wide_string_same2);
EXPECT_TRUE(wide_string_same2 == wide_string);
- CFX_WideString wide_string1(L"he");
- CFX_WideString wide_string2(L"hellp");
- CFX_WideString wide_string3(L"hellod");
+ WideString wide_string1(L"he");
+ WideString wide_string2(L"hellp");
+ WideString wide_string3(L"hellod");
EXPECT_FALSE(wide_string == wide_string1);
EXPECT_FALSE(wide_string == wide_string2);
EXPECT_FALSE(wide_string == wide_string3);
@@ -121,8 +121,8 @@ TEST(fxcrt, WideStringOperatorEQ) {
EXPECT_FALSE(wide_string2 == wide_string);
EXPECT_FALSE(wide_string3 == wide_string);
- CFX_WideStringC null_string_c;
- CFX_WideStringC empty_string_c(L"");
+ WideStringView null_string_c;
+ WideStringView empty_string_c(L"");
EXPECT_TRUE(null_string == null_string_c);
EXPECT_TRUE(null_string == empty_string_c);
EXPECT_TRUE(empty_string == null_string_c);
@@ -136,13 +136,13 @@ TEST(fxcrt, WideStringOperatorEQ) {
EXPECT_TRUE(null_string_c == deleted_string);
EXPECT_TRUE(empty_string_c == deleted_string);
- CFX_WideStringC wide_string_c_same1(L"hello");
+ WideStringView wide_string_c_same1(L"hello");
EXPECT_TRUE(wide_string == wide_string_c_same1);
EXPECT_TRUE(wide_string_c_same1 == wide_string);
- CFX_WideStringC wide_string_c1(L"he");
- CFX_WideStringC wide_string_c2(L"hellp");
- CFX_WideStringC wide_string_c3(L"hellod");
+ WideStringView wide_string_c1(L"he");
+ WideStringView wide_string_c2(L"hellp");
+ WideStringView wide_string_c3(L"hellod");
EXPECT_FALSE(wide_string == wide_string_c1);
EXPECT_FALSE(wide_string == wide_string_c2);
EXPECT_FALSE(wide_string == wide_string_c3);
@@ -180,16 +180,16 @@ TEST(fxcrt, WideStringOperatorEQ) {
EXPECT_FALSE(c_string3 == wide_string);
}
-TEST(fxcrt, WideStringOperatorNE) {
- CFX_WideString null_string;
+TEST(WideString, OperatorNE) {
+ WideString null_string;
EXPECT_FALSE(null_string != null_string);
- CFX_WideString empty_string(L"");
+ WideString empty_string(L"");
EXPECT_FALSE(empty_string != empty_string);
EXPECT_FALSE(empty_string != null_string);
EXPECT_FALSE(null_string != empty_string);
- CFX_WideString deleted_string(L"hello");
+ WideString deleted_string(L"hello");
deleted_string.Delete(0, 5);
EXPECT_FALSE(deleted_string != deleted_string);
EXPECT_FALSE(deleted_string != null_string);
@@ -197,7 +197,7 @@ TEST(fxcrt, WideStringOperatorNE) {
EXPECT_FALSE(null_string != deleted_string);
EXPECT_FALSE(null_string != empty_string);
- CFX_WideString wide_string(L"hello");
+ WideString wide_string(L"hello");
EXPECT_FALSE(wide_string != wide_string);
EXPECT_TRUE(wide_string != null_string);
EXPECT_TRUE(wide_string != empty_string);
@@ -206,17 +206,17 @@ TEST(fxcrt, WideStringOperatorNE) {
EXPECT_TRUE(empty_string != wide_string);
EXPECT_TRUE(deleted_string != wide_string);
- CFX_WideString wide_string_same1(L"hello");
+ WideString wide_string_same1(L"hello");
EXPECT_FALSE(wide_string != wide_string_same1);
EXPECT_FALSE(wide_string_same1 != wide_string);
- CFX_WideString wide_string_same2(wide_string);
+ WideString wide_string_same2(wide_string);
EXPECT_FALSE(wide_string != wide_string_same2);
EXPECT_FALSE(wide_string_same2 != wide_string);
- CFX_WideString wide_string1(L"he");
- CFX_WideString wide_string2(L"hellp");
- CFX_WideString wide_string3(L"hellod");
+ WideString wide_string1(L"he");
+ WideString wide_string2(L"hellp");
+ WideString wide_string3(L"hellod");
EXPECT_TRUE(wide_string != wide_string1);
EXPECT_TRUE(wide_string != wide_string2);
EXPECT_TRUE(wide_string != wide_string3);
@@ -224,8 +224,8 @@ TEST(fxcrt, WideStringOperatorNE) {
EXPECT_TRUE(wide_string2 != wide_string);
EXPECT_TRUE(wide_string3 != wide_string);
- CFX_WideStringC null_string_c;
- CFX_WideStringC empty_string_c(L"");
+ WideStringView null_string_c;
+ WideStringView empty_string_c(L"");
EXPECT_FALSE(null_string != null_string_c);
EXPECT_FALSE(null_string != empty_string_c);
EXPECT_FALSE(empty_string != null_string_c);
@@ -237,13 +237,13 @@ TEST(fxcrt, WideStringOperatorNE) {
EXPECT_FALSE(null_string_c != empty_string);
EXPECT_FALSE(empty_string_c != empty_string);
- CFX_WideStringC wide_string_c_same1(L"hello");
+ WideStringView wide_string_c_same1(L"hello");
EXPECT_FALSE(wide_string != wide_string_c_same1);
EXPECT_FALSE(wide_string_c_same1 != wide_string);
- CFX_WideStringC wide_string_c1(L"he");
- CFX_WideStringC wide_string_c2(L"hellp");
- CFX_WideStringC wide_string_c3(L"hellod");
+ WideStringView wide_string_c1(L"he");
+ WideStringView wide_string_c2(L"hellp");
+ WideStringView wide_string_c3(L"hellod");
EXPECT_TRUE(wide_string != wide_string_c1);
EXPECT_TRUE(wide_string != wide_string_c2);
EXPECT_TRUE(wide_string != wide_string_c3);
@@ -281,8 +281,8 @@ TEST(fxcrt, WideStringOperatorNE) {
EXPECT_TRUE(c_string3 != wide_string);
}
-TEST(fxcrt, WideStringConcatInPlace) {
- CFX_WideString fred;
+TEST(WideString, ConcatInPlace) {
+ WideString fred;
fred.Concat(L"FRED", 4);
EXPECT_EQ(L"FRED", fred);
@@ -295,14 +295,14 @@ TEST(fxcrt, WideStringConcatInPlace) {
fred.Concat(L"D", 1);
EXPECT_EQ(L"FRED", fred);
- CFX_WideString copy = fred;
+ WideString copy = fred;
fred.Concat(L"DY", 2);
EXPECT_EQ(L"FREDDY", fred);
EXPECT_EQ(L"FRED", copy);
}
-TEST(fxcrt, WideStringRemove) {
- CFX_WideString freed(L"FREED");
+TEST(WideString, Remove) {
+ WideString freed(L"FREED");
freed.Remove(L'E');
EXPECT_EQ(L"FRD", freed);
freed.Remove(L'F');
@@ -314,13 +314,13 @@ TEST(fxcrt, WideStringRemove) {
freed.Remove(L'R');
EXPECT_EQ(L"", freed);
- CFX_WideString empty;
+ WideString empty;
empty.Remove(L'X');
EXPECT_EQ(L"", empty);
}
-TEST(fxcrt, WideStringRemoveCopies) {
- CFX_WideString freed(L"FREED");
+TEST(WideString, RemoveCopies) {
+ WideString freed(L"FREED");
const wchar_t* old_buffer = freed.c_str();
// No change with single reference - no copy.
@@ -334,7 +334,7 @@ TEST(fxcrt, WideStringRemoveCopies) {
EXPECT_EQ(old_buffer, freed.c_str());
// No change with multiple references - no copy.
- CFX_WideString shared(freed);
+ WideString shared(freed);
freed.Remove(L'Q');
EXPECT_EQ(L"FRD", freed);
EXPECT_EQ(old_buffer, freed.c_str());
@@ -348,8 +348,8 @@ TEST(fxcrt, WideStringRemoveCopies) {
EXPECT_EQ(old_buffer, shared.c_str());
}
-TEST(fxcrt, WideStringReplace) {
- CFX_WideString fred(L"FRED");
+TEST(WideString, Replace) {
+ WideString fred(L"FRED");
fred.Replace(L"FR", L"BL");
EXPECT_EQ(L"BLED", fred);
fred.Replace(L"D", L"DDY");
@@ -366,8 +366,8 @@ TEST(fxcrt, WideStringReplace) {
EXPECT_EQ(L"", fred);
}
-TEST(fxcrt, WideStringInsert) {
- CFX_WideString fred(L"FRED");
+TEST(WideString, Insert) {
+ WideString fred(L"FRED");
EXPECT_EQ(5u, fred.Insert(0, 'S'));
EXPECT_EQ(L"SFRED", fred);
EXPECT_EQ(6u, fred.Insert(1, 'T'));
@@ -379,20 +379,20 @@ TEST(fxcrt, WideStringInsert) {
EXPECT_EQ(8u, fred.Insert(12, 'P'));
EXPECT_EQ(L"STFRUEDV", fred);
{
- CFX_WideString empty;
+ WideString empty;
EXPECT_EQ(1u, empty.Insert(0, 'X'));
EXPECT_EQ(L"X", empty);
}
{
- CFX_WideString empty;
+ WideString empty;
EXPECT_EQ(0u, empty.Insert(5, 'X'));
EXPECT_NE(L"X", empty);
}
}
-TEST(fxcrt, WideStringInsertAtFrontAndInsertAtBack) {
+TEST(WideString, InsertAtFrontAndInsertAtBack) {
{
- CFX_WideString empty;
+ WideString empty;
EXPECT_EQ(1u, empty.InsertAtFront('D'));
EXPECT_EQ(L"D", empty);
EXPECT_EQ(2u, empty.InsertAtFront('E'));
@@ -403,7 +403,7 @@ TEST(fxcrt, WideStringInsertAtFrontAndInsertAtBack) {
EXPECT_EQ(L"FRED", empty);
}
{
- CFX_WideString empty;
+ WideString empty;
EXPECT_EQ(1u, empty.InsertAtBack('F'));
EXPECT_EQ(L"F", empty);
EXPECT_EQ(2u, empty.InsertAtBack('R'));
@@ -414,7 +414,7 @@ TEST(fxcrt, WideStringInsertAtFrontAndInsertAtBack) {
EXPECT_EQ(L"FRED", empty);
}
{
- CFX_WideString empty;
+ WideString empty;
EXPECT_EQ(1u, empty.InsertAtBack('E'));
EXPECT_EQ(L"E", empty);
EXPECT_EQ(2u, empty.InsertAtFront('R'));
@@ -426,8 +426,8 @@ TEST(fxcrt, WideStringInsertAtFrontAndInsertAtBack) {
}
}
-TEST(fxcrt, WideStringDelete) {
- CFX_WideString fred(L"FRED");
+TEST(WideString, Delete) {
+ WideString fred(L"FRED");
EXPECT_EQ(4u, fred.Delete(0, 0));
EXPECT_EQ(L"FRED", fred);
EXPECT_EQ(2u, fred.Delete(0, 2));
@@ -439,15 +439,15 @@ TEST(fxcrt, WideStringDelete) {
EXPECT_EQ(0u, fred.Delete(0));
EXPECT_EQ(L"", fred);
- CFX_WideString empty;
+ WideString empty;
EXPECT_EQ(0u, empty.Delete(0));
EXPECT_EQ(L"", empty);
EXPECT_EQ(0u, empty.Delete(1));
EXPECT_EQ(L"", empty);
}
-TEST(fxcrt, WideStringMid) {
- CFX_WideString fred(L"FRED");
+TEST(WideString, Mid) {
+ WideString fred(L"FRED");
EXPECT_EQ(L"", fred.Mid(0, 0));
EXPECT_EQ(L"", fred.Mid(3, 0));
EXPECT_EQ(L"FRED", fred.Mid(0, 4));
@@ -465,12 +465,12 @@ TEST(fxcrt, WideStringMid) {
EXPECT_EQ(L"", fred.Mid(1, 4));
EXPECT_EQ(L"", fred.Mid(4, 1));
- CFX_WideString empty;
+ WideString empty;
EXPECT_EQ(L"", empty.Mid(0, 0));
}
-TEST(fxcrt, WideStringLeft) {
- CFX_WideString fred(L"FRED");
+TEST(WideString, Left) {
+ WideString fred(L"FRED");
EXPECT_EQ(L"", fred.Left(0));
EXPECT_EQ(L"F", fred.Left(1));
EXPECT_EQ(L"FR", fred.Left(2));
@@ -479,13 +479,13 @@ TEST(fxcrt, WideStringLeft) {
EXPECT_EQ(L"", fred.Left(5));
- CFX_WideString empty;
+ WideString empty;
EXPECT_EQ(L"", empty.Left(0));
EXPECT_EQ(L"", empty.Left(1));
}
-TEST(fxcrt, WideStringRight) {
- CFX_WideString fred(L"FRED");
+TEST(WideString, Right) {
+ WideString fred(L"FRED");
EXPECT_EQ(L"", fred.Right(0));
EXPECT_EQ(L"D", fred.Right(1));
EXPECT_EQ(L"ED", fred.Right(2));
@@ -494,29 +494,29 @@ TEST(fxcrt, WideStringRight) {
EXPECT_EQ(L"", fred.Right(5));
- CFX_WideString empty;
+ WideString empty;
EXPECT_EQ(L"", empty.Right(0));
EXPECT_EQ(L"", empty.Right(1));
}
-TEST(fxcrt, WideStringFind) {
- CFX_WideString null_string;
+TEST(WideString, Find) {
+ WideString null_string;
EXPECT_FALSE(null_string.Find(L'a').has_value());
EXPECT_FALSE(null_string.Find(L'\0').has_value());
- CFX_WideString empty_string(L"");
+ WideString empty_string(L"");
EXPECT_FALSE(empty_string.Find(L'a').has_value());
EXPECT_FALSE(empty_string.Find(L'\0').has_value());
pdfium::Optional<FX_STRSIZE> result;
- CFX_WideString single_string(L"a");
+ WideString single_string(L"a");
result = single_string.Find(L'a');
ASSERT_TRUE(result.has_value());
EXPECT_EQ(0u, result.value());
EXPECT_FALSE(single_string.Find(L'b').has_value());
EXPECT_FALSE(single_string.Find(L'\0').has_value());
- CFX_WideString longer_string(L"abccc");
+ WideString longer_string(L"abccc");
result = longer_string.Find(L'a');
ASSERT_TRUE(result.has_value());
EXPECT_EQ(0u, result.value());
@@ -539,7 +539,7 @@ TEST(fxcrt, WideStringFind) {
EXPECT_EQ(3u, result.value());
EXPECT_FALSE(longer_string.Find(L"d").has_value());
- CFX_WideString hibyte_string(
+ WideString hibyte_string(
L"ab\xff8c"
L"def");
result = hibyte_string.Find(L'\xff8c');
@@ -547,22 +547,22 @@ TEST(fxcrt, WideStringFind) {
EXPECT_EQ(2u, result.value());
}
-TEST(fxcrt, WideStringUpperLower) {
- CFX_WideString fred(L"F-Re.42D");
+TEST(WideString, UpperLower) {
+ WideString fred(L"F-Re.42D");
fred.MakeLower();
EXPECT_EQ(L"f-re.42d", fred);
fred.MakeUpper();
EXPECT_EQ(L"F-RE.42D", fred);
- CFX_WideString empty;
+ WideString empty;
empty.MakeLower();
EXPECT_EQ(L"", empty);
empty.MakeUpper();
EXPECT_EQ(L"", empty);
}
-TEST(fxcrt, WideStringTrimRight) {
- CFX_WideString fred(L" FRED ");
+TEST(WideString, TrimRight) {
+ WideString fred(L" FRED ");
fred.TrimRight();
EXPECT_EQ(L" FRED", fred);
fred.TrimRight(L'E');
@@ -572,7 +572,7 @@ TEST(fxcrt, WideStringTrimRight) {
fred.TrimRight(L"ERP");
EXPECT_EQ(L" F", fred);
- CFX_WideString blank(L" ");
+ WideString blank(L" ");
blank.TrimRight(L"ERP");
EXPECT_EQ(L" ", blank);
blank.TrimRight(L'E');
@@ -580,7 +580,7 @@ TEST(fxcrt, WideStringTrimRight) {
blank.TrimRight();
EXPECT_EQ(L"", blank);
- CFX_WideString empty;
+ WideString empty;
empty.TrimRight(L"ERP");
EXPECT_EQ(L"", empty);
empty.TrimRight(L'E');
@@ -589,10 +589,10 @@ TEST(fxcrt, WideStringTrimRight) {
EXPECT_EQ(L"", empty);
}
-TEST(fxcrt, WideStringTrimRightCopies) {
+TEST(WideString, TrimRightCopies) {
{
// With a single reference, no copy takes place.
- CFX_WideString fred(L" FRED ");
+ WideString fred(L" FRED ");
const wchar_t* old_buffer = fred.c_str();
fred.TrimRight();
EXPECT_EQ(L" FRED", fred);
@@ -600,8 +600,8 @@ TEST(fxcrt, WideStringTrimRightCopies) {
}
{
// With multiple references, we must copy.
- CFX_WideString fred(L" FRED ");
- CFX_WideString other_fred = fred;
+ WideString fred(L" FRED ");
+ WideString other_fred = fred;
const wchar_t* old_buffer = fred.c_str();
fred.TrimRight();
EXPECT_EQ(L" FRED", fred);
@@ -610,8 +610,8 @@ TEST(fxcrt, WideStringTrimRightCopies) {
}
{
// With multiple references, but no modifications, no copy.
- CFX_WideString fred(L"FRED");
- CFX_WideString other_fred = fred;
+ WideString fred(L"FRED");
+ WideString other_fred = fred;
const wchar_t* old_buffer = fred.c_str();
fred.TrimRight();
EXPECT_EQ(L"FRED", fred);
@@ -620,8 +620,8 @@ TEST(fxcrt, WideStringTrimRightCopies) {
}
}
-TEST(fxcrt, WideStringTrimLeft) {
- CFX_WideString fred(L" FRED ");
+TEST(WideString, TrimLeft) {
+ WideString fred(L" FRED ");
fred.TrimLeft();
EXPECT_EQ(L"FRED ", fred);
fred.TrimLeft(L'E');
@@ -631,7 +631,7 @@ TEST(fxcrt, WideStringTrimLeft) {
fred.TrimLeft(L"ERP");
EXPECT_EQ(L"D ", fred);
- CFX_WideString blank(L" ");
+ WideString blank(L" ");
blank.TrimLeft(L"ERP");
EXPECT_EQ(L" ", blank);
blank.TrimLeft(L'E');
@@ -639,7 +639,7 @@ TEST(fxcrt, WideStringTrimLeft) {
blank.TrimLeft();
EXPECT_EQ(L"", blank);
- CFX_WideString empty;
+ WideString empty;
empty.TrimLeft(L"ERP");
EXPECT_EQ(L"", empty);
empty.TrimLeft(L'E');
@@ -648,10 +648,10 @@ TEST(fxcrt, WideStringTrimLeft) {
EXPECT_EQ(L"", empty);
}
-TEST(fxcrt, WideStringTrimLeftCopies) {
+TEST(WideString, TrimLeftCopies) {
{
// With a single reference, no copy takes place.
- CFX_WideString fred(L" FRED ");
+ WideString fred(L" FRED ");
const wchar_t* old_buffer = fred.c_str();
fred.TrimLeft();
EXPECT_EQ(L"FRED ", fred);
@@ -659,8 +659,8 @@ TEST(fxcrt, WideStringTrimLeftCopies) {
}
{
// With multiple references, we must copy.
- CFX_WideString fred(L" FRED ");
- CFX_WideString other_fred = fred;
+ WideString fred(L" FRED ");
+ WideString other_fred = fred;
const wchar_t* old_buffer = fred.c_str();
fred.TrimLeft();
EXPECT_EQ(L"FRED ", fred);
@@ -669,8 +669,8 @@ TEST(fxcrt, WideStringTrimLeftCopies) {
}
{
// With multiple references, but no modifications, no copy.
- CFX_WideString fred(L"FRED");
- CFX_WideString other_fred = fred;
+ WideString fred(L"FRED");
+ WideString other_fred = fred;
const wchar_t* old_buffer = fred.c_str();
fred.TrimLeft();
EXPECT_EQ(L"FRED", fred);
@@ -679,9 +679,9 @@ TEST(fxcrt, WideStringTrimLeftCopies) {
}
}
-TEST(fxcrt, WideStringReserve) {
+TEST(WideString, Reserve) {
{
- CFX_WideString str;
+ WideString str;
str.Reserve(6);
const wchar_t* old_buffer = str.c_str();
str += L"ABCDEF";
@@ -690,7 +690,7 @@ TEST(fxcrt, WideStringReserve) {
EXPECT_NE(old_buffer, str.c_str());
}
{
- CFX_WideString str(L"A");
+ WideString str(L"A");
str.Reserve(6);
const wchar_t* old_buffer = str.c_str();
str += L"BCDEF";
@@ -700,16 +700,16 @@ TEST(fxcrt, WideStringReserve) {
}
}
-TEST(fxcrt, WideStringGetBuffer) {
+TEST(WideString, GetBuffer) {
{
- CFX_WideString str;
+ WideString str;
wchar_t* buffer = str.GetBuffer(12);
wcscpy(buffer, L"clams");
str.ReleaseBuffer(str.GetStringLength());
EXPECT_EQ(L"clams", str);
}
{
- CFX_WideString str(L"cl");
+ WideString str(L"cl");
wchar_t* buffer = str.GetBuffer(12);
wcscpy(buffer + 2, L"ams");
str.ReleaseBuffer(str.GetStringLength());
@@ -717,9 +717,9 @@ TEST(fxcrt, WideStringGetBuffer) {
}
}
-TEST(fxcrt, WideStringReleaseBuffer) {
+TEST(WideString, ReleaseBuffer) {
{
- CFX_WideString str;
+ WideString str;
str.Reserve(12);
str += L"clams";
const wchar_t* old_buffer = str.c_str();
@@ -728,7 +728,7 @@ TEST(fxcrt, WideStringReleaseBuffer) {
EXPECT_EQ(L"clam", str);
}
{
- CFX_WideString str(L"c");
+ WideString str(L"c");
str.Reserve(12);
str += L"lams";
const wchar_t* old_buffer = str.c_str();
@@ -737,7 +737,7 @@ TEST(fxcrt, WideStringReleaseBuffer) {
EXPECT_EQ(L"clam", str);
}
{
- CFX_WideString str;
+ WideString str;
str.Reserve(200);
str += L"clams";
const wchar_t* old_buffer = str.c_str();
@@ -746,7 +746,7 @@ TEST(fxcrt, WideStringReleaseBuffer) {
EXPECT_EQ(L"clam", str);
}
{
- CFX_WideString str(L"c");
+ WideString str(L"c");
str.Reserve(200);
str += L"lams";
const wchar_t* old_buffer = str.c_str();
@@ -756,16 +756,16 @@ TEST(fxcrt, WideStringReleaseBuffer) {
}
}
-TEST(fxcrt, WideStringEmptyReverseIterator) {
- CFX_WideString empty;
+TEST(WideString, EmptyReverseIterator) {
+ WideString empty;
auto iter = empty.rbegin();
EXPECT_TRUE(iter == empty.rend());
EXPECT_FALSE(iter != empty.rend());
EXPECT_FALSE(iter < empty.rend());
}
-TEST(fxcrt, WideStringOneCharReverseIterator) {
- CFX_WideString one_str(L"a");
+TEST(WideString, OneCharReverseIterator) {
+ WideString one_str(L"a");
auto iter = one_str.rbegin();
EXPECT_FALSE(iter == one_str.rend());
EXPECT_TRUE(iter != one_str.rend());
@@ -778,8 +778,8 @@ TEST(fxcrt, WideStringOneCharReverseIterator) {
EXPECT_FALSE(iter < one_str.rend());
}
-TEST(fxcrt, WideStringMultiCharReverseIterator) {
- CFX_WideString multi_str(L"abcd");
+TEST(WideString, MultiCharReverseIterator) {
+ WideString multi_str(L"abcd");
auto iter = multi_str.rbegin();
EXPECT_FALSE(iter == multi_str.rend());
@@ -823,17 +823,17 @@ TEST(fxcrt, WideStringMultiCharReverseIterator) {
EXPECT_TRUE(iter == multi_str.rbegin());
}
-TEST(fxcrt, WideStringUTF16LE_Encode) {
+TEST(WideString, UTF16LE_Encode) {
struct UTF16LEEncodeCase {
- CFX_WideString ws;
- CFX_ByteString bs;
+ WideString ws;
+ ByteString bs;
} utf16le_encode_cases[] = {
- {L"", CFX_ByteString("\0\0", 2)},
- {L"abc", CFX_ByteString("a\0b\0c\0\0\0", 8)},
- {L"abcdef", CFX_ByteString("a\0b\0c\0d\0e\0f\0\0\0", 14)},
- {L"abc\0def", CFX_ByteString("a\0b\0c\0\0\0", 8)},
- {L"\xaabb\xccdd", CFX_ByteString("\xbb\xaa\xdd\xcc\0\0", 6)},
- {L"\x3132\x6162", CFX_ByteString("\x32\x31\x62\x61\0\0", 6)},
+ {L"", ByteString("\0\0", 2)},
+ {L"abc", ByteString("a\0b\0c\0\0\0", 8)},
+ {L"abcdef", ByteString("a\0b\0c\0d\0e\0f\0\0\0", 14)},
+ {L"abc\0def", ByteString("a\0b\0c\0\0\0", 8)},
+ {L"\xaabb\xccdd", ByteString("\xbb\xaa\xdd\xcc\0\0", 6)},
+ {L"\x3132\x6162", ByteString("\x32\x31\x62\x61\0\0", 6)},
};
for (size_t i = 0; i < FX_ArraySize(utf16le_encode_cases); ++i) {
@@ -843,27 +843,27 @@ TEST(fxcrt, WideStringUTF16LE_Encode) {
}
}
-TEST(fxcrt, WideStringCFromVector) {
- std::vector<CFX_WideStringC::UnsignedType> null_vec;
- CFX_WideStringC null_string(null_vec);
+TEST(WideStringView, FromVector) {
+ std::vector<WideStringView::UnsignedType> null_vec;
+ WideStringView null_string(null_vec);
EXPECT_EQ(0u, null_string.GetLength());
- std::vector<CFX_WideStringC::UnsignedType> lower_a_vec(
- 10, static_cast<CFX_WideStringC::UnsignedType>(L'a'));
- CFX_WideStringC lower_a_string(lower_a_vec);
+ std::vector<WideStringView::UnsignedType> lower_a_vec(
+ 10, static_cast<WideStringView::UnsignedType>(L'a'));
+ WideStringView lower_a_string(lower_a_vec);
EXPECT_EQ(10u, lower_a_string.GetLength());
EXPECT_EQ(L"aaaaaaaaaa", lower_a_string);
- std::vector<CFX_WideStringC::UnsignedType> cleared_vec;
+ std::vector<WideStringView::UnsignedType> cleared_vec;
cleared_vec.push_back(42);
cleared_vec.pop_back();
- CFX_WideStringC cleared_string(cleared_vec);
+ WideStringView cleared_string(cleared_vec);
EXPECT_EQ(0u, cleared_string.GetLength());
EXPECT_EQ(nullptr, cleared_string.raw_str());
}
-TEST(fxcrt, WideStringCElementAccess) {
- CFX_WideStringC abc(L"abc");
+TEST(WideStringView, ElementAccess) {
+ WideStringView abc(L"abc");
EXPECT_EQ(L'a', static_cast<wchar_t>(abc[0]));
EXPECT_EQ(L'b', static_cast<wchar_t>(abc[1]));
EXPECT_EQ(L'c', static_cast<wchar_t>(abc[2]));
@@ -872,11 +872,11 @@ TEST(fxcrt, WideStringCElementAccess) {
#endif
}
-TEST(fxcrt, WideStringCOperatorLT) {
- CFX_WideStringC empty;
- CFX_WideStringC a(L"a");
- CFX_WideStringC abc(L"\x0110qq"); // Comes InsertAtFront despite endianness.
- CFX_WideStringC def(L"\x1001qq"); // Comes InsertAtBack despite endianness.
+TEST(WideStringView, OperatorLT) {
+ WideStringView empty;
+ WideStringView a(L"a");
+ WideStringView abc(L"\x0110qq"); // Comes InsertAtFront despite endianness.
+ WideStringView def(L"\x1001qq"); // Comes InsertAtBack despite endianness.
EXPECT_FALSE(empty < empty);
EXPECT_FALSE(a < a);
@@ -902,21 +902,21 @@ TEST(fxcrt, WideStringCOperatorLT) {
EXPECT_FALSE(def < abc);
}
-TEST(fxcrt, WideStringCOperatorEQ) {
- CFX_WideStringC wide_string_c(L"hello");
+TEST(WideStringView, OperatorEQ) {
+ WideStringView wide_string_c(L"hello");
EXPECT_TRUE(wide_string_c == wide_string_c);
- CFX_WideStringC wide_string_c_same1(L"hello");
+ WideStringView wide_string_c_same1(L"hello");
EXPECT_TRUE(wide_string_c == wide_string_c_same1);
EXPECT_TRUE(wide_string_c_same1 == wide_string_c);
- CFX_WideStringC wide_string_c_same2(wide_string_c);
+ WideStringView wide_string_c_same2(wide_string_c);
EXPECT_TRUE(wide_string_c == wide_string_c_same2);
EXPECT_TRUE(wide_string_c_same2 == wide_string_c);
- CFX_WideStringC wide_string_c1(L"he");
- CFX_WideStringC wide_string_c2(L"hellp");
- CFX_WideStringC wide_string_c3(L"hellod");
+ WideStringView wide_string_c1(L"he");
+ WideStringView wide_string_c2(L"hellp");
+ WideStringView wide_string_c3(L"hellod");
EXPECT_FALSE(wide_string_c == wide_string_c1);
EXPECT_FALSE(wide_string_c == wide_string_c2);
EXPECT_FALSE(wide_string_c == wide_string_c3);
@@ -924,13 +924,13 @@ TEST(fxcrt, WideStringCOperatorEQ) {
EXPECT_FALSE(wide_string_c2 == wide_string_c);
EXPECT_FALSE(wide_string_c3 == wide_string_c);
- CFX_WideString wide_string_same1(L"hello");
+ WideString wide_string_same1(L"hello");
EXPECT_TRUE(wide_string_c == wide_string_same1);
EXPECT_TRUE(wide_string_same1 == wide_string_c);
- CFX_WideString wide_string1(L"he");
- CFX_WideString wide_string2(L"hellp");
- CFX_WideString wide_string3(L"hellod");
+ WideString wide_string1(L"he");
+ WideString wide_string2(L"hellp");
+ WideString wide_string3(L"hellod");
EXPECT_FALSE(wide_string_c == wide_string1);
EXPECT_FALSE(wide_string_c == wide_string2);
EXPECT_FALSE(wide_string_c == wide_string3);
@@ -954,21 +954,21 @@ TEST(fxcrt, WideStringCOperatorEQ) {
EXPECT_FALSE(c_string3 == wide_string_c);
}
-TEST(fxcrt, WideStringCOperatorNE) {
- CFX_WideStringC wide_string_c(L"hello");
+TEST(WideStringView, OperatorNE) {
+ WideStringView wide_string_c(L"hello");
EXPECT_FALSE(wide_string_c != wide_string_c);
- CFX_WideStringC wide_string_c_same1(L"hello");
+ WideStringView wide_string_c_same1(L"hello");
EXPECT_FALSE(wide_string_c != wide_string_c_same1);
EXPECT_FALSE(wide_string_c_same1 != wide_string_c);
- CFX_WideStringC wide_string_c_same2(wide_string_c);
+ WideStringView wide_string_c_same2(wide_string_c);
EXPECT_FALSE(wide_string_c != wide_string_c_same2);
EXPECT_FALSE(wide_string_c_same2 != wide_string_c);
- CFX_WideStringC wide_string_c1(L"he");
- CFX_WideStringC wide_string_c2(L"hellp");
- CFX_WideStringC wide_string_c3(L"hellod");
+ WideStringView wide_string_c1(L"he");
+ WideStringView wide_string_c2(L"hellp");
+ WideStringView wide_string_c3(L"hellod");
EXPECT_TRUE(wide_string_c != wide_string_c1);
EXPECT_TRUE(wide_string_c != wide_string_c2);
EXPECT_TRUE(wide_string_c != wide_string_c3);
@@ -976,13 +976,13 @@ TEST(fxcrt, WideStringCOperatorNE) {
EXPECT_TRUE(wide_string_c2 != wide_string_c);
EXPECT_TRUE(wide_string_c3 != wide_string_c);
- CFX_WideString wide_string_same1(L"hello");
+ WideString wide_string_same1(L"hello");
EXPECT_FALSE(wide_string_c != wide_string_same1);
EXPECT_FALSE(wide_string_same1 != wide_string_c);
- CFX_WideString wide_string1(L"he");
- CFX_WideString wide_string2(L"hellp");
- CFX_WideString wide_string3(L"hellod");
+ WideString wide_string1(L"he");
+ WideString wide_string2(L"hellp");
+ WideString wide_string3(L"hellod");
EXPECT_TRUE(wide_string_c != wide_string1);
EXPECT_TRUE(wide_string_c != wide_string2);
EXPECT_TRUE(wide_string_c != wide_string3);
@@ -1006,24 +1006,24 @@ TEST(fxcrt, WideStringCOperatorNE) {
EXPECT_TRUE(c_string3 != wide_string_c);
}
-TEST(fxcrt, WideStringCFind) {
- CFX_WideStringC null_string;
+TEST(WideStringView, Find) {
+ WideStringView null_string;
EXPECT_FALSE(null_string.Find(L'a').has_value());
EXPECT_FALSE(null_string.Find(L'\0').has_value());
- CFX_WideStringC empty_string(L"");
+ WideStringView empty_string(L"");
EXPECT_FALSE(empty_string.Find(L'a').has_value());
EXPECT_FALSE(empty_string.Find(L'\0').has_value());
pdfium::Optional<FX_STRSIZE> result;
- CFX_WideStringC single_string(L"a");
+ WideStringView single_string(L"a");
result = single_string.Find(L'a');
ASSERT_TRUE(result.has_value());
EXPECT_EQ(0u, result.value());
EXPECT_FALSE(single_string.Find(L'b').has_value());
EXPECT_FALSE(single_string.Find(L'\0').has_value());
- CFX_WideStringC longer_string(L"abccc");
+ WideStringView longer_string(L"abccc");
result = longer_string.Find(L'a');
ASSERT_TRUE(result.has_value());
EXPECT_EQ(0u, result.value());
@@ -1033,7 +1033,7 @@ TEST(fxcrt, WideStringCFind) {
EXPECT_FALSE(longer_string.Find(L'd').has_value());
EXPECT_FALSE(longer_string.Find(L'\0').has_value());
- CFX_WideStringC hibyte_string(
+ WideStringView hibyte_string(
L"ab\xFF8c"
L"def");
result = hibyte_string.Find(L'\xFF8c');
@@ -1041,8 +1041,8 @@ TEST(fxcrt, WideStringCFind) {
EXPECT_EQ(2u, result.value());
}
-TEST(fxcrt, WideStringCNullIterator) {
- CFX_WideStringC null_str;
+TEST(WideStringView, NullIterator) {
+ WideStringView null_str;
int32_t sum = 0;
bool any_present = false;
for (const auto& c : null_str) {
@@ -1053,8 +1053,8 @@ TEST(fxcrt, WideStringCNullIterator) {
EXPECT_EQ(0, sum);
}
-TEST(fxcrt, WideStringCEmptyIterator) {
- CFX_WideStringC empty_str(L"");
+TEST(WideStringView, EmptyIterator) {
+ WideStringView empty_str(L"");
int32_t sum = 0;
bool any_present = false;
for (const auto& c : empty_str) {
@@ -1065,8 +1065,8 @@ TEST(fxcrt, WideStringCEmptyIterator) {
EXPECT_EQ(0, sum);
}
-TEST(fxcrt, WideStringCOneCharIterator) {
- CFX_WideStringC one_str(L"a");
+TEST(WideStringView, OneCharIterator) {
+ WideStringView one_str(L"a");
int32_t sum = 0;
bool any_present = false;
for (const auto& c : one_str) {
@@ -1077,8 +1077,8 @@ TEST(fxcrt, WideStringCOneCharIterator) {
EXPECT_EQ(static_cast<int32_t>(L'a'), sum);
}
-TEST(fxcrt, WideStringCMultiCharIterator) {
- CFX_WideStringC one_str(L"abc");
+TEST(WideStringView, MultiCharIterator) {
+ WideStringView one_str(L"abc");
int32_t sum = 0;
bool any_present = false;
for (const auto& c : one_str) {
@@ -1089,16 +1089,16 @@ TEST(fxcrt, WideStringCMultiCharIterator) {
EXPECT_EQ(static_cast<int32_t>(L'a' + L'b' + L'c'), sum);
}
-TEST(fxcrt, WideStringCEmptyReverseIterator) {
- CFX_WideStringC empty;
+TEST(WideStringView, EmptyReverseIterator) {
+ WideStringView empty;
auto iter = empty.rbegin();
EXPECT_TRUE(iter == empty.rend());
EXPECT_FALSE(iter != empty.rend());
EXPECT_FALSE(iter < empty.rend());
}
-TEST(fxcrt, WideStringCOneCharReverseIterator) {
- CFX_WideStringC one_str(L"a");
+TEST(WideStringView, OneCharReverseIterator) {
+ WideStringView one_str(L"a");
auto iter = one_str.rbegin();
EXPECT_FALSE(iter == one_str.rend());
EXPECT_TRUE(iter != one_str.rend());
@@ -1111,8 +1111,8 @@ TEST(fxcrt, WideStringCOneCharReverseIterator) {
EXPECT_FALSE(iter < one_str.rend());
}
-TEST(fxcrt, WideStringCMultiCharReverseIterator) {
- CFX_WideStringC multi_str(L"abcd");
+TEST(WideStringView, MultiCharReverseIterator) {
+ WideStringView multi_str(L"abcd");
auto iter = multi_str.rbegin();
EXPECT_FALSE(iter == multi_str.rend());
@@ -1156,8 +1156,8 @@ TEST(fxcrt, WideStringCMultiCharReverseIterator) {
EXPECT_TRUE(iter == multi_str.rbegin());
}
-TEST(fxcrt, WideStringCAnyAllNoneOf) {
- CFX_WideStringC str(L"aaaaaaaaaaaaaaaaab");
+TEST(WideStringView, AnyAllNoneOf) {
+ WideStringView str(L"aaaaaaaaaaaaaaaaab");
EXPECT_FALSE(std::all_of(str.begin(), str.end(),
[](const wchar_t& c) { return c == L'a'; }));
@@ -1172,112 +1172,112 @@ TEST(fxcrt, WideStringCAnyAllNoneOf) {
EXPECT_FALSE(pdfium::ContainsValue(str, L'z'));
}
-TEST(fxcrt, WideStringCTrimmedRight) {
- CFX_WideStringC fred(L"FRED");
+TEST(WideStringView, TrimmedRight) {
+ WideStringView fred(L"FRED");
EXPECT_EQ(L"FRED", fred.TrimmedRight(L'E'));
EXPECT_EQ(L"FRE", fred.TrimmedRight(L'D'));
- CFX_WideStringC fredd(L"FREDD");
+ WideStringView fredd(L"FREDD");
EXPECT_EQ(L"FRE", fred.TrimmedRight(L'D'));
}
-TEST(fxcrt, WideStringFormatWidth) {
+TEST(WideString, FormatWidth) {
{
- CFX_WideString str;
+ WideString str;
str.Format(L"%5d", 1);
EXPECT_EQ(L" 1", str);
}
{
- CFX_WideString str;
+ WideString str;
str.Format(L"%d", 1);
EXPECT_EQ(L"1", str);
}
{
- CFX_WideString str;
+ WideString str;
str.Format(L"%*d", 5, 1);
EXPECT_EQ(L" 1", str);
}
{
- CFX_WideString str;
+ WideString str;
str.Format(L"%-1d", 1);
EXPECT_EQ(L"1", str);
}
{
- CFX_WideString str;
+ WideString str;
str.Format(L"%0d", 1);
EXPECT_EQ(L"1", str);
}
{
- CFX_WideString str;
+ WideString str;
str.Format(L"%1048576d", 1);
EXPECT_EQ(L"", str);
}
}
-TEST(fxcrt, WideStringFormatPrecision) {
+TEST(WideString, FormatPrecision) {
{
- CFX_WideString str;
+ WideString str;
str.Format(L"%.2f", 1.12345);
EXPECT_EQ(L"1.12", str);
}
{
- CFX_WideString str;
+ WideString str;
str.Format(L"%.*f", 3, 1.12345);
EXPECT_EQ(L"1.123", str);
}
{
- CFX_WideString str;
+ WideString str;
str.Format(L"%f", 1.12345);
EXPECT_EQ(L"1.123450", str);
}
{
- CFX_WideString str;
+ WideString str;
str.Format(L"%-1f", 1.12345);
EXPECT_EQ(L"1.123450", str);
}
{
- CFX_WideString str;
+ WideString str;
str.Format(L"%0f", 1.12345);
EXPECT_EQ(L"1.123450", str);
}
{
- CFX_WideString str;
+ WideString str;
str.Format(L"%.1048576f", 1.2);
EXPECT_EQ(L"", str);
}
}
-TEST(fxcrt, WideStringFormatOutOfRangeChar) {
- CFX_WideString str;
+TEST(WideString, FormatOutOfRangeChar) {
+ WideString str;
str.Format(L"unsupported char '%c'", 0x00FF00FF);
}
-TEST(fxcrt, EmptyWideString) {
- CFX_WideString empty_str;
+TEST(WideString, Empty) {
+ WideString empty_str;
EXPECT_TRUE(empty_str.IsEmpty());
EXPECT_EQ(0u, empty_str.GetLength());
const wchar_t* cstr = empty_str.c_str();
EXPECT_EQ(0u, FXSYS_wcslen(cstr));
}
-TEST(fxcrt, WidStringInitializerList) {
- CFX_WideString many_str({L"clams", L" and ", L"oysters"});
+TEST(CFX_WidString, InitializerList) {
+ WideString many_str({L"clams", L" and ", L"oysters"});
EXPECT_EQ(L"clams and oysters", many_str);
many_str = {L"fish", L" and ", L"chips", L" and ", L"soda"};
EXPECT_EQ(L"fish and chips and soda", many_str);
}
-TEST(fxcrt, WideStringNullIterator) {
- CFX_WideString null_str;
+TEST(WideString, NullIterator) {
+ WideString null_str;
int32_t sum = 0;
bool any_present = false;
for (const auto& c : null_str) {
@@ -1288,8 +1288,8 @@ TEST(fxcrt, WideStringNullIterator) {
EXPECT_EQ(0, sum);
}
-TEST(fxcrt, WideStringEmptyIterator) {
- CFX_WideString empty_str(L"");
+TEST(WideString, EmptyIterator) {
+ WideString empty_str(L"");
int32_t sum = 0;
bool any_present = false;
for (const auto& c : empty_str) {
@@ -1300,8 +1300,8 @@ TEST(fxcrt, WideStringEmptyIterator) {
EXPECT_EQ(0, sum);
}
-TEST(fxcrt, WideStringOneCharIterator) {
- CFX_WideString one_str(L"a");
+TEST(WideString, OneCharIterator) {
+ WideString one_str(L"a");
int32_t sum = 0;
bool any_present = false;
for (const auto& c : one_str) {
@@ -1312,8 +1312,8 @@ TEST(fxcrt, WideStringOneCharIterator) {
EXPECT_EQ(static_cast<int32_t>(L'a'), sum);
}
-TEST(fxcrt, WideStringMultiCharIterator) {
- CFX_WideString one_str(L"abc");
+TEST(WideString, MultiCharIterator) {
+ WideString one_str(L"abc");
int32_t sum = 0;
bool any_present = false;
for (const auto& c : one_str) {
@@ -1324,8 +1324,8 @@ TEST(fxcrt, WideStringMultiCharIterator) {
EXPECT_EQ(static_cast<int32_t>(L'a' + L'b' + L'c'), sum);
}
-TEST(fxcrt, WideStringAnyAllNoneOf) {
- CFX_WideString str(L"aaaaaaaaaaaaaaaaab");
+TEST(WideString, AnyAllNoneOf) {
+ WideString str(L"aaaaaaaaaaaaaaaaab");
EXPECT_FALSE(std::all_of(str.begin(), str.end(),
[](const wchar_t& c) { return c == L'a'; }));
@@ -1340,11 +1340,11 @@ TEST(fxcrt, WideStringAnyAllNoneOf) {
EXPECT_FALSE(pdfium::ContainsValue(str, L'z'));
}
-TEST(fxcrt, OStreamWideStringOverload) {
+TEST(WideString, OStreamOverload) {
std::ostringstream stream;
// Basic case, empty string
- CFX_WideString str;
+ WideString str;
stream << str;
EXPECT_EQ("", stream.str());
@@ -1359,7 +1359,7 @@ TEST(fxcrt, OStreamWideStringOverload) {
stream << "abc" << str << "ghi";
EXPECT_EQ("abcdefghi", stream.str());
- // Changing the CFX_WideString does not change the stream it was written to.
+ // Changing the WideString does not change the stream it was written to.
str = L"123";
EXPECT_EQ("abcdefghi", stream.str());
@@ -1370,35 +1370,35 @@ TEST(fxcrt, OStreamWideStringOverload) {
wchar_t stringWithNulls[]{'x', 'y', '\0', 'z'};
- // Writing a CFX_WideString with nulls and no specified length treats it as
+ // Writing a WideString with nulls and no specified length treats it as
// a C-style null-terminated string.
- str = CFX_WideString(stringWithNulls);
+ str = WideString(stringWithNulls);
EXPECT_EQ(2u, str.GetLength());
stream.str("");
stream << str;
EXPECT_EQ(2u, stream.tellp());
- // Writing a CFX_WideString with nulls but specifying its length treats it as
+ // Writing a WideString with nulls but specifying its length treats it as
// a C++-style string.
- str = CFX_WideString(stringWithNulls, 4);
+ str = WideString(stringWithNulls, 4);
EXPECT_EQ(4u, str.GetLength());
stream.str("");
stream << str;
EXPECT_EQ(4u, stream.tellp());
// << operators can be chained.
- CFX_WideString str1(L"abc");
- CFX_WideString str2(L"def");
+ WideString str1(L"abc");
+ WideString str2(L"def");
stream.str("");
stream << str1 << str2;
EXPECT_EQ("abcdef", stream.str());
}
-TEST(fxcrt, WideOStreamWideStringOverload) {
+TEST(WideString, WideOStreamOverload) {
std::wostringstream stream;
// Basic case, empty string
- CFX_WideString str;
+ WideString str;
stream << str;
EXPECT_EQ(L"", stream.str());
@@ -1413,7 +1413,7 @@ TEST(fxcrt, WideOStreamWideStringOverload) {
stream << L"abc" << str << L"ghi";
EXPECT_EQ(L"abcdefghi", stream.str());
- // Changing the CFX_WideString does not change the stream it was written to.
+ // Changing the WideString does not change the stream it was written to.
str = L"123";
EXPECT_EQ(L"abcdefghi", stream.str());
@@ -1424,35 +1424,35 @@ TEST(fxcrt, WideOStreamWideStringOverload) {
wchar_t stringWithNulls[]{'x', 'y', '\0', 'z'};
- // Writing a CFX_WideString with nulls and no specified length treats it as
+ // Writing a WideString with nulls and no specified length treats it as
// a C-style null-terminated string.
- str = CFX_WideString(stringWithNulls);
+ str = WideString(stringWithNulls);
EXPECT_EQ(2u, str.GetLength());
stream.str(L"");
stream << str;
EXPECT_EQ(2u, stream.tellp());
- // Writing a CFX_WideString with nulls but specifying its length treats it as
+ // Writing a WideString with nulls but specifying its length treats it as
// a C++-style string.
- str = CFX_WideString(stringWithNulls, 4);
+ str = WideString(stringWithNulls, 4);
EXPECT_EQ(4u, str.GetLength());
stream.str(L"");
stream << str;
EXPECT_EQ(4u, stream.tellp());
// << operators can be chained.
- CFX_WideString str1(L"abc");
- CFX_WideString str2(L"def");
+ WideString str1(L"abc");
+ WideString str2(L"def");
stream.str(L"");
stream << str1 << str2;
EXPECT_EQ(L"abcdef", stream.str());
}
-TEST(fxcrt, OStreamWideStringCOverload) {
+TEST(WideStringView, OStreamOverload) {
// Basic case, empty string
{
std::ostringstream stream;
- CFX_WideStringC str;
+ WideStringView str;
stream << str;
EXPECT_EQ("", stream.str());
}
@@ -1460,7 +1460,7 @@ TEST(fxcrt, OStreamWideStringCOverload) {
// Basic case, non-empty string
{
std::ostringstream stream;
- CFX_WideStringC str(L"def");
+ WideStringView str(L"def");
stream << "abc" << str << "ghi";
EXPECT_EQ("abcdefghi", stream.str());
}
@@ -1468,15 +1468,15 @@ TEST(fxcrt, OStreamWideStringCOverload) {
// Basic case, wide character
{
std::ostringstream stream;
- CFX_WideStringC str(L"\u20AC");
+ WideStringView str(L"\u20AC");
stream << str;
EXPECT_EQ("\u20AC", stream.str());
}
- // Changing the CFX_WideStringC does not change the stream it was written to.
+ // Changing the WideStringView does not change the stream it was written to.
{
std::ostringstream stream;
- CFX_WideStringC str(L"abc");
+ WideStringView str(L"abc");
stream << str;
str = L"123";
EXPECT_EQ("abc", stream.str());
@@ -1485,7 +1485,7 @@ TEST(fxcrt, OStreamWideStringCOverload) {
// Writing it again to the stream will use the latest value.
{
std::ostringstream stream;
- CFX_WideStringC str(L"abc");
+ WideStringView str(L"abc");
stream << str;
stream.str("");
str = L"123";
@@ -1493,24 +1493,24 @@ TEST(fxcrt, OStreamWideStringCOverload) {
EXPECT_EQ("123", stream.str());
}
- // Writing a CFX_WideStringC with nulls and no specified length treats it as
+ // Writing a WideStringView with nulls and no specified length treats it as
// a C-style null-terminated string.
{
wchar_t stringWithNulls[]{'x', 'y', '\0', 'z'};
std::ostringstream stream;
- CFX_WideStringC str(stringWithNulls);
+ WideStringView str(stringWithNulls);
EXPECT_EQ(2u, str.GetLength());
stream << str;
EXPECT_EQ(2u, stream.tellp());
str = L"";
}
- // Writing a CFX_WideStringC with nulls but specifying its length treats it as
+ // Writing a WideStringView with nulls but specifying its length treats it as
// a C++-style string.
{
wchar_t stringWithNulls[]{'x', 'y', '\0', 'z'};
std::ostringstream stream;
- CFX_WideStringC str(stringWithNulls, 4);
+ WideStringView str(stringWithNulls, 4);
EXPECT_EQ(4u, str.GetLength());
stream << str;
EXPECT_EQ(4u, stream.tellp());
@@ -1520,18 +1520,18 @@ TEST(fxcrt, OStreamWideStringCOverload) {
// << operators can be chained.
{
std::ostringstream stream;
- CFX_WideStringC str1(L"abc");
- CFX_WideStringC str2(L"def");
+ WideStringView str1(L"abc");
+ WideStringView str2(L"def");
stream << str1 << str2;
EXPECT_EQ("abcdef", stream.str());
}
}
-TEST(fxcrt, WideOStreamWideStringCOverload) {
+TEST(WideStringView, WideOStreamOverload) {
// Basic case, empty string
{
std::wostringstream stream;
- CFX_WideStringC str;
+ WideStringView str;
stream << str;
EXPECT_EQ(L"", stream.str());
}
@@ -1539,7 +1539,7 @@ TEST(fxcrt, WideOStreamWideStringCOverload) {
// Basic case, non-empty string
{
std::wostringstream stream;
- CFX_WideStringC str(L"def");
+ WideStringView str(L"def");
stream << "abc" << str << "ghi";
EXPECT_EQ(L"abcdefghi", stream.str());
}
@@ -1547,15 +1547,15 @@ TEST(fxcrt, WideOStreamWideStringCOverload) {
// Basic case, wide character
{
std::wostringstream stream;
- CFX_WideStringC str(L"\u20AC");
+ WideStringView str(L"\u20AC");
stream << str;
EXPECT_EQ(L"\u20AC", stream.str());
}
- // Changing the CFX_WideStringC does not change the stream it was written to.
+ // Changing the WideStringView does not change the stream it was written to.
{
std::wostringstream stream;
- CFX_WideStringC str(L"abc");
+ WideStringView str(L"abc");
stream << str;
str = L"123";
EXPECT_EQ(L"abc", stream.str());
@@ -1564,7 +1564,7 @@ TEST(fxcrt, WideOStreamWideStringCOverload) {
// Writing it again to the stream will use the latest value.
{
std::wostringstream stream;
- CFX_WideStringC str(L"abc");
+ WideStringView str(L"abc");
stream << str;
stream.str(L"");
str = L"123";
@@ -1572,23 +1572,23 @@ TEST(fxcrt, WideOStreamWideStringCOverload) {
EXPECT_EQ(L"123", stream.str());
}
- // Writing a CFX_WideStringC with nulls and no specified length treats it as
+ // Writing a WideStringView with nulls and no specified length treats it as
// a C-style null-terminated string.
{
wchar_t stringWithNulls[]{'x', 'y', '\0', 'z'};
std::wostringstream stream;
- CFX_WideStringC str(stringWithNulls);
+ WideStringView str(stringWithNulls);
EXPECT_EQ(2u, str.GetLength());
stream << str;
EXPECT_EQ(2u, stream.tellp());
}
- // Writing a CFX_WideStringC with nulls but specifying its length treats it as
+ // Writing a WideStringView with nulls but specifying its length treats it as
// a C++-style string.
{
wchar_t stringWithNulls[]{'x', 'y', '\0', 'z'};
std::wostringstream stream;
- CFX_WideStringC str(stringWithNulls, 4);
+ WideStringView str(stringWithNulls, 4);
EXPECT_EQ(4u, str.GetLength());
stream << str;
EXPECT_EQ(4u, stream.tellp());
@@ -1597,8 +1597,8 @@ TEST(fxcrt, WideOStreamWideStringCOverload) {
// << operators can be chained.
{
std::wostringstream stream;
- CFX_WideStringC str1(L"abc");
- CFX_WideStringC str2(L"def");
+ WideStringView str1(L"abc");
+ WideStringView str2(L"def");
stream << str1 << str2;
EXPECT_EQ(L"abcdef", stream.str());
}
diff --git a/core/fxcrt/xml/cfx_saxcontext.h b/core/fxcrt/xml/cfx_saxcontext.h
index f66c76c9cc..d4d74a385b 100644
--- a/core/fxcrt/xml/cfx_saxcontext.h
+++ b/core/fxcrt/xml/cfx_saxcontext.h
@@ -18,7 +18,7 @@ class CFX_SAXContext {
~CFX_SAXContext();
std::ostringstream m_TextBuf;
- CFX_ByteString m_bsTagName;
+ ByteString m_bsTagName;
CFX_SAXItem::Type m_eNode;
};
diff --git a/core/fxcrt/xml/cfx_saxreader.cpp b/core/fxcrt/xml/cfx_saxreader.cpp
index 641dc08688..e2c09d14cc 100644
--- a/core/fxcrt/xml/cfx_saxreader.cpp
+++ b/core/fxcrt/xml/cfx_saxreader.cpp
@@ -293,8 +293,8 @@ void CFX_SAXReader::ParseChar(uint8_t ch) {
m_iEntityStart = -1;
// NOTE: Relies on negative lengths being treated as empty strings.
- CFX_ByteString csEntity(m_Data.data() + iSaveStart + 1,
- CurrentDataIndex() - iSaveStart - 1);
+ ByteString csEntity(m_Data.data() + iSaveStart + 1,
+ CurrentDataIndex() - iSaveStart - 1);
int32_t iLen = csEntity.GetLength();
if (iLen == 0)
return;
@@ -649,7 +649,7 @@ void CFX_SAXReader::NotifyData() {
m_pHandler->OnTagData(
pItem->m_pNode,
m_bCharData ? CFX_SAXItem::Type::CharData : CFX_SAXItem::Type::Text,
- CFX_ByteStringC(m_Data), m_File.m_dwCur + m_dwDataOffset);
+ ByteStringView(m_Data), m_File.m_dwCur + m_dwDataOffset);
}
void CFX_SAXReader::NotifyEnter() {
@@ -662,7 +662,7 @@ void CFX_SAXReader::NotifyEnter() {
if (pItem->m_eNode == CFX_SAXItem::Type::Tag ||
pItem->m_eNode == CFX_SAXItem::Type::Instruction) {
- pItem->m_pNode = m_pHandler->OnTagEnter(CFX_ByteStringC(m_Data),
+ pItem->m_pNode = m_pHandler->OnTagEnter(ByteStringView(m_Data),
pItem->m_eNode, m_dwNodePos);
}
}
@@ -677,8 +677,8 @@ void CFX_SAXReader::NotifyAttribute() {
if (pItem->m_eNode == CFX_SAXItem::Type::Tag ||
pItem->m_eNode == CFX_SAXItem::Type::Instruction) {
- m_pHandler->OnTagAttribute(pItem->m_pNode, CFX_ByteStringC(m_Name),
- CFX_ByteStringC(m_Data));
+ m_pHandler->OnTagAttribute(pItem->m_pNode, ByteStringView(m_Name),
+ ByteStringView(m_Data));
}
}
@@ -717,7 +717,7 @@ void CFX_SAXReader::NotifyEnd() {
return;
if (pItem->m_eNode == CFX_SAXItem::Type::Tag)
- m_pHandler->OnTagEnd(pItem->m_pNode, CFX_ByteStringC(m_Data), m_dwNodePos);
+ m_pHandler->OnTagEnd(pItem->m_pNode, ByteStringView(m_Data), m_dwNodePos);
}
void CFX_SAXReader::NotifyTargetData() {
@@ -730,10 +730,10 @@ void CFX_SAXReader::NotifyTargetData() {
if (pItem->m_eNode == CFX_SAXItem::Type::Instruction) {
m_pHandler->OnTargetData(pItem->m_pNode, pItem->m_eNode,
- CFX_ByteStringC(m_Name), m_dwNodePos);
+ ByteStringView(m_Name), m_dwNodePos);
} else if (pItem->m_eNode == CFX_SAXItem::Type::Comment) {
m_pHandler->OnTargetData(pItem->m_pNode, pItem->m_eNode,
- CFX_ByteStringC(m_Data), m_dwNodePos);
+ ByteStringView(m_Data), m_dwNodePos);
}
}
diff --git a/core/fxcrt/xml/cfx_saxreader.h b/core/fxcrt/xml/cfx_saxreader.h
index 3db1c7c80c..51d9e43121 100644
--- a/core/fxcrt/xml/cfx_saxreader.h
+++ b/core/fxcrt/xml/cfx_saxreader.h
@@ -75,24 +75,24 @@ class CFX_SAXReader {
class HandlerIface {
public:
virtual ~HandlerIface() {}
- virtual CFX_SAXContext* OnTagEnter(const CFX_ByteStringC& bsTagName,
+ virtual CFX_SAXContext* OnTagEnter(const ByteStringView& bsTagName,
CFX_SAXItem::Type eType,
uint32_t dwStartPos) = 0;
virtual void OnTagAttribute(CFX_SAXContext* pTag,
- const CFX_ByteStringC& bsAttri,
- const CFX_ByteStringC& bsValue) = 0;
+ const ByteStringView& bsAttri,
+ const ByteStringView& bsValue) = 0;
virtual void OnTagBreak(CFX_SAXContext* pTag) = 0;
virtual void OnTagData(CFX_SAXContext* pTag,
CFX_SAXItem::Type eType,
- const CFX_ByteStringC& bsData,
+ const ByteStringView& bsData,
uint32_t dwStartPos) = 0;
virtual void OnTagClose(CFX_SAXContext* pTag, uint32_t dwEndPos) = 0;
virtual void OnTagEnd(CFX_SAXContext* pTag,
- const CFX_ByteStringC& bsTagName,
+ const ByteStringView& bsTagName,
uint32_t dwEndPos) = 0;
virtual void OnTargetData(CFX_SAXContext* pTag,
CFX_SAXItem::Type eType,
- const CFX_ByteStringC& bsData,
+ const ByteStringView& bsData,
uint32_t dwStartPos) = 0;
};
diff --git a/core/fxcrt/xml/cfx_saxreader_unittest.cpp b/core/fxcrt/xml/cfx_saxreader_unittest.cpp
index 62828500c9..13d06325a7 100644
--- a/core/fxcrt/xml/cfx_saxreader_unittest.cpp
+++ b/core/fxcrt/xml/cfx_saxreader_unittest.cpp
@@ -17,28 +17,28 @@ namespace {
class MockHandler : public CFX_SAXReader::HandlerIface {
public:
MOCK_METHOD3(OnTagEnter,
- CFX_SAXContext*(const CFX_ByteStringC& bsTagName,
+ CFX_SAXContext*(const ByteStringView& bsTagName,
CFX_SAXItem::Type eType,
uint32_t dwStartPos));
MOCK_METHOD3(OnTagAttribute,
void(CFX_SAXContext* pTag,
- const CFX_ByteStringC& bsAttri,
- const CFX_ByteStringC& bsValue));
+ const ByteStringView& bsAttri,
+ const ByteStringView& bsValue));
MOCK_METHOD1(OnTagBreak, void(CFX_SAXContext* pTag));
MOCK_METHOD4(OnTagData,
void(CFX_SAXContext* pTag,
CFX_SAXItem::Type eType,
- const CFX_ByteStringC& bsData,
+ const ByteStringView& bsData,
uint32_t dwStartPos));
MOCK_METHOD2(OnTagClose, void(CFX_SAXContext* pTag, uint32_t dwEndPos));
MOCK_METHOD3(OnTagEnd,
void(CFX_SAXContext* pTag,
- const CFX_ByteStringC& bsTagName,
+ const ByteStringView& bsTagName,
uint32_t dwEndPos));
MOCK_METHOD4(OnTargetData,
void(CFX_SAXContext* pTag,
CFX_SAXItem::Type eType,
- const CFX_ByteStringC& bsData,
+ const ByteStringView& bsData,
uint32_t dwStartPos));
};
diff --git a/core/fxcrt/xml/cfx_saxreaderhandler.cpp b/core/fxcrt/xml/cfx_saxreaderhandler.cpp
index b8399ff5cc..d255ce924d 100644
--- a/core/fxcrt/xml/cfx_saxreaderhandler.cpp
+++ b/core/fxcrt/xml/cfx_saxreaderhandler.cpp
@@ -18,7 +18,7 @@ CFX_SAXReaderHandler::CFX_SAXReaderHandler(CFX_ChecksumContext* pContext)
CFX_SAXReaderHandler::~CFX_SAXReaderHandler() {}
CFX_SAXContext* CFX_SAXReaderHandler::OnTagEnter(
- const CFX_ByteStringC& bsTagName,
+ const ByteStringView& bsTagName,
CFX_SAXItem::Type eType,
uint32_t dwStartPos) {
UpdateChecksum(true);
@@ -38,8 +38,8 @@ CFX_SAXContext* CFX_SAXReaderHandler::OnTagEnter(
}
void CFX_SAXReaderHandler::OnTagAttribute(CFX_SAXContext* pTag,
- const CFX_ByteStringC& bsAttri,
- const CFX_ByteStringC& bsValue) {
+ const ByteStringView& bsAttri,
+ const ByteStringView& bsValue) {
if (!pTag)
return;
pTag->m_TextBuf << " " << bsAttri << "=\"" << bsValue << "\"";
@@ -55,7 +55,7 @@ void CFX_SAXReaderHandler::OnTagBreak(CFX_SAXContext* pTag) {
void CFX_SAXReaderHandler::OnTagData(CFX_SAXContext* pTag,
CFX_SAXItem::Type eType,
- const CFX_ByteStringC& bsData,
+ const ByteStringView& bsData,
uint32_t dwStartPos) {
if (!pTag)
return;
@@ -75,13 +75,13 @@ void CFX_SAXReaderHandler::OnTagClose(CFX_SAXContext* pTag, uint32_t dwEndPos) {
if (pTag->m_eNode == CFX_SAXItem::Type::Instruction)
pTag->m_TextBuf << "?>";
else if (pTag->m_eNode == CFX_SAXItem::Type::Tag)
- pTag->m_TextBuf << "></" << pTag->m_bsTagName.AsStringC() << ">";
+ pTag->m_TextBuf << "></" << pTag->m_bsTagName.AsStringView() << ">";
UpdateChecksum(false);
}
void CFX_SAXReaderHandler::OnTagEnd(CFX_SAXContext* pTag,
- const CFX_ByteStringC& bsTagName,
+ const ByteStringView& bsTagName,
uint32_t dwEndPos) {
if (!pTag)
return;
@@ -92,7 +92,7 @@ void CFX_SAXReaderHandler::OnTagEnd(CFX_SAXContext* pTag,
void CFX_SAXReaderHandler::OnTargetData(CFX_SAXContext* pTag,
CFX_SAXItem::Type eType,
- const CFX_ByteStringC& bsData,
+ const ByteStringView& bsData,
uint32_t dwStartPos) {
if (!pTag && eType != CFX_SAXItem::Type::Comment)
return;
@@ -122,7 +122,7 @@ void CFX_SAXReaderHandler::UpdateChecksum(bool bCheckSpace) {
}
}
if (bUpdata)
- m_pContext->Update(CFX_ByteStringC(pBuffer, iLength));
+ m_pContext->Update(ByteStringView(pBuffer, iLength));
m_SAXContext.m_TextBuf.str("");
}
diff --git a/core/fxcrt/xml/cfx_saxreaderhandler.h b/core/fxcrt/xml/cfx_saxreaderhandler.h
index c5e1dc28b6..263008f1ff 100644
--- a/core/fxcrt/xml/cfx_saxreaderhandler.h
+++ b/core/fxcrt/xml/cfx_saxreaderhandler.h
@@ -18,24 +18,24 @@ class CFX_SAXReaderHandler : public CFX_SAXReader::HandlerIface {
explicit CFX_SAXReaderHandler(CFX_ChecksumContext* pContext);
~CFX_SAXReaderHandler() override;
- CFX_SAXContext* OnTagEnter(const CFX_ByteStringC& bsTagName,
+ CFX_SAXContext* OnTagEnter(const ByteStringView& bsTagName,
CFX_SAXItem::Type eType,
uint32_t dwStartPos) override;
void OnTagAttribute(CFX_SAXContext* pTag,
- const CFX_ByteStringC& bsAttri,
- const CFX_ByteStringC& bsValue) override;
+ const ByteStringView& bsAttri,
+ const ByteStringView& bsValue) override;
void OnTagBreak(CFX_SAXContext* pTag) override;
void OnTagData(CFX_SAXContext* pTag,
CFX_SAXItem::Type eType,
- const CFX_ByteStringC& bsData,
+ const ByteStringView& bsData,
uint32_t dwStartPos) override;
void OnTagClose(CFX_SAXContext* pTag, uint32_t dwEndPos) override;
void OnTagEnd(CFX_SAXContext* pTag,
- const CFX_ByteStringC& bsTagName,
+ const ByteStringView& bsTagName,
uint32_t dwEndPos) override;
void OnTargetData(CFX_SAXContext* pTag,
CFX_SAXItem::Type eType,
- const CFX_ByteStringC& bsData,
+ const ByteStringView& bsData,
uint32_t dwStartPos) override;
private:
diff --git a/core/fxcrt/xml/cfx_xmlattributenode.cpp b/core/fxcrt/xml/cfx_xmlattributenode.cpp
index 9ea6756839..6104747793 100644
--- a/core/fxcrt/xml/cfx_xmlattributenode.cpp
+++ b/core/fxcrt/xml/cfx_xmlattributenode.cpp
@@ -8,28 +8,27 @@
#include "core/fxcrt/fx_extension.h"
-CFX_XMLAttributeNode::CFX_XMLAttributeNode(const CFX_WideString& name)
+CFX_XMLAttributeNode::CFX_XMLAttributeNode(const WideString& name)
: CFX_XMLNode(), name_(name) {
ASSERT(name_.GetLength() > 0);
}
CFX_XMLAttributeNode::~CFX_XMLAttributeNode() {}
-bool CFX_XMLAttributeNode::HasAttribute(const CFX_WideString& name) const {
+bool CFX_XMLAttributeNode::HasAttribute(const WideString& name) const {
return attrs_.find(name) != attrs_.end();
}
-CFX_WideString CFX_XMLAttributeNode::GetString(
- const CFX_WideString& name) const {
+WideString CFX_XMLAttributeNode::GetString(const WideString& name) const {
auto it = attrs_.find(name);
- return it != attrs_.end() ? it->second : CFX_WideString();
+ return it != attrs_.end() ? it->second : WideString();
}
-void CFX_XMLAttributeNode::SetString(const CFX_WideString& name,
- const CFX_WideString& value) {
+void CFX_XMLAttributeNode::SetString(const WideString& name,
+ const WideString& value) {
attrs_[name] = value;
}
-void CFX_XMLAttributeNode::RemoveAttribute(const CFX_WideString& name) {
+void CFX_XMLAttributeNode::RemoveAttribute(const WideString& name) {
attrs_.erase(name);
}
diff --git a/core/fxcrt/xml/cfx_xmlattributenode.h b/core/fxcrt/xml/cfx_xmlattributenode.h
index e8f358eb59..1ac9b84db2 100644
--- a/core/fxcrt/xml/cfx_xmlattributenode.h
+++ b/core/fxcrt/xml/cfx_xmlattributenode.h
@@ -15,30 +15,30 @@
class CFX_XMLAttributeNode : public CFX_XMLNode {
public:
- explicit CFX_XMLAttributeNode(const CFX_WideString& name);
+ explicit CFX_XMLAttributeNode(const WideString& name);
~CFX_XMLAttributeNode() override;
// CFX_XMLNode
FX_XMLNODETYPE GetType() const override = 0;
std::unique_ptr<CFX_XMLNode> Clone() override = 0;
- CFX_WideString GetName() const { return name_; }
- const std::map<CFX_WideString, CFX_WideString>& GetAttributes() const {
+ WideString GetName() const { return name_; }
+ const std::map<WideString, WideString>& GetAttributes() const {
return attrs_;
}
- void SetAttributes(const std::map<CFX_WideString, CFX_WideString>& attrs) {
+ void SetAttributes(const std::map<WideString, WideString>& attrs) {
attrs_ = attrs;
}
- bool HasAttribute(const CFX_WideString& name) const;
+ bool HasAttribute(const WideString& name) const;
- void SetString(const CFX_WideString& name, const CFX_WideString& value);
- CFX_WideString GetString(const CFX_WideString& name) const;
+ void SetString(const WideString& name, const WideString& value);
+ WideString GetString(const WideString& name) const;
- void RemoveAttribute(const CFX_WideString& name);
+ void RemoveAttribute(const WideString& name);
private:
- CFX_WideString name_;
- std::map<CFX_WideString, CFX_WideString> attrs_;
+ WideString name_;
+ std::map<WideString, WideString> attrs_;
};
#endif // CORE_FXCRT_XML_CFX_XMLATTRIBUTENODE_H_
diff --git a/core/fxcrt/xml/cfx_xmlchardata.cpp b/core/fxcrt/xml/cfx_xmlchardata.cpp
index 185bd064df..902d139c99 100644
--- a/core/fxcrt/xml/cfx_xmlchardata.cpp
+++ b/core/fxcrt/xml/cfx_xmlchardata.cpp
@@ -8,7 +8,7 @@
#include "third_party/base/ptr_util.h"
-CFX_XMLCharData::CFX_XMLCharData(const CFX_WideString& wsCData)
+CFX_XMLCharData::CFX_XMLCharData(const WideString& wsCData)
: CFX_XMLText(wsCData) {}
CFX_XMLCharData::~CFX_XMLCharData() {}
diff --git a/core/fxcrt/xml/cfx_xmlchardata.h b/core/fxcrt/xml/cfx_xmlchardata.h
index c5c007be90..9a4710fa51 100644
--- a/core/fxcrt/xml/cfx_xmlchardata.h
+++ b/core/fxcrt/xml/cfx_xmlchardata.h
@@ -14,7 +14,7 @@
class CFX_XMLCharData : public CFX_XMLText {
public:
- explicit CFX_XMLCharData(const CFX_WideString& wsCData);
+ explicit CFX_XMLCharData(const WideString& wsCData);
~CFX_XMLCharData() override;
FX_XMLNODETYPE GetType() const override;
diff --git a/core/fxcrt/xml/cfx_xmldoc.cpp b/core/fxcrt/xml/cfx_xmldoc.cpp
index 6fce38cea6..e9a09b761b 100644
--- a/core/fxcrt/xml/cfx_xmldoc.cpp
+++ b/core/fxcrt/xml/cfx_xmldoc.cpp
@@ -53,7 +53,7 @@ void CFX_XMLDoc::SaveXMLNode(
CFX_XMLNode* pNode = (CFX_XMLNode*)pINode;
switch (pNode->GetType()) {
case FX_XMLNODE_Instruction: {
- CFX_WideString ws;
+ WideString ws;
CFX_XMLInstruction* pInstruction = (CFX_XMLInstruction*)pNode;
if (pInstruction->GetName().CompareNoCase(L"xml") == 0) {
ws = L"<?xml version=\"1.0\" encoding=\"";
@@ -66,13 +66,13 @@ void CFX_XMLDoc::SaveXMLNode(
ws += L"UTF-8";
}
ws += L"\"?>";
- pXMLStream->WriteString(ws.AsStringC());
+ pXMLStream->WriteString(ws.AsStringView());
} else {
ws.Format(L"<?%s", pInstruction->GetName().c_str());
- pXMLStream->WriteString(ws.AsStringC());
+ pXMLStream->WriteString(ws.AsStringView());
for (auto it : pInstruction->GetAttributes()) {
- CFX_WideString wsValue = it.second;
+ WideString wsValue = it.second;
wsValue.Replace(L"&", L"&amp;");
wsValue.Replace(L"<", L"&lt;");
wsValue.Replace(L">", L"&gt;");
@@ -84,28 +84,28 @@ void CFX_XMLDoc::SaveXMLNode(
ws += L"=\"";
ws += wsValue;
ws += L"\"";
- pXMLStream->WriteString(ws.AsStringC());
+ pXMLStream->WriteString(ws.AsStringView());
}
for (auto target : pInstruction->GetTargetData()) {
ws = L" \"";
ws += target;
ws += L"\"";
- pXMLStream->WriteString(ws.AsStringC());
+ pXMLStream->WriteString(ws.AsStringView());
}
ws = L"?>";
- pXMLStream->WriteString(ws.AsStringC());
+ pXMLStream->WriteString(ws.AsStringView());
}
break;
}
case FX_XMLNODE_Element: {
- CFX_WideString ws;
+ WideString ws;
ws = L"<";
ws += static_cast<CFX_XMLElement*>(pNode)->GetName();
- pXMLStream->WriteString(ws.AsStringC());
+ pXMLStream->WriteString(ws.AsStringView());
for (auto it : static_cast<CFX_XMLElement*>(pNode)->GetAttributes()) {
- CFX_WideString wsValue = it.second;
+ WideString wsValue = it.second;
wsValue.Replace(L"&", L"&amp;");
wsValue.Replace(L"<", L"&lt;");
wsValue.Replace(L">", L"&gt;");
@@ -117,11 +117,11 @@ void CFX_XMLDoc::SaveXMLNode(
ws += L"=\"";
ws += wsValue;
ws += L"\"";
- pXMLStream->WriteString(ws.AsStringC());
+ pXMLStream->WriteString(ws.AsStringView());
}
if (pNode->m_pChild) {
ws = L"\n>";
- pXMLStream->WriteString(ws.AsStringC());
+ pXMLStream->WriteString(ws.AsStringView());
CFX_XMLNode* pChild = pNode->m_pChild;
while (pChild) {
SaveXMLNode(pXMLStream, static_cast<CFX_XMLNode*>(pChild));
@@ -133,24 +133,24 @@ void CFX_XMLDoc::SaveXMLNode(
} else {
ws = L"\n/>";
}
- pXMLStream->WriteString(ws.AsStringC());
+ pXMLStream->WriteString(ws.AsStringView());
break;
}
case FX_XMLNODE_Text: {
- CFX_WideString ws = static_cast<CFX_XMLText*>(pNode)->GetText();
+ WideString ws = static_cast<CFX_XMLText*>(pNode)->GetText();
ws.Replace(L"&", L"&amp;");
ws.Replace(L"<", L"&lt;");
ws.Replace(L">", L"&gt;");
ws.Replace(L"\'", L"&apos;");
ws.Replace(L"\"", L"&quot;");
- pXMLStream->WriteString(ws.AsStringC());
+ pXMLStream->WriteString(ws.AsStringView());
break;
}
case FX_XMLNODE_CharData: {
- CFX_WideString ws = L"<![CDATA[";
+ WideString ws = L"<![CDATA[";
ws += static_cast<CFX_XMLCharData*>(pNode)->GetText();
ws += L"]]>";
- pXMLStream->WriteString(ws.AsStringC());
+ pXMLStream->WriteString(ws.AsStringView());
break;
}
case FX_XMLNODE_Unknown:
diff --git a/core/fxcrt/xml/cfx_xmlelement.cpp b/core/fxcrt/xml/cfx_xmlelement.cpp
index 5b5fe45561..1317e9a72b 100644
--- a/core/fxcrt/xml/cfx_xmlelement.cpp
+++ b/core/fxcrt/xml/cfx_xmlelement.cpp
@@ -15,7 +15,7 @@
#include "third_party/base/ptr_util.h"
#include "third_party/base/stl_util.h"
-CFX_XMLElement::CFX_XMLElement(const CFX_WideString& wsTag)
+CFX_XMLElement::CFX_XMLElement(const WideString& wsTag)
: CFX_XMLAttributeNode(wsTag) {}
CFX_XMLElement::~CFX_XMLElement() {}
@@ -28,7 +28,7 @@ std::unique_ptr<CFX_XMLNode> CFX_XMLElement::Clone() {
auto pClone = pdfium::MakeUnique<CFX_XMLElement>(GetName());
pClone->SetAttributes(GetAttributes());
- CFX_WideString wsText;
+ WideString wsText;
CFX_XMLNode* pChild = m_pChild;
while (pChild) {
switch (pChild->GetType()) {
@@ -44,21 +44,21 @@ std::unique_ptr<CFX_XMLNode> CFX_XMLElement::Clone() {
return std::move(pClone);
}
-CFX_WideString CFX_XMLElement::GetLocalTagName() const {
+WideString CFX_XMLElement::GetLocalTagName() const {
auto pos = GetName().Find(L':');
return pos.has_value()
? GetName().Right(GetName().GetLength() - pos.value() - 1)
: GetName();
}
-CFX_WideString CFX_XMLElement::GetNamespacePrefix() const {
+WideString CFX_XMLElement::GetNamespacePrefix() const {
auto pos = GetName().Find(L':');
- return pos.has_value() ? GetName().Left(pos.value()) : CFX_WideString();
+ return pos.has_value() ? GetName().Left(pos.value()) : WideString();
}
-CFX_WideString CFX_XMLElement::GetNamespaceURI() const {
- CFX_WideString wsAttri(L"xmlns");
- CFX_WideString wsPrefix = GetNamespacePrefix();
+WideString CFX_XMLElement::GetNamespaceURI() const {
+ WideString wsAttri(L"xmlns");
+ WideString wsPrefix = GetNamespacePrefix();
if (wsPrefix.GetLength() > 0) {
wsAttri += L":";
wsAttri += wsPrefix;
@@ -76,10 +76,10 @@ CFX_WideString CFX_XMLElement::GetNamespaceURI() const {
}
return pElement->GetString(wsAttri);
}
- return CFX_WideString();
+ return WideString();
}
-CFX_WideString CFX_XMLElement::GetTextData() const {
+WideString CFX_XMLElement::GetTextData() const {
CFX_WideTextBuf buffer;
CFX_XMLNode* pChild = m_pChild;
while (pChild) {
@@ -96,7 +96,7 @@ CFX_WideString CFX_XMLElement::GetTextData() const {
return buffer.MakeString();
}
-void CFX_XMLElement::SetTextData(const CFX_WideString& wsText) {
+void CFX_XMLElement::SetTextData(const WideString& wsText) {
if (wsText.GetLength() < 1)
return;
InsertChildNode(new CFX_XMLText(wsText));
diff --git a/core/fxcrt/xml/cfx_xmlelement.h b/core/fxcrt/xml/cfx_xmlelement.h
index 20780342af..59e3af6a44 100644
--- a/core/fxcrt/xml/cfx_xmlelement.h
+++ b/core/fxcrt/xml/cfx_xmlelement.h
@@ -15,19 +15,19 @@
class CFX_XMLElement : public CFX_XMLAttributeNode {
public:
- explicit CFX_XMLElement(const CFX_WideString& wsTag);
+ explicit CFX_XMLElement(const WideString& wsTag);
~CFX_XMLElement() override;
// CFX_XMLNode
FX_XMLNODETYPE GetType() const override;
std::unique_ptr<CFX_XMLNode> Clone() override;
- CFX_WideString GetLocalTagName() const;
- CFX_WideString GetNamespacePrefix() const;
- CFX_WideString GetNamespaceURI() const;
+ WideString GetLocalTagName() const;
+ WideString GetNamespacePrefix() const;
+ WideString GetNamespaceURI() const;
- CFX_WideString GetTextData() const;
- void SetTextData(const CFX_WideString& wsText);
+ WideString GetTextData() const;
+ void SetTextData(const WideString& wsText);
};
#endif // CORE_FXCRT_XML_CFX_XMLELEMENT_H_
diff --git a/core/fxcrt/xml/cfx_xmlinstruction.cpp b/core/fxcrt/xml/cfx_xmlinstruction.cpp
index 3c7deda92a..75a4a2eec6 100644
--- a/core/fxcrt/xml/cfx_xmlinstruction.cpp
+++ b/core/fxcrt/xml/cfx_xmlinstruction.cpp
@@ -12,7 +12,7 @@
#include "third_party/base/ptr_util.h"
#include "third_party/base/stl_util.h"
-CFX_XMLInstruction::CFX_XMLInstruction(const CFX_WideString& wsTarget)
+CFX_XMLInstruction::CFX_XMLInstruction(const WideString& wsTarget)
: CFX_XMLAttributeNode(wsTarget) {}
CFX_XMLInstruction::~CFX_XMLInstruction() {}
@@ -28,7 +28,7 @@ std::unique_ptr<CFX_XMLNode> CFX_XMLInstruction::Clone() {
return std::move(pClone);
}
-void CFX_XMLInstruction::AppendData(const CFX_WideString& wsData) {
+void CFX_XMLInstruction::AppendData(const WideString& wsData) {
m_TargetData.push_back(wsData);
}
diff --git a/core/fxcrt/xml/cfx_xmlinstruction.h b/core/fxcrt/xml/cfx_xmlinstruction.h
index 99554fc239..ff27dae3a4 100644
--- a/core/fxcrt/xml/cfx_xmlinstruction.h
+++ b/core/fxcrt/xml/cfx_xmlinstruction.h
@@ -15,21 +15,19 @@
class CFX_XMLInstruction : public CFX_XMLAttributeNode {
public:
- explicit CFX_XMLInstruction(const CFX_WideString& wsTarget);
+ explicit CFX_XMLInstruction(const WideString& wsTarget);
~CFX_XMLInstruction() override;
// CFX_XMLNode
FX_XMLNODETYPE GetType() const override;
std::unique_ptr<CFX_XMLNode> Clone() override;
- const std::vector<CFX_WideString>& GetTargetData() const {
- return m_TargetData;
- }
- void AppendData(const CFX_WideString& wsData);
+ const std::vector<WideString>& GetTargetData() const { return m_TargetData; }
+ void AppendData(const WideString& wsData);
void RemoveData(int32_t index);
private:
- std::vector<CFX_WideString> m_TargetData;
+ std::vector<WideString> m_TargetData;
};
#endif // CORE_FXCRT_XML_CFX_XMLINSTRUCTION_H_
diff --git a/core/fxcrt/xml/cfx_xmlnode.cpp b/core/fxcrt/xml/cfx_xmlnode.cpp
index 47b3105f10..7a893af4a0 100644
--- a/core/fxcrt/xml/cfx_xmlnode.cpp
+++ b/core/fxcrt/xml/cfx_xmlnode.cpp
@@ -84,7 +84,7 @@ CFX_XMLNode* CFX_XMLNode::GetPath(const wchar_t* pPath,
if (iLength == 0) {
return nullptr;
}
- CFX_WideString csPath;
+ WideString csPath;
const wchar_t* pStart = pPath;
const wchar_t* pEnd = pPath + iLength;
wchar_t ch;
@@ -105,7 +105,7 @@ CFX_XMLNode* CFX_XMLNode::GetPath(const wchar_t* pPath,
} else if (csPath.Compare(L".") == 0) {
pFind = (CFX_XMLNode*)this;
} else {
- CFX_WideString wsTag;
+ WideString wsTag;
CFX_XMLNode* pNode = m_pChild;
while (pNode) {
if (pNode->GetType() == FX_XMLNODE_Element) {
@@ -334,7 +334,7 @@ void CFX_XMLNode::SaveXMLNode(
CFX_XMLNode* pNode = (CFX_XMLNode*)this;
switch (pNode->GetType()) {
case FX_XMLNODE_Instruction: {
- CFX_WideString ws;
+ WideString ws;
CFX_XMLInstruction* pInstruction = (CFX_XMLInstruction*)pNode;
if (pInstruction->GetName().CompareNoCase(L"xml") == 0) {
ws = L"<?xml version=\"1.0\" encoding=\"";
@@ -347,13 +347,13 @@ void CFX_XMLNode::SaveXMLNode(
ws += L"UTF-8";
}
ws += L"\"?>";
- pXMLStream->WriteString(ws.AsStringC());
+ pXMLStream->WriteString(ws.AsStringView());
} else {
ws.Format(L"<?%s", pInstruction->GetName().c_str());
- pXMLStream->WriteString(ws.AsStringC());
+ pXMLStream->WriteString(ws.AsStringView());
for (auto it : pInstruction->GetAttributes()) {
- CFX_WideString wsValue = it.second;
+ WideString wsValue = it.second;
wsValue.Replace(L"&", L"&amp;");
wsValue.Replace(L"<", L"&lt;");
wsValue.Replace(L">", L"&gt;");
@@ -365,28 +365,28 @@ void CFX_XMLNode::SaveXMLNode(
ws += L"=\"";
ws += wsValue;
ws += L"\"";
- pXMLStream->WriteString(ws.AsStringC());
+ pXMLStream->WriteString(ws.AsStringView());
}
for (auto target : pInstruction->GetTargetData()) {
ws = L" \"";
ws += target;
ws += L"\"";
- pXMLStream->WriteString(ws.AsStringC());
+ pXMLStream->WriteString(ws.AsStringView());
}
ws = L"?>";
- pXMLStream->WriteString(ws.AsStringC());
+ pXMLStream->WriteString(ws.AsStringView());
}
break;
}
case FX_XMLNODE_Element: {
- CFX_WideString ws;
+ WideString ws;
ws = L"<";
ws += static_cast<CFX_XMLElement*>(pNode)->GetName();
- pXMLStream->WriteString(ws.AsStringC());
+ pXMLStream->WriteString(ws.AsStringView());
for (auto it : static_cast<CFX_XMLElement*>(pNode)->GetAttributes()) {
- CFX_WideString wsValue = it.second;
+ WideString wsValue = it.second;
wsValue.Replace(L"&", L"&amp;");
wsValue.Replace(L"<", L"&lt;");
wsValue.Replace(L">", L"&gt;");
@@ -398,11 +398,11 @@ void CFX_XMLNode::SaveXMLNode(
ws += L"=\"";
ws += wsValue;
ws += L"\"";
- pXMLStream->WriteString(ws.AsStringC());
+ pXMLStream->WriteString(ws.AsStringView());
}
if (pNode->m_pChild) {
ws = L"\n>";
- pXMLStream->WriteString(ws.AsStringC());
+ pXMLStream->WriteString(ws.AsStringView());
CFX_XMLNode* pChild = pNode->m_pChild;
while (pChild) {
pChild->SaveXMLNode(pXMLStream);
@@ -414,24 +414,24 @@ void CFX_XMLNode::SaveXMLNode(
} else {
ws = L"\n/>";
}
- pXMLStream->WriteString(ws.AsStringC());
+ pXMLStream->WriteString(ws.AsStringView());
break;
}
case FX_XMLNODE_Text: {
- CFX_WideString ws = static_cast<CFX_XMLText*>(pNode)->GetText();
+ WideString ws = static_cast<CFX_XMLText*>(pNode)->GetText();
ws.Replace(L"&", L"&amp;");
ws.Replace(L"<", L"&lt;");
ws.Replace(L">", L"&gt;");
ws.Replace(L"\'", L"&apos;");
ws.Replace(L"\"", L"&quot;");
- pXMLStream->WriteString(ws.AsStringC());
+ pXMLStream->WriteString(ws.AsStringView());
break;
}
case FX_XMLNODE_CharData: {
- CFX_WideString ws = L"<![CDATA[";
+ WideString ws = L"<![CDATA[";
ws += static_cast<CFX_XMLCharData*>(pNode)->GetText();
ws += L"]]>";
- pXMLStream->WriteString(ws.AsStringC());
+ pXMLStream->WriteString(ws.AsStringView());
break;
}
case FX_XMLNODE_Unknown:
diff --git a/core/fxcrt/xml/cfx_xmlparser.cpp b/core/fxcrt/xml/cfx_xmlparser.cpp
index ce45481512..280c06d3f1 100644
--- a/core/fxcrt/xml/cfx_xmlparser.cpp
+++ b/core/fxcrt/xml/cfx_xmlparser.cpp
@@ -101,7 +101,7 @@ int32_t CFX_XMLParser::DoParser() {
m_pParent = m_pChild;
if (m_dwCheckStatus != 0x03 && m_NodeStack.size() == 3) {
- CFX_WideString wsTag =
+ WideString wsTag =
static_cast<CFX_XMLElement*>(m_pChild)->GetLocalTagName();
if (wsTag == L"template") {
m_dwCheckStatus |= 0x01;
diff --git a/core/fxcrt/xml/cfx_xmlparser.h b/core/fxcrt/xml/cfx_xmlparser.h
index 9746d78ae8..f98b658d9a 100644
--- a/core/fxcrt/xml/cfx_xmlparser.h
+++ b/core/fxcrt/xml/cfx_xmlparser.h
@@ -38,8 +38,8 @@ class CFX_XMLParser {
CFX_XMLNode* m_pParent;
CFX_XMLNode* m_pChild;
std::stack<CFX_XMLNode*> m_NodeStack;
- CFX_WideString m_ws1;
- CFX_WideString m_ws2;
+ WideString m_ws1;
+ WideString m_ws2;
FX_XmlSyntaxResult m_syntaxParserResult;
};
diff --git a/core/fxcrt/xml/cfx_xmlsyntaxparser.cpp b/core/fxcrt/xml/cfx_xmlsyntaxparser.cpp
index bbbc4f4399..d55985240d 100644
--- a/core/fxcrt/xml/cfx_xmlsyntaxparser.cpp
+++ b/core/fxcrt/xml/cfx_xmlsyntaxparser.cpp
@@ -623,7 +623,7 @@ void CFX_XMLSyntaxParser::ParseTextChar(wchar_t character) {
m_pCurrentBlock[m_iIndexInBlock++] = character;
m_BlockBuffer.IncrementDataLength();
if (m_iEntityStart > -1 && character == L';') {
- CFX_WideString csEntity = m_BlockBuffer.GetTextData(
+ WideString csEntity = m_BlockBuffer.GetTextData(
m_iEntityStart + 1,
m_BlockBuffer.GetDataLength() - 1 - m_iEntityStart - 1);
int32_t iLen = csEntity.GetLength();
diff --git a/core/fxcrt/xml/cfx_xmlsyntaxparser.h b/core/fxcrt/xml/cfx_xmlsyntaxparser.h
index c59cabae19..d3f4bf2edb 100644
--- a/core/fxcrt/xml/cfx_xmlsyntaxparser.h
+++ b/core/fxcrt/xml/cfx_xmlsyntaxparser.h
@@ -50,27 +50,27 @@ class CFX_XMLSyntaxParser {
int32_t GetCurrentNodeNumber() const { return m_iCurrentNodeNum; }
int32_t GetLastNodeNumber() const { return m_iLastNodeNum; }
- CFX_WideString GetTargetName() const {
+ WideString GetTargetName() const {
return m_BlockBuffer.GetTextData(0, m_iTextDataLength);
}
- CFX_WideString GetTagName() const {
+ WideString GetTagName() const {
return m_BlockBuffer.GetTextData(0, m_iTextDataLength);
}
- CFX_WideString GetAttributeName() const {
+ WideString GetAttributeName() const {
return m_BlockBuffer.GetTextData(0, m_iTextDataLength);
}
- CFX_WideString GetAttributeValue() const {
+ WideString GetAttributeValue() const {
return m_BlockBuffer.GetTextData(0, m_iTextDataLength);
}
- CFX_WideString GetTextData() const {
+ WideString GetTextData() const {
return m_BlockBuffer.GetTextData(0, m_iTextDataLength);
}
- CFX_WideString GetTargetData() const {
+ WideString GetTargetData() const {
return m_BlockBuffer.GetTextData(0, m_iTextDataLength);
}
diff --git a/core/fxcrt/xml/cfx_xmltext.cpp b/core/fxcrt/xml/cfx_xmltext.cpp
index 4c41fcd9f8..83ad0434bf 100644
--- a/core/fxcrt/xml/cfx_xmltext.cpp
+++ b/core/fxcrt/xml/cfx_xmltext.cpp
@@ -8,7 +8,7 @@
#include "third_party/base/ptr_util.h"
-CFX_XMLText::CFX_XMLText(const CFX_WideString& wsText)
+CFX_XMLText::CFX_XMLText(const WideString& wsText)
: CFX_XMLNode(), m_wsText(wsText) {}
CFX_XMLText::~CFX_XMLText() {}
diff --git a/core/fxcrt/xml/cfx_xmltext.h b/core/fxcrt/xml/cfx_xmltext.h
index 20fb858302..e9f35855f5 100644
--- a/core/fxcrt/xml/cfx_xmltext.h
+++ b/core/fxcrt/xml/cfx_xmltext.h
@@ -14,18 +14,18 @@
class CFX_XMLText : public CFX_XMLNode {
public:
- explicit CFX_XMLText(const CFX_WideString& wsText);
+ explicit CFX_XMLText(const WideString& wsText);
~CFX_XMLText() override;
// CFX_XMLNode
FX_XMLNODETYPE GetType() const override;
std::unique_ptr<CFX_XMLNode> Clone() override;
- CFX_WideString GetText() const { return m_wsText; }
- void SetText(const CFX_WideString& wsText) { m_wsText = wsText; }
+ WideString GetText() const { return m_wsText; }
+ void SetText(const WideString& wsText) { m_wsText = wsText; }
private:
- CFX_WideString m_wsText;
+ WideString m_wsText;
};
#endif // CORE_FXCRT_XML_CFX_XMLTEXT_H_
diff --git a/core/fxcrt/xml/cxml_attritem.cpp b/core/fxcrt/xml/cxml_attritem.cpp
index 8e55799a62..cbbf3f6041 100644
--- a/core/fxcrt/xml/cxml_attritem.cpp
+++ b/core/fxcrt/xml/cxml_attritem.cpp
@@ -6,7 +6,7 @@
#include "core/fxcrt/xml/cxml_attritem.h"
-bool CXML_AttrItem::Matches(const CFX_ByteString& space,
- const CFX_ByteString& name) const {
+bool CXML_AttrItem::Matches(const ByteString& space,
+ const ByteString& name) const {
return (space.IsEmpty() || m_QSpaceName == space) && m_AttrName == name;
}
diff --git a/core/fxcrt/xml/cxml_attritem.h b/core/fxcrt/xml/cxml_attritem.h
index 63305e80c8..84d82950f9 100644
--- a/core/fxcrt/xml/cxml_attritem.h
+++ b/core/fxcrt/xml/cxml_attritem.h
@@ -11,11 +11,11 @@
class CXML_AttrItem {
public:
- bool Matches(const CFX_ByteString& space, const CFX_ByteString& name) const;
+ bool Matches(const ByteString& space, const ByteString& name) const;
- CFX_ByteString m_QSpaceName;
- CFX_ByteString m_AttrName;
- CFX_WideString m_Value;
+ ByteString m_QSpaceName;
+ ByteString m_AttrName;
+ WideString m_Value;
};
#endif // CORE_FXCRT_XML_CXML_ATTRITEM_H_
diff --git a/core/fxcrt/xml/cxml_attrmap.cpp b/core/fxcrt/xml/cxml_attrmap.cpp
index 8d226fe5f0..733bbeaa71 100644
--- a/core/fxcrt/xml/cxml_attrmap.cpp
+++ b/core/fxcrt/xml/cxml_attrmap.cpp
@@ -13,8 +13,8 @@ CXML_AttrMap::CXML_AttrMap() {}
CXML_AttrMap::~CXML_AttrMap() {}
-const CFX_WideString* CXML_AttrMap::Lookup(const CFX_ByteString& space,
- const CFX_ByteString& name) const {
+const WideString* CXML_AttrMap::Lookup(const ByteString& space,
+ const ByteString& name) const {
if (!m_pMap)
return nullptr;
@@ -25,9 +25,9 @@ const CFX_WideString* CXML_AttrMap::Lookup(const CFX_ByteString& space,
return nullptr;
}
-void CXML_AttrMap::SetAt(const CFX_ByteString& space,
- const CFX_ByteString& name,
- const CFX_WideString& value) {
+void CXML_AttrMap::SetAt(const ByteString& space,
+ const ByteString& name,
+ const WideString& value) {
if (!m_pMap)
m_pMap = pdfium::MakeUnique<std::vector<CXML_AttrItem>>();
@@ -38,7 +38,7 @@ void CXML_AttrMap::SetAt(const CFX_ByteString& space,
}
}
- m_pMap->push_back({space, name, CFX_WideString(value)});
+ m_pMap->push_back({space, name, WideString(value)});
}
int CXML_AttrMap::GetSize() const {
diff --git a/core/fxcrt/xml/cxml_attrmap.h b/core/fxcrt/xml/cxml_attrmap.h
index 0a026d31d7..a09522b53c 100644
--- a/core/fxcrt/xml/cxml_attrmap.h
+++ b/core/fxcrt/xml/cxml_attrmap.h
@@ -18,14 +18,14 @@ class CXML_AttrMap {
CXML_AttrMap();
~CXML_AttrMap();
- const CFX_WideString* Lookup(const CFX_ByteString& space,
- const CFX_ByteString& name) const;
+ const WideString* Lookup(const ByteString& space,
+ const ByteString& name) const;
int GetSize() const;
CXML_AttrItem& GetAt(int index) const;
- void SetAt(const CFX_ByteString& space,
- const CFX_ByteString& name,
- const CFX_WideString& value);
+ void SetAt(const ByteString& space,
+ const ByteString& name,
+ const WideString& value);
std::unique_ptr<std::vector<CXML_AttrItem>> m_pMap;
};
diff --git a/core/fxcrt/xml/cxml_content.cpp b/core/fxcrt/xml/cxml_content.cpp
index fe0c185bb7..a235009424 100644
--- a/core/fxcrt/xml/cxml_content.cpp
+++ b/core/fxcrt/xml/cxml_content.cpp
@@ -6,7 +6,7 @@
#include "core/fxcrt/xml/cxml_content.h"
-CXML_Content::CXML_Content(bool bCDATA, const CFX_WideStringC& content)
+CXML_Content::CXML_Content(bool bCDATA, const WideStringView& content)
: m_bCDATA(bCDATA), m_Content(content) {}
CXML_Content::~CXML_Content() {}
diff --git a/core/fxcrt/xml/cxml_content.h b/core/fxcrt/xml/cxml_content.h
index 641efe6720..97c1abfe1c 100644
--- a/core/fxcrt/xml/cxml_content.h
+++ b/core/fxcrt/xml/cxml_content.h
@@ -12,7 +12,7 @@
class CXML_Content : public CXML_Object {
public:
- CXML_Content(bool bCDATA, const CFX_WideStringC& content);
+ CXML_Content(bool bCDATA, const WideStringView& content);
~CXML_Content() override;
// CXML_Object:
@@ -20,7 +20,7 @@ class CXML_Content : public CXML_Object {
const CXML_Content* AsContent() const override;
bool m_bCDATA;
- CFX_WideString m_Content;
+ WideString m_Content;
};
#endif // CORE_FXCRT_XML_CXML_CONTENT_H_
diff --git a/core/fxcrt/xml/cxml_element.cpp b/core/fxcrt/xml/cxml_element.cpp
index ec0a73b00d..42cbdec311 100644
--- a/core/fxcrt/xml/cxml_element.cpp
+++ b/core/fxcrt/xml/cxml_element.cpp
@@ -19,8 +19,8 @@ std::unique_ptr<CXML_Element> CXML_Element::Parse(const void* pBuffer,
}
CXML_Element::CXML_Element(const CXML_Element* pParent,
- const CFX_ByteStringC& qSpace,
- const CFX_ByteStringC& tagname)
+ const ByteStringView& qSpace,
+ const ByteStringView& tagname)
: m_pParent(pParent), m_QSpaceName(qSpace), m_TagName(tagname) {}
CXML_Element::~CXML_Element() {}
@@ -33,23 +33,22 @@ const CXML_Element* CXML_Element::AsElement() const {
return this;
}
-CFX_ByteString CXML_Element::GetTagName(bool bQualified) const {
+ByteString CXML_Element::GetTagName(bool bQualified) const {
if (!bQualified || m_QSpaceName.IsEmpty()) {
return m_TagName;
}
- CFX_ByteString bsTag = m_QSpaceName;
+ ByteString bsTag = m_QSpaceName;
bsTag += ":";
bsTag += m_TagName;
return bsTag;
}
-CFX_ByteString CXML_Element::GetNamespace(bool bQualified) const {
+ByteString CXML_Element::GetNamespace(bool bQualified) const {
return bQualified ? m_QSpaceName : GetNamespaceURI(m_QSpaceName);
}
-CFX_ByteString CXML_Element::GetNamespaceURI(
- const CFX_ByteString& qName) const {
- const CFX_WideString* pwsSpace;
+ByteString CXML_Element::GetNamespaceURI(const ByteString& qName) const {
+ const WideString* pwsSpace;
const CXML_Element* pElement = this;
do {
if (qName.IsEmpty())
@@ -61,13 +60,13 @@ CFX_ByteString CXML_Element::GetNamespaceURI(
pElement = pElement->GetParent();
} while (pElement);
- return pwsSpace ? pwsSpace->UTF8Encode() : CFX_ByteString();
+ return pwsSpace ? pwsSpace->UTF8Encode() : ByteString();
}
void CXML_Element::GetAttrByIndex(int index,
- CFX_ByteString* space,
- CFX_ByteString* name,
- CFX_WideString* value) const {
+ ByteString* space,
+ ByteString* name,
+ WideString* value) const {
if (index < 0 || index >= m_AttrMap.GetSize())
return;
@@ -77,26 +76,26 @@ void CXML_Element::GetAttrByIndex(int index,
*value = item.m_Value;
}
-bool CXML_Element::HasAttr(const CFX_ByteStringC& name) const {
- CFX_ByteStringC bsSpace;
- CFX_ByteStringC bsName;
+bool CXML_Element::HasAttr(const ByteStringView& name) const {
+ ByteStringView bsSpace;
+ ByteStringView bsName;
FX_XML_SplitQualifiedName(name, bsSpace, bsName);
- return !!m_AttrMap.Lookup(CFX_ByteString(bsSpace), CFX_ByteString(bsName));
+ return !!m_AttrMap.Lookup(ByteString(bsSpace), ByteString(bsName));
}
-bool CXML_Element::GetAttrValue(const CFX_ByteStringC& name,
- CFX_WideString& attribute) const {
- CFX_ByteStringC bsSpace;
- CFX_ByteStringC bsName;
+bool CXML_Element::GetAttrValue(const ByteStringView& name,
+ WideString& attribute) const {
+ ByteStringView bsSpace;
+ ByteStringView bsName;
FX_XML_SplitQualifiedName(name, bsSpace, bsName);
return GetAttrValue(bsSpace, bsName, attribute);
}
-bool CXML_Element::GetAttrValue(const CFX_ByteStringC& space,
- const CFX_ByteStringC& name,
- CFX_WideString& attribute) const {
- const CFX_WideString* pValue =
- m_AttrMap.Lookup(CFX_ByteString(space), CFX_ByteString(name));
+bool CXML_Element::GetAttrValue(const ByteStringView& space,
+ const ByteStringView& name,
+ WideString& attribute) const {
+ const WideString* pValue =
+ m_AttrMap.Lookup(ByteString(space), ByteString(name));
if (!pValue)
return false;
@@ -104,13 +103,13 @@ bool CXML_Element::GetAttrValue(const CFX_ByteStringC& space,
return true;
}
-bool CXML_Element::GetAttrInteger(const CFX_ByteStringC& name,
+bool CXML_Element::GetAttrInteger(const ByteStringView& name,
int& attribute) const {
- CFX_ByteStringC bsSpace;
- CFX_ByteStringC bsName;
+ ByteStringView bsSpace;
+ ByteStringView bsName;
FX_XML_SplitQualifiedName(name, bsSpace, bsName);
- const CFX_WideString* pwsValue =
- m_AttrMap.Lookup(CFX_ByteString(bsSpace), CFX_ByteString(bsName));
+ const WideString* pwsValue =
+ m_AttrMap.Lookup(ByteString(bsSpace), ByteString(bsName));
if (!pwsValue)
return false;
@@ -118,11 +117,11 @@ bool CXML_Element::GetAttrInteger(const CFX_ByteStringC& name,
return true;
}
-bool CXML_Element::GetAttrInteger(const CFX_ByteStringC& space,
- const CFX_ByteStringC& name,
+bool CXML_Element::GetAttrInteger(const ByteStringView& space,
+ const ByteStringView& name,
int& attribute) const {
- const CFX_WideString* pwsValue =
- m_AttrMap.Lookup(CFX_ByteString(space), CFX_ByteString(name));
+ const WideString* pwsValue =
+ m_AttrMap.Lookup(ByteString(space), ByteString(name));
if (!pwsValue)
return false;
@@ -130,19 +129,19 @@ bool CXML_Element::GetAttrInteger(const CFX_ByteStringC& space,
return true;
}
-bool CXML_Element::GetAttrFloat(const CFX_ByteStringC& name,
+bool CXML_Element::GetAttrFloat(const ByteStringView& name,
float& attribute) const {
- CFX_ByteStringC bsSpace;
- CFX_ByteStringC bsName;
+ ByteStringView bsSpace;
+ ByteStringView bsName;
FX_XML_SplitQualifiedName(name, bsSpace, bsName);
return GetAttrFloat(bsSpace, bsName, attribute);
}
-bool CXML_Element::GetAttrFloat(const CFX_ByteStringC& space,
- const CFX_ByteStringC& name,
+bool CXML_Element::GetAttrFloat(const ByteStringView& space,
+ const ByteStringView& name,
float& attribute) const {
- const CFX_WideString* pValue =
- m_AttrMap.Lookup(CFX_ByteString(space), CFX_ByteString(name));
+ const WideString* pValue =
+ m_AttrMap.Lookup(ByteString(space), ByteString(name));
if (!pValue)
return false;
@@ -150,8 +149,8 @@ bool CXML_Element::GetAttrFloat(const CFX_ByteStringC& space,
return true;
}
-uint32_t CXML_Element::CountElements(const CFX_ByteStringC& space,
- const CFX_ByteStringC& tag) const {
+uint32_t CXML_Element::CountElements(const ByteStringView& space,
+ const ByteStringView& tag) const {
int count = 0;
for (const auto& pChild : m_Children) {
const CXML_Element* pKid = pChild->AsElement();
@@ -167,8 +166,8 @@ CXML_Object* CXML_Element::GetChild(uint32_t index) const {
return index < m_Children.size() ? m_Children[index].get() : nullptr;
}
-CXML_Element* CXML_Element::GetElement(const CFX_ByteStringC& space,
- const CFX_ByteStringC& tag,
+CXML_Element* CXML_Element::GetElement(const ByteStringView& space,
+ const ByteStringView& tag,
int nth) const {
if (nth < 0)
return nullptr;
@@ -196,10 +195,10 @@ uint32_t CXML_Element::FindElement(CXML_Element* pElement) const {
return 0xFFFFFFFF;
}
-void CXML_Element::SetTag(const CFX_ByteStringC& qTagName) {
+void CXML_Element::SetTag(const ByteStringView& qTagName) {
ASSERT(!qTagName.IsEmpty());
- CFX_ByteStringC bsSpace;
- CFX_ByteStringC bsName;
+ ByteStringView bsSpace;
+ ByteStringView bsName;
FX_XML_SplitQualifiedName(qTagName, bsSpace, bsName);
m_QSpaceName = bsSpace;
m_TagName = bsName;
diff --git a/core/fxcrt/xml/cxml_element.h b/core/fxcrt/xml/cxml_element.h
index a4b4b14129..91ac731021 100644
--- a/core/fxcrt/xml/cxml_element.h
+++ b/core/fxcrt/xml/cxml_element.h
@@ -18,85 +18,84 @@ class CXML_Element : public CXML_Object {
static std::unique_ptr<CXML_Element> Parse(const void* pBuffer, size_t size);
CXML_Element(const CXML_Element* pParent,
- const CFX_ByteStringC& qSpace,
- const CFX_ByteStringC& tagname);
+ const ByteStringView& qSpace,
+ const ByteStringView& tagname);
~CXML_Element() override;
// CXML_Object:
CXML_Element* AsElement() override;
const CXML_Element* AsElement() const override;
- CFX_ByteString GetTagName(bool bQualified = false) const;
- CFX_ByteString GetNamespace(bool bQualified = false) const;
- CFX_ByteString GetNamespaceURI(const CFX_ByteString& qName) const;
+ ByteString GetTagName(bool bQualified = false) const;
+ ByteString GetNamespace(bool bQualified = false) const;
+ ByteString GetNamespaceURI(const ByteString& qName) const;
const CXML_Element* GetParent() const { return m_pParent.Get(); }
uint32_t CountAttrs() const { return m_AttrMap.GetSize(); }
void GetAttrByIndex(int index,
- CFX_ByteString* space,
- CFX_ByteString* name,
- CFX_WideString* value) const;
- bool HasAttr(const CFX_ByteStringC& qName) const;
- bool GetAttrValue(const CFX_ByteStringC& name,
- CFX_WideString& attribute) const;
- CFX_WideString GetAttrValue(const CFX_ByteStringC& name) const {
- CFX_WideString attr;
+ ByteString* space,
+ ByteString* name,
+ WideString* value) const;
+ bool HasAttr(const ByteStringView& qName) const;
+ bool GetAttrValue(const ByteStringView& name, WideString& attribute) const;
+ WideString GetAttrValue(const ByteStringView& name) const {
+ WideString attr;
GetAttrValue(name, attr);
return attr;
}
- bool GetAttrValue(const CFX_ByteStringC& space,
- const CFX_ByteStringC& name,
- CFX_WideString& attribute) const;
- CFX_WideString GetAttrValue(const CFX_ByteStringC& space,
- const CFX_ByteStringC& name) const {
- CFX_WideString attr;
+ bool GetAttrValue(const ByteStringView& space,
+ const ByteStringView& name,
+ WideString& attribute) const;
+ WideString GetAttrValue(const ByteStringView& space,
+ const ByteStringView& name) const {
+ WideString attr;
GetAttrValue(space, name, attr);
return attr;
}
- bool GetAttrInteger(const CFX_ByteStringC& name, int& attribute) const;
- int GetAttrInteger(const CFX_ByteStringC& name) const {
+ bool GetAttrInteger(const ByteStringView& name, int& attribute) const;
+ int GetAttrInteger(const ByteStringView& name) const {
int attr = 0;
GetAttrInteger(name, attr);
return attr;
}
- bool GetAttrInteger(const CFX_ByteStringC& space,
- const CFX_ByteStringC& name,
+ bool GetAttrInteger(const ByteStringView& space,
+ const ByteStringView& name,
int& attribute) const;
- int GetAttrInteger(const CFX_ByteStringC& space,
- const CFX_ByteStringC& name) const {
+ int GetAttrInteger(const ByteStringView& space,
+ const ByteStringView& name) const {
int attr = 0;
GetAttrInteger(space, name, attr);
return attr;
}
- bool GetAttrFloat(const CFX_ByteStringC& name, float& attribute) const;
- float GetAttrFloat(const CFX_ByteStringC& name) const {
+ bool GetAttrFloat(const ByteStringView& name, float& attribute) const;
+ float GetAttrFloat(const ByteStringView& name) const {
float attr = 0;
GetAttrFloat(name, attr);
return attr;
}
- bool GetAttrFloat(const CFX_ByteStringC& space,
- const CFX_ByteStringC& name,
+ bool GetAttrFloat(const ByteStringView& space,
+ const ByteStringView& name,
float& attribute) const;
- float GetAttrFloat(const CFX_ByteStringC& space,
- const CFX_ByteStringC& name) const {
+ float GetAttrFloat(const ByteStringView& space,
+ const ByteStringView& name) const {
float attr = 0;
GetAttrFloat(space, name, attr);
return attr;
}
uint32_t CountChildren() const { return m_Children.size(); }
- uint32_t CountElements(const CFX_ByteStringC& space,
- const CFX_ByteStringC& tag) const;
+ uint32_t CountElements(const ByteStringView& space,
+ const ByteStringView& tag) const;
CXML_Object* GetChild(uint32_t index) const;
- CXML_Element* GetElement(const CFX_ByteStringC& space,
- const CFX_ByteStringC& tag,
+ CXML_Element* GetElement(const ByteStringView& space,
+ const ByteStringView& tag,
int nth) const;
uint32_t FindElement(CXML_Element* pElement) const;
- void SetTag(const CFX_ByteStringC& qTagName);
+ void SetTag(const ByteStringView& qTagName);
void RemoveChild(uint32_t index);
private:
@@ -104,8 +103,8 @@ class CXML_Element : public CXML_Object {
friend class CXML_Composer;
CFX_UnownedPtr<const CXML_Element> const m_pParent;
- CFX_ByteString m_QSpaceName;
- CFX_ByteString m_TagName;
+ ByteString m_QSpaceName;
+ ByteString m_TagName;
CXML_AttrMap m_AttrMap;
std::vector<std::unique_ptr<CXML_Object>> m_Children;
};
diff --git a/core/fxcrt/xml/cxml_parser.cpp b/core/fxcrt/xml/cxml_parser.cpp
index 9679e2cd41..adf83c7148 100644
--- a/core/fxcrt/xml/cxml_parser.cpp
+++ b/core/fxcrt/xml/cxml_parser.cpp
@@ -78,9 +78,9 @@ bool g_FXCRT_XML_IsNameChar(uint8_t ch) {
} // namespace
-void FX_XML_SplitQualifiedName(const CFX_ByteStringC& bsFullName,
- CFX_ByteStringC& bsSpace,
- CFX_ByteStringC& bsName) {
+void FX_XML_SplitQualifiedName(const ByteStringView& bsFullName,
+ ByteStringView& bsSpace,
+ ByteStringView& bsName) {
if (bsFullName.IsEmpty())
return;
@@ -139,7 +139,7 @@ void CXML_Parser::SkipWhiteSpaces() {
} while (ReadNextBlock());
}
-void CXML_Parser::GetName(CFX_ByteString* space, CFX_ByteString* name) {
+void CXML_Parser::GetName(ByteString* space, ByteString* name) {
m_nOffset = m_nBufferOffset + static_cast<FX_FILESIZE>(m_dwIndex);
if (IsEOF())
return;
@@ -149,7 +149,7 @@ void CXML_Parser::GetName(CFX_ByteString* space, CFX_ByteString* name) {
while (m_dwIndex < m_dwBufferSize) {
uint8_t ch = m_pBuffer[m_dwIndex];
if (ch == ':') {
- *space = CFX_ByteString(buf);
+ *space = ByteString(buf);
buf.str("");
} else if (g_FXCRT_XML_IsNameChar(ch)) {
buf << static_cast<char>(ch);
@@ -162,10 +162,10 @@ void CXML_Parser::GetName(CFX_ByteString* space, CFX_ByteString* name) {
if (m_dwIndex < m_dwBufferSize || IsEOF())
break;
} while (ReadNextBlock());
- *name = CFX_ByteString(buf);
+ *name = ByteString(buf);
}
-void CXML_Parser::SkipLiterals(const CFX_ByteStringC& str) {
+void CXML_Parser::SkipLiterals(const ByteStringView& str) {
m_nOffset = m_nBufferOffset + static_cast<FX_FILESIZE>(m_dwIndex);
if (IsEOF()) {
return;
@@ -281,7 +281,7 @@ uint32_t CXML_Parser::GetCharRef() {
return code;
}
-void CXML_Parser::GetAttrValue(CFX_WideString& value) {
+void CXML_Parser::GetAttrValue(WideString& value) {
m_nOffset = m_nBufferOffset + static_cast<FX_FILESIZE>(m_dwIndex);
if (IsEOF())
return;
@@ -323,8 +323,8 @@ void CXML_Parser::GetAttrValue(CFX_WideString& value) {
void CXML_Parser::GetTagName(bool bStartTag,
bool* bEndTag,
- CFX_ByteString* space,
- CFX_ByteString* name) {
+ ByteString* space,
+ ByteString* name) {
m_nOffset = m_nBufferOffset + static_cast<FX_FILESIZE>(m_dwIndex);
if (IsEOF())
return;
@@ -389,18 +389,18 @@ std::unique_ptr<CXML_Element> CXML_Parser::ParseElementInternal(
if (IsEOF())
return nullptr;
- CFX_ByteString tag_name;
- CFX_ByteString tag_space;
+ ByteString tag_name;
+ ByteString tag_space;
bool bEndTag;
GetTagName(bStartTag, &bEndTag, &tag_space, &tag_name);
if (tag_name.IsEmpty() || bEndTag)
return nullptr;
auto pElement = pdfium::MakeUnique<CXML_Element>(
- pParent, tag_space.AsStringC(), tag_name.AsStringC());
+ pParent, tag_space.AsStringView(), tag_name.AsStringView());
do {
- CFX_ByteString attr_space;
- CFX_ByteString attr_name;
+ ByteString attr_space;
+ ByteString attr_name;
while (m_dwIndex < m_dwBufferSize) {
SkipWhiteSpaces();
if (IsEOF())
@@ -422,7 +422,7 @@ std::unique_ptr<CXML_Element> CXML_Parser::ParseElementInternal(
if (IsEOF())
break;
- CFX_WideString attr_value;
+ WideString attr_value;
GetAttrValue(attr_value);
pElement->m_AttrMap.SetAt(attr_space, attr_name, attr_value);
}
@@ -474,19 +474,20 @@ std::unique_ptr<CXML_Element> CXML_Parser::ParseElementInternal(
SkipWhiteSpaces();
iState = 0;
} else if (ch == '/') {
- CFX_ByteString space;
- CFX_ByteString name;
+ ByteString space;
+ ByteString name;
GetName(&space, &name);
SkipWhiteSpaces();
m_dwIndex++;
iState = 10;
} else {
content << decoder.GetResult();
- CFX_WideString dataStr = content.MakeString();
+ WideString dataStr = content.MakeString();
if (!bCDATA)
dataStr.TrimRight(L" \t\r\n");
- InsertContentSegment(bCDATA, dataStr.AsStringC(), pElement.get());
+ InsertContentSegment(bCDATA, dataStr.AsStringView(),
+ pElement.get());
content.Clear();
decoder.Clear();
bCDATA = false;
@@ -524,10 +525,10 @@ std::unique_ptr<CXML_Element> CXML_Parser::ParseElementInternal(
break;
} while (ReadNextBlock());
content << decoder.GetResult();
- CFX_WideString dataStr = content.MakeString();
+ WideString dataStr = content.MakeString();
dataStr.TrimRight(L" \t\r\n");
- InsertContentSegment(bCDATA, dataStr.AsStringC(), pElement.get());
+ InsertContentSegment(bCDATA, dataStr.AsStringView(), pElement.get());
content.Clear();
decoder.Clear();
bCDATA = false;
@@ -535,7 +536,7 @@ std::unique_ptr<CXML_Element> CXML_Parser::ParseElementInternal(
}
void CXML_Parser::InsertContentSegment(bool bCDATA,
- const CFX_WideStringC& content,
+ const WideStringView& content,
CXML_Element* pElement) {
if (content.IsEmpty())
return;
diff --git a/core/fxcrt/xml/cxml_parser.h b/core/fxcrt/xml/cxml_parser.h
index 33bd711ee1..ee5a1b6e18 100644
--- a/core/fxcrt/xml/cxml_parser.h
+++ b/core/fxcrt/xml/cxml_parser.h
@@ -26,18 +26,18 @@ class CXML_Parser {
bool IsEOF();
bool HaveAvailData();
void SkipWhiteSpaces();
- void GetName(CFX_ByteString* space, CFX_ByteString* name);
- void GetAttrValue(CFX_WideString& value);
+ void GetName(ByteString* space, ByteString* name);
+ void GetAttrValue(WideString& value);
uint32_t GetCharRef();
void GetTagName(bool bStartTag,
bool* bEndTag,
- CFX_ByteString* space,
- CFX_ByteString* name);
- void SkipLiterals(const CFX_ByteStringC& str);
+ ByteString* space,
+ ByteString* name);
+ void SkipLiterals(const ByteStringView& str);
std::unique_ptr<CXML_Element> ParseElement(CXML_Element* pParent,
bool bStartTag);
void InsertContentSegment(bool bCDATA,
- const CFX_WideStringC& content,
+ const WideStringView& content,
CXML_Element* pElement);
void InsertCDATASegment(CFX_UTF8Decoder& decoder, CXML_Element* pElement);
@@ -54,8 +54,8 @@ class CXML_Parser {
size_t m_dwIndex;
};
-void FX_XML_SplitQualifiedName(const CFX_ByteStringC& bsFullName,
- CFX_ByteStringC& bsSpace,
- CFX_ByteStringC& bsName);
+void FX_XML_SplitQualifiedName(const ByteStringView& bsFullName,
+ ByteStringView& bsSpace,
+ ByteStringView& bsName);
#endif // CORE_FXCRT_XML_CXML_PARSER_H_
diff --git a/core/fxge/android/cfpf_skiafont.cpp b/core/fxge/android/cfpf_skiafont.cpp
index e00aa840e4..1ca0f576be 100644
--- a/core/fxge/android/cfpf_skiafont.cpp
+++ b/core/fxge/android/cfpf_skiafont.cpp
@@ -41,15 +41,15 @@ CFPF_SkiaFont* CFPF_SkiaFont::Retain() {
return this;
}
-CFX_ByteString CFPF_SkiaFont::GetFamilyName() {
+ByteString CFPF_SkiaFont::GetFamilyName() {
if (!m_Face)
- return CFX_ByteString();
- return CFX_ByteString(FXFT_Get_Face_Family_Name(m_Face));
+ return ByteString();
+ return ByteString(FXFT_Get_Face_Family_Name(m_Face));
}
-CFX_ByteString CFPF_SkiaFont::GetPsName() {
+ByteString CFPF_SkiaFont::GetPsName() {
if (!m_Face)
- return CFX_ByteString();
+ return ByteString();
return FXFT_Get_Postscript_Name(m_Face);
}
@@ -181,7 +181,7 @@ uint32_t CFPF_SkiaFont::GetFontData(uint32_t dwTable,
bool CFPF_SkiaFont::InitFont(CFPF_SkiaFontMgr* pFontMgr,
CFPF_SkiaFontDescriptor* pFontDes,
- const CFX_ByteStringC& bsFamily,
+ const ByteStringView& bsFamily,
uint32_t dwStyle,
uint8_t uCharset) {
if (!pFontMgr || !pFontDes)
diff --git a/core/fxge/android/cfpf_skiafont.h b/core/fxge/android/cfpf_skiafont.h
index 5686e9e31f..c842d5abb9 100644
--- a/core/fxge/android/cfpf_skiafont.h
+++ b/core/fxge/android/cfpf_skiafont.h
@@ -22,8 +22,8 @@ class CFPF_SkiaFont {
void Release();
CFPF_SkiaFont* Retain();
- CFX_ByteString GetFamilyName();
- CFX_ByteString GetPsName();
+ ByteString GetFamilyName();
+ ByteString GetPsName();
uint32_t GetFontStyle() const { return m_dwStyle; }
uint8_t GetCharset() const { return m_uCharset; }
int32_t GetGlyphIndex(wchar_t wUnicode);
@@ -38,7 +38,7 @@ class CFPF_SkiaFont {
bool InitFont(CFPF_SkiaFontMgr* pFontMgr,
CFPF_SkiaFontDescriptor* pFontDes,
- const CFX_ByteStringC& bsFamily,
+ const ByteStringView& bsFamily,
uint32_t dwStyle,
uint8_t uCharset);
diff --git a/core/fxge/android/cfpf_skiafontmgr.cpp b/core/fxge/android/cfpf_skiafontmgr.cpp
index 16a6df5f8f..a50b9ead63 100644
--- a/core/fxge/android/cfpf_skiafontmgr.cpp
+++ b/core/fxge/android/cfpf_skiafontmgr.cpp
@@ -158,7 +158,7 @@ uint32_t FPF_SkiaGetCharset(uint8_t uCharset) {
return FPF_SKIACHARSET_Default;
}
-uint32_t FPF_SKIANormalizeFontName(const CFX_ByteStringC& bsfamily) {
+uint32_t FPF_SKIANormalizeFontName(const ByteStringView& bsfamily) {
uint32_t dwHash = 0;
int32_t iLength = bsfamily.GetLength();
const char* pBuffer = bsfamily.unterminated_c_str();
@@ -171,10 +171,10 @@ uint32_t FPF_SKIANormalizeFontName(const CFX_ByteStringC& bsfamily) {
return dwHash;
}
-uint32_t FPF_SKIAGetFamilyHash(const CFX_ByteStringC& bsFamily,
+uint32_t FPF_SKIAGetFamilyHash(const ByteStringView& bsFamily,
uint32_t dwStyle,
uint8_t uCharset) {
- CFX_ByteString bsFont(bsFamily);
+ ByteString bsFont(bsFamily);
if (dwStyle & FXFONT_BOLD)
bsFont += "Bold";
if (dwStyle & FXFONT_ITALIC)
@@ -191,14 +191,14 @@ bool FPF_SkiaIsCJK(uint8_t uCharset) {
(uCharset == FX_CHARSET_Hangul) || (uCharset == FX_CHARSET_ShiftJIS);
}
-bool FPF_SkiaMaybeSymbol(const CFX_ByteStringC& bsFacename) {
- CFX_ByteString bsName(bsFacename);
+bool FPF_SkiaMaybeSymbol(const ByteStringView& bsFacename) {
+ ByteString bsName(bsFacename);
bsName.MakeLower();
return bsName.Contains("symbol");
}
-bool FPF_SkiaMaybeArabic(const CFX_ByteStringC& bsFacename) {
- CFX_ByteString bsName(bsFacename);
+bool FPF_SkiaMaybeArabic(const ByteStringView& bsFacename) {
+ ByteString bsName(bsFacename);
bsName.MakeLower();
return bsName.Contains("arabic");
}
@@ -280,7 +280,7 @@ void CFPF_SkiaFontMgr::LoadSystemFonts() {
m_bLoaded = true;
}
-CFPF_SkiaFont* CFPF_SkiaFontMgr::CreateFont(const CFX_ByteStringC& bsFamilyname,
+CFPF_SkiaFont* CFPF_SkiaFontMgr::CreateFont(const ByteStringView& bsFamilyname,
uint8_t uCharset,
uint32_t dwStyle,
uint32_t dwMatch) {
@@ -387,7 +387,7 @@ FXFT_Face CFPF_SkiaFontMgr::GetFontFace(
return face;
}
-FXFT_Face CFPF_SkiaFontMgr::GetFontFace(const CFX_ByteStringC& bsFile,
+FXFT_Face CFPF_SkiaFontMgr::GetFontFace(const ByteStringView& bsFile,
int32_t iFaceIndex) {
if (bsFile.IsEmpty())
return nullptr;
@@ -421,23 +421,23 @@ FXFT_Face CFPF_SkiaFontMgr::GetFontFace(const uint8_t* pBuffer,
return face;
}
-void CFPF_SkiaFontMgr::ScanPath(const CFX_ByteString& path) {
+void CFPF_SkiaFontMgr::ScanPath(const ByteString& path) {
DIR* handle = FX_OpenFolder(path.c_str());
if (!handle)
return;
- CFX_ByteString filename;
+ ByteString filename;
bool bFolder = false;
while (FX_GetNextFile(handle, &filename, &bFolder)) {
if (bFolder) {
if (filename == "." || filename == "..")
continue;
} else {
- CFX_ByteString ext = filename.Right(4);
+ ByteString ext = filename.Right(4);
ext.MakeLower();
if (ext != ".ttf" && ext != ".ttc" && ext != ".otf")
continue;
}
- CFX_ByteString fullpath(path);
+ ByteString fullpath(path);
fullpath += "/";
fullpath += filename;
if (bFolder)
@@ -448,8 +448,8 @@ void CFPF_SkiaFontMgr::ScanPath(const CFX_ByteString& path) {
FX_CloseFolder(handle);
}
-void CFPF_SkiaFontMgr::ScanFile(const CFX_ByteString& file) {
- FXFT_Face face = GetFontFace(file.AsStringC());
+void CFPF_SkiaFontMgr::ScanFile(const ByteString& file) {
+ FXFT_Face face = GetFontFace(file.AsStringView());
if (!face)
return;
CFPF_SkiaPathFont* pFontDesc = new CFPF_SkiaPathFont;
diff --git a/core/fxge/android/cfpf_skiafontmgr.h b/core/fxge/android/cfpf_skiafontmgr.h
index 4d0ea0e0d2..78d01717b9 100644
--- a/core/fxge/android/cfpf_skiafontmgr.h
+++ b/core/fxge/android/cfpf_skiafontmgr.h
@@ -25,7 +25,7 @@ class CFPF_SkiaFontMgr {
~CFPF_SkiaFontMgr();
void LoadSystemFonts();
- CFPF_SkiaFont* CreateFont(const CFX_ByteStringC& bsFamilyname,
+ CFPF_SkiaFont* CreateFont(const ByteStringView& bsFamilyname,
uint8_t uCharset,
uint32_t dwStyle,
uint32_t dwMatch = 0);
@@ -33,14 +33,14 @@ class CFPF_SkiaFontMgr {
bool InitFTLibrary();
FXFT_Face GetFontFace(const CFX_RetainPtr<IFX_SeekableReadStream>& pFileRead,
int32_t iFaceIndex = 0);
- FXFT_Face GetFontFace(const CFX_ByteStringC& bsFile, int32_t iFaceIndex = 0);
+ FXFT_Face GetFontFace(const ByteStringView& bsFile, int32_t iFaceIndex = 0);
FXFT_Face GetFontFace(const uint8_t* pBuffer,
size_t szBuffer,
int32_t iFaceIndex = 0);
private:
- void ScanPath(const CFX_ByteString& path);
- void ScanFile(const CFX_ByteString& file);
+ void ScanPath(const ByteString& path);
+ void ScanFile(const ByteString& file);
void ReportFace(FXFT_Face face, CFPF_SkiaFontDescriptor* pFontDesc);
bool m_bLoaded;
diff --git a/core/fxge/android/cfx_androidfontinfo.cpp b/core/fxge/android/cfx_androidfontinfo.cpp
index 1183cdeaaa..c6c3e61866 100644
--- a/core/fxge/android/cfx_androidfontinfo.cpp
+++ b/core/fxge/android/cfx_androidfontinfo.cpp
@@ -63,7 +63,7 @@ uint32_t CFX_AndroidFontInfo::GetFontData(void* hFont,
return static_cast<CFPF_SkiaFont*>(hFont)->GetFontData(table, buffer, size);
}
-bool CFX_AndroidFontInfo::GetFaceName(void* hFont, CFX_ByteString* name) {
+bool CFX_AndroidFontInfo::GetFaceName(void* hFont, ByteString* name) {
if (!hFont)
return false;
diff --git a/core/fxge/android/cfx_androidfontinfo.h b/core/fxge/android/cfx_androidfontinfo.h
index 17bbf89a3e..3fde349fb3 100644
--- a/core/fxge/android/cfx_androidfontinfo.h
+++ b/core/fxge/android/cfx_androidfontinfo.h
@@ -35,7 +35,7 @@ class CFX_AndroidFontInfo : public IFX_SystemFontInfo {
uint32_t table,
uint8_t* buffer,
uint32_t size) override;
- bool GetFaceName(void* hFont, CFX_ByteString* name) override;
+ bool GetFaceName(void* hFont, ByteString* name) override;
bool GetFontCharset(void* hFont, int* charset) override;
void DeleteFont(void* hFont) override;
diff --git a/core/fxge/apple/fx_mac_imp.cpp b/core/fxge/apple/fx_mac_imp.cpp
index 2eee8e2e62..637984797a 100644
--- a/core/fxge/apple/fx_mac_imp.cpp
+++ b/core/fxge/apple/fx_mac_imp.cpp
@@ -51,7 +51,7 @@ class CFX_MacFontInfo : public CFX_FolderFontInfo {
const char JAPAN_GOTHIC[] = "Hiragino Kaku Gothic Pro W6";
const char JAPAN_MINCHO[] = "Hiragino Mincho Pro W6";
-void GetJapanesePreference(CFX_ByteString* face, int weight, int pitch_family) {
+void GetJapanesePreference(ByteString* face, int weight, int pitch_family) {
if (face->Contains("Gothic")) {
*face = JAPAN_GOTHIC;
return;
@@ -66,9 +66,9 @@ void* CFX_MacFontInfo::MapFont(int weight,
int pitch_family,
const char* cstr_face,
int& iExact) {
- CFX_ByteString face = cstr_face;
+ ByteString face = cstr_face;
for (size_t i = 0; i < FX_ArraySize(g_Base14Substs); ++i) {
- if (face == CFX_ByteStringC(g_Base14Substs[i].m_pName)) {
+ if (face == ByteStringView(g_Base14Substs[i].m_pName)) {
face = g_Base14Substs[i].m_pSubstName;
iExact = true;
return GetFont(face.c_str());
@@ -83,7 +83,7 @@ void* CFX_MacFontInfo::MapFont(int weight,
// fonts in |m_FontList| with |face| in the name, and examine the fonts to
// see which best matches the requested characteristics.
if (!face.Contains("Bold") && !face.Contains("Italic")) {
- CFX_ByteString new_face = face;
+ ByteString new_face = face;
if (weight > 400)
new_face += " Bold";
if (bItalic)
diff --git a/core/fxge/cfx_facecache.cpp b/core/fxge/cfx_facecache.cpp
index eac28074fc..74b38ef61d 100644
--- a/core/fxge/cfx_facecache.cpp
+++ b/core/fxge/cfx_facecache.cpp
@@ -299,7 +299,7 @@ const CFX_GlyphBitmap* CFX_FaceCache::LoadGlyphBitmap(const CFX_Font* pFont,
}
}
#endif
- CFX_ByteString FaceGlyphsKey(keygen.m_Key, keygen.m_KeyLen);
+ ByteString FaceGlyphsKey(keygen.m_Key, keygen.m_KeyLen);
#if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_ || defined _SKIA_SUPPORT_ || \
defined _SKIA_SUPPORT_PATHS_
return LookUpGlyphBitmap(pFont, pMatrix, FaceGlyphsKey, glyph_index,
@@ -344,7 +344,7 @@ const CFX_GlyphBitmap* CFX_FaceCache::LoadGlyphBitmap(const CFX_Font* pFont,
keygen.Generate(6, nMatrixA, nMatrixB, nMatrixC, nMatrixD, dest_width,
anti_alias);
}
- CFX_ByteString FaceGlyphsKey2(keygen.m_Key, keygen.m_KeyLen);
+ ByteString FaceGlyphsKey2(keygen.m_Key, keygen.m_KeyLen);
text_flags |= FXTEXT_NO_NATIVETEXT;
return LookUpGlyphBitmap(pFont, pMatrix, FaceGlyphsKey2, glyph_index,
bFontStyle, dest_width, anti_alias);
@@ -375,7 +375,7 @@ void CFX_FaceCache::InitPlatform() {}
CFX_GlyphBitmap* CFX_FaceCache::LookUpGlyphBitmap(
const CFX_Font* pFont,
const CFX_Matrix* pMatrix,
- const CFX_ByteString& FaceGlyphsKey,
+ const ByteString& FaceGlyphsKey,
uint32_t glyph_index,
bool bFontStyle,
int dest_width,
diff --git a/core/fxge/cfx_facecache.h b/core/fxge/cfx_facecache.h
index 076ba1f330..58b08edde5 100644
--- a/core/fxge/cfx_facecache.h
+++ b/core/fxge/cfx_facecache.h
@@ -52,7 +52,7 @@ class CFX_FaceCache {
int anti_alias);
CFX_GlyphBitmap* LookUpGlyphBitmap(const CFX_Font* pFont,
const CFX_Matrix* pMatrix,
- const CFX_ByteString& FaceGlyphsKey,
+ const ByteString& FaceGlyphsKey,
uint32_t glyph_index,
bool bFontStyle,
int dest_width,
@@ -61,7 +61,7 @@ class CFX_FaceCache {
void DestroyPlatform();
FXFT_Face const m_Face;
- std::map<CFX_ByteString, std::unique_ptr<CFX_SizeGlyphCache>> m_SizeMap;
+ std::map<ByteString, std::unique_ptr<CFX_SizeGlyphCache>> m_SizeMap;
std::map<uint32_t, std::unique_ptr<CFX_PathData>> m_PathMap;
#if defined _SKIA_SUPPORT_ || _SKIA_SUPPORT_PATHS_
sk_sp<SkTypeface> m_pTypeface;
diff --git a/core/fxge/cfx_folderfontinfo.cpp b/core/fxge/cfx_folderfontinfo.cpp
index f4f57e4b05..0dc61c998f 100644
--- a/core/fxge/cfx_folderfontinfo.cpp
+++ b/core/fxge/cfx_folderfontinfo.cpp
@@ -36,18 +36,18 @@ const struct {
{"Times-Italic", "Times New Roman Italic"},
};
-CFX_ByteString FPDF_ReadStringFromFile(FILE* pFile, uint32_t size) {
- CFX_ByteString buffer;
+ByteString FPDF_ReadStringFromFile(FILE* pFile, uint32_t size) {
+ ByteString buffer;
if (!fread(buffer.GetBuffer(size), size, 1, pFile))
- return CFX_ByteString();
+ return ByteString();
buffer.ReleaseBuffer(size);
return buffer;
}
-CFX_ByteString FPDF_LoadTableFromTT(FILE* pFile,
- const uint8_t* pTables,
- uint32_t nTables,
- uint32_t tag) {
+ByteString FPDF_LoadTableFromTT(FILE* pFile,
+ const uint8_t* pTables,
+ uint32_t nTables,
+ uint32_t tag) {
for (uint32_t i = 0; i < nTables; i++) {
const uint8_t* p = pTables + i * 16;
if (GET_TT_LONG(p) == tag) {
@@ -57,7 +57,7 @@ CFX_ByteString FPDF_LoadTableFromTT(FILE* pFile,
return FPDF_ReadStringFromFile(pFile, size);
}
}
- return CFX_ByteString();
+ return ByteString();
}
uint32_t GetCharset(int charset) {
@@ -106,7 +106,7 @@ CFX_FolderFontInfo::CFX_FolderFontInfo() {}
CFX_FolderFontInfo::~CFX_FolderFontInfo() {}
-void CFX_FolderFontInfo::AddPath(const CFX_ByteString& path) {
+void CFX_FolderFontInfo::AddPath(const ByteString& path) {
m_PathList.push_back(path);
}
@@ -117,25 +117,25 @@ bool CFX_FolderFontInfo::EnumFontList(CFX_FontMapper* pMapper) {
return true;
}
-void CFX_FolderFontInfo::ScanPath(const CFX_ByteString& path) {
+void CFX_FolderFontInfo::ScanPath(const ByteString& path) {
FX_FileHandle* handle = FX_OpenFolder(path.c_str());
if (!handle)
return;
- CFX_ByteString filename;
+ ByteString filename;
bool bFolder;
while (FX_GetNextFile(handle, &filename, &bFolder)) {
if (bFolder) {
if (filename == "." || filename == "..")
continue;
} else {
- CFX_ByteString ext = filename.Right(4);
+ ByteString ext = filename.Right(4);
ext.MakeUpper();
if (ext != ".TTF" && ext != ".OTF" && ext != ".TTC")
continue;
}
- CFX_ByteString fullpath = path;
+ ByteString fullpath = path;
#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
fullpath += "\\";
#else
@@ -148,7 +148,7 @@ void CFX_FolderFontInfo::ScanPath(const CFX_ByteString& path) {
FX_CloseFolder(handle);
}
-void CFX_FolderFontInfo::ScanFile(const CFX_ByteString& path) {
+void CFX_FolderFontInfo::ScanFile(const ByteString& path) {
FILE* pFile = fopen(path.c_str(), "rb");
if (!pFile)
return;
@@ -190,7 +190,7 @@ void CFX_FolderFontInfo::ScanFile(const CFX_ByteString& path) {
fclose(pFile);
}
-void CFX_FolderFontInfo::ReportFace(const CFX_ByteString& path,
+void CFX_FolderFontInfo::ReportFace(const ByteString& path,
FILE* pFile,
uint32_t filesize,
uint32_t offset) {
@@ -200,21 +200,20 @@ void CFX_FolderFontInfo::ReportFace(const CFX_ByteString& path,
return;
uint32_t nTables = GET_TT_SHORT(buffer + 4);
- CFX_ByteString tables = FPDF_ReadStringFromFile(pFile, nTables * 16);
+ ByteString tables = FPDF_ReadStringFromFile(pFile, nTables * 16);
if (tables.IsEmpty())
return;
- CFX_ByteString names =
+ ByteString names =
FPDF_LoadTableFromTT(pFile, tables.raw_str(), nTables, 0x6e616d65);
if (names.IsEmpty())
return;
- CFX_ByteString facename =
- GetNameFromTT(names.raw_str(), names.GetLength(), 1);
+ ByteString facename = GetNameFromTT(names.raw_str(), names.GetLength(), 1);
if (facename.IsEmpty())
return;
- CFX_ByteString style = GetNameFromTT(names.raw_str(), names.GetLength(), 2);
+ ByteString style = GetNameFromTT(names.raw_str(), names.GetLength(), 2);
if (style != "Regular")
facename += " " + style;
@@ -223,7 +222,7 @@ void CFX_FolderFontInfo::ReportFace(const CFX_ByteString& path,
auto pInfo = pdfium::MakeUnique<CFX_FontFaceInfo>(path, facename, tables,
offset, filesize);
- CFX_ByteString os2 =
+ ByteString os2 =
FPDF_LoadTableFromTT(pFile, tables.raw_str(), nTables, 0x4f532f32);
if (os2.GetLength() >= 86) {
const uint8_t* p = os2.raw_str() + 78;
@@ -262,7 +261,7 @@ void CFX_FolderFontInfo::ReportFace(const CFX_ByteString& path,
m_FontList[facename] = std::move(pInfo);
}
-void* CFX_FolderFontInfo::GetSubstFont(const CFX_ByteString& face) {
+void* CFX_FolderFontInfo::GetSubstFont(const ByteString& face) {
for (size_t iBaseFont = 0; iBaseFont < FX_ArraySize(Base14Substs);
iBaseFont++) {
if (face == Base14Substs[iBaseFont].m_pName)
@@ -284,7 +283,7 @@ void* CFX_FolderFontInfo::FindFont(int weight,
uint32_t charset_flag = GetCharset(charset);
int32_t iBestSimilar = 0;
for (const auto& it : m_FontList) {
- const CFX_ByteString& bsName = it.first;
+ const ByteString& bsName = it.first;
CFX_FontFaceInfo* pFont = it.second.get();
if (!(pFont->m_Charsets & charset_flag) && charset != FX_CHARSET_Default)
continue;
@@ -367,7 +366,7 @@ uint32_t CFX_FolderFontInfo::GetFontData(void* hFont,
void CFX_FolderFontInfo::DeleteFont(void* hFont) {}
-bool CFX_FolderFontInfo::GetFaceName(void* hFont, CFX_ByteString* name) {
+bool CFX_FolderFontInfo::GetFaceName(void* hFont, ByteString* name) {
if (!hFont)
return false;
*name = static_cast<CFX_FontFaceInfo*>(hFont)->m_FaceName;
diff --git a/core/fxge/cfx_folderfontinfo.h b/core/fxge/cfx_folderfontinfo.h
index 82ed902b22..e7c3f21a9f 100644
--- a/core/fxge/cfx_folderfontinfo.h
+++ b/core/fxge/cfx_folderfontinfo.h
@@ -21,7 +21,7 @@ class CFX_FolderFontInfo : public IFX_SystemFontInfo {
CFX_FolderFontInfo();
~CFX_FolderFontInfo() override;
- void AddPath(const CFX_ByteString& path);
+ void AddPath(const ByteString& path);
// IFX_SytemFontInfo:
bool EnumFontList(CFX_FontMapper* pMapper) override;
@@ -43,17 +43,17 @@ class CFX_FolderFontInfo : public IFX_SystemFontInfo {
uint8_t* buffer,
uint32_t size) override;
void DeleteFont(void* hFont) override;
- bool GetFaceName(void* hFont, CFX_ByteString* name) override;
+ bool GetFaceName(void* hFont, ByteString* name) override;
bool GetFontCharset(void* hFont, int* charset) override;
protected:
- void ScanPath(const CFX_ByteString& path);
- void ScanFile(const CFX_ByteString& path);
- void ReportFace(const CFX_ByteString& path,
+ void ScanPath(const ByteString& path);
+ void ScanFile(const ByteString& path);
+ void ReportFace(const ByteString& path,
FILE* pFile,
uint32_t filesize,
uint32_t offset);
- void* GetSubstFont(const CFX_ByteString& face);
+ void* GetSubstFont(const ByteString& face);
void* FindFont(int weight,
bool bItalic,
int charset,
@@ -61,8 +61,8 @@ class CFX_FolderFontInfo : public IFX_SystemFontInfo {
const char* family,
bool bMatchName);
- std::map<CFX_ByteString, std::unique_ptr<CFX_FontFaceInfo>> m_FontList;
- std::vector<CFX_ByteString> m_PathList;
+ std::map<ByteString, std::unique_ptr<CFX_FontFaceInfo>> m_FontList;
+ std::vector<ByteString> m_PathList;
CFX_UnownedPtr<CFX_FontMapper> m_pMapper;
};
diff --git a/core/fxge/cfx_font.cpp b/core/fxge/cfx_font.cpp
index 7a51df1b85..017b120dd4 100644
--- a/core/fxge/cfx_font.cpp
+++ b/core/fxge/cfx_font.cpp
@@ -291,7 +291,7 @@ void CFX_Font::DeleteFace() {
m_Face = nullptr;
}
-void CFX_Font::LoadSubst(const CFX_ByteString& face_name,
+void CFX_Font::LoadSubst(const ByteString& face_name,
bool bTrueType,
uint32_t flags,
int weight,
@@ -446,7 +446,7 @@ bool CFX_Font::IsItalic() const {
if (FXFT_Is_Face_Italic(m_Face) == FXFT_STYLE_FLAG_ITALIC)
return true;
- CFX_ByteString str(FXFT_Get_Face_Style_Name(m_Face));
+ ByteString str(FXFT_Get_Face_Style_Name(m_Face));
str.MakeLower();
return str.Contains("italic");
}
@@ -459,31 +459,31 @@ bool CFX_Font::IsFixedWidth() const {
return m_Face && FXFT_Is_Face_fixedwidth(m_Face) != 0;
}
-CFX_ByteString CFX_Font::GetPsName() const {
+ByteString CFX_Font::GetPsName() const {
if (!m_Face)
- return CFX_ByteString();
+ return ByteString();
- CFX_ByteString psName = FXFT_Get_Postscript_Name(m_Face);
+ ByteString psName = FXFT_Get_Postscript_Name(m_Face);
if (psName.IsEmpty())
psName = "Untitled";
return psName;
}
-CFX_ByteString CFX_Font::GetFamilyName() const {
+ByteString CFX_Font::GetFamilyName() const {
if (!m_Face && !m_pSubstFont)
- return CFX_ByteString();
+ return ByteString();
if (m_Face)
- return CFX_ByteString(FXFT_Get_Face_Family_Name(m_Face));
+ return ByteString(FXFT_Get_Face_Family_Name(m_Face));
return m_pSubstFont->m_Family;
}
-CFX_ByteString CFX_Font::GetFaceName() const {
+ByteString CFX_Font::GetFaceName() const {
if (!m_Face && !m_pSubstFont)
- return CFX_ByteString();
+ return ByteString();
if (m_Face) {
- CFX_ByteString style = CFX_ByteString(FXFT_Get_Face_Style_Name(m_Face));
- CFX_ByteString facename = GetFamilyName();
+ ByteString style = ByteString(FXFT_Get_Face_Style_Name(m_Face));
+ ByteString facename = GetFamilyName();
if (facename.IsEmpty())
facename = "Untitled";
if (!style.IsEmpty() && style != "Regular")
diff --git a/core/fxge/cfx_fontmapper.cpp b/core/fxge/cfx_fontmapper.cpp
index bff9fad5c3..4e26c62eeb 100644
--- a/core/fxge/cfx_fontmapper.cpp
+++ b/core/fxge/cfx_fontmapper.cpp
@@ -170,7 +170,7 @@ const struct CODEPAGE_MAP {
};
int CompareFontFamilyString(const void* key, const void* element) {
- CFX_ByteString str_key((const char*)key);
+ ByteString str_key((const char*)key);
const AltFontFamily* family = reinterpret_cast<const AltFontFamily*>(element);
if (str_key.Contains(family->m_pFontName))
return 0;
@@ -182,8 +182,8 @@ int CompareString(const void* key, const void* element) {
reinterpret_cast<const AltFontName*>(element)->m_pName);
}
-CFX_ByteString TT_NormalizeName(const char* family) {
- CFX_ByteString norm(family);
+ByteString TT_NormalizeName(const char* family) {
+ ByteString norm(family);
norm.Remove(' ');
norm.Remove('-');
norm.Remove(',');
@@ -207,7 +207,7 @@ uint8_t GetCharsetFromCodePage(uint16_t codepage) {
return FX_CHARSET_Default;
}
-CFX_ByteString GetFontFamily(CFX_ByteString fontName, int nStyle) {
+ByteString GetFontFamily(ByteString fontName, int nStyle) {
if (fontName.Contains("Script")) {
if ((nStyle & FX_FONT_STYLE_Bold) == FX_FONT_STYLE_Bold)
fontName = "ScriptMTBold";
@@ -222,23 +222,23 @@ CFX_ByteString GetFontFamily(CFX_ByteString fontName, int nStyle) {
AltFontFamily* found = reinterpret_cast<AltFontFamily*>(bsearch(
fontName.c_str(), g_AltFontFamilies, FX_ArraySize(g_AltFontFamilies),
sizeof(AltFontFamily), CompareFontFamilyString));
- return found ? CFX_ByteString(found->m_pFontFamily) : fontName;
+ return found ? ByteString(found->m_pFontFamily) : fontName;
}
-CFX_ByteString ParseStyle(const char* pStyle, int iLen, int iIndex) {
+ByteString ParseStyle(const char* pStyle, int iLen, int iIndex) {
std::ostringstream buf;
if (!iLen || iLen <= iIndex)
- return CFX_ByteString(buf);
+ return ByteString(buf);
while (iIndex < iLen) {
if (pStyle[iIndex] == ',')
break;
buf << pStyle[iIndex];
++iIndex;
}
- return CFX_ByteString(buf);
+ return ByteString(buf);
}
-int32_t GetStyleType(const CFX_ByteString& bsStyle, bool bReverse) {
+int32_t GetStyleType(const ByteString& bsStyle, bool bReverse) {
int32_t iLen = bsStyle.GetLength();
if (!iLen)
return -1;
@@ -260,7 +260,7 @@ int32_t GetStyleType(const CFX_ByteString& bsStyle, bool bReverse) {
return -1;
}
-bool CheckSupportThirdPartFont(CFX_ByteString name, int& PitchFamily) {
+bool CheckSupportThirdPartFont(ByteString name, int& PitchFamily) {
if (name == "MyriadPro") {
PitchFamily &= ~FXFONT_FF_ROMAN;
return true;
@@ -305,23 +305,23 @@ void CFX_FontMapper::SetSystemFontInfo(
m_pFontInfo = std::move(pFontInfo);
}
-CFX_ByteString CFX_FontMapper::GetPSNameFromTT(void* hFont) {
+ByteString CFX_FontMapper::GetPSNameFromTT(void* hFont) {
if (!m_pFontInfo)
- return CFX_ByteString();
+ return ByteString();
uint32_t size = m_pFontInfo->GetFontData(hFont, kTableNAME, nullptr, 0);
if (!size)
- return CFX_ByteString();
+ return ByteString();
std::vector<uint8_t> buffer(size);
uint8_t* buffer_ptr = buffer.data();
uint32_t bytes_read =
m_pFontInfo->GetFontData(hFont, kTableNAME, buffer_ptr, size);
return bytes_read == size ? GetNameFromTT(buffer_ptr, bytes_read, 6)
- : CFX_ByteString();
+ : ByteString();
}
-void CFX_FontMapper::AddInstalledFont(const CFX_ByteString& name, int charset) {
+void CFX_FontMapper::AddInstalledFont(const ByteString& name, int charset) {
if (!m_pFontInfo)
return;
@@ -343,7 +343,7 @@ void CFX_FontMapper::AddInstalledFont(const CFX_ByteString& name, int charset) {
return;
}
- CFX_ByteString new_name = GetPSNameFromTT(hFont);
+ ByteString new_name = GetPSNameFromTT(hFont);
if (!new_name.IsEmpty())
m_LocalizedTTFonts.push_back(std::make_pair(new_name, name));
m_pFontInfo->DeleteFont(hFont);
@@ -360,22 +360,20 @@ void CFX_FontMapper::LoadInstalledFonts() {
m_bListLoaded = true;
}
-CFX_ByteString CFX_FontMapper::MatchInstalledFonts(
- const CFX_ByteString& norm_name) {
+ByteString CFX_FontMapper::MatchInstalledFonts(const ByteString& norm_name) {
LoadInstalledFonts();
int i;
for (i = pdfium::CollectionSize<int>(m_InstalledTTFonts) - 1; i >= 0; i--) {
- CFX_ByteString norm1 = TT_NormalizeName(m_InstalledTTFonts[i].c_str());
+ ByteString norm1 = TT_NormalizeName(m_InstalledTTFonts[i].c_str());
if (norm1 == norm_name)
return m_InstalledTTFonts[i];
}
for (i = pdfium::CollectionSize<int>(m_LocalizedTTFonts) - 1; i >= 0; i--) {
- CFX_ByteString norm1 =
- TT_NormalizeName(m_LocalizedTTFonts[i].first.c_str());
+ ByteString norm1 = TT_NormalizeName(m_LocalizedTTFonts[i].first.c_str());
if (norm1 == norm_name)
return m_LocalizedTTFonts[i].second;
}
- return CFX_ByteString();
+ return ByteString();
}
FXFT_Face CFX_FontMapper::UseInternalSubst(CFX_SubstFont* pSubstFont,
@@ -418,7 +416,7 @@ FXFT_Face CFX_FontMapper::UseInternalSubst(CFX_SubstFont* pSubstFont,
return m_MMFaces[0];
}
-FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name,
+FXFT_Face CFX_FontMapper::FindSubstFont(const ByteString& name,
bool bTrueType,
uint32_t flags,
int weight,
@@ -429,7 +427,7 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name,
weight = FXFONT_FW_NORMAL;
italic_angle = 0;
}
- CFX_ByteString SubstName = name;
+ ByteString SubstName = name;
SubstName.Remove(' ');
if (bTrueType && name.GetLength() > 0 && name[0] == '@')
SubstName = name.Right(name.GetLength() - 1);
@@ -445,8 +443,8 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name,
return UseInternalSubst(pSubstFont, 13, italic_angle, weight, 0);
}
int iBaseFont = 0;
- CFX_ByteString family;
- CFX_ByteString style;
+ ByteString family;
+ ByteString style;
bool bHasComma = false;
bool bHasHyphen = false;
auto pos = SubstName.Find(",", 0);
@@ -459,7 +457,7 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name,
family = SubstName;
}
for (; iBaseFont < 12; iBaseFont++) {
- if (family == CFX_ByteStringC(g_Base14FontNames[iBaseFont]))
+ if (family == ByteStringView(g_Base14FontNames[iBaseFont]))
break;
}
int PitchFamily = 0;
@@ -505,7 +503,7 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name,
const char* pStyle = style.c_str();
int i = 0;
bool bFirstItem = true;
- CFX_ByteString buf;
+ ByteString buf;
while (i < nLen) {
buf = ParseStyle(pStyle, nLen, i);
int32_t nRet = GetStyleType(buf, false);
@@ -568,7 +566,7 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name,
PitchFamily);
}
family = GetFontFamily(family, nStyle);
- CFX_ByteString match = MatchInstalledFonts(TT_NormalizeName(family.c_str()));
+ ByteString match = MatchInstalledFonts(TT_NormalizeName(family.c_str()));
if (match.IsEmpty() && family != SubstName &&
(!bHasComma && (!bHasHyphen || (bHasHyphen && !bStyleAvail)))) {
match = MatchInstalledFonts(TT_NormalizeName(SubstName.c_str()));
@@ -742,7 +740,7 @@ FXFT_Face CFX_FontMapper::FindSubstFontByUnicode(uint32_t dwUnicode,
if (ttc_size) {
face = GetCachedTTCFace(hFont, 0x74746366, ttc_size, font_size);
} else {
- CFX_ByteString SubstName;
+ ByteString SubstName;
m_pFontInfo->GetFaceName(hFont, &SubstName);
face = GetCachedFace(hFont, SubstName, weight, bItalic, font_size);
}
@@ -791,7 +789,7 @@ FXFT_Face CFX_FontMapper::GetCachedTTCFace(void* hFont,
}
FXFT_Face CFX_FontMapper::GetCachedFace(void* hFont,
- CFX_ByteString SubstName,
+ ByteString SubstName,
int weight,
bool bItalic,
uint32_t font_size) {
@@ -808,7 +806,7 @@ FXFT_Face CFX_FontMapper::GetCachedFace(void* hFont,
return face;
}
-int PDF_GetStandardFontName(CFX_ByteString* name) {
+int PDF_GetStandardFontName(ByteString* name) {
AltFontName* found = static_cast<AltFontName*>(
bsearch(name->c_str(), g_AltFontNames, FX_ArraySize(g_AltFontNames),
sizeof(AltFontName), CompareString));
diff --git a/core/fxge/cfx_fontmapper.h b/core/fxge/cfx_fontmapper.h
index 1b262bf0f4..3f28c73150 100644
--- a/core/fxge/cfx_fontmapper.h
+++ b/core/fxge/cfx_fontmapper.h
@@ -23,10 +23,10 @@ class CFX_FontMapper {
void SetSystemFontInfo(std::unique_ptr<IFX_SystemFontInfo> pFontInfo);
IFX_SystemFontInfo* GetSystemFontInfo() { return m_pFontInfo.get(); }
- void AddInstalledFont(const CFX_ByteString& name, int charset);
+ void AddInstalledFont(const ByteString& name, int charset);
void LoadInstalledFonts();
- FXFT_Face FindSubstFont(const CFX_ByteString& face_name,
+ FXFT_Face FindSubstFont(const ByteString& face_name,
bool bTrueType,
uint32_t flags,
int weight,
@@ -41,19 +41,17 @@ class CFX_FontMapper {
#endif // PDF_ENABLE_XFA
bool IsBuiltinFace(const FXFT_Face face) const;
int GetFaceSize() const;
- CFX_ByteString GetFaceName(int index) const {
- return m_FaceArray[index].name;
- }
+ ByteString GetFaceName(int index) const { return m_FaceArray[index].name; }
- std::vector<CFX_ByteString> m_InstalledTTFonts;
- std::vector<std::pair<CFX_ByteString, CFX_ByteString>> m_LocalizedTTFonts;
+ std::vector<ByteString> m_InstalledTTFonts;
+ std::vector<std::pair<ByteString, ByteString>> m_LocalizedTTFonts;
private:
static const size_t MM_FACE_COUNT = 2;
static const size_t FOXIT_FACE_COUNT = 14;
- CFX_ByteString GetPSNameFromTT(void* hFont);
- CFX_ByteString MatchInstalledFonts(const CFX_ByteString& norm_name);
+ ByteString GetPSNameFromTT(void* hFont);
+ ByteString MatchInstalledFonts(const ByteString& norm_name);
FXFT_Face UseInternalSubst(CFX_SubstFont* pSubstFont,
int iBaseFont,
int italic_angle,
@@ -64,19 +62,19 @@ class CFX_FontMapper {
uint32_t ttc_size,
uint32_t font_size);
FXFT_Face GetCachedFace(void* hFont,
- CFX_ByteString SubstName,
+ ByteString SubstName,
int weight,
bool bItalic,
uint32_t font_size);
struct FaceData {
- CFX_ByteString name;
+ ByteString name;
uint32_t charset;
};
bool m_bListLoaded;
FXFT_Face m_MMFaces[MM_FACE_COUNT];
- CFX_ByteString m_LastFamily;
+ ByteString m_LastFamily;
std::vector<FaceData> m_FaceArray;
std::unique_ptr<IFX_SystemFontInfo> m_pFontInfo;
FXFT_Face m_FoxitFaces[FOXIT_FACE_COUNT];
diff --git a/core/fxge/cfx_fontmgr.cpp b/core/fxge/cfx_fontmgr.cpp
index c8beb515f0..f68598e4b6 100644
--- a/core/fxge/cfx_fontmgr.cpp
+++ b/core/fxge/cfx_fontmgr.cpp
@@ -46,18 +46,18 @@ const BuiltinFont g_MMFonts[2] = {
{g_FoxitSansMMFontData, 66919},
};
-CFX_ByteString KeyNameFromFace(const CFX_ByteString& face_name,
- int weight,
- bool bItalic) {
- CFX_ByteString key(face_name);
+ByteString KeyNameFromFace(const ByteString& face_name,
+ int weight,
+ bool bItalic) {
+ ByteString key(face_name);
key += ',';
- key += CFX_ByteString::FormatInteger(weight);
+ key += ByteString::FormatInteger(weight);
key += bItalic ? 'I' : 'N';
return key;
}
-CFX_ByteString KeyNameFromSize(int ttc_size, uint32_t checksum) {
- CFX_ByteString key;
+ByteString KeyNameFromSize(int ttc_size, uint32_t checksum) {
+ ByteString key;
key.Format("%d:%d", ttc_size, checksum);
return key;
}
@@ -110,7 +110,7 @@ void CFX_FontMgr::SetSystemFontInfo(
m_pBuiltinMapper->SetSystemFontInfo(std::move(pFontInfo));
}
-FXFT_Face CFX_FontMgr::FindSubstFont(const CFX_ByteString& face_name,
+FXFT_Face CFX_FontMgr::FindSubstFont(const ByteString& face_name,
bool bTrueType,
uint32_t flags,
int weight,
@@ -122,7 +122,7 @@ FXFT_Face CFX_FontMgr::FindSubstFont(const CFX_ByteString& face_name,
italic_angle, CharsetCP, pSubstFont);
}
-FXFT_Face CFX_FontMgr::GetCachedFace(const CFX_ByteString& face_name,
+FXFT_Face CFX_FontMgr::GetCachedFace(const ByteString& face_name,
int weight,
bool bItalic,
uint8_t*& pFontData) {
@@ -136,7 +136,7 @@ FXFT_Face CFX_FontMgr::GetCachedFace(const CFX_ByteString& face_name,
return pFontDesc->m_SingleFace;
}
-FXFT_Face CFX_FontMgr::AddCachedFace(const CFX_ByteString& face_name,
+FXFT_Face CFX_FontMgr::AddCachedFace(const ByteString& face_name,
int weight,
bool bItalic,
uint8_t* pData,
diff --git a/core/fxge/cfx_fontmgr.h b/core/fxge/cfx_fontmgr.h
index 7ccad807df..eddb1efd56 100644
--- a/core/fxge/cfx_fontmgr.h
+++ b/core/fxge/cfx_fontmgr.h
@@ -24,11 +24,11 @@ class CFX_FontMgr {
void InitFTLibrary();
- FXFT_Face GetCachedFace(const CFX_ByteString& face_name,
+ FXFT_Face GetCachedFace(const ByteString& face_name,
int weight,
bool bItalic,
uint8_t*& pFontData);
- FXFT_Face AddCachedFace(const CFX_ByteString& face_name,
+ FXFT_Face AddCachedFace(const ByteString& face_name,
int weight,
bool bItalic,
uint8_t* pData,
@@ -47,7 +47,7 @@ class CFX_FontMgr {
FXFT_Face GetFixedFace(const uint8_t* pData, uint32_t size, int face_index);
void ReleaseFace(FXFT_Face face);
void SetSystemFontInfo(std::unique_ptr<IFX_SystemFontInfo> pFontInfo);
- FXFT_Face FindSubstFont(const CFX_ByteString& face_name,
+ FXFT_Face FindSubstFont(const ByteString& face_name,
bool bTrueType,
uint32_t flags,
int weight,
@@ -61,7 +61,7 @@ class CFX_FontMgr {
private:
std::unique_ptr<CFX_FontMapper> m_pBuiltinMapper;
- std::map<CFX_ByteString, std::unique_ptr<CTTFontDesc>> m_FaceMap;
+ std::map<ByteString, std::unique_ptr<CTTFontDesc>> m_FaceMap;
FXFT_Library m_FTLibrary;
bool m_FTLibrarySupportsHinting;
};
diff --git a/core/fxge/cfx_renderdevice.cpp b/core/fxge/cfx_renderdevice.cpp
index 959c909b5e..5e9f5ae0c9 100644
--- a/core/fxge/cfx_renderdevice.cpp
+++ b/core/fxge/cfx_renderdevice.cpp
@@ -336,7 +336,7 @@ bool ShouldDrawDeviceText(const CFX_Font* pFont, uint32_t text_flags) {
if (text_flags & FXFONT_CIDFONT)
return false;
- const CFX_ByteString bsPsName = pFont->GetPsName();
+ const ByteString bsPsName = pFont->GetPsName();
if (bsPsName.Contains("+ZJHL"))
return false;
diff --git a/core/fxge/cfx_substfont.h b/core/fxge/cfx_substfont.h
index 01196d442a..5225bd38f3 100644
--- a/core/fxge/cfx_substfont.h
+++ b/core/fxge/cfx_substfont.h
@@ -16,7 +16,7 @@ class CFX_SubstFont {
public:
CFX_SubstFont();
- CFX_ByteString m_Family;
+ ByteString m_Family;
int m_Charset;
uint32_t m_SubstFlags;
int m_Weight;
diff --git a/core/fxge/fx_font.h b/core/fxge/fx_font.h
index 57fdb54821..021efee7d9 100644
--- a/core/fxge/fx_font.h
+++ b/core/fxge/fx_font.h
@@ -87,7 +87,7 @@ class CFX_Font {
CFX_Font();
~CFX_Font();
- void LoadSubst(const CFX_ByteString& face_name,
+ void LoadSubst(const ByteString& face_name,
bool bTrueType,
uint32_t flags,
int weight,
@@ -130,9 +130,9 @@ class CFX_Font {
bool IsBold() const;
bool IsFixedWidth() const;
bool IsVertical() const { return m_bVertical; }
- CFX_ByteString GetPsName() const;
- CFX_ByteString GetFamilyName() const;
- CFX_ByteString GetFaceName() const;
+ ByteString GetPsName() const;
+ ByteString GetFamilyName() const;
+ ByteString GetFaceName() const;
bool IsTTFont() const;
bool GetBBox(FX_RECT& bbox);
bool IsEmbedded() const { return m_bEmbedded; }
@@ -183,15 +183,15 @@ class CFX_Font {
class CFX_FontFaceInfo {
public:
- CFX_FontFaceInfo(CFX_ByteString filePath,
- CFX_ByteString faceName,
- CFX_ByteString fontTables,
+ CFX_FontFaceInfo(ByteString filePath,
+ ByteString faceName,
+ ByteString fontTables,
uint32_t fontOffset,
uint32_t fileSize);
- const CFX_ByteString m_FilePath;
- const CFX_ByteString m_FaceName;
- const CFX_ByteString m_FontTables;
+ const ByteString m_FilePath;
+ const ByteString m_FaceName;
+ const ByteString m_FontTables;
const uint32_t m_FontOffset;
const uint32_t m_FileSize;
uint32_t m_Styles;
@@ -229,10 +229,10 @@ FX_RECT FXGE_GetGlyphsBBox(const std::vector<FXTEXT_GLYPHPOS>& glyphs,
float retinaScaleX,
float retinaScaleY);
-CFX_ByteString GetNameFromTT(const uint8_t* name_table,
- uint32_t name_table_size,
- uint32_t name);
+ByteString GetNameFromTT(const uint8_t* name_table,
+ uint32_t name_table_size,
+ uint32_t name);
-int PDF_GetStandardFontName(CFX_ByteString* name);
+int PDF_GetStandardFontName(ByteString* name);
#endif // CORE_FXGE_FX_FONT_H_
diff --git a/core/fxge/fx_ge_fontmap.cpp b/core/fxge/fx_ge_fontmap.cpp
index 7ac4fada5c..0f2703875d 100644
--- a/core/fxge/fx_ge_fontmap.cpp
+++ b/core/fxge/fx_ge_fontmap.cpp
@@ -9,28 +9,28 @@
#include "core/fxge/cfx_fontmapper.h"
#include "core/fxge/ifx_systemfontinfo.h"
-static CFX_ByteString GetStringFromTable(const uint8_t* string_ptr,
- uint32_t string_ptr_length,
- uint16_t offset,
- uint16_t length) {
+static ByteString GetStringFromTable(const uint8_t* string_ptr,
+ uint32_t string_ptr_length,
+ uint16_t offset,
+ uint16_t length) {
if (string_ptr_length < static_cast<uint32_t>(offset + length)) {
- return CFX_ByteString();
+ return ByteString();
}
- return CFX_ByteString(string_ptr + offset, length);
+ return ByteString(string_ptr + offset, length);
}
-CFX_ByteString GetNameFromTT(const uint8_t* name_table,
- uint32_t name_table_size,
- uint32_t name_id) {
+ByteString GetNameFromTT(const uint8_t* name_table,
+ uint32_t name_table_size,
+ uint32_t name_id) {
if (!name_table || name_table_size < 6) {
- return CFX_ByteString();
+ return ByteString();
}
uint32_t name_count = GET_TT_SHORT(name_table + 2);
uint32_t string_offset = GET_TT_SHORT(name_table + 4);
// We will ignore the possibility of overlap of structures and
// string table as if it's all corrupt there's not a lot we can do.
if (name_table_size < string_offset) {
- return CFX_ByteString();
+ return ByteString();
}
const uint8_t* string_ptr = name_table + string_offset;
@@ -38,7 +38,7 @@ CFX_ByteString GetNameFromTT(const uint8_t* name_table,
name_table += 6;
name_table_size -= 6;
if (name_table_size < name_count * 12) {
- return CFX_ByteString();
+ return ByteString();
}
for (uint32_t i = 0; i < name_count; i++, name_table += 12) {
@@ -49,7 +49,7 @@ CFX_ByteString GetNameFromTT(const uint8_t* name_table,
GET_TT_SHORT(name_table + 8));
}
}
- return CFX_ByteString();
+ return ByteString();
}
#ifdef PDF_ENABLE_XFA
void* IFX_SystemFontInfo::MapFontByUnicode(uint32_t dwUnicode,
@@ -79,9 +79,9 @@ std::unique_ptr<IFX_SystemFontInfo> IFX_SystemFontInfo::CreateDefault(
}
#endif
-CFX_FontFaceInfo::CFX_FontFaceInfo(CFX_ByteString filePath,
- CFX_ByteString faceName,
- CFX_ByteString fontTables,
+CFX_FontFaceInfo::CFX_FontFaceInfo(ByteString filePath,
+ ByteString faceName,
+ ByteString fontTables,
uint32_t fontOffset,
uint32_t fileSize)
: m_FilePath(filePath),
diff --git a/core/fxge/fx_ge_linux.cpp b/core/fxge/fx_ge_linux.cpp
index d17ddf2d3d..650510f63e 100644
--- a/core/fxge/fx_ge_linux.cpp
+++ b/core/fxge/fx_ge_linux.cpp
@@ -44,7 +44,7 @@ const char* const g_LinuxHGFontList[] = {
size_t GetJapanesePreference(const char* facearr,
int weight,
int pitch_family) {
- CFX_ByteString face = facearr;
+ ByteString face = facearr;
if (face.Contains("Gothic") ||
face.Contains("\x83\x53\x83\x56\x83\x62\x83\x4e")) {
if (face.Contains("PGothic") ||
diff --git a/core/fxge/ifx_systemfontinfo.h b/core/fxge/ifx_systemfontinfo.h
index ca7ca2c455..cb85f7fde4 100644
--- a/core/fxge/ifx_systemfontinfo.h
+++ b/core/fxge/ifx_systemfontinfo.h
@@ -42,7 +42,7 @@ class IFX_SystemFontInfo {
uint32_t table,
uint8_t* buffer,
uint32_t size) = 0;
- virtual bool GetFaceName(void* hFont, CFX_ByteString* name) = 0;
+ virtual bool GetFaceName(void* hFont, ByteString* name) = 0;
virtual bool GetFontCharset(void* hFont, int* charset) = 0;
virtual int GetFaceIndex(void* hFont);
virtual void DeleteFont(void* hFont) = 0;
diff --git a/core/fxge/win32/cfx_psrenderer.cpp b/core/fxge/win32/cfx_psrenderer.cpp
index c02058d1dd..5586d9f921 100644
--- a/core/fxge/win32/cfx_psrenderer.cpp
+++ b/core/fxge/win32/cfx_psrenderer.cpp
@@ -669,9 +669,9 @@ bool CFX_PSRenderer::DrawText(int nChars,
last_fontnum = ps_fontnum;
}
buf << pCharPos[i].m_Origin.x << " " << pCharPos[i].m_Origin.y << " m";
- CFX_ByteString hex;
+ ByteString hex;
hex.Format("<%02X>", ps_glyphindex);
- buf << hex.AsStringC() << "Tj\n";
+ buf << hex.AsStringView() << "Tj\n";
}
buf << "Q\n";
m_pStream->WriteBlock(buf.str().c_str(), buf.tellp());
diff --git a/core/fxge/win32/cfx_windowsdib.h b/core/fxge/win32/cfx_windowsdib.h
index 3ecbb5835d..28f152acfa 100644
--- a/core/fxge/win32/cfx_windowsdib.h
+++ b/core/fxge/win32/cfx_windowsdib.h
@@ -33,8 +33,7 @@ class CFX_WindowsDIB : public CFX_DIBitmap {
~CFX_WindowsDIB() override;
- static CFX_ByteString GetBitmapInfo(
- const CFX_RetainPtr<CFX_DIBitmap>& pBitmap);
+ static ByteString GetBitmapInfo(const CFX_RetainPtr<CFX_DIBitmap>& pBitmap);
static HBITMAP GetDDBitmap(const CFX_RetainPtr<CFX_DIBitmap>& pBitmap,
HDC hDC);
diff --git a/core/fxge/win32/cpsoutput.cpp b/core/fxge/win32/cpsoutput.cpp
index 1af6dbdced..83f2fc09c6 100644
--- a/core/fxge/win32/cpsoutput.cpp
+++ b/core/fxge/win32/cpsoutput.cpp
@@ -31,6 +31,6 @@ bool CPSOutput::WriteBlock(const void* str, size_t len) {
return true;
}
-bool CPSOutput::WriteString(const CFX_ByteStringC& str) {
+bool CPSOutput::WriteString(const ByteStringView& str) {
return WriteBlock(str.unterminated_c_str(), str.GetLength());
}
diff --git a/core/fxge/win32/cpsoutput.h b/core/fxge/win32/cpsoutput.h
index 42ad109a80..d140de95f4 100644
--- a/core/fxge/win32/cpsoutput.h
+++ b/core/fxge/win32/cpsoutput.h
@@ -19,7 +19,7 @@ class CPSOutput : public IFX_WriteStream {
// IFX_Writestream
bool WriteBlock(const void* str, size_t len) override;
- bool WriteString(const CFX_ByteStringC& str) override;
+ bool WriteString(const ByteStringView& str) override;
private:
HDC m_hDC;
diff --git a/core/fxge/win32/fx_win32_device.cpp b/core/fxge/win32/fx_win32_device.cpp
index 9c8da591c6..bb7bf6fea1 100644
--- a/core/fxge/win32/fx_win32_device.cpp
+++ b/core/fxge/win32/fx_win32_device.cpp
@@ -73,7 +73,7 @@ const FontNameMap g_JpFontNameMap[] = {
{"MS Gothic", "Jun101-Light"},
};
-bool GetSubFontName(CFX_ByteString* name) {
+bool GetSubFontName(ByteString* name) {
for (size_t i = 0; i < FX_ArraySize(g_JpFontNameMap); ++i) {
if (!FXSYS_stricmp(name->c_str(), g_JpFontNameMap[i].m_pSrcFontName)) {
*name = g_JpFontNameMap[i].m_pSubFontName;
@@ -349,23 +349,21 @@ class CFX_Win32FontInfo final : public IFX_SystemFontInfo {
uint32_t table,
uint8_t* buffer,
uint32_t size) override;
- bool GetFaceName(void* hFont, CFX_ByteString* name) override;
+ bool GetFaceName(void* hFont, ByteString* name) override;
bool GetFontCharset(void* hFont, int* charset) override;
void DeleteFont(void* hFont) override;
bool IsOpenTypeFromDiv(const LOGFONTA* plf);
bool IsSupportFontFormDiv(const LOGFONTA* plf);
void AddInstalledFont(const LOGFONTA* plf, uint32_t FontType);
- void GetGBPreference(CFX_ByteString& face, int weight, int picth_family);
- void GetJapanesePreference(CFX_ByteString& face,
- int weight,
- int picth_family);
- CFX_ByteString FindFont(const CFX_ByteString& name);
+ void GetGBPreference(ByteString& face, int weight, int picth_family);
+ void GetJapanesePreference(ByteString& face, int weight, int picth_family);
+ ByteString FindFont(const ByteString& name);
HDC m_hDC;
CFX_UnownedPtr<CFX_FontMapper> m_pMapper;
- CFX_ByteString m_LastFamily;
- CFX_ByteString m_KaiTi, m_FangSong;
+ ByteString m_LastFamily;
+ ByteString m_KaiTi, m_FangSong;
};
int CALLBACK FontEnumProc(const LOGFONTA* plf,
@@ -429,7 +427,7 @@ bool CFX_Win32FontInfo::IsSupportFontFormDiv(const LOGFONTA* plf) {
void CFX_Win32FontInfo::AddInstalledFont(const LOGFONTA* plf,
uint32_t FontType) {
- CFX_ByteString name(plf->lfFaceName);
+ ByteString name(plf->lfFaceName);
if (name.GetLength() > 0 && name[0] == '@')
return;
@@ -458,21 +456,21 @@ bool CFX_Win32FontInfo::EnumFontList(CFX_FontMapper* pMapper) {
return true;
}
-CFX_ByteString CFX_Win32FontInfo::FindFont(const CFX_ByteString& name) {
+ByteString CFX_Win32FontInfo::FindFont(const ByteString& name) {
if (!m_pMapper)
return name;
for (size_t i = 0; i < m_pMapper->m_InstalledTTFonts.size(); ++i) {
- CFX_ByteString thisname = m_pMapper->m_InstalledTTFonts[i];
+ ByteString thisname = m_pMapper->m_InstalledTTFonts[i];
if (thisname.Left(name.GetLength()) == name)
return m_pMapper->m_InstalledTTFonts[i];
}
for (size_t i = 0; i < m_pMapper->m_LocalizedTTFonts.size(); ++i) {
- CFX_ByteString thisname = m_pMapper->m_LocalizedTTFonts[i].first;
+ ByteString thisname = m_pMapper->m_LocalizedTTFonts[i].first;
if (thisname.Left(name.GetLength()) == name)
return m_pMapper->m_LocalizedTTFonts[i].second;
}
- return CFX_ByteString();
+ return ByteString();
}
void* CFX_Win32FallbackFontInfo::MapFont(int weight,
@@ -500,7 +498,7 @@ void* CFX_Win32FallbackFontInfo::MapFont(int weight,
return FindFont(weight, bItalic, charset, pitch_family, cstr_face, !bCJK);
}
-void CFX_Win32FontInfo::GetGBPreference(CFX_ByteString& face,
+void CFX_Win32FontInfo::GetGBPreference(ByteString& face,
int weight,
int picth_family) {
if (face.Contains("KaiTi") || face.Contains("\xbf\xac")) {
@@ -530,7 +528,7 @@ void CFX_Win32FontInfo::GetGBPreference(CFX_ByteString& face,
}
}
-void CFX_Win32FontInfo::GetJapanesePreference(CFX_ByteString& face,
+void CFX_Win32FontInfo::GetJapanesePreference(ByteString& face,
int weight,
int picth_family) {
if (face.Contains("Gothic") ||
@@ -573,10 +571,10 @@ void* CFX_Win32FontInfo::MapFont(int weight,
int pitch_family,
const char* cstr_face,
int& iExact) {
- CFX_ByteString face = cstr_face;
+ ByteString face = cstr_face;
int iBaseFont;
for (iBaseFont = 0; iBaseFont < 12; iBaseFont++)
- if (face == CFX_ByteStringC(g_Base14Substs[iBaseFont].m_pName)) {
+ if (face == ByteStringView(g_Base14Substs[iBaseFont].m_pName)) {
face = g_Base14Substs[iBaseFont].m_pWinName;
weight = g_Base14Substs[iBaseFont].m_bBold ? FW_BOLD : FW_NORMAL;
bItalic = g_Base14Substs[iBaseFont].m_bItalic;
@@ -607,15 +605,15 @@ void* CFX_Win32FontInfo::MapFont(int weight,
if (face.EqualNoCase(facebuf))
return hFont;
- CFX_WideString wsFace = CFX_WideString::FromLocal(facebuf);
+ WideString wsFace = WideString::FromLocal(facebuf);
for (size_t i = 0; i < FX_ArraySize(g_VariantNames); ++i) {
if (face != g_VariantNames[i].m_pFaceName)
continue;
const unsigned short* pName = reinterpret_cast<const unsigned short*>(
g_VariantNames[i].m_pVariantName);
- FX_STRSIZE len = CFX_WideString::WStringLength(pName);
- CFX_WideString wsName = CFX_WideString::FromUTF16LE(pName, len);
+ FX_STRSIZE len = WideString::WStringLength(pName);
+ WideString wsName = WideString::FromUTF16LE(pName, len);
if (wsFace == wsName)
return hFont;
}
@@ -665,7 +663,7 @@ uint32_t CFX_Win32FontInfo::GetFontData(void* hFont,
return size;
}
-bool CFX_Win32FontInfo::GetFaceName(void* hFont, CFX_ByteString* name) {
+bool CFX_Win32FontInfo::GetFaceName(void* hFont, ByteString* name) {
char facebuf[100];
HFONT hOldFont = (HFONT)::SelectObject(m_hDC, (HFONT)hFont);
int ret = ::GetTextFaceA(m_hDC, 100, facebuf);
@@ -702,7 +700,7 @@ std::unique_ptr<IFX_SystemFontInfo> IFX_SystemFontInfo::CreateDefault(
CHAR windows_path[MAX_PATH] = {};
DWORD path_len = ::GetWindowsDirectoryA(windows_path, MAX_PATH);
if (path_len > 0 && path_len < MAX_PATH) {
- CFX_ByteString fonts_path(windows_path);
+ ByteString fonts_path(windows_path);
fonts_path += "\\Fonts";
pInfoFallback->AddPath(fonts_path);
}
@@ -799,7 +797,7 @@ bool CGdiDeviceDriver::GDI_SetDIBits(
int width = pSrcRect->Width(), height = pSrcRect->Height();
LPBYTE pBuffer = pBitmap->GetBuffer();
- CFX_ByteString info = CFX_WindowsDIB::GetBitmapInfo(pBitmap);
+ ByteString info = CFX_WindowsDIB::GetBitmapInfo(pBitmap);
((BITMAPINFOHEADER*)info.c_str())->biHeight *= -1;
FX_RECT dst_rect(0, 0, width, height);
dst_rect.Intersect(0, 0, pBitmap->GetWidth(), pBitmap->GetHeight());
@@ -817,7 +815,7 @@ bool CGdiDeviceDriver::GDI_SetDIBits(
}
int width = pSrcRect->Width(), height = pSrcRect->Height();
LPBYTE pBuffer = pBitmap->GetBuffer();
- CFX_ByteString info = CFX_WindowsDIB::GetBitmapInfo(pBitmap);
+ ByteString info = CFX_WindowsDIB::GetBitmapInfo(pBitmap);
::SetDIBitsToDevice(m_hDC, left, top, width, height, pSrcRect->left,
pBitmap->GetHeight() - pSrcRect->bottom, 0,
pBitmap->GetHeight(), pBuffer,
@@ -840,7 +838,7 @@ bool CGdiDeviceDriver::GDI_StretchDIBits(
if (pBitmap->IsCmykImage() && !pBitmap->ConvertFormat(FXDIB_Rgb))
return false;
- CFX_ByteString info = CFX_WindowsDIB::GetBitmapInfo(pBitmap);
+ ByteString info = CFX_WindowsDIB::GetBitmapInfo(pBitmap);
if ((int64_t)abs(dest_width) * abs(dest_height) <
(int64_t)pBitmap1->GetWidth() * pBitmap1->GetHeight() * 4 ||
(flags & FXDIB_INTERPOL) || (flags & FXDIB_BICUBIC_INTERPOL)) {
@@ -854,7 +852,7 @@ bool CGdiDeviceDriver::GDI_StretchDIBits(
(int64_t)abs(dest_width) * abs(dest_height))) {
pToStrechBitmap = pBitmap->StretchTo(dest_width, dest_height, 0, nullptr);
}
- CFX_ByteString toStrechBitmapInfo =
+ ByteString toStrechBitmapInfo =
CFX_WindowsDIB::GetBitmapInfo(pToStrechBitmap);
::StretchDIBits(m_hDC, dest_left, dest_top, dest_width, dest_height, 0, 0,
pToStrechBitmap->GetWidth(), pToStrechBitmap->GetHeight(),
diff --git a/core/fxge/win32/fx_win32_dib.cpp b/core/fxge/win32/fx_win32_dib.cpp
index d1e5688ee1..c00543b169 100644
--- a/core/fxge/win32/fx_win32_dib.cpp
+++ b/core/fxge/win32/fx_win32_dib.cpp
@@ -11,9 +11,9 @@
#include "core/fxge/win32/cfx_windowsdib.h"
#include "core/fxge/win32/win32_int.h"
-CFX_ByteString CFX_WindowsDIB::GetBitmapInfo(
+ByteString CFX_WindowsDIB::GetBitmapInfo(
const CFX_RetainPtr<CFX_DIBitmap>& pBitmap) {
- CFX_ByteString result;
+ ByteString result;
int len = sizeof(BITMAPINFOHEADER);
if (pBitmap->GetBPP() == 1 || pBitmap->GetBPP() == 8) {
len += sizeof(DWORD) * (int)(1 << pBitmap->GetBPP());
@@ -102,7 +102,7 @@ CFX_RetainPtr<CFX_DIBitmap> CFX_WindowsDIB::LoadFromBuf(BITMAPINFO* pbmi,
HBITMAP CFX_WindowsDIB::GetDDBitmap(const CFX_RetainPtr<CFX_DIBitmap>& pBitmap,
HDC hDC) {
- CFX_ByteString info = GetBitmapInfo(pBitmap);
+ ByteString info = GetBitmapInfo(pBitmap);
return CreateDIBitmap(hDC, (BITMAPINFOHEADER*)info.c_str(), CBM_INIT,
pBitmap->GetBuffer(), (BITMAPINFO*)info.c_str(),
DIB_RGB_COLORS);
@@ -139,7 +139,7 @@ CFX_RetainPtr<CFX_DIBitmap> CFX_WindowsDIB::LoadFromFile(
DeleteDC(hDC);
return nullptr;
}
- CFX_ByteString info = GetBitmapInfo(pDIBitmap);
+ ByteString info = GetBitmapInfo(pDIBitmap);
int ret = GetDIBits(hDC, hBitmap, 0, height, pDIBitmap->GetBuffer(),
(BITMAPINFO*)info.c_str(), DIB_RGB_COLORS);
DeleteDC(hDC);
@@ -149,7 +149,7 @@ CFX_RetainPtr<CFX_DIBitmap> CFX_WindowsDIB::LoadFromFile(
}
CFX_RetainPtr<CFX_DIBitmap> CFX_WindowsDIB::LoadFromFile(const char* filename) {
- return LoadFromFile(CFX_WideString::FromLocal(filename).c_str());
+ return LoadFromFile(WideString::FromLocal(filename).c_str());
}
CFX_RetainPtr<CFX_DIBitmap> CFX_WindowsDIB::LoadDIBitmap(
@@ -175,7 +175,7 @@ CFX_RetainPtr<CFX_DIBitmap> CFX_WindowsDIB::LoadDIBitmap(
DeleteDC(hDC);
return nullptr;
}
- CFX_ByteString info = GetBitmapInfo(pDIBitmap);
+ ByteString info = GetBitmapInfo(pDIBitmap);
int ret = GetDIBits(hDC, hBitmap, 0, height, pDIBitmap->GetBuffer(),
(BITMAPINFO*)info.c_str(), DIB_RGB_COLORS);
DeleteDC(hDC);
diff --git a/core/fxge/win32/fx_win32_gdipext.cpp b/core/fxge/win32/fx_win32_gdipext.cpp
index 04788d6138..8161c5d333 100644
--- a/core/fxge/win32/fx_win32_gdipext.cpp
+++ b/core/fxge/win32/fx_win32_gdipext.cpp
@@ -682,7 +682,7 @@ CGdiplusExt::CGdiplusExt() {
m_pGdiRemoveFontMemResourseEx = nullptr;
}
void CGdiplusExt::Load() {
- CFX_ByteString strPlusPath = "";
+ ByteString strPlusPath = "";
char buf[MAX_PATH];
GetSystemDirectoryA(buf, MAX_PATH);
strPlusPath += buf;
diff --git a/core/fxge/win32/fx_win32_print.cpp b/core/fxge/win32/fx_win32_print.cpp
index ecd7be57c7..fa2c8b7ef3 100644
--- a/core/fxge/win32/fx_win32_print.cpp
+++ b/core/fxge/win32/fx_win32_print.cpp
@@ -232,7 +232,7 @@ bool CGdiPrinterDriver::DrawDeviceText(int nChars,
lf.lfItalic = pFont->IsItalic();
lf.lfCharSet = DEFAULT_CHARSET;
- const CFX_WideString wsName = pFont->GetFaceName().UTF8Decode();
+ const WideString wsName = pFont->GetFaceName().UTF8Decode();
size_t iNameLen =
std::min(wsName.GetLength(), static_cast<size_t>(LF_FACESIZE - 1));
memcpy(lf.lfFaceName, wsName.c_str(), sizeof(lf.lfFaceName[0]) * iNameLen);
@@ -288,7 +288,7 @@ bool CGdiPrinterDriver::DrawDeviceText(int nChars,
SetBkMode(m_hDC, TRANSPARENT);
// Text
- CFX_WideString wsText;
+ WideString wsText;
std::vector<INT> spacing(nChars);
float fPreviousOriginX = 0;
for (int i = 0; i < nChars; ++i) {
@@ -609,7 +609,7 @@ bool CTextOnlyPrinterDriver::DrawDeviceText(int nChars,
// errors below. Value chosen based on the title of https://crbug.com/18383
const double kScaleFactor = 10;
- CFX_WideString wsText;
+ WideString wsText;
int totalLength = nChars;
// Detect new lines and add clrf characters (since this is Windows only).
@@ -638,7 +638,7 @@ bool CTextOnlyPrinterDriver::DrawDeviceText(int nChars,
wsText += charpos.m_Unicode;
}
size_t len = totalLength;
- CFX_ByteString text = CFX_ByteString::FromUnicode(wsText);
+ ByteString text = ByteString::FromUnicode(wsText);
while (len > 0) {
char buffer[1026];
size_t send_len = std::min(len, static_cast<size_t>(1024));