D RTTI?
H. S. Teoh
hsteoh at quickfur.ath.cx
Tue Mar 6 10:17:56 PST 2012
On Tue, Mar 06, 2012 at 08:17:07AM +0100, Jacob Carlborg wrote:
> On 2012-03-05 21:16, H. S. Teoh wrote:
> >I know D doesn't really have RTTI yet, but I'm experimenting with
> >"faking" it by doing something like:
> >
> > class A {
> > string prop1;
> > int prop2;
> > ...
> > void serialize() {
> > __serialize(this);
> > }
> > }
> >
> > void __serialize(T)(T obj) {
> > writeln(typeid(obj));
> > foreach (name; __traits(derivedMembers, T)) {
> > writefln("%s = %s", name,
> > __traits(getMember,obj,name));
> > }
> > }
[...]
> If you actually want serialization, and this was not just an
> example, you can use Orange:
>
> https://github.com/jacob-carlborg/orange
> http://www.dsource.org/projects/orange/
[...]
For my purposes, I will eventually need to serialize only a subset of an
object's properties, and only for a certain class of objects. Does
Orange support selective serializations?
T
--
Having a smoking section in a restaurant is like having a peeing section
in a swimming pool. -- Edward Burr
More information about the Digitalmars-d-learn
mailing list