0
Files
mark a. foltz ae73185f88 [Open Screen] Replace ConstDataSpan with ByteView.
ConstDataSpan was a struct used to represent a pointer-and-length in
the libcast authentication code.  Replace it with ByteView which serves
the same purpose.

Also adds some conversion functions and a const std::vector ctor
override to Span, which simplifies conversions from various other objects.  These also allows various inline casts and conversion macros
to be removed.

Eventually I want to remove all uses of std::string and
pointer-and-length for binary data in this code, but this is a step
in that direction.

Change-Id: Idce296374e7382baf8d45927da60422676df635e
Reviewed-on: https://chromium-review.googlesource.com/c/openscreen/+/4409082
Reviewed-by: Jordan Bayles <jophba@chromium.org>
2023-04-15 03:36:33 +00:00

20 lines
547 B
C++

// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "util/span_util.h"
namespace openscreen {
ByteView ByteViewFromString(const std::string& str) {
return ByteView{reinterpret_cast<const uint8_t* const>(str.data()),
str.size()};
}
std::string ByteViewToString(const ByteView& bytes) {
return std::string(reinterpret_cast<const char* const>(bytes.data()),
bytes.size());
}
} // namespace openscreen