#include "FileOut.h" #include "UmlItem.h" #include #include FileOut::FileOut(QFile * fp) : QTextStream(fp), _indent(0){ } void FileOut::indent() { QTextStream & ts = *this; for (int n = _indent; n > 0; n -= 1) ts << '\t'; } void FileOut::id(const UmlItem * x) { ((QTextStream &) *this) << " xmi.id=\"BOUML_" << ((void *) x) << '"'; } void FileOut::idref(const UmlItem * x) { ((QTextStream &) *this) << " xmi.idref=\"BOUML_" << ((void *) x) << '"'; } void FileOut::idref(QCString s, const UmlItem * x) { QString keys; { QTextStream keyst(&keys, IO_WriteOnly); keyst << ((void *) x) << "_" << s; } QMap::ConstIterator it = _modifiedtypes.find((const char *) keys); if (it == _modifiedtypes.end()) it = _modifiedtypes.insert((const char *) keys, _modifiedtypes.count()); ((QTextStream &) *this) << " xmi.idref=\"BOUML_basedontype_" << it.data() << '"'; } void FileOut::ref(const UmlItem * x) { ((QTextStream &) *this) << "BOUML_" << ((void *) x); } void FileOut::idref_datatype(const QCString & t) { QMap::ConstIterator it = _datatypes.find(t); if (it == _datatypes.end()) it = _datatypes.insert(t, _datatypes.count()); ((QTextStream &) *this) << " xmi.idref=\"BOUML_datatype_" << it.data() << '"'; } void FileOut::define_datatypes(int taggedvalue_mode) { QMap::ConstIterator it; for (it = _datatypes.begin(); it != _datatypes.end(); ++it) { indent(); (*this) << "\n"; } for (it = _modifiedtypes.begin(); it != _modifiedtypes.end(); ++it) { QCString k = it.key(); int index = k.find('_'); indent(); (*this) << "\n"; switch (taggedvalue_mode) { case 1: indent(); (*this) << "\t\n"; indent(); (*this) << "\t\t\n"; indent(); (*this) << "\t\n"; break; case 2: indent(); (*this) << "\t\n"; indent(); (*this) << "\t\tbasedOn\n"; indent(); (*this) << "\t\tBOUML_" << k.left(index) << "\n"; indent(); (*this) << "\t\n"; break; } indent(); (*this) << "\n"; } } void FileOut::quote(const char * s) { for (;;) { switch (*s) { case 0: return; case '<': (*this) << "<"; break; case '>': (*this) << ">"; break; case '"': (*this) << """; break; case '&': (*this) << "&"; break; default: (*this) << *s; } s += 1; } }