mirror of
https://github.com/BlackMATov/meta.hpp.git
synced 2025-12-15 03:45:30 +07:00
parameter state
This commit is contained in:
@@ -31,6 +31,7 @@
|
||||
#include "meta_states/function.hpp"
|
||||
#include "meta_states/member.hpp"
|
||||
#include "meta_states/method.hpp"
|
||||
#include "meta_states/parameter.hpp"
|
||||
#include "meta_states/scope.hpp"
|
||||
#include "meta_states/variable.hpp"
|
||||
|
||||
|
||||
@@ -109,6 +109,7 @@ namespace meta_hpp
|
||||
class function;
|
||||
class member;
|
||||
class method;
|
||||
class parameter;
|
||||
class scope;
|
||||
class variable;
|
||||
|
||||
@@ -120,6 +121,7 @@ namespace meta_hpp
|
||||
struct function_state;
|
||||
struct member_state;
|
||||
struct method_state;
|
||||
struct parameter_state;
|
||||
struct scope_state;
|
||||
struct variable_state;
|
||||
|
||||
@@ -129,6 +131,7 @@ namespace meta_hpp
|
||||
using function_state_ptr = std::shared_ptr<function_state>;
|
||||
using member_state_ptr = std::shared_ptr<member_state>;
|
||||
using method_state_ptr = std::shared_ptr<method_state>;
|
||||
using parameter_state_ptr = std::shared_ptr<parameter_state>;
|
||||
using scope_state_ptr = std::shared_ptr<scope_state>;
|
||||
using variable_state_ptr = std::shared_ptr<variable_state>;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ namespace meta_hpp::detail
|
||||
std::is_same_v<T, function> ||
|
||||
std::is_same_v<T, member> ||
|
||||
std::is_same_v<T, method> ||
|
||||
std::is_same_v<T, parameter> ||
|
||||
std::is_same_v<T, scope> ||
|
||||
std::is_same_v<T, variable>;
|
||||
|
||||
|
||||
@@ -267,6 +267,22 @@ namespace meta_hpp
|
||||
friend auto detail::state_access<method>(const method&);
|
||||
};
|
||||
|
||||
class parameter final {
|
||||
public:
|
||||
explicit parameter() = default;
|
||||
explicit parameter(detail::parameter_state_ptr state);
|
||||
|
||||
[[nodiscard]] bool is_valid() const noexcept;
|
||||
[[nodiscard]] explicit operator bool() const noexcept;
|
||||
|
||||
[[nodiscard]] const parameter_index& get_index() const noexcept;
|
||||
[[nodiscard]] const any_type& get_type() const noexcept;
|
||||
[[nodiscard]] const std::string& get_name() const noexcept;
|
||||
private:
|
||||
detail::parameter_state_ptr state_;
|
||||
friend auto detail::state_access<parameter>(const parameter&);
|
||||
};
|
||||
|
||||
class scope final {
|
||||
public:
|
||||
explicit scope() = default;
|
||||
@@ -440,6 +456,13 @@ namespace meta_hpp::detail
|
||||
[[nodiscard]] static method_state_ptr make(std::string name, Method method);
|
||||
};
|
||||
|
||||
struct parameter_state final {
|
||||
parameter_index index;
|
||||
|
||||
template < typename Parameter >
|
||||
[[nodiscard]] static parameter_state_ptr make(std::string name);
|
||||
};
|
||||
|
||||
struct scope_state final {
|
||||
scope_index index;
|
||||
|
||||
|
||||
47
headers/meta.hpp/meta_states/parameter.hpp
Normal file
47
headers/meta.hpp/meta_states/parameter.hpp
Normal file
@@ -0,0 +1,47 @@
|
||||
/*******************************************************************************
|
||||
* This file is part of the "https://github.com/blackmatov/meta.hpp"
|
||||
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||
* Copyright (C) 2021, by Matvey Cherevko (blackmatov@gmail.com)
|
||||
******************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../meta_base.hpp"
|
||||
#include "../meta_states.hpp"
|
||||
|
||||
namespace meta_hpp::detail
|
||||
{
|
||||
template < typename Parameter >
|
||||
inline parameter_state_ptr parameter_state::make(std::string name) {
|
||||
return std::make_shared<parameter_state>(parameter_state{
|
||||
.index{parameter_index::make<Parameter>(std::move(name))},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
namespace meta_hpp
|
||||
{
|
||||
|
||||
inline parameter::parameter(detail::parameter_state_ptr state)
|
||||
: state_{std::move(state)} {}
|
||||
|
||||
inline bool parameter::is_valid() const noexcept {
|
||||
return !!state_;
|
||||
}
|
||||
|
||||
inline parameter::operator bool() const noexcept {
|
||||
return is_valid();
|
||||
}
|
||||
|
||||
inline const parameter_index& parameter::get_index() const noexcept {
|
||||
return state_->index;
|
||||
}
|
||||
|
||||
inline const any_type& parameter::get_type() const noexcept {
|
||||
return state_->index.get_type();
|
||||
}
|
||||
|
||||
inline const std::string& parameter::get_name() const noexcept {
|
||||
return state_->index.get_name();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user