| foreach : 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 "foreach".
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 files "schema/schema_obj.hpp", "tgl_block.hpp", "../cppxmlobj/reflect/jscript_object_navigator.hpp", "../cppxmlobj/xmlobj_ref.hpp", "tgl_structure_parser.hpp" and "tgl_block_parser.hpp" are included.
Loop over all objects ina vectr of objects, outputing for each one.
xmlobj::xmlobj *o = obj;
if (_location != "")
{
ph::reflect::jscript_object_navigator n(obj->root(), filedef->console(), false, false);
ph::common::object_base *no = n.navigate(o, _location);
if (!no)
{
filedef->error("Could not find location [" + _location + "] in object.");
return;
}
o = dynamic_cast<xmlobj::xmlobj *>(no);
if (!o)
{
filedef->error("Internal error. How could the object returned not be an xmlobj?.");
return;
}
}
ph::common::object_base *comp = o->get_composite_object(_vector);
if (!comp)
{
filedef->error("No composite member '" + _vector + "'.");
return;
}
ph::xmlobj::xmlobj_vector *v = dynamic_cast<ph::xmlobj::xmlobj_vector *>(comp);
if (v)
{
// loop through all of the members
for (std::vector<ph::common::object_base *>::iterator i=v->begin();
i != v->end(); i++)
{
bool first = i == v->begin();
bool last = (i+1) == v->end();
if (!(*i)->pretendable())
{
filedef->error("Object has no pretendable interface.");
return;
}
ph::tools::schema::schema_obj *o = dynamic_cast<ph::tools::schema::schema_obj *>(
(*i)->pretendable()->realobject());
if (!o)
{
filedef->error("Object is not a schema_obj.");
return;
}
tgl_block_parser parser(this, o, first, last, filedef);
if (!parser.write_output(_structure))
{
filedef->error("Could not process blocks.");
return;
}
}
}
else
{
ph::xmlobj::xmlobj_ref *r = dynamic_cast<ph::xmlobj::xmlobj_ref *>(comp);
if (r)
{
if (r->obj())
{
ph::tools::schema::schema_obj *o2 = dynamic_cast<ph::tools::schema::schema_obj *>(r->obj());
if (!o2)
{
filedef->error("Object is not a schema_obj.");
return;
}
tgl_block_parser parser(this, o2, true, false, filedef);
if (!parser.write_output(_structure))
{
filedef->error("Could not process blocks.");
return;
}
}
}
else
{
filedef->error("Composite member [" + _vector + "] is not an xmlobj_vector or xmlobj_ref.");
return;
}
}