Open doudouodong opened 1 year ago
I've run into something similar while trying to follow the example rapidjson to/from that you appear to be using here. My library uses JsonGLIB as its target type, and I'm currently testing how to handle registered object members that are shared pointers to other RTTR_ENABLE'd structures. I've found that in order for my variation of the fromjson_recursive
function to work, I have to get the properties off the obj.get_type().get_raw_type().get_properties();
rather than obj.get_derived_type().get_properties()
(which seems to work fine for value -type object members.
Despite being able to now pull the property list and apparently read and set the various members on this passed in rttr
instance, the output structure does not have the created instance set on its member (I.e., target.shared_ptr_member.get()
is nullptr
.)
Did you ever make headway with this?
ifndef PSDLAYERH
define PSDLAYERH
include "rttr/registration"
class PSDLayer { public: PSDLayer(); virtual ~PSDLayer();
public: int left; int top; int right; int bottom;
};
endif //PSDLAYERH
include "core/psdlayer.h"
PSDLayer::PSDLayer():left(0),top(0),right(0),bottom(0){}
PSDLayer::~PSDLayer(){}
RTTRREGISTRATION { rttr::registration::class("PSDLayer")
.property("left", &PSDLayer::left)
.property("top", &PSDLayer::top)
.property("right", &PSDLayer::right)
.property("bottom", &PSDLayer::bottom)
;
}
ifndef PSDTYPELAYERH
define PSDTYPELAYERH
include
include "core/psdlayer.h"
class PSDTypeLayer : public PSDLayer { public: PSDTypeLayer(); ~PSDTypeLayer();
public: RTTR_ENABLE(PSDLayer) public: std::string vips_text; };
endif // PSDTYPELAYERH
include "core/psdtypelayer.h"
PSDTypeLayer::PSDTypeLayer() {
}
PSDTypeLayer::~PSDTypeLayer() {
}
RTTRREGISTRATION { rttr::registration::class("PSDTypeLayer")
.property("vips_text", &PSDTypeLayer::vips_text)
;
}
ifndef PSDLAYERVECTORH
define PSDLAYERVECTORH
include
include "core/psdlayer.h"
class PSDLayerVector { public: PSDLayerVector(); ~PSDLayerVector();
public: std::vector<std::shared_ptr> layers;
};
endif //PSDLAYERVECTORH
include "core/psdlayervector.h"
PSDLayerVector::PSDLayerVector() {
}
PSDLayerVector::~PSDLayerVector() {
}
RTTRREGISTRATION { rttr::registration::class("PSDLayerVector")
.property("layers", &PSDLayerVector::layers)
;
}
int main(int argc, char** argv) { PSDLayerVector layers;
}