diff --git a/cmake/FindYamlCpp.cmake b/cmake/FindYamlCpp.cmake deleted file mode 100644 index e2b40709..00000000 --- a/cmake/FindYamlCpp.cmake +++ /dev/null @@ -1,10 +0,0 @@ -# Try to find yaml-cpp -# YAMLCPP_FOUND - system has yaml-cpp -# YAMLCPP_INCLUDE_DIR - the yaml-cpp include directory -# YAMLCPP_LIBRARY - the yaml-cpp library - -FIND_PATH(YAMLCPP_INCLUDE_DIR NAMES yaml.h PATH_SUFFIXES yaml-cpp) -FIND_LIBRARY(YAMLCPP_LIBRARY NAMES libyaml-cpp.a yaml-cpp) -INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(YamlCpp DEFAULT_MSG YAMLCPP_LIBRARY YAMLCPP_INCLUDE_DIR) -MARK_AS_ADVANCED(YAMLCPP_LIBRARY YAMLCPP_INCLUDE_DIR) \ No newline at end of file diff --git a/data/modules/messagebox/messagebox.yml b/data/modules/messagebox/messagebox.yml index dc8473c0..5cf4b510 100644 --- a/data/modules/messagebox/messagebox.yml +++ b/data/modules/messagebox/messagebox.yml @@ -1,15 +1,15 @@ -window#messageBoxWindow: +window#messageBoxWindow size: [192, 78] anchors.horizontalCenter: parent.horizontalCenter anchors.verticalCenter: parent.verticalCenter - label#textLabel: + label#textLabel anchors.horizontalCenter: parent.horizontalCenter anchors.top: parent.top margin.top: 27 - button#okButton: + button#okButton text: Ok size: [43, 20] anchors.right: parent.right diff --git a/src/framework/graphics/font.cpp b/src/framework/graphics/font.cpp index 335c1089..cd65474e 100644 --- a/src/framework/graphics/font.cpp +++ b/src/framework/graphics/font.cpp @@ -102,7 +102,7 @@ bool Font::load(const std::string& file) // read custom widths if(doc->hasNode("glyph widths")) { std::map glyphWidths; - (*(doc->at("glyph widths"))) >> glyphWidths; + doc->readAt("glyph widths", &glyphWidths); foreach(const auto& pair, glyphWidths) m_glyphsSize[pair.first].setWidth(pair.second); } diff --git a/src/framework/util/fml.cpp b/src/framework/util/fml.cpp index 8e9ba2e4..a9cbd25b 100644 --- a/src/framework/util/fml.cpp +++ b/src/framework/util/fml.cpp @@ -2,7 +2,6 @@ #include #include -#include namespace FML { diff --git a/src/framework/util/fml.h b/src/framework/util/fml.h index a1fcf622..e6dc196f 100644 --- a/src/framework/util/fml.h +++ b/src/framework/util/fml.h @@ -72,7 +72,7 @@ public: // extracting values operator template - friend void operator >> (const Node& node, T& value); + friend bool operator >> (const Node& node, T& value); // get nodes Node* at(const std::string& childTag) const; @@ -85,13 +85,18 @@ public: // read values template T read(T def = T()) const { - T value = def; - *this >> value; - return value; + T v = def; + *this >> v; + return v; + } + + template + bool read(T* v) const { + return (*this >> *v); } template - T readAt(const std::string childTag, T def = T()) const { + T readAt(const std::string& childTag, T def = T()) const { T v = def; for(NodeList::const_iterator it = m_children.begin(); it != m_children.end(); ++it) { if((*it)->tag() == childTag) { @@ -102,6 +107,15 @@ public: return v; } + template + bool readAt(const std::string& childTag, T* v) const { + for(NodeList::const_iterator it = m_children.begin(); it != m_children.end(); ++it) { + if((*it)->tag() == childTag) + return (*(*it) >> *v); + } + return false; + } + void addNode(Node* node); private: @@ -118,23 +132,28 @@ private: // Node operators template -void operator >> (const Node& node, T& v) +bool operator >> (const Node& node, T& v) { - fml_convert(node.value(), v); + return fml_convert(node.value(), v); } template -void operator >> (const Node& node, std::vector& v) +bool operator >> (const Node& node, std::vector& v) { + bool ret = true; v.clear(); v.resize(node.size()); - for(unsigned i=0;i> v[i]; + for(unsigned i=0;i> v[i])) + ret = false; + } + return ret; } template -void operator >> (const Node& node, std::map& m) +bool operator >> (const Node& node, std::map& m) { + bool ret = true; m.clear(); for(Node::const_iterator it = node.begin(); it != node.end(); ++it) { Node* child = (*it); @@ -143,8 +162,10 @@ void operator >> (const Node& node, std::map& m) if(fml_convert(child->tag(), k)) { *child >> v; m[k] = v; + ret = false; } } + return ret; } @@ -198,20 +219,4 @@ private: } // namespace FML { -// enable usage with foreach -namespace boost -{ - // specialize range_mutable_iterator and range_const_iterator in namespace boost - template<> - struct range_mutable_iterator< FML::Node > - { - typedef FML::Node::iterator type; - }; - - template<> - struct range_const_iterator< FML::Node > - { - typedef FML::Node::const_iterator type; - }; -} #endif // FML_H