WidgetInfo ResourceLayout::parseWidget(xml::ElementEnumerator& _widget) { WidgetInfo widgetInfo; std::string tmp; _widget->findAttribute("type", widgetInfo.type); _widget->findAttribute("skin", widgetInfo.skin); _widget->findAttribute("layer", widgetInfo.layer); if (_widget->findAttribute("align", tmp)) widgetInfo.align = Align::parse(tmp); _widget->findAttribute("name", widgetInfo.name); if (_widget->findAttribute("style", tmp)) widgetInfo.style = WidgetStyle::parse(tmp); IntCoord coord; if (_widget->findAttribute("position", tmp)) { widgetInfo.intCoord = IntCoord::parse(tmp); widgetInfo.positionType = WidgetInfo::Pixels; } else if (_widget->findAttribute("position_real", tmp)) { widgetInfo.floatCoord = FloatCoord::parse(tmp); widgetInfo.positionType = WidgetInfo::Relative; } // берем детей и крутимся xml::ElementEnumerator node = _widget->getElementEnumerator(); while (node.next()) { if (node->getName() == "Widget") { widgetInfo.childWidgetsInfo.push_back(parseWidget(node)); } else if (node->getName() == "Property") { widgetInfo.properties.push_back(PairString(node->findAttribute("key"), node->findAttribute("value"))); } else if (node->getName() == "UserString") { widgetInfo.userStrings[node->findAttribute("key")] = node->findAttribute("value"); } else if (node->getName() == "Controller") { ControllerInfo controllerInfo; controllerInfo.type = node->findAttribute("type"); xml::ElementEnumerator prop = node->getElementEnumerator(); while (prop.next("Property")) { controllerInfo.properties[prop->findAttribute("key")] = prop->findAttribute("value"); } } } return widgetInfo; }
std::list<PairString> Object::getListArg(const std::string & str) { size_t i = 0; size_t tmp; std::list<PairString> _list; while ((i = str.find(':', i)) != std::string::npos && str[i]) { tmp = i - 1; while (tmp > 0 && str[tmp] != ',') tmp--; tmp += str[tmp] == ',' ? 1 : 0; std::string first = str.substr(tmp, i - tmp); i++; tmp = str.find(',', i); std::string sec = ""; if (tmp != std::string::npos) sec = str.substr(i, tmp - i); else sec = str.substr(i, str.size() - i); _list.push_front(PairString(first, sec)); } return _list; }