summaryrefslogtreecommitdiff
path: root/core/fxcrt/cfx_bytestring.h
AgeCommit message (Collapse)Author
2017-08-15Remove GetAt from string classesRyan Harrison
This method duplicates the behaviour of the const [] operator and doesn't offer any additional safety. Folding them into one implementation. SetAt is retained, since implementing the non-const [] operator to replace SetAt has potential performance concerns. Specifically many non-obvious cases of reading an element using [] will cause a realloc & copy. BUG=pdfium:860 Change-Id: I3ef5e5e5a15376f040256b646eb0d90636e24b67 Reviewed-on: https://pdfium-review.googlesource.com/10870 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-08-11Add checks of index operations on string classesRyan Harrison
Specifically the index parameter passed in to GetAt(), SetAt() and operator[] are now being tested to be in bounds. BUG=chromium:752480, pdfium:828 Change-Id: I9e94d58c98a8eaaaae53cd0e3ffe2123ea17d8c4 Reviewed-on: https://pdfium-review.googlesource.com/10651 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-08-10Make CFX_ByteString(ostringstream) const.Henrique Nakashima
Change-Id: I782379cc7f93b93ed34a5d0a39ee2f198c650465 Reviewed-on: https://pdfium-review.googlesource.com/10430 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
2017-08-02Remove unused FromUnicode methodRyan Harrison
A helper method for FromUnicode existed that converted wchar_t* to CFX_WideString before calling the remaining FromUnicode. This method is not used in the code base, so it has been removed. This simplifies converting FX_STRSIZE to be unsigned, since one of parameters to this method was of type FX_STRSIZE. BUG=pdfium:828 Change-Id: I3da677b84ac3b82ba48497e26d2ac80dd14302e6 Reviewed-on: https://pdfium-review.googlesource.com/9910 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2017-08-02Remove parameter from GetIDRyan Harrison
All of the call sites for this method used the default value, so it has been removed. This simplifies converting FX_STRSIZE to be unsigned, since the removed parameter was of this type. BUG=pdfium:828 Change-Id: I369285aed561731ab34ec6d30de0d21fb3431492 Reviewed-on: https://pdfium-review.googlesource.com/9891 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2017-08-02Rewrite how string Insert() methods handle out of bound indicesRyan Harrison
The existing behaviour was to clamp the provided index to the valid bounds. This would lead to programming errors being hidden, since inserting would still do something even if the index calculation was wrong. The behaviour of these methods has been changed to instead early return when this occurs, returning the old length value. The caller can check if the call to Insert actually did anything by comparing the returned value to the length before calling insert. All of the existing calls to Insert have been tested by running all of the tests with asserts in the Insert method to check the index is in bounds. Additionally the call sites have been manually inspected. The majority of them are of the form Insert(0, foo) and the rest tend to be in a loop advancing from 0 to length. Convenience methods InsertAtFront/InsertAtBack have been added to handle calling Insert when the intent is for the character to be added to the beginning or end of the string. Existing call sites to Insert that do this have been converted. This work was originally being performed to check if there would be any issues in these methods with making FX_STRSIZE unsigned. BUG=pdfium:828 Change-Id: I60cee5ad45338aa8ed46569de7bcc78a76db18f7 Reviewed-on: https://pdfium-review.googlesource.com/9870 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-08-01Remove support for negative params to ReleaseBuffer()Ryan Harrison
This CL removes the default param value for this method, which was negative. It also adds in a method to get buffer lengths, so that the callsites can explictly passing in the length of the buffer if they were using the default value previously. BUG=pdfium:828 Change-Id: I0170771ee81970b8b601631015ab3e6e39fea8ea Reviewed-on: https://pdfium-review.googlesource.com/9790 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2017-07-27Remove single param Mid() method from string classesRyan Harrison
This support is being removed from CFX_ByteString, CFX_ByteStringC, CFX_WideString, and CFX_WideStringC. This standardizes all of these classes to only have one Mid method that takes in 2 params, offset and count. Count now must be positive. The old behaviour of calculating the length for the user if -1 is passed in for the count has been removed. This work is in preperation for converting these classes to not accept negative lengths anywhere and thus make the underlying size type unsigned. BUG=pdfium:828 Change-Id: I5f15e7b7b00b264231817f143e2da88ee6f69e7b Reviewed-on: https://pdfium-review.googlesource.com/9430 Reviewed-by: (OOO Jul 28 - Aug 8) dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2017-06-28Add << overload for CFX_StringCTemplate classeschromium/3144Ryan Harrison
BUG=pdfium:790 Change-Id: I4a3623dc0daac6ff8407c09cd00e9f2e4e5dd2d7 Reviewed-on: https://pdfium-review.googlesource.com/7051 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-06-27Adding overload for ostream << CFX_ByteStringHenrique Nakashima
Bug: pdfium:731 Change-Id: I285332c8f9d988327e8633cb0746af2b76c401e5 Reviewed-on: https://pdfium-review.googlesource.com/6911 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-06-09Revert "Revert "Adding constructor of CFX_ByteString that takes a ↵Henrique Nakashima
std::ostringstream."" This reverts commit 53827cbbfebae66dd31f7aa30d3ee5c88716897a. Reason for revert: Rollforward of original CL - test failures were flakes. Original change's description: > Revert "Adding constructor of CFX_ByteString that takes a std::ostringstream." > > This reverts commit 4633d52736c4b926eceb1e18c4b379ff57fd31fa. > > Reason for revert: windows_xfa_clang broke? > > Original change's description: > > Adding constructor of CFX_ByteString that takes a std::ostringstream. > > > > Bug: pdfium:731 > > Change-Id: Ia0734deb3f309732dccae5c0cf6131d32713e87a > > Reviewed-on: https://pdfium-review.googlesource.com/6394 > > Reviewed-by: dsinclair <dsinclair@chromium.org> > > Commit-Queue: Henrique Nakashima <hnakashima@chromium.org> > > TBR=dsinclair@chromium.org,hnakashima@chromium.org > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: pdfium:731 > > Change-Id: I674aa1be12d6777c4d565d3131910ac5a11d8dc0 > Reviewed-on: https://pdfium-review.googlesource.com/6395 > Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> > Commit-Queue: Henrique Nakashima <hnakashima@chromium.org> TBR=dsinclair@chromium.org,pdfium-reviews@googlegroups.com,hnakashima@chromium.org No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: pdfium:731 Change-Id: I4a31a1a6bdb128016183c1059f0bfe1fa559a89e Reviewed-on: https://pdfium-review.googlesource.com/6434 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
2017-06-08Revert "Adding constructor of CFX_ByteString that takes a std::ostringstream."Henrique Nakashima
This reverts commit 4633d52736c4b926eceb1e18c4b379ff57fd31fa. Reason for revert: windows_xfa_clang broke? Original change's description: > Adding constructor of CFX_ByteString that takes a std::ostringstream. > > Bug: pdfium:731 > Change-Id: Ia0734deb3f309732dccae5c0cf6131d32713e87a > Reviewed-on: https://pdfium-review.googlesource.com/6394 > Reviewed-by: dsinclair <dsinclair@chromium.org> > Commit-Queue: Henrique Nakashima <hnakashima@chromium.org> TBR=dsinclair@chromium.org,hnakashima@chromium.org No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: pdfium:731 Change-Id: I674aa1be12d6777c4d565d3131910ac5a11d8dc0 Reviewed-on: https://pdfium-review.googlesource.com/6395 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
2017-06-08Adding constructor of CFX_ByteString that takes a std::ostringstream.Henrique Nakashima
Bug: pdfium:731 Change-Id: Ia0734deb3f309732dccae5c0cf6131d32713e87a Reviewed-on: https://pdfium-review.googlesource.com/6394 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
2017-04-25Delete some CFX string ctors.Lei Zhang
Prevent implicit construction of CFX_WideString from non-wchar_t variables. Similarly prevent implicit construction of CFX_ByteString from non-char variables. Fix up CBC_OnedCodaBarWriter which tries to do the above, and simplify code there using pdfium::ContainsValue(). Same for CPDF_FileSpec. Change-Id: I3db7125a68ef3f64c2f235d38e974767cd083dc3 Reviewed-on: https://pdfium-review.googlesource.com/4478 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-04-17Add iterators for Byte/WideStringCs.Tom Sepez
Change-Id: I40ec07c0da54bcf36c83fa26ff457cd4b98a91cf Reviewed-on: https://pdfium-review.googlesource.com/4261 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2017-04-07Create initializer-list ctor for strings.Tom Sepez
Also use safe arithmetic for two-arg ctor. Change-Id: I5d541d9b2d5fe5b939f4cc8c22cf034f5cb01176 Reviewed-on: https://pdfium-review.googlesource.com/3955 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2017-03-31Re-arrange fxcrt string files to match naming.Tom Sepez
The top-level fx_string.h is kept to include all strings. Put all fx_atof code in fx_basic_util.cpp rather than header. Change-Id: I61fe768f2e1ddf8438d27e410929f4cff918a9a3 Reviewed-on: https://pdfium-review.googlesource.com/3530 Reviewed-by: Nicolás Peña <npm@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>