Chromium Code Reviews| Index: net/der/input.cc |
| diff --git a/net/der/input.cc b/net/der/input.cc |
| index 5065ccaca93e9bdc3ffc06b5af2eaa332d57f1ae..d81d32dd35d274f8263581780a0c624485cf1acc 100644 |
| --- a/net/der/input.cc |
| +++ b/net/der/input.cc |
| @@ -19,6 +19,12 @@ Input::Input() : data_(nullptr), len_(0) { |
| Input::Input(const uint8_t* data, size_t len) : data_(data), len_(len) { |
| } |
| +Input::Input(const base::StringPiece& in) |
| + : data_(reinterpret_cast<const uint8_t*>(in.data())), len_(in.length()) {} |
| + |
| +Input::Input(const std::string* s) |
| + : data_(reinterpret_cast<const uint8_t*>(s->data())), len_(s->size()) {} |
|
eroman
2016/01/13 22:54:00
Could also delegate to stringpiece ctor
: Input
nharper
2016/01/13 23:04:47
That looks a little cleaner. Done.
|
| + |
| bool Input::Equals(const Input& other) const { |
| if (len_ != other.len_) |
| return false; |
| @@ -29,6 +35,10 @@ std::string Input::AsString() const { |
| return std::string(reinterpret_cast<const char*>(data_), len_); |
| } |
| +base::StringPiece Input::AsStringPiece() const { |
| + return base::StringPiece(reinterpret_cast<const char*>(data_), len_); |
| +} |
| + |
| bool operator<(const Input& lhs, const Input& rhs) { |
| return std::lexicographical_compare( |
| lhs.UnsafeData(), lhs.UnsafeData() + lhs.Length(), rhs.UnsafeData(), |