added index attribute to field class
This commit is contained in:
@@ -64,8 +64,9 @@ class field
|
||||
public:
|
||||
explicit field(std::string name);
|
||||
template<typename Type>
|
||||
field(std::string name, Type value)
|
||||
field(std::string name, Type value, int index = -1)
|
||||
: name_(std::move(name))
|
||||
, index_(index)
|
||||
, value_(value)
|
||||
, type_(field_traits<Type>::type()) {}
|
||||
field(const field &x) = default;
|
||||
@@ -81,6 +82,7 @@ public:
|
||||
}
|
||||
|
||||
[[nodiscard]] const std::string& name() const;
|
||||
[[nodiscard]] int index() const;
|
||||
|
||||
template<class Type>
|
||||
std::optional<Type> as() const
|
||||
@@ -103,6 +105,7 @@ public:
|
||||
|
||||
private:
|
||||
std::string name_;
|
||||
int index_{-1};
|
||||
any_type value_;
|
||||
field_type type_;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user