summaryrefslogtreecommitdiff
path: root/indra/llxuixml/llxuiparser.cpp
diff options
context:
space:
mode:
authorRichard Linden <none@none>2011-11-08 13:48:38 -0800
committerRichard Linden <none@none>2011-11-08 13:48:38 -0800
commit7e6e3d20f334547d8cea78e8e0b37106efebe028 (patch)
tree92869b7a8b8dede9e79562eec0f235338db6f9b2 /indra/llxuixml/llxuiparser.cpp
parentb6858df0dd9fa06ec8fa56c5ba63925a790b4811 (diff)
added Lazy modifier to params to support recursion
ChoiceBlock can now derive from another param block Params with name/value support can be assigned directly in C++ code using param = "named_value"
Diffstat (limited to 'indra/llxuixml/llxuiparser.cpp')
-rw-r--r--indra/llxuixml/llxuiparser.cpp258
1 files changed, 197 insertions, 61 deletions
diff --git a/indra/llxuixml/llxuiparser.cpp b/indra/llxuixml/llxuiparser.cpp
index 878f992178..cdf578113a 100644
--- a/indra/llxuixml/llxuiparser.cpp
+++ b/indra/llxuixml/llxuiparser.cpp
@@ -59,28 +59,26 @@ const char* NO_VALUE_MARKER = "no_value";
const S32 LINE_NUMBER_HERE = 0;
-struct MaxOccur : public LLInitParam::ChoiceBlock<MaxOccur>
+struct MaxOccursValues : public LLInitParam::TypeValuesHelper<U32, MaxOccursValues>
{
- Alternative<int> count;
- Alternative<std::string> unbounded;
-
- MaxOccur()
- : unbounded("", "unbounded")
- {}
+ using TypeValuesHelper<U32, MaxOccursValues>::operator =;
+ typedef std::string name_t;
+ static void declareValues()
+ {
+ declare("unbounded", U32_MAX);
+ }
};
struct Occurs : public LLInitParam::Block<Occurs>
{
- Optional<S32> minOccurs;
- Optional<MaxOccur> maxOccurs;
+ Optional<U32> minOccurs;
+ Optional<U32, MaxOccursValues> maxOccurs;
+ Multiple<U32, AnyAmount, MaxOccursValues> foo;
Occurs()
- : minOccurs("minOccurs"),
- maxOccurs("maxOccurs")
- {
- minOccurs = 0;
- maxOccurs.unbounded.choose();
- }
+ : minOccurs("minOccurs", 0),
+ maxOccurs("maxOccurs", U32_MAX)
+ {}
};
@@ -103,18 +101,15 @@ namespace LLInitParam
};
}
-struct Name : public LLInitParam::Block<Name>
-{
- Mandatory<std::string> name;
-
- Name()
- : name("name")
- {}
-};
+struct Element;
+struct Group;
+struct Choice;
+struct Sequence;
+struct Any;
struct Attribute : public LLInitParam::Block<Attribute>
{
- Mandatory<Name> name;
+ Mandatory<std::string> name;
Mandatory<std::string> type;
Mandatory<EUse> use;
@@ -122,41 +117,170 @@ struct Attribute : public LLInitParam::Block<Attribute>
: name("name"),
type("type"),
use("use")
+ {}
+};
+
+struct Any : public LLInitParam::Block<Any, Occurs>
+{
+ Optional<std::string> _namespace;
+
+ Any()
+ : _namespace("namespace")
+ {}
+};
+
+struct All : public LLInitParam::Block<All, Occurs>
+{
+ Multiple<Lazy<Element>> elements;
+
+ All()
+ : elements("element")
{
+ maxOccurs = 1;
}
};
-struct ComplexType : public LLInitParam::Block<ComplexType>
+struct Choice : public LLInitParam::ChoiceBlock<Choice, Occurs>
+{
+ Alternative<Lazy<Element>> element;
+ Alternative<Lazy<Group>> group;
+ Alternative<Lazy<Choice>> choice;
+ Alternative<Lazy<Sequence>> sequence;
+ Alternative<Lazy<Any>> any;
+
+ Choice()
+ : element("element"),
+ group("group"),
+ choice("choice"),
+ sequence("sequence"),
+ any("any")
+ {}
+
+};
+
+struct Sequence : public LLInitParam::ChoiceBlock<Sequence, Occurs>
+{
+ Alternative<Lazy<Element>> element;
+ Alternative<Lazy<Group>> group;
+ Alternative<Lazy<Choice>> choice;
+ Alternative<Lazy<Sequence>> sequence;
+ Alternative<Lazy<Any>> any;
+};
+
+struct GroupContents : public LLInitParam::ChoiceBlock<GroupContents, Occurs>
{
- Multiple<Attribute> attribute;
- //Multiple<struct Element> elements;
- Optional<bool> mixed;
+ Alternative<All> all;
+ Alternative<Choice> choice;
+ Alternative<Sequence> sequence;
+
+ GroupContents()
+ : all("all"),
+ choice("choice"),
+ sequence("sequence")
+ {}
+};
+
+struct Group : public LLInitParam::Block<Group, GroupContents>
+{
+ Optional<std::string> name,
+ ref;
+
+ Group()
+ : name("name"),
+ ref("ref")
+ {}
+};
+
+struct Restriction : public LLInitParam::Block<Restriction>
+{
+};
+
+struct Extension : public LLInitParam::Block<Extension>
+{
+};
+
+struct SimpleContent : public LLInitParam::ChoiceBlock<SimpleContent>
+{
+ Alternative<Restriction> restriction;
+ Alternative<Extension> extension;
+
+ SimpleContent()
+ : restriction("restriction"),
+ extension("extension")
+ {}
+};
+
+struct SimpleType : public LLInitParam::Block<SimpleType>
+{
+ // TODO
+};
+
+struct ComplexContent : public LLInitParam::Block<ComplexContent, SimpleContent>
+{
+ Optional<bool> mixed;
+
+ ComplexContent()
+ : mixed("mixed", true)
+ {}
+};
+
+struct ComplexTypeContents : public LLInitParam::ChoiceBlock<ComplexTypeContents>
+{
+ Alternative<SimpleContent> simple_content;
+ Alternative<ComplexContent> complex_content;
+ Alternative<Group> group;
+ Alternative<All> all;
+ Alternative<Choice> choice;
+ Alternative<Sequence> sequence;
+
+ ComplexTypeContents()
+ : simple_content("simpleContent"),
+ complex_content("complexContent"),
+ group("group"),
+ all("all"),
+ choice("choice"),
+ sequence("sequence")
+ {}
+};
+
+struct ComplexType : public LLInitParam::Block<ComplexType, ComplexTypeContents>
+{
+ Optional<std::string> name;
+ Optional<bool> mixed;
+
+ Multiple<Attribute> attribute;
+ Multiple<Lazy<Element>> elements;
ComplexType()
- : attribute("xs:attribute"),
- //elements("xs:element"),
+ : name("name"),
+ attribute("xs:attribute"),
+ elements("xs:element"),
mixed("mixed")
{
- mixed = true;
}
};
-struct Element : public LLInitParam::Block<Element, Occurs>
+struct ElementContents : public LLInitParam::ChoiceBlock<ElementContents, Occurs>
{
- Mandatory<ComplexType> complexType;
- Mandatory<Name> name;
+ Alternative<SimpleType> simpleType;
+ Alternative<ComplexType> complexType;
- Element()
- : complexType("xs:complexType")
+ ElementContents()
+ : simpleType("simpleType"),
+ complexType("complexType")
{}
};
-struct Elements : public LLInitParam::Block<Elements, Occurs>
+struct Element : public LLInitParam::Block<Element, ElementContents>
{
- Multiple<Element> elements;
+ Optional<std::string> name,
+ ref,
+ type;
- Elements()
- : elements("xs:element")
+ Element()
+ : name("xs:name"),
+ ref("xs:ref"),
+ type("xs:type")
{}
};
@@ -164,28 +288,32 @@ struct Schema : public LLInitParam::Block<Schema>
{
private:
Mandatory<std::string> targetNamespace,
- xmlns;
+ xmlns,
+ xs;
public:
Optional<std::string> attributeFormDefault,
- elementFormDefault,
- xs;
+ elementFormDefault;
- Optional<Elements> elements;
+ Mandatory<Element> root_element;
void setNameSpace(const std::string& ns) {targetNamespace = ns; xmlns = ns;}
- Schema()
+ Schema(const std::string& ns = LLStringUtil::null)
: attributeFormDefault("attributeFormDefault"),
elementFormDefault("elementFormDefault"),
xs("xmlns:xs"),
targetNamespace("targetNamespace"),
xmlns("xmlns"),
- elements("xs:choice")
+ root_element("xs:element")
{
attributeFormDefault = "unqualified";
elementFormDefault = "qualified";
xs = "http://www.w3.org/2001/XMLSchema";
+ if (!ns.empty())
+ {
+ setNameSpace(ns);
+ };
}
};
@@ -214,22 +342,30 @@ LLXSDWriter::LLXSDWriter()
void LLXSDWriter::writeXSD(const std::string& type_name, LLXMLNodePtr node, const LLInitParam::BaseBlock& block, const std::string& xml_namespace)
{
+ Schema schema(xml_namespace);
+
+ schema.root_element.name = type_name;
+ Choice& choice = schema.root_element.complexType.choice;
+
+ choice.minOccurs = 0;
+ choice.maxOccurs = "unbounded";
+
mSchemaNode = node;
- node->setName("xs:schema");
- node->createChild("attributeFormDefault", true)->setStringValue("unqualified");
- node->createChild("elementFormDefault", true)->setStringValue("qualified");
- node->createChild("targetNamespace", true)->setStringValue(xml_namespace);
- node->createChild("xmlns:xs", true)->setStringValue("http://www.w3.org/2001/XMLSchema");
- node->createChild("xmlns", true)->setStringValue(xml_namespace);
-
- node = node->createChild("xs:complexType", false);
- node->createChild("name", true)->setStringValue(type_name);
- node->createChild("mixed", true)->setStringValue("true");
-
- mAttributeNode = node;
- mElementNode = node->createChild("xs:choice", false);
- mElementNode->createChild("minOccurs", true)->setStringValue("0");
- mElementNode->createChild("maxOccurs", true)->setStringValue("unbounded");
+ //node->setName("xs:schema");
+ //node->createChild("attributeFormDefault", true)->setStringValue("unqualified");
+ //node->createChild("elementFormDefault", true)->setStringValue("qualified");
+ //node->createChild("targetNamespace", true)->setStringValue(xml_namespace);
+ //node->createChild("xmlns:xs", true)->setStringValue("http://www.w3.org/2001/XMLSchema");
+ //node->createChild("xmlns", true)->setStringValue(xml_namespace);
+
+ //node = node->createChild("xs:complexType", false);
+ //node->createChild("name", true)->setStringValue(type_name);
+ //node->createChild("mixed", true)->setStringValue("true");
+
+ //mAttributeNode = node;
+ //mElementNode = node->createChild("xs:choice", false);
+ //mElementNode->createChild("minOccurs", true)->setStringValue("0");
+ //mElementNode->createChild("maxOccurs", true)->setStringValue("unbounded");
block.inspectBlock(*this);
// duplicate element choices