mirror of
https://github.com/revng/revng
synced 2026-06-21 14:07:57 +00:00
49287e9de7
This commit: * Drops `KeyTraits::toString`: if needed, use `getNameFromYAMLScalar`. * Makes many methods in TupleTree.h return `nullptr` or `std::optional` in order to gracefully handle failures. * Provides `KeyTraits` specializations for integral types and tuple-like composed by types providing `KeyTraits`. * Introduces `CompositeScalar`, which enables tuple-like objects to be YAML-serializable scalars by joining the YAML-serialization of its members through a customziable character. * Implements `PathMatcher`, a very simple "regular expression" mechanism for paths on tuple trees. * Introduce testing for the Model.
28 lines
649 B
C++
28 lines
649 B
C++
#pragma once
|
|
|
|
//
|
|
// This file is distributed under the MIT License. See LICENSE.md for details.
|
|
//
|
|
|
|
#include "revng/ADT/KeyTraits.h"
|
|
#include "revng/ADT/STLExtras.h"
|
|
|
|
template<typename T, typename = void>
|
|
struct KeyedObjectTraits {
|
|
// static * key(const T &);
|
|
// static T fromKey(* Key);
|
|
};
|
|
|
|
/// Inherit if T is the key of itself
|
|
template<typename T>
|
|
struct IdentityKeyedObjectTraits {
|
|
static T key(const T &Obj) { return Obj; }
|
|
|
|
static T fromKey(T Obj) { return Obj; }
|
|
};
|
|
|
|
/// Trivial specialization for integral types
|
|
template<typename T>
|
|
struct KeyedObjectTraits<T, enable_if_is_integral_t<T>>
|
|
: public IdentityKeyedObjectTraits<T> {};
|