moddef-cpp
Idiomatic C++ runtime for ModDef
Loading...
Searching...
No Matches
str.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2
11#ifndef MODDEF_STR_HPP
12#define MODDEF_STR_HPP
13
14#include <cstdint>
15#include <string_view>
16
17extern "C" {
18#include "moddef/str.h"
19}
20
21namespace moddef {
22
23inline md_str_t to_c(std::string_view s) noexcept {
24 return md_str_t{s.data(), static_cast<uint16_t>(s.size())};
25}
26
27inline std::string_view from_c(md_str_t s) noexcept {
28 return std::string_view{s.p, s.len};
29}
30
31} // namespace moddef
32
33#endif // MODDEF_STR_HPP
Definition device.hpp:28
md_err_t to_c(Error e) noexcept
Definition error.hpp:47
Error from_c(md_err_t e) noexcept
Definition error.hpp:46