summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--slicer/json/serializer.cpp6
-rw-r--r--slicer/slicer/modelParts.cpp4
-rw-r--r--slicer/slicer/modelParts.h20
-rw-r--r--slicer/slicer/parser.cpp2
-rw-r--r--slicer/slicer/slicer.h18
-rw-r--r--slicer/test/serializers.cpp10
-rw-r--r--slicer/xml/serializer.cpp6
7 files changed, 40 insertions, 26 deletions
diff --git a/slicer/json/serializer.cpp b/slicer/json/serializer.cpp
index 0c704a5..f6e7415 100644
--- a/slicer/json/serializer.cpp
+++ b/slicer/json/serializer.cpp
@@ -149,7 +149,7 @@ namespace Slicer {
{
modelPart->Create();
for (const auto & element : a) {
- auto emp = modelPart->GetChild();
+ auto emp = modelPart->GetAnonChild();
if (emp) {
emp->Create();
boost::apply_visitor(DocumentTreeIterate(emp), *element);
@@ -256,7 +256,7 @@ namespace Slicer {
Glib::ustring doc(buffer.str());
Glib::ustring::const_iterator itr = doc.begin();
json::Value obj = json::parseValue(itr);
- auto mp = modelRoot->GetChild();
+ auto mp = modelRoot->GetAnonChild();
boost::apply_visitor(DocumentTreeIterate(mp), obj);
}
@@ -282,7 +282,7 @@ namespace Slicer {
void
JsonValueDeserializer::Deserialize(ModelPartPtr modelRoot)
{
- auto mp = modelRoot->GetChild();
+ auto mp = modelRoot->GetAnonChild();
boost::apply_visitor(DocumentTreeIterate(mp), value);
}
diff --git a/slicer/slicer/modelParts.cpp b/slicer/slicer/modelParts.cpp
index b070bef..ede9d64 100644
--- a/slicer/slicer/modelParts.cpp
+++ b/slicer/slicer/modelParts.cpp
@@ -92,9 +92,9 @@ namespace Slicer {
}
ModelPartPtr
- ModelPart::GetChild(const HookFilter & flt)
+ ModelPart::GetAnonChild(const HookFilter & flt)
{
- auto ref = GetChildRef(flt);
+ auto ref = GetAnonChildRef(flt);
return ref ? ref->Child() : ModelPartPtr(NULL);
}
diff --git a/slicer/slicer/modelParts.h b/slicer/slicer/modelParts.h
index 9027f92..deb32e1 100644
--- a/slicer/slicer/modelParts.h
+++ b/slicer/slicer/modelParts.h
@@ -173,9 +173,9 @@ namespace Slicer {
virtual ~ModelPart() = default;
virtual void OnEachChild(const ChildHandler &) = 0;
- ModelPartPtr GetChild(const HookFilter & = HookFilter());
+ ModelPartPtr GetAnonChild(const HookFilter & = HookFilter());
ModelPartPtr GetChild(const std::string & memberName, const HookFilter & = HookFilter());
- virtual ChildRefPtr GetChildRef(const HookFilter & = HookFilter()) = 0;
+ virtual ChildRefPtr GetAnonChildRef(const HookFilter & = HookFilter()) = 0;
virtual ChildRefPtr GetChildRef(const std::string & memberName, const HookFilter & = HookFilter()) = 0;
virtual ModelPartPtr GetSubclassModelPart(const std::string &);
virtual TypeId GetTypeId() const;
@@ -206,7 +206,7 @@ namespace Slicer {
{
}
virtual void OnEachChild(const ChildHandler &) { }
- virtual ChildRefPtr GetChildRef(const HookFilter &) override { return NULL; }
+ virtual ChildRefPtr GetAnonChildRef(const HookFilter &) override { return NULL; }
virtual ChildRefPtr GetChildRef(const std::string &, const HookFilter &) override { return NULL; }
virtual void SetValue(ValueSourcePtr s) override { s->set(Member); }
virtual void GetValue(ValueTargetPtr s) override { s->get(Member); }
@@ -231,7 +231,7 @@ namespace Slicer {
{
}
virtual void OnEachChild(const ChildHandler &) { }
- virtual ChildRefPtr GetChildRef(const HookFilter &) override { return NULL; }
+ virtual ChildRefPtr GetAnonChildRef(const HookFilter &) override { return NULL; }
virtual ChildRefPtr GetChildRef(const std::string &, const HookFilter &) override { return NULL; }
virtual void SetValue(ValueSourcePtr s) override;
virtual void GetValue(ValueTargetPtr s) override;
@@ -279,10 +279,10 @@ namespace Slicer {
modelPart->Create();
}
}
- virtual ChildRefPtr GetChildRef(const HookFilter & flt) override
+ virtual ChildRefPtr GetAnonChildRef(const HookFilter & flt) override
{
if (OptionalMember) {
- return modelPart->GetChildRef(flt);
+ return modelPart->GetAnonChildRef(flt);
}
return NULL;
}
@@ -373,7 +373,7 @@ namespace Slicer {
}
}
- virtual ChildRefPtr GetChildRef(const HookFilter & flt) override
+ virtual ChildRefPtr GetAnonChildRef(const HookFilter & flt) override
{
for (const auto & h : hooks) {
if (!flt || flt(h)) {
@@ -504,7 +504,7 @@ namespace Slicer {
}
}
- virtual ChildRefPtr GetChildRef(const HookFilter &) override
+ virtual ChildRefPtr GetAnonChildRef(const HookFilter &) override
{
mp->Create();
return new DirectChildRef(mp);
@@ -565,7 +565,7 @@ namespace Slicer {
}
}
- ChildRefPtr GetChildRef(const HookFilter &) override
+ ChildRefPtr GetAnonChildRef(const HookFilter &) override
{
sequence.push_back(typename element_type::value_type());
return new DirectChildRef(ModelPartFor(sequence.back()));
@@ -647,7 +647,7 @@ namespace Slicer {
}
}
- ChildRefPtr GetChildRef(const HookFilter &) override
+ ChildRefPtr GetAnonChildRef(const HookFilter &) override
{
return new DirectChildRef(new ModelPartForDictionaryElementInserter<T>(dictionary));
}
diff --git a/slicer/slicer/parser.cpp b/slicer/slicer/parser.cpp
index 0e00dc1..d2d05a2 100644
--- a/slicer/slicer/parser.cpp
+++ b/slicer/slicer/parser.cpp
@@ -304,7 +304,7 @@ namespace Slicer {
else {
fprintf(cpp, "\t(void)name;\n");
}
- fprintf(cpp, "\treturn GetChildRef(flt);\n}\n\n");
+ fprintf(cpp, "\treturn GetAnonChildRef(flt);\n}\n\n");
fprintf(cpp, "template<>\n");
fprintf(cpp, "ModelPartPtr\n");
diff --git a/slicer/slicer/slicer.h b/slicer/slicer/slicer.h
index ba0184c..c837913 100644
--- a/slicer/slicer/slicer.h
+++ b/slicer/slicer/slicer.h
@@ -8,7 +8,7 @@
namespace Slicer {
template <typename Deserializer, typename Object, typename ... SerializerParams>
Object
- Deserialize(SerializerParams & ... sp)
+ DeserializeAny(SerializerParams & ... sp)
{
IceUtil::Handle<ModelPartForRoot<Object>> root = new ModelPartForRoot<Object>();
DeserializerPtr deserializer = new Deserializer(sp ...);
@@ -16,14 +16,28 @@ namespace Slicer {
return root->GetModel();
}
+ template <typename Deserializer, typename Object, typename ... SerializerParams>
+ Object
+ Deserialize(SerializerParams & ... sp)
+ {
+ return *DeserializeAny<Deserializer, IceInternal::Handle<Object>, SerializerParams...>(sp ...);
+ }
+
template <typename Serializer, typename Object, typename ... SerializerParams>
void
- Serialize(Object object, SerializerParams & ... sp)
+ SerializeAny(Object object, SerializerParams & ... sp)
{
IceUtil::Handle<ModelPartForRoot<Object>> root = new ModelPartForRoot<Object>(object);
SerializerPtr serializer = new Serializer(sp ...);
serializer->Serialize(root);
}
+
+ template <typename Serializer, typename Object, typename ... SerializerParams>
+ void
+ Serialize(IceInternal::Handle<Object> object, SerializerParams & ... sp)
+ {
+ SerializeAny(*object, sp ...);
+ }
}
#endif
diff --git a/slicer/test/serializers.cpp b/slicer/test/serializers.cpp
index f489af3..6151420 100644
--- a/slicer/test/serializers.cpp
+++ b/slicer/test/serializers.cpp
@@ -35,7 +35,7 @@ class FileBased : public FileStructure {
const fs::path outputXml = tmpf / fs::change_extension(infile, "xml");
BOOST_TEST_CHECKPOINT("Deserialize: " << input);
- T p = Slicer::Deserialize<DeserializerIn, T>(input);
+ T p = Slicer::DeserializeAny<DeserializerIn, T>(input);
if (check) {
BOOST_TEST_CHECKPOINT("Check1: " << input);
@@ -43,10 +43,10 @@ class FileBased : public FileStructure {
}
BOOST_TEST_CHECKPOINT("Serialize " << input << " -> " << outputJson);
- Slicer::Serialize<Slicer::JsonFileSerializer>(p, outputJson);
+ Slicer::SerializeAny<Slicer::JsonFileSerializer>(p, outputJson);
BOOST_TEST_CHECKPOINT("Serialize " << input << " -> " << outputXml);
- Slicer::Serialize<Slicer::XmlFileSerializer>(p, outputXml);
+ Slicer::SerializeAny<Slicer::XmlFileSerializer>(p, outputXml);
if (check) {
BOOST_TEST_CHECKPOINT("Check2: " << input);
@@ -74,7 +74,7 @@ class FileBased : public FileStructure {
Internal docRead = in(input);
BOOST_TEST_CHECKPOINT("Deserialize: " << input);
- T p = Slicer::Deserialize<Deserializer, T>(docRead);
+ T p = Slicer::DeserializeAny<Deserializer, T>(docRead);
ifree(docRead);
if (check) {
@@ -84,7 +84,7 @@ class FileBased : public FileStructure {
BOOST_TEST_CHECKPOINT("Serialize: " << input);
Internal docWrite;
- Slicer::Serialize<Serializer>(p, docWrite);
+ Slicer::SerializeAny<Serializer>(p, docWrite);
if (check) {
BOOST_TEST_CHECKPOINT("Check2: " << input);
diff --git a/slicer/xml/serializer.cpp b/slicer/xml/serializer.cpp
index e3482f2..225a1b3 100644
--- a/slicer/xml/serializer.cpp
+++ b/slicer/xml/serializer.cpp
@@ -177,7 +177,7 @@ namespace Slicer {
if (smpr) {
auto smp = smpr->Child();
if (metaDataFlagSet(smpr->ChildMetaData(), md_bare)) {
- smp = smp->GetChild();
+ smp = smp->GetAnonChild();
}
if (smp) {
if (auto typeIdPropName = smp->GetTypeIdProperty()) {
@@ -207,8 +207,8 @@ namespace Slicer {
else if (auto content = dynamic_cast<const xmlpp::ContentNode *>(node)) {
ModelPartPtr smp;
if (!content->is_white_space()) {
- smp = mp->GetChild(boost::bind(metaDataFlagSet, boost::bind(&Slicer::HookCommon::GetMetadata, _1), md_text));
- }
+ smp = mp->GetAnonChild(boost::bind(metaDataFlagSet, boost::bind(&Slicer::HookCommon::GetMetadata, _1), md_text));
+ }
if (smp) {
smp->SetValue(new XmlContentValueSource(content));
}