Sygaldry
Loading...
Searching...
No Matches
sygac-metadata.hpp
1#pragma once
2/*
3Copyright 2023 Travis J. West, https://traviswest.ca, Input Devices and Music
4Interaction Laboratory (IDMIL), Centre for Interdisciplinary Research in Music
5Media and Technology (CIRMMT), McGill University, Montréal, Canada, and Univ.
6Lille, Inria, CNRS, Centrale Lille, UMR 9189 CRIStAL, F-59000 Lille, France
7
8SPDX-License-Identifier: MIT
9*/
10
11#include <concepts>
12#include "sygah-consteval.hpp"
13
14namespace sygaldry {
15
19
23
24#define text_concept(CONCEPT_NAME) template<typename T> \
25concept has_##CONCEPT_NAME = requires \
26{ \
27 {std::decay_t<T>::CONCEPT_NAME()} -> std::convertible_to<std::string>; \
28 {std::decay_t<T>::CONCEPT_NAME()} -> std::convertible_to<std::string_view>; \
29 {std::decay_t<T>::CONCEPT_NAME()} -> std::convertible_to<const char *>; \
30}; \
31template<has_##CONCEPT_NAME T> \
32constexpr auto CONCEPT_NAME##_of(const T&) { return T::CONCEPT_NAME(); } \
33 \
34template<has_##CONCEPT_NAME T> \
35_consteval auto CONCEPT_NAME##_of() { return std::decay_t<T>::CONCEPT_NAME(); }
36
37text_concept(name);
38text_concept(author);
39text_concept(email);
40text_concept(license);
41text_concept(description);
42text_concept(uuid);
43text_concept(unit);
44text_concept(version);
45text_concept(date);
46
47#undef text_concept
48
51}
52