forwards : 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 "forwards".

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.

Implementations

C++

The files "schema/schema_method.hpp", "schema/schema_object.hpp", "schema/schema_obj.hpp", "schema/schema_typename.hpp", "tgl_structure_parser.hpp", "tgl_list_parser.hpp" and "boost/tokenizer.hpp" are included.

Work out any forward declarations needed.

	// create a set for the includes.
	std::set<std::string> forwards;
	
	// add in any forward classes from methods.
	{
		ph::xmlobj::xmlobj_typed_vector<ph::tools::schema::schema_method> *v = 
			dynamic_cast<ph::xmlobj::xmlobj_typed_vector<ph::tools::schema::schema_method> *>(
				obj->get_composite_object("methods"));
		if (!v)
		{
			filedef->error("No composite member 'methods'.");
			return;
		}
		
		for (ph::xmlobj::xmlobj_typed_vector<ph::tools::schema::schema_method>::iterator i=v->begin();
			i != v->end(); i++)
		{
			ph::xmlobj::xmlobj_typed_ref<ph::tools::schema::schema_typename> *r = 
				dynamic_cast<ph::xmlobj::xmlobj_typed_ref<ph::tools::schema::schema_typename> *>(
					i->get_composite_object("returns"));
			if (!r)
			{
				filedef->error("No composite member 'methods/returns'.");
				return;
			}
			if (r->get())
			{
				std::string reftype = r->get()->get("reftype");
				if (reftype != "")
				{
					if (!declare_reftype(filedef, obj, reftype, &forwards))
						return;
				}
			}
			
			ph::xmlobj::xmlobj_typed_vector<ph::tools::schema::schema_typename> *a = 
				dynamic_cast<ph::xmlobj::xmlobj_typed_vector<ph::tools::schema::schema_typename> *>(
					i->get_composite_object("arguments"));
			if (!a)
			{
				filedef->error("No composite member 'methods/arguments'.");
				return;
			}
			for (ph::xmlobj::xmlobj_typed_vector<ph::tools::schema::schema_typename>::iterator j=a->begin();
				j != a->end(); j++)
			{
				std::string reftype = j->get("reftype");
				if (reftype != "")
				{
					if (!declare_reftype(filedef, obj, reftype, &forwards))
						return;
				}
			}
		}
	}
	
	// and do the same with the members.
	{
		ph::xmlobj::xmlobj_typed_vector<ph::tools::schema::schema_typename> *v = 
			dynamic_cast<ph::xmlobj::xmlobj_typed_vector<ph::tools::schema::schema_typename> *>(
				obj->get_composite_object("members"));
		if (!v)
		{
			filedef->error("No composite member 'members'.");
			return;
		}
			
		for (ph::xmlobj::xmlobj_typed_vector<ph::tools::schema::schema_typename>::iterator i=v->begin();
				i != v->end(); i++)
		{
			std::string reftype = i->get("reftype");
			if (reftype != "")
			{
				if (!declare_reftype(filedef, obj, reftype, &forwards))
					return;
			}
		}
	}
	
	// TBD: we should create a graph of namespaces so that we correctly nest them etc.
	// for now, we just declare them ouitright each time.
	boost::char_separator<char> sep(":");
	for (std::set<std::string>::iterator i=forwards.begin(); i != forwards.end(); i++)
	{
		// split out the namespaces.
		std::vector<std::string> names;
		boost::tokenizer<boost::char_separator<char> > t(*i, sep);
		for (boost::tokenizer<boost::char_separator<char> >::iterator j=t.begin(); j != t.end(); j++)
			names.push_back(*j);
				
		if (names.size() == 1 && _local)
			filedef->write_output("class " + *i + ";\\n");
		else if (names.size() > 0 && !_local && names[0] == "std")
		{
			// don't output std declarations.
		}
		else if (names.size() > 1 && !_local)
		{
			for (unsigned int k=0; k < (names.size() - 1); k++)
				filedef->write_output("namespace " + names[k] + " { ");
			filedef->write_output("\\nclass " + names[names.size() - 1] + ";\\n");
			for (unsigned int k=0; k < (names.size() - 1); k++)
				filedef->write_output("}; ");
			filedef->write_output("\\n");
		}
	}

Generated: Wed Apr 5 23:55:56 EST 2006 using "xsltproc ... docbook.xsl". Copyright (c) 2003, 2004, 2005; Paul Hamilton; pHamtec P/L. Use, modification, and distribution is provided free of any limitations.