diff options
author | David Benjamin <davidben@google.com> | 2024-01-29 22:20:18 -0500 |
---|---|---|
committer | Boringssl LUCI CQ <boringssl-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2024-02-09 20:16:17 +0000 |
commit | 71c589682f7d1dabc08b56ef7a0a28913e44110e (patch) | |
tree | 68a342ed537670a3c98a429684489edb290dda98 /pki/input.h | |
parent | 10605c0d1e4b408dbd8fcfcae3897581afefb730 (diff) | |
download | boringssl-71c589682f7d1dabc08b56ef7a0a28913e44110e.zip boringssl-71c589682f7d1dabc08b56ef7a0a28913e44110e.tar.gz boringssl-71c589682f7d1dabc08b56ef7a0a28913e44110e.tar.bz2 |
Add functions to convert from Span<const uint8> and std::string_view
These can replace the current der::Input-specific string_view methods. I
converted many of the uses within the library, but we should take a pass
over the library and turn many of the std::strings into
std::vector<uint8_t>.
On MSVC, we have to pass /Zc:__cplusplus for __cplusplus to be set
correctly. For now, I'm going to try just adding the flag, but if pki
gets used in more places before we bump our minimum to C++17, we may
want to start looking at _MSVC_LANG instead.
There are actually a few places outside of pki that could use this, but
we sadly can't use them until we require C++17 across the board.
Bug: 661
Change-Id: I1002d9f2e1e4a2592760e8938560894d42a9b58c
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/65908
Reviewed-by: Bob Beck <bbe@google.com>
Reviewed-by: Matt Mueller <mattm@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
Diffstat (limited to 'pki/input.h')
-rw-r--r-- | pki/input.h | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/pki/input.h b/pki/input.h index 4a94110..30ce5d4 100644 --- a/pki/input.h +++ b/pki/input.h @@ -44,6 +44,8 @@ class OPENSSL_EXPORT Input { constexpr explicit Input(const uint8_t *data, size_t len) : data_(MakeConstSpan(data, len)) {} + // Deprecated: Use StringAsBytes. + // // Creates an Input from a std::string_view. The constructed Input is only // valid as long as |data| points to live memory. If constructed from, say, a // |std::string|, mutating the vector will invalidate the Input. @@ -69,13 +71,17 @@ class OPENSSL_EXPORT Input { constexpr Input first(size_t len) const { return Input(data_.first(len)); } constexpr Input last(size_t len) const { return Input(data_.last(len)); } + // Deprecated: use BytesAsStringView and convert to std::string. + // // Returns a copy of the data represented by this object as a std::string. std::string AsString() const; + // Deprecated: Use ByteAsString. + // // Returns a std::string_view pointing to the same data as the Input. The // resulting string_view must not outlive the data that was used to construct // this Input. - std::string_view AsStringView() const; + std::string_view AsStringView() const { return BytesAsStringView(data_); } // Deprecated: This class implicitly converts to bssl::Span<const uint8_t>. // |