Closed iwbnwif closed 8 years ago
Another related enhancement might be to expose the property lists, at least sorted by position. This will allow the use of range-based-for to iterate through the properties (and possibly functions if there is a use case for that).
For example:
int i = 0; for (const ponder::Property& prop : metaclass.propertyList())
{
std::cout << "Field " << i++ << " is: " << prop.name() << std::endl;
// Check for width and hidden tags.
if (prop.hasTag("width"))
std::cout << "Field " << prop.name() << " has width: " << prop.tag("width") << std::endl;
}
In 1.1 branch: Access by index added. Property and function iterators added.
The shortcut
UserObject::get(const std::string & property)
is provided as a shortcut forobject.getClass().property(name).get(object)
.Would it be possible to provide an equivalent for indexed access to properties, i.e.
UserObject::get(const size_t index)
?Justification: this helps when iterating over all properties in a class instance.
Probably it would be good to provide the
set
equivalent for completeness.