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
7#include <cxxabi.h>
8#include <string>
9
18template <typename T> std::string msgpack_schema_name(T const&)
19{
20 // If we have a T::MSGPACK_SCHEMA_NAME member, use that.
21 if constexpr (requires { T::MSGPACK_SCHEMA_NAME; }) {
22 return T::MSGPACK_SCHEMA_NAME;
23 }
24 char* result_cstr = abi::__cxa_demangle(typeid(T).name(), nullptr, nullptr, nullptr);
25 std::string result = result_cstr;
26 if (result.find("basic_string") != std::string::npos) {
27 return "string";
28 }
29 if (result == "i") {
30 return "int";
31 }
32
33 if (result.find('<') != static_cast<size_t>(-1)) {
34 result = result.substr(0, result.find('<'));
35 }
36 if (result.rfind(':') != static_cast<size_t>(-1)) {
37 result = result.substr(result.rfind(':') + 1, result.size());
38 }
39 std::free(result_cstr); // NOLINT
40 return result;
41}
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
std::string msgpack_schema_name(T const &)