[DEV] update new ejson interface

This commit is contained in:
Edouard DUPIN 2016-04-20 21:19:11 +02:00
parent c7efaf95ab
commit dbc6b3439d

View File

@ -13,10 +13,6 @@
#include <etk/os/FSNode.h> #include <etk/os/FSNode.h>
#include <gale/resource/Manager.h> #include <gale/resource/Manager.h>
#undef __class__
#define __class__ "GlyphPainting"
appl::GlyphPainting::GlyphPainting() { appl::GlyphPainting::GlyphPainting() {
addResourceType("appl::GlyphPainting"); addResourceType("appl::GlyphPainting");
@ -34,7 +30,7 @@ appl::GlyphPainting::~GlyphPainting() {
void appl::GlyphPainting::reload() { void appl::GlyphPainting::reload() {
ejson::Document doc; 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()); APPL_ERROR("Can not load file : '" << m_name << "' = " << etk::FSNode(m_name).getFileSystemName());
return; return;
} }
@ -45,22 +41,22 @@ void appl::GlyphPainting::reload() {
doc.generate(tmppppp); doc.generate(tmppppp);
APPL_DEBUG(tmppppp); APPL_DEBUG(tmppppp);
*/ */
std::shared_ptr<ejson::Array> baseArray = doc.getArray("ednColor"); ejson::Array baseArray = doc["ednColor"].toArray();
if (baseArray == nullptr) { if (baseArray.exist() == false) {
APPL_ERROR("Can not get basic array : 'ednColor'"); APPL_ERROR("Can not get basic array : 'ednColor'");
return; return;
} }
for (size_t iii = 0; iii < baseArray->size(); ++iii) { for (const auto it : baseArray) {
std::shared_ptr<ejson::Object> tmpObj = baseArray->getObject(iii); ejson::Object tmpObj = it.toObject();
if (tmpObj == nullptr) { if (tmpObj.exist() == false) {
APPL_DEBUG(" can not get object in 'ednColor' id=" << iii); APPL_DEBUG(" can not get object in 'ednColor' it=" << it);
continue; continue;
} }
std::string name = tmpObj->getStringValue("name", ""); std::string name = tmpObj.getStringValue("name", "");
std::string background = tmpObj->getStringValue("background", "#FFF0"); std::string background = tmpObj.getStringValue("background", "#FFF0");
std::string foreground = tmpObj->getStringValue("foreground", "#000F"); std::string foreground = tmpObj.getStringValue("foreground", "#000F");
bool italic = tmpObj->getBooleanValue("italic", false); bool italic = tmpObj.getBooleanValue("italic", false);
bool bold = tmpObj->getBooleanValue("bold", false); bool bold = tmpObj.getBooleanValue("bold", false);
APPL_VERBOSE("find new color : '" << name << "' fg='" << foreground << "' bg='" << background << "' italic='" << italic << "' bold='" << bold << "'"); APPL_VERBOSE("find new color : '" << name << "' fg='" << foreground << "' bg='" << background << "' italic='" << italic << "' bold='" << bold << "'");
bool findElement = false; bool findElement = false;
for (size_t jjj=0; jjj<m_list.size(); ++jjj) { for (size_t jjj=0; jjj<m_list.size(); ++jjj) {