You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.)
#ifndef PSDLAYER_H_
#define PSDLAYER_H_
#include "rttr/registration"
class PSDLayer
{
public:
PSDLayer();
virtual ~PSDLayer();
public:
int left;
int top;
int right;
int bottom;
};
#endif //PSDLAYER_H_
#include "core/psdlayer.h"
PSDLayer::PSDLayer():left(0),top(0),right(0),bottom(0){}
PSDLayer::~PSDLayer(){}
RTTR_REGISTRATION
{
rttr::registration::class_("PSDLayer")
.property("left", &PSDLayer::left)
.property("top", &PSDLayer::top)
.property("right", &PSDLayer::right)
.property("bottom", &PSDLayer::bottom)
;
}
#ifndef PSDTYPELAYER_H_
#define PSDTYPELAYER_H_
#include
#include "core/psdlayer.h"
class PSDTypeLayer : public PSDLayer
{
public:
PSDTypeLayer();
~PSDTypeLayer();
public:
RTTR_ENABLE(PSDLayer)
public:
std::string vips_text;
};
#endif // PSDTYPELAYER_H_
#include "core/psdtypelayer.h"
PSDTypeLayer::PSDTypeLayer()
{
}
PSDTypeLayer::~PSDTypeLayer()
{
}
RTTR_REGISTRATION
{
rttr::registration::class_("PSDTypeLayer")
.property("vips_text", &PSDTypeLayer::vips_text)
;
}
#ifndef PSDLAYERVECTOR_H_
#define PSDLAYERVECTOR_H_
#include
#include "core/psdlayer.h"
class PSDLayerVector
{
public:
PSDLayerVector();
~PSDLayerVector();
public:
std::vector<std::shared_ptr> layers;
};
#endif //PSDLAYERVECTOR_H_
#include "core/psdlayervector.h"
PSDLayerVector::PSDLayerVector()
{
}
PSDLayerVector::~PSDLayerVector()
{
}
RTTR_REGISTRATION
{
rttr::registration::class_("PSDLayerVector")
.property("layers", &PSDLayerVector::layers)
;
}
int main(int argc, char** argv)
{
PSDLayerVector layers;
}
The text was updated successfully, but these errors were encountered: