billyquith / ponder

C++ reflection library with Lua binding, and JSON and XML serialisation.
http://billyquith.github.io/ponder/
Other
633 stars 92 forks source link

Supports STL containers? #58

Open iceboundflame opened 7 years ago

iceboundflame commented 7 years ago

This library looks pretty neat! Does it support containers (e.g. std::map, std::vector, std::set) of objects? I see ArrayProperty but it only seems to support vectors. I am dealing with some objects that have multiple layers of containers, e.g. map of map of vectors.

If it's not supported, how might this library be extended to support these containers?

billyquith commented 7 years ago

Thanks! - Most of the effort so far has been in refactoring Boost out of the library, and now separating "uses" of the type data from the the type data itself. I'm gradually adding functionality as is required. Containers haven't really had much attention, but that doesn't mean they are going to be ignored.

Please look at the 2.1 branch if you are grokking the code. This is will shortly be in master. There isn't really a rigorous versioning system at the moment, it is really so I don't break master whilst refactoring and there is a show of progress.

How might the library be extended? This usually involves finding some use cases, branching, refactoring, and the arm waving and wailing when the problem becomes harder than anticipated. Then lots of ☕ and I find thinking in the 🛀 very constructive, but not ideal for meetings. 😄

A map of map of map of vectors. Hmm. Just thinking out loud... Ponder declarations require concrete types, i.e. you can't register a template. STL containers have a standard interfaces, perhaps there needs to be a utility class when you can declare a container by passing it the type it contains? This would save duplication of declarations. e.g.

ponder::stl::declareMap<K,V>();
ponder::stl::declareVector<V>();

ObjectTraits may need work.

What are you trying to do with the API, broadly speaking?

billyquith commented 7 years ago

how might this library be extended to support these containers?

You could perhaps use properties or regular class functions to access and modify your containers. These can then be declared in the usual way?