ConfigParserData& m_data;
};
-class FeatureParser : public ElementParser
-{
- public:
- struct ParamParser : public ElementParser
- {
- virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
- const DPL::String& /*name*/)
- {
- return &IgnoringParser::Create;
- }
-
- virtual void Accept(const XmlAttribute& attribute)
- {
- if (attribute.name == L"name") {
- m_name = attribute.value;
- NormalizeString(m_name);
- } else if (attribute.name == L"value") {
- m_value = attribute.value;
- NormalizeString(m_value);
- }
- }
-
- virtual void Accept(const Element& /*element*/)
- {}
-
- virtual void Accept(const Text& /*text*/)
- {
- ThrowMsg(Exception::ParseError, "param element must be empty");
- }
-
- virtual void Verify()
- {
- if (m_name.IsNull() || *m_name == L"") {
- return;
- }
- if (m_value.IsNull() || *m_value == L"") {
- return;
- }
-
- ConfigParserData::Param param(*m_name);
- param.value = *m_value;
-
- if (m_data.paramsList.find(param) == m_data.paramsList.end()) {
- m_data.paramsList.insert(param);
- }
- }
-
- ParamParser(ConfigParserData::Feature& data) :
- ElementParser(),
- m_data(data)
- {}
-
- private:
- DPL::OptionalString m_name;
- DPL::OptionalString m_value;
- ConfigParserData::Feature& m_data;
- };
-
- virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
- const DPL::String& name)
- {
- if (name == L"param") {
- return DPL::MakeDelegate(this, &FeatureParser::OnParamElement);
- } else {
- return &IgnoringParser::Create;
- }
- }
-
- virtual void Accept(const Text& /*text*/)
- {}
-
- virtual void Accept(const Element& /*element*/)
- {}
-
- virtual void Accept(const XmlAttribute& attribute)
- {
- if (attribute.name == L"name") {
- m_feature.name = attribute.value;
- } else if (attribute.name == L"required") {
- if (attribute.value == L"false") {
- m_feature.required = false;
- } else {
- m_feature.required = true;
- }
- }
- }
-
- virtual void Verify()
- {
- LibIri::Wrapper iri(DPL::ToUTF8String(m_feature.name).c_str());
-
- if (m_feature.name != L"") {
- if (iri.Validate()) {
- if (m_data.featuresList.find(m_feature) ==
- m_data.featuresList.end())
- {
- m_data.featuresList.insert(m_feature);
- } else {
- LogDebug("Ignoring feature with name" <<
- DPL::ToUTF8String(m_feature.name));
- }
- } else {
- if (m_feature.required) {
- //Throw only if required
- ThrowMsg(Exception::ParseError, "invalid feature IRI");
- }
- }
- }
- }
-
- ElementParserPtr OnParamElement()
- {
- return ElementParserPtr(new ParamParser(m_feature));
- }
-
- FeatureParser(ConfigParserData& data) :
- ElementParser(),
- m_data(data),
- m_feature(L"")
- {}
-
- private:
- ConfigParserData& m_data;
- ConfigParserData::Feature m_feature;
-};
-
class PreferenceParser : public ElementParser
{
public:
m_privilege.name = attribute.value;
}
}
- m_feature.required = false;
}
virtual void Verify()
m_data.featuresList.insert(m_feature);
} else {
LogDebug("Ignoring feature with name" <<
- DPL::ToUTF8String(m_feature.name));
+ DPL::ToUTF8String(m_feature.name));
}
}
}
if (attribute.value == L"ture") {
m_multiSupport = true;
- }
+ }
}
}
ElementParser(),
m_data(data),
m_account(data.accountProvider),
- m_properNamespace(false)
+ m_properNamespace(false),
+ m_multiSupport(false)
{}
private:
m_map[L"icon"] = DPL::MakeDelegate(this, &WidgetParser::OnIconElement);
m_map[L"content"] =
DPL::MakeDelegate(this, &WidgetParser::OnContentElement);
- m_map[L"feature"] =
- DPL::MakeDelegate(this, &WidgetParser::OnFeatureElement);
m_map[L"preference"] =
DPL::MakeDelegate(this, &WidgetParser::OnPreferenceElement);
m_map[L"link"] = DPL::MakeDelegate(this, &WidgetParser::OnLinkElement);
return ElementParserPtr(new ContentParser(m_data));
}
-ElementParserPtr WidgetParser::OnFeatureElement()
-{
- return ElementParserPtr(new FeatureParser(m_data));
-}
-
ElementParserPtr WidgetParser::OnPreferenceElement()
{
return ElementParserPtr(new PreferenceParser(m_data));