From dbc6b3439d4389c8370059005dd12ac002b0685b Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Wed, 20 Apr 2016 21:19:11 +0200 Subject: [PATCH] [DEV] update new ejson interface --- sources/appl/GlyphPainting.cpp | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/sources/appl/GlyphPainting.cpp b/sources/appl/GlyphPainting.cpp index bfed5a4..4d0310a 100644 --- a/sources/appl/GlyphPainting.cpp +++ b/sources/appl/GlyphPainting.cpp @@ -13,10 +13,6 @@ #include #include -#undef __class__ -#define __class__ "GlyphPainting" - - appl::GlyphPainting::GlyphPainting() { addResourceType("appl::GlyphPainting"); @@ -34,7 +30,7 @@ appl::GlyphPainting::~GlyphPainting() { void appl::GlyphPainting::reload() { ejson::Document doc; - if (false == doc.load(m_name)) { + if (doc.load(m_name) == false) { APPL_ERROR("Can not load file : '" << m_name << "' = " << etk::FSNode(m_name).getFileSystemName()); return; } @@ -45,22 +41,22 @@ void appl::GlyphPainting::reload() { doc.generate(tmppppp); APPL_DEBUG(tmppppp); */ - std::shared_ptr baseArray = doc.getArray("ednColor"); - if (baseArray == nullptr) { + ejson::Array baseArray = doc["ednColor"].toArray(); + if (baseArray.exist() == false) { APPL_ERROR("Can not get basic array : 'ednColor'"); return; } - for (size_t iii = 0; iii < baseArray->size(); ++iii) { - std::shared_ptr tmpObj = baseArray->getObject(iii); - if (tmpObj == nullptr) { - APPL_DEBUG(" can not get object in 'ednColor' id=" << iii); + for (const auto it : baseArray) { + ejson::Object tmpObj = it.toObject(); + if (tmpObj.exist() == false) { + APPL_DEBUG(" can not get object in 'ednColor' it=" << it); continue; } - std::string name = tmpObj->getStringValue("name", ""); - std::string background = tmpObj->getStringValue("background", "#FFF0"); - std::string foreground = tmpObj->getStringValue("foreground", "#000F"); - bool italic = tmpObj->getBooleanValue("italic", false); - bool bold = tmpObj->getBooleanValue("bold", false); + std::string name = tmpObj.getStringValue("name", ""); + std::string background = tmpObj.getStringValue("background", "#FFF0"); + std::string foreground = tmpObj.getStringValue("foreground", "#000F"); + bool italic = tmpObj.getBooleanValue("italic", false); + bool bold = tmpObj.getBooleanValue("bold", false); APPL_VERBOSE("find new color : '" << name << "' fg='" << foreground << "' bg='" << background << "' italic='" << italic << "' bold='" << bold << "'"); bool findElement = false; for (size_t jjj=0; jjj