AUI Framework  master
Cross-platform base for C++ UI apps
Loading...
Searching...
No Matches
AModelMeta.h
    1/*
    2 * AUI Framework - Declarative UI toolkit for modern C++20
    3 * Copyright (C) 2020-2025 Alex2772 and Contributors
    4 *
    5 * SPDX-License-Identifier: MPL-2.0
    6 *
    7 * This Source Code Form is subject to the terms of the Mozilla Public
    8 * License, v. 2.0. If a copy of the MPL was not distributed with this
    9 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
   10 */
   11
   12#pragma once
   13
   14#include <cassert>
   15#include <AUI/Common/AMap.h>
   16#include <AUI/Common/AString.h>
   17#include <AUI/Reflect/AField.h>
   18
   19template<class T>
   21    using Model = T;
   22};
   23
   51template<class T>
   53    static AMap<AString, _<AField<T>>> getFields() { AUI_ASSERT(0); return {};}
   54    static AString getSqlTable() { AUI_ASSERT(0); return {};}
   55};
   56
   57#define A_META(name) template<> struct AModelMeta< name >: AModelMetaBase< name >
   58#define A_FIELDS static AMap<AString, _<AField<Model>>> getFields()
   59#define A_FIELD(name) {#name, AField<Model>::make(&Model:: name )},
   60#define A_SQL_TABLE(name) static AString getSqlTable() { return name;}
   61
A std::map with AUI extensions.
Definition AMap.h:218
Represents a Unicode character string.
Definition AString.h:38
#define AUI_ASSERT(condition)
Asserts that the passed condition evaluates to true.
Definition Assert.h:55
Definition AModelMeta.h:20
Defines model metadata (list of fields, name of appropriate sql table, etc...)
Definition AModelMeta.h:52