| webtangle : output |
Output the block to the stream.
Any other method of any other object can call this method. This is called 'public' access.
The data-type returned is "voidtype";
This method is contained in the object "webtangle".
The method takes the following arguments:
filedef : Pointer to tgl_structure_parser
Not sure.
obj : Pointer to @schemaobj
Not sure.
This method is overridden from an abstract method with the same signature found in the object @block.
The namespaces "ph::tools::schema" and "ph::xmlobj" are used.
The files "tgl_structure_parser.hpp", "schema/schema_implementation.hpp", "schema/schema_web.hpp", "schema/schema_websection.hpp" and "schema/schema_attribute.hpp" are included.
Loop over all sections finding "root" and output it. If the entire web has a language, then don't bother with language declarations on each source block.
// get the web for the current object for the right language and output it.
xmlobj_typed_vector<schema_implementation> *implementations =
dynamic_cast<xmlobj_typed_vector<schema_implementation> *>(
obj->get_composite_object("implementations"));
if (!implementations)
{
filedef->error("No composite member 'implementations'.");
return;
}
for (xmlobj_typed_vector<schema_implementation>::iterator i=implementations->begin();
i != implementations->end(); i++)
{
schema_web *web = dynamic_cast<schema_web *>(&*i);
if (!web)
continue;
std::string language = web->get("language");
if (language != "" && language != _language)
continue;
xmlobj_typed_vector<schema_attribute> *attributes =
dynamic_cast<xmlobj_typed_vector<schema_attribute> *>(
web->get_composite_object("attributes"));
if (!attributes)
{
filedef->error("No composite member 'attributes'.");
return;
}
if (attributes->count() == 1)
{
if (_attributes != "[]")
{
std::string a = "[" + attributes->begin()->name() + "]";
if (_attributes != a)
continue;
}
}
else if (attributes->count() > 0)
{
filedef->error("Only supporting a single attribute. Write the code for more than 1.");
return;
}
xmlobj_typed_vector<schema_websection> *sections =
dynamic_cast<xmlobj_typed_vector<schema_websection> *>(
web->get_composite_object("sections"));
if (!sections)
{
filedef->error("No composite member 'sections'.");
return;
}
for (xmlobj_typed_vector<schema_websection>::iterator j=sections->begin();
j != sections->end(); j++)
{
if (j->name() == "root")
{
if (!write_section(filedef, web, &*j))
return;
}
}
}