25 #include <tqtextstream.h>
38 fprintf( stderr,
"[dcopidl2cpp] Usage: dcopidl2cpp [ --no-skel | --no-stub ] [--c++-suffix <suffix>] file\n" );
41 int main(
int argc,
char** argv )
44 if ( *tqVersion() ==
'1' ) {
45 fprintf( stderr,
"[dcopidl2cpp] dcopidl2cpp appears to be linked to Qt 1 instead of Qt >= 2 ! Aborting.\n" );
53 bool generate_skel =
true;
54 bool generate_stub =
true;
56 TQString suffix =
"cpp";
60 if ( strcmp( argv[argpos],
"--no-skel" ) == 0 )
62 generate_skel =
false;
63 for (
int i = argpos; i < argc - 1; i++) argv[i] = argv[i+1];
66 else if ( strcmp( argv[argpos],
"--no-stub" ) == 0 )
68 generate_stub =
false;
69 for (
int i = argpos; i < argc - 1; i++) argv[i] = argv[i+1];
72 else if ( strcmp( argv[argpos],
"--no-signals" ) == 0 )
76 for (
int i = argpos; i < argc - 1; i++) argv[i] = argv[i+1];
79 else if ( strcmp( argv[argpos],
"--c++-suffix" ) == 0)
81 if (argc - 1 < argpos) {
85 suffix = argv[argpos+1];
86 for (
int i = argpos; i < argc - 2; i++) argv[i] = argv[i+2];
94 TQFile in( TQFile::decodeName(argv[argpos]) );
95 if ( !in.open( IO_ReadOnly ) )
96 tqFatal(
"Could not read %s", argv[argpos] );
99 doc.setContent( &in );
101 TQDomElement de = doc.documentElement();
102 Q_ASSERT( de.tagName() ==
"DCOP-IDL" );
104 TQString base( argv[argpos] );
107 int pos = base.findRev(
'.' );
109 base = base.left( pos );
111 pos = idl.findRev(
'/');
113 idl = idl.mid( pos+1 );
116 generateSkel( idl, base +
"_skel." + suffix, de );
118 if ( generate_stub ) {
119 TQString header = base;
120 generateStub( idl, header +
"_stub.h", de );
121 pos = header.findRev(
'/');
123 header = header.mid( pos+1 );
124 generateStubImpl( idl, header +
"_stub.h", base+
".h", base +
"_stub." + suffix, de);