From 1e44e62ad33ac8e73af18de01b122e3c3198e438 Mon Sep 17 00:00:00 2001 From: Andreas Stöckel Date: Thu, 16 Apr 2015 01:11:44 +0200 Subject: Generate unique IDs for XmlOutput and serialize those --- src/core/common/VariantConverter.cpp | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'src/core') diff --git a/src/core/common/VariantConverter.cpp b/src/core/common/VariantConverter.cpp index 699576b..ad0da83 100644 --- a/src/core/common/VariantConverter.cpp +++ b/src/core/common/VariantConverter.cpp @@ -304,15 +304,27 @@ bool VariantConverter::toString(Variant &var, Logger &logger, Mode mode) return true; } case VariantType::OBJECT: { - // Print object address and type + // Fetch the attached object, abort if it is a nullptr Variant::objectType obj = var.asObject(); - std::stringstream ss; - ss << "type()->name << ")"; + if (obj == nullptr) { + var = ""; + return true; + } + + // Check whether the object has an id attached -- if yes, output + // that id + Rooted id = obj->readData("id"); + if (id != nullptr && id->v.isString()) { + var = id->v; + return true; } - ss << ">"; + + // Otherwise print object address and type + std::stringstream ss; + ss << "type()->name + << ")>"; var = ss.str().c_str(); + return true; } case VariantType::FUNCTION: { -- cgit v1.2.3