diff options
author | Tom Sepez <tsepez@chromium.org> | 2017-04-13 13:41:24 -0700 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-04-13 22:06:11 +0000 |
commit | 3cfff70244e31f48068c32cbc4c070468f4c3e85 (patch) | |
tree | 331dc0766a512ac5854c4deba76a6174942cdc02 /core/fxcrt/cfx_string_c_template.h | |
parent | 7b7c6532310eeeabadae7b34fdf86f4a890951e8 (diff) | |
download | pdfium-3cfff70244e31f48068c32cbc4c070468f4c3e85.tar.xz |
Add ability to make StringCs from std::vector<>s.
Pre-cursor to using more std::vector<uint8_t> as byte buffers.
The widestring test case is more complicated, where we're not sure
of having any particular uint*_t type to match wchar_t.
Change-Id: Ic27980f16cdbc61fac7c11f39a85eea58d19bacb
Reviewed-on: https://pdfium-review.googlesource.com/4153
Reviewed-by: dsinclair <dsinclair@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'core/fxcrt/cfx_string_c_template.h')
-rw-r--r-- | core/fxcrt/cfx_string_c_template.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/core/fxcrt/cfx_string_c_template.h b/core/fxcrt/cfx_string_c_template.h index b52817d790..4aba2cd4b9 100644 --- a/core/fxcrt/cfx_string_c_template.h +++ b/core/fxcrt/cfx_string_c_template.h @@ -9,8 +9,10 @@ #include <algorithm> #include <type_traits> +#include <vector> #include "core/fxcrt/fx_system.h" +#include "third_party/base/stl_util.h" // An immutable string with caller-provided storage which must outlive the // string itself. These are not necessarily nul-terminated, so that substring @@ -53,6 +55,12 @@ class CFX_StringCTemplate { m_Length = src.m_Length; } + // Any changes to |vec| invalidate the string. + explicit CFX_StringCTemplate(const std::vector<UnsignedType>& vec) { + m_Ptr = vec.data(); + m_Length = pdfium::CollectionSize<FX_STRSIZE>(vec); + } + CFX_StringCTemplate& operator=(const CharType* src) { m_Ptr = reinterpret_cast<const UnsignedType*>(src); m_Length = src ? FXSYS_len(src) : 0; |