Files
shaka-packager/packager/utils/bytes_to_string_view.h
Joey Parrish b1c79e5052
Some checks failed
Update Issues / update-issues (push) Has been cancelled
Release / Settings (push) Has been cancelled
Release / Artifacts (push) Has been cancelled
Release / Update NPM (push) Has been cancelled
Release / Build (push) Has been cancelled
Release / release (push) Has been cancelled
Release / Compute latest release flag (push) Has been cancelled
Release / Update docs (push) Has been cancelled
Release / Update docker image (push) Has been cancelled
Sync Labels / sync-labels (push) Has been cancelled
chore: Fix build in Arch and other dockers (#1506)
This adds missing cstdint headers in every header where we reference a
uint*_t.

This also adds a cmake definition that works around a guard in newer
cmakes that is meant to guard against libraries that only work in older
ones. (`-DCMAKE_POLICY_VERSION_MINIMUM=3.5`)
2025-08-12 11:41:25 -07:00

30 lines
913 B
C++

// Copyright 2022 Google LLC. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
#ifndef PACKAGER_UTILS_BYTES_TO_STRING_VIEW_H_
#define PACKAGER_UTILS_BYTES_TO_STRING_VIEW_H_
#include <cstdint>
#include <string_view>
#include <vector>
namespace shaka {
/// Convert byte array to string_view
inline std::string_view byte_array_to_string_view(const uint8_t* bytes,
size_t bytes_size) {
return {reinterpret_cast<const char*>(bytes), bytes_size};
}
/// Convert byte vector to string_view
inline std::string_view byte_vector_to_string_view(
const std::vector<uint8_t>& bytes) {
return byte_array_to_string_view(bytes.data(), bytes.size());
}
} // namespace shaka
#endif // PACKAGER_UTILS_BYTES_TO_STRING_VIEW_H_