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