#ifndef UI_BASE_METADATA_PROPERTY_METADATA_H_
#define UI_BASE_METADATA_PROPERTY_METADATA_H_
#include <concepts>
#include <string>
#include <type_traits>
#include <utility>
#include "base/component_export.h"
#include "base/notreached.h"
#include "ui/base/class_property.h"
#include "ui/base/metadata/base_type_conversion.h"
#include "ui/base/metadata/metadata_cache.h"
#include "ui/base/metadata/metadata_types.h"
namespace ui {
namespace metadata {
namespace internal {
template <typename TKey, typename TValue>
struct ClassPropertyMetaDataTypeHelper;
ClassPropertyMetaDataTypeHelper<const ui::ClassProperty<TKValue_> *const, TValue_>;
template <typename TClass>
TClass* AsClass(void* obj) { … }
}
template <typename TClass,
typename TValue,
typename TRet,
TRet (TClass::*Get)() const,
typename TConverter = ui::metadata::TypeConverter<TValue>>
class ObjectPropertyReadOnlyMetaData : public ui::metadata::MemberMetaDataBase {
public:
using MemberMetaDataBase::MemberMetaDataBase;
ObjectPropertyReadOnlyMetaData(const ObjectPropertyReadOnlyMetaData&) =
delete;
ObjectPropertyReadOnlyMetaData& operator=(
const ObjectPropertyReadOnlyMetaData&) = delete;
~ObjectPropertyReadOnlyMetaData() override = default;
std::u16string GetValueAsString(void* obj) const override { … }
ui::metadata::PropertyFlags GetPropertyFlags() const override { … }
const char* GetMemberNamePrefix() const override { … }
private:
static constexpr bool kTypeIsSerializable = TConverter::is_serializable;
static constexpr bool kTypeIsReadOnly = TConverter::is_read_only;
};
template <typename TClass,
typename TValue,
typename TSig,
TSig Set,
typename TRet,
TRet (TClass::*Get)() const,
typename TConverter = ui::metadata::TypeConverter<TValue>>
class ObjectPropertyMetaData
: public ObjectPropertyReadOnlyMetaData<TClass,
TValue,
TRet,
Get,
TConverter> {
public:
using ObjectPropertyReadOnlyMetaData<TClass, TValue, TRet, Get, TConverter>::
ObjectPropertyReadOnlyMetaData;
ObjectPropertyMetaData(const ObjectPropertyMetaData&) = delete;
ObjectPropertyMetaData& operator=(const ObjectPropertyMetaData&) = delete;
~ObjectPropertyMetaData() override = default;
void SetValueAsString(void* obj, const std::u16string& new_value) override { … }
ui::metadata::MemberMetaDataBase::ValueStrings GetValidValues()
const override { … }
ui::metadata::PropertyFlags GetPropertyFlags() const override { … }
private:
static constexpr bool kTypeIsSerializable = TConverter::is_serializable;
static constexpr bool kTypeIsReadOnly = TConverter::is_read_only;
};
template <typename TClass,
typename TKey,
typename TValue,
typename TConverter = ui::metadata::TypeConverter<TValue>>
class ClassPropertyMetaData : public ui::metadata::MemberMetaDataBase {
public:
using TypeHelper = internal::ClassPropertyMetaDataTypeHelper<TKey, TValue>;
ClassPropertyMetaData(TKey key, const std::string& property_type)
: … { … }
ClassPropertyMetaData(const ClassPropertyMetaData&) = delete;
ClassPropertyMetaData& operator=(const ClassPropertyMetaData&) = delete;
~ClassPropertyMetaData() override = default;
std::u16string GetValueAsString(void* obj) const override { … }
void SetValueAsString(void* obj, const std::u16string& new_value) override { … }
ui::metadata::PropertyFlags GetPropertyFlags() const override { … }
private:
TKey key_;
static constexpr bool kTypeIsSerializable = TConverter::is_serializable;
static constexpr bool kTypeIsReadOnly = TConverter::is_read_only;
};
}
}
#endif