Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
schema_name.hpp
Go to the documentation of this file.
1#pragma once
3#include <cxxabi.h>
4#include <string>
5
14template <typename T> std::string msgpack_schema_name(T const&)
15{
16 // If we have a T::MSGPACK_SCHEMA_NAME member, use that.
17 if constexpr (requires { T::MSGPACK_SCHEMA_NAME; }) {
18 return T::MSGPACK_SCHEMA_NAME;
19 }
20 char* result_cstr = abi::__cxa_demangle(typeid(T).name(), nullptr, nullptr, nullptr);
21 std::string result = result_cstr;
22 if (result.find("basic_string") != std::string::npos) {
23 return "string";
24 }
25 if (result == "i") {
26 return "int";
27 }
28
29 if (result.find('<') != static_cast<size_t>(-1)) {
30 result = result.substr(0, result.find('<'));
31 }
32 if (result.rfind(':') != static_cast<size_t>(-1)) {
33 result = result.substr(result.rfind(':') + 1, result.size());
34 }
35 std::free(result_cstr); // NOLINT
36 return result;
37}
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
std::string msgpack_schema_name(T const &)