Shaka Packager SDK
Loading...
Searching...
No Matches
bytes_to_string_view.h
1// Copyright 2022 Google LLC. All rights reserved.
2//
3// Use of this source code is governed by a BSD-style
4// license that can be found in the LICENSE file or at
5// https://developers.google.com/open-source/licenses/bsd
6
7#ifndef PACKAGER_UTILS_BYTES_TO_STRING_VIEW_H_
8#define PACKAGER_UTILS_BYTES_TO_STRING_VIEW_H_
9
10#include <string_view>
11#include <vector>
12
13namespace shaka {
14
16inline std::string_view byte_array_to_string_view(const uint8_t* bytes,
17 size_t bytes_size) {
18 return {reinterpret_cast<const char*>(bytes), bytes_size};
19}
20
22inline std::string_view byte_vector_to_string_view(
23 const std::vector<uint8_t>& bytes) {
24 return byte_array_to_string_view(bytes.data(), bytes.size());
25}
26
27} // namespace shaka
28#endif // PACKAGER_UTILS_BYTES_TO_STRING_VIEW_H_
All the methods that are virtual are virtual for mocking.
std::string_view byte_vector_to_string_view(const std::vector< uint8_t > &bytes)
Convert byte vector to string_view.
std::string_view byte_array_to_string_view(const uint8_t *bytes, size_t bytes_size)
Convert byte array to string_view.