summaryrefslogtreecommitdiffstats
path: root/kode/kxml_compiler/creator.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'kode/kxml_compiler/creator.cpp')
-rw-r--r--kode/kxml_compiler/creator.cpp166
1 files changed, 83 insertions, 83 deletions
diff --git a/kode/kxml_compiler/creator.cpp b/kode/kxml_compiler/creator.cpp
index 1277d8d71..591265887 100644
--- a/kode/kxml_compiler/creator.cpp
+++ b/kode/kxml_compiler/creator.cpp
@@ -36,11 +36,11 @@
#include <ksimpleconfig.h>
#include <kstandarddirs.h>
-#include <qfile.h>
-#include <qtextstream.h>
-#include <qdom.h>
-#include <qregexp.h>
-#include <qmap.h>
+#include <tqfile.h>
+#include <tqtextstream.h>
+#include <tqdom.h>
+#include <tqregexp.h>
+#include <tqmap.h>
#include <iostream>
@@ -50,7 +50,7 @@ Creator::Creator( XmlParserType p, XmlWriterType w )
setExternalClassNames();
}
-void Creator::setExternalClassPrefix( const QString &prefix )
+void Creator::setExternalClassPrefix( const TQString &prefix )
{
mExternalClassPrefix = prefix;
@@ -65,18 +65,18 @@ void Creator::setExternalClassNames()
KODE::File &Creator::file() { return mFile; }
-QString Creator::upperFirst( const QString &str )
+TQString Creator::upperFirst( const TQString &str )
{
return KODE::Style::upperFirst( str );
}
-QString Creator::lowerFirst( const QString &str )
+TQString Creator::lowerFirst( const TQString &str )
{
return KODE::Style::lowerFirst( str );
}
-void Creator::createProperty( KODE::Class &c, const QString &type,
- const QString &name )
+void Creator::createProperty( KODE::Class &c, const TQString &type,
+ const TQString &name )
{
KODE::MemberVariable v( name, type );
c.addMemberVariable( v );
@@ -95,28 +95,28 @@ void Creator::createProperty( KODE::Class &c, const QString &type,
void Creator::createElementFunctions( KODE::Class &c, Element *e )
{
if ( e->hasText ) {
- createProperty( c, "QString", e->name );
+ createProperty( c, "TQString", e->name );
if ( mXmlParserType == XmlParserCustomExternal ) {
createTextElementParserCustom( c, e );
}
return;
}
- QString type = upperFirst( e->name );
+ TQString type = upperFirst( e->name );
if ( !mFile.hasClass( type ) ) {
createClass( e );
}
- QString name = lowerFirst( e->name );
+ TQString name = lowerFirst( e->name );
if ( e->pattern.oneOrMore || e->pattern.zeroOrMore ||
e->pattern.choice || e->pattern.optional ) {
registerListTypedef( type );
- c.addHeaderInclude( "qvaluelist.h" );
+ c.addHeaderInclude( "tqvaluelist.h" );
type = type + "::List";
- QString className = upperFirst( name );
+ TQString className = upperFirst( name );
name = name + "List";
KODE::Function adder( "add" + className, "void" );
@@ -135,7 +135,7 @@ void Creator::createElementFunctions( KODE::Class &c, Element *e )
void Creator::createClass( Element *element )
{
- QString className = upperFirst( element->name );
+ TQString className = upperFirst( element->name );
if ( mProcessedClasses.find( className ) != mProcessedClasses.end() ) {
return;
@@ -145,21 +145,21 @@ void Creator::createClass( Element *element )
mProcessedClasses.append( className );
- QValueList<Attribute *>::ConstIterator itA;
+ TQValueList<Attribute *>::ConstIterator itA;
for( itA = element->attributes.begin();
itA != element->attributes.end(); ++itA ) {
Attribute *a = *itA;
- createProperty( c, "QString", a->name );
+ createProperty( c, "TQString", a->name );
}
- QValueList<Element *>::ConstIterator itE;
+ TQValueList<Element *>::ConstIterator itE;
for( itE = element->elements.begin(); itE != element->elements.end();
++itE ) {
createElementFunctions( c, *itE );
}
- QValueList<Reference *>::ConstIterator itR;
+ TQValueList<Reference *>::ConstIterator itR;
for( itR = element->references.begin(); itR != element->references.end();
++itR ) {
Element e;
@@ -176,15 +176,15 @@ void Creator::createClass( Element *element )
void Creator::createElementWriter( KODE::Class &c, Element *element )
{
- KODE::Function writer( "writeElement", "QString" );
+ KODE::Function writer( "writeElement", "TQString" );
KODE::Code code;
- code += "QString xml;";
+ code += "TQString xml;";
- QString tag = "<" + element->name;
+ TQString tag = "<" + element->name;
- QValueList<Attribute *>::ConstIterator it3;
+ TQValueList<Attribute *>::ConstIterator it3;
for( it3 = element->attributes.begin(); it3 != element->attributes.end();
++it3 ) {
tag += " " + (*it3)->name + "=\\\"\" + " + (*it3)->name + "() + \"\\\"";
@@ -201,10 +201,10 @@ void Creator::createElementWriter( KODE::Class &c, Element *element )
if ( !element->isEmpty ) {
code += "indent( 2 );";
- QValueList<Element *>::ConstIterator it;
+ TQValueList<Element *>::ConstIterator it;
for( it = element->elements.begin(); it != element->elements.end(); ++it ) {
Element *e = *it;
- QString type = upperFirst( e->name );
+ TQString type = upperFirst( e->name );
if ( e->pattern.oneOrMore || e->pattern.zeroOrMore ) {
code += type + "::List list = " + e->name + "List();";
code += type + "::List::ConstIterator it;";
@@ -223,11 +223,11 @@ void Creator::createElementWriter( KODE::Class &c, Element *element )
}
}
- QValueList<Reference *>::ConstIterator it2;
+ TQValueList<Reference *>::ConstIterator it2;
for( it2 = element->references.begin(); it2 != element->references.end();
++it2 ) {
Reference *r = *it2;
- QString type = upperFirst( r->name );
+ TQString type = upperFirst( r->name );
if ( r->pattern.oneOrMore || r->pattern.zeroOrMore ) {
code += type + "::List list2 = " + r->name + "List();";
code += type + "::List::ConstIterator it2;";
@@ -268,11 +268,11 @@ void Creator::createElementParser( KODE::Class &c, Element *e )
void Creator::createTextElementParserCustom( KODE::Class &, Element *e )
{
- KODE::Function parser( "parseElement" + upperFirst( e->name ), "QString" );
+ KODE::Function parser( "parseElement" + upperFirst( e->name ), "TQString" );
KODE::Code code;
- code += "QString result;";
+ code += "TQString result;";
code.newLine();
KODE::StateMachine sm;
@@ -285,7 +285,7 @@ void Creator::createTextElementParserCustom( KODE::Class &, Element *e )
stateCode += "} else if ( c == '&' ) {";
stateCode += " entityStart = mRunning + 1;";
stateCode += "} else if ( entityStart >= 0 && c == ';' ) {";
- stateCode += " QString entity = mBuffer.mid( entityStart, mRunning - entityStart );";
+ stateCode += " TQString entity = mBuffer.mid( entityStart, mRunning - entityStart );";
stateCode += " if ( entity == \"quot\" ) result += '\"';";
stateCode += " entityStart = -1;";
stateCode += "} else if ( entityStart < 0 ) {";
@@ -330,7 +330,7 @@ void Creator::createTextElementParserCustom( KODE::Class &, Element *e )
code.newLine();
code += "while ( mRunning < mBuffer.length() ) {";
code.indent();
- code += "QChar c = mBuffer[ mRunning ];";
+ code += "TQChar c = mBuffer[ mRunning ];";
code.addBlock( sm.transitionLogic() );
code += "++mRunning;";
code.unindent();
@@ -382,9 +382,9 @@ void Creator::createElementParserCustom( KODE::Class &c, Element *e )
for( it = e->elements.begin(); it != e->elements.end(); ++it ) {
createFoundTextFunction( (*it)->name );
- QString eName = upperFirst( (*it)->name );
+ TQString eName = upperFirst( (*it)->name );
stateCode += "} else if ( foundText" + eName + "() ) {";
- QString line = " result->";
+ TQString line = " result->";
if ( (*it)->hasText ) line += "set";
else line += "add";
line += eName + "( parseElement" + eName + "() );";
@@ -395,7 +395,7 @@ void Creator::createElementParserCustom( KODE::Class &c, Element *e )
for( it3 = e->references.begin(); it3 != e->references.end(); ++it3 ) {
createFoundTextFunction( (*it3)->name );
- QString eName = upperFirst( (*it3)->name );
+ TQString eName = upperFirst( (*it3)->name );
stateCode += "} else if ( foundText" + eName + "() ) {";
stateCode += " result->add" + eName + "( parseElement" + eName + "() );";
stateCode += " state = WHITESPACE;";
@@ -451,7 +451,7 @@ void Creator::createElementParserCustom( KODE::Class &c, Element *e )
code += "while ( mRunning < mBuffer.length() ) {";
code.indent();
- code += "QChar c = mBuffer[ mRunning ];";
+ code += "TQChar c = mBuffer[ mRunning ];";
if ( e->isEmpty ) {
code += "if ( c == '>' ) {";
@@ -485,11 +485,11 @@ KODE::Code Creator::createAttributeScanner( Attribute *a, bool firstAttribute )
{
KODE::Code code;
- QString aName = upperFirst( a->name );
+ TQString aName = upperFirst( a->name );
createFoundTextFunction( a->name );
- QString line;
+ TQString line;
if ( !firstAttribute ) line = "} else ";
line += "if ( foundText" + aName + "() ) {";
code += line;
@@ -509,7 +509,7 @@ KODE::Code Creator::createAttributeScanner( Attribute *a, bool firstAttribute )
void Creator::createElementParserDom( KODE::Class &c, Element *e )
{
- QString functionName;
+ TQString functionName;
if ( externalParser() ) functionName = "parseElement" + c.name();
else functionName = "parseElement";
@@ -517,7 +517,7 @@ void Creator::createElementParserDom( KODE::Class &c, Element *e )
parser.setStatic( true );
parser.setDocs( "Parse XML object from DOM element." );
- parser.addArgument( "const QDomElement &element" );
+ parser.addArgument( "const TQDomElement &element" );
KODE::Code code;
@@ -533,27 +533,27 @@ void Creator::createElementParserDom( KODE::Class &c, Element *e )
code += c.name() + " *result = new " + c.name() + "();";
code.newLine();
- code += "QDomNode n;";
+ code += "TQDomNode n;";
code += "for( n = element.firstChild(); !n.isNull();"
" n = n.nextSibling() ) {";
code.indent();
- code += "QDomElement e = n.toElement();";
+ code += "TQDomElement e = n.toElement();";
- QValueList<Element *>::ConstIterator it;
+ TQValueList<Element *>::ConstIterator it;
for( it = e->elements.begin(); it != e->elements.end(); ++it ) {
- QString condition;
+ TQString condition;
if ( it != e->elements.begin() ) condition = "else ";
condition += "if";
code += condition + " ( e.tagName() == \"" + (*it)->name + "\" ) {";
code.indent();
- QString className = upperFirst( (*it)->name );
+ TQString className = upperFirst( (*it)->name );
if ( (*it)->hasText ) {
code += "result->set" + className + "( e.text() );";
} else {
- QString line = className + " *o = ";
+ TQString line = className + " *o = ";
if ( externalParser() ) {
line += "parseElement" + className;
} else {
@@ -571,18 +571,18 @@ void Creator::createElementParserDom( KODE::Class &c, Element *e )
code.newLine();
- QValueList<Reference *>::ConstIterator it3;
+ TQValueList<Reference *>::ConstIterator it3;
for( it3 = e->references.begin(); it3 != e->references.end(); ++it3 ) {
- QString condition;
+ TQString condition;
if ( it3 != e->references.begin() ) condition = "else ";
condition += "if";
code += condition + " ( e.tagName() == \"" + (*it3)->name + "\" ) {";
code.indent();
- QString className = upperFirst( (*it3)->name );
+ TQString className = upperFirst( (*it3)->name );
- QString line = className + " *o = ";
+ TQString line = className + " *o = ";
if ( externalParser() ) {
line += "parseElement" + className;
} else {
@@ -601,7 +601,7 @@ void Creator::createElementParserDom( KODE::Class &c, Element *e )
code += "}";
code.newLine();
- QValueList<Attribute *>::ConstIterator it2;
+ TQValueList<Attribute *>::ConstIterator it2;
for( it2 = e->attributes.begin(); it2 != e->attributes.end(); ++it2 ) {
code += "result->set" + upperFirst( (*it2)->name ) +
"( element.attribute( \"" + (*it2)->name + "\" ) );";
@@ -619,32 +619,32 @@ void Creator::createElementParserDom( KODE::Class &c, Element *e )
}
}
-void Creator::registerListTypedef( const QString &type )
+void Creator::registerListTypedef( const TQString &type )
{
if ( !mListTypedefs.contains( type ) ) mListTypedefs.append( type );
}
void Creator::createListTypedefs()
{
- QStringList::ConstIterator it;
+ TQStringList::ConstIterator it;
for( it = mListTypedefs.begin(); it != mListTypedefs.end(); ++it ) {
KODE::Class c = mFile.findClass( *it );
if ( !c.isValid() ) continue;
- c.addTypedef( KODE::Typedef( "QValueList<" + *it + " *>", "List" ) );
+ c.addTypedef( KODE::Typedef( "TQValueList<" + *it + " *>", "List" ) );
mFile.insertClass( c );
}
}
void Creator::createIndenter( KODE::File &file )
{
- KODE::Function indenter( "indent", "QString" );
+ KODE::Function indenter( "indent", "TQString" );
indenter.addArgument( "int n = 0" );
KODE::Code code;
code += "static int i = 0;";
code += "i += n;";
- code += "QString space;";
+ code += "TQString space;";
code += "return space.fill( ' ', i );";
indenter.setBody( code );
@@ -652,15 +652,15 @@ void Creator::createIndenter( KODE::File &file )
file.addFileFunction( indenter );
}
-void Creator::createFileWriter( Element *element, const QString &dtd )
+void Creator::createFileWriter( Element *element, const TQString &dtd )
{
- QString className = upperFirst( element->name );
+ TQString className = upperFirst( element->name );
KODE::Class c = mFile.findClass( className );
c.addInclude( "kdebug.h" );
- c.addInclude( "qtextstream.h" );
- c.addInclude( "qfile.h" );
+ c.addInclude( "tqtextstream.h" );
+ c.addInclude( "tqfile.h" );
if ( !externalWriter() ) {
createIndenter( mFile );
@@ -668,19 +668,19 @@ void Creator::createFileWriter( Element *element, const QString &dtd )
KODE::Function writer( "writeFile", "bool" );
- writer.addArgument( "const QString &filename" );
+ writer.addArgument( "const TQString &filename" );
- c.addInclude( "qfile.h" );
+ c.addInclude( "tqfile.h" );
KODE::Code code;
- code += "QFile file( filename );";
+ code += "TQFile file( filename );";
code += "if ( !file.open( IO_WriteOnly ) ) {";
code += " kdError() << \"Unable to open file '\" << filename << \"'\" << endl;";
code += " return false;";
code += "}";
code += "";
- code += "QTextStream ts( &file );";
+ code += "TQTextStream ts( &file );";
code += "ts << \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?>\\n\";";
code += "ts << \"<!DOCTYPE features SYSTEM \\\"" + dtd + "\\\">\\n\";";
@@ -714,29 +714,29 @@ void Creator::createFileParserCustom( Element *element )
{
kdDebug() << "Creator::createFileParserCustom()" << endl;
- QString className = upperFirst( element->name );
+ TQString className = upperFirst( element->name );
KODE::Function parser( "parseFile", className + " *" );
- parser.addArgument( "const QString &filename" );
+ parser.addArgument( "const TQString &filename" );
- mParserClass.addInclude( "qfile.h" );
+ mParserClass.addInclude( "tqfile.h" );
mParserClass.addInclude( "kdebug.h" );
mParserClass.addMemberVariable( KODE::MemberVariable( "mBuffer",
- "QString" ) );
+ "TQString" ) );
mParserClass.addMemberVariable( KODE::MemberVariable( "mRunning",
"unsigned int" ) );
KODE::Code code;
- code += "QFile file( filename );";
+ code += "TQFile file( filename );";
code += "if ( !file.open( IO_ReadOnly ) ) {";
code += " kdError() << \"Unable to open file '\" << filename << \"'\" << endl;";
code += " return 0;";
code += "}";
code += "";
- code += "QTextStream ts( &file );";
+ code += "TQTextStream ts( &file );";
code += "mBuffer = ts.read();";
code += "";
code += "mRunning = 0;";
@@ -771,7 +771,7 @@ void Creator::createFileParserCustom( Element *element )
code += "while ( mRunning < mBuffer.length() ) {";
code.indent();
- code += "QChar c = mBuffer[ mRunning ];";
+ code += "TQChar c = mBuffer[ mRunning ];";
code.addBlock( sm.transitionLogic() );
code += "++mRunning;";
code.unindent();
@@ -785,9 +785,9 @@ void Creator::createFileParserCustom( Element *element )
mParserClass.addFunction( parser );
}
-void Creator::createFoundTextFunction( const QString &text )
+void Creator::createFoundTextFunction( const TQString &text )
{
- QString functionName = "foundText" + upperFirst( text );
+ TQString functionName = "foundText" + upperFirst( text );
if ( mParserClass.hasFunction( functionName ) ) return;
@@ -798,8 +798,8 @@ void Creator::createFoundTextFunction( const QString &text )
code += "if ( mBuffer[ mRunning ] != '" + text.right( 1 ) + "' ) return false;";
code += "";
code += "return mBuffer.mid( mRunning - " +
- QString::number( text.length() - 1 ) + ", " +
- QString::number( text.length() ) + " ) == \"" + text + "\";";
+ TQString::number( text.length() - 1 ) + ", " +
+ TQString::number( text.length() ) + " ) == \"" + text + "\";";
f.setBody( code );
@@ -810,7 +810,7 @@ void Creator::createFileParserDom( Element *element )
{
kdDebug() << "Creator::createFileParserDom()" << endl;
- QString className = upperFirst( element->name );
+ TQString className = upperFirst( element->name );
KODE::Class c;
@@ -823,23 +823,23 @@ void Creator::createFileParserDom( Element *element )
KODE::Function parser( "parseFile", className + " *" );
parser.setStatic( true );
- parser.addArgument( "const QString &filename" );
+ parser.addArgument( "const TQString &filename" );
- c.addInclude( "qfile.h" );
- c.addInclude( "qdom.h" );
+ c.addInclude( "tqfile.h" );
+ c.addInclude( "tqdom.h" );
c.addInclude( "kdebug.h" );
KODE::Code code;
- code += "QFile file( filename );";
+ code += "TQFile file( filename );";
code += "if ( !file.open( IO_ReadOnly ) ) {";
code += " kdError() << \"Unable to open file '\" << filename << \"'\" << endl;";
code += " return 0;";
code += "}";
code += "";
- code += "QString errorMsg;";
+ code += "TQString errorMsg;";
code += "int errorLine, errorCol;";
- code += "QDomDocument doc;";
+ code += "TQDomDocument doc;";
code += "if ( !doc.setContent( &file, false, &errorMsg, &errorLine, &errorCol ) ) {";
code += " kdError() << errorMsg << \" at \" << errorLine << \",\" << errorCol << endl;";
code += " return 0;";
@@ -849,7 +849,7 @@ void Creator::createFileParserDom( Element *element )
code += "";
- QString line = className + " *c = parseElement";
+ TQString line = className + " *c = parseElement";
if ( externalParser() ) line += className;
line += "( doc.documentElement() );";
code += line;