# dcop Library API Documentation

Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Namespaces | Source Files

# cpp/main.cpp

    00001 /*****************************************************************
    00002 Copyright (c) 1999 Torben Weis <weis@kde.org>
    00003 Copyright (c) 2000 Matthias Ettrich <ettrich@kde.org>
    00004
    00005 Permission is hereby granted, free of charge, to any person obtaining a copy
    00006 of this software and associated documentation files (the "Software"), to deal
    00007 in the Software without restriction, including without limitation the rights
    00008 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    00009 copies of the Software, and to permit persons to whom the Software is
    00010 furnished to do so, subject to the following conditions:
    00011
    00012 The above copyright notice and this permission notice shall be included in
    00013 all copies or substantial portions of the Software.
    00014
    00015 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    00016 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    00017 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
    00018 AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
    00019 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
    00020 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    00021
    00022 ******************************************************************/
    00023 #include <qdom.h>
    00024 #include <qfile.h>
    00025 #include <qtextstream.h>
    00026 #include <qstring.h>
    00027
    00028 #include <string.h>
    00029 #include <stdlib.h>
    00030 #include <stdio.h>
    00031 #include <unistd.h>
    00032 #include "main.h"
    00033
    00034
    00035
    00036 void usage()
    00037 {
    00038     fprintf( stderr, "Usage: dcopidl2cpp [ --no-skel | --no-stub ] [--c++-suffix <suffix>] file\n" );
    00039 }
    00040
    00041 int main( int argc, char** argv )
    00042 {
    00043
    00044     if ( *qVersion() == '1' ) {
    00045         fprintf( stderr, "dcopidl2cpp appears to be linked to Qt 1 instead of Qt >= 2 ! Aborting.\n" );
    00046         exit(1);
    00047     }
    00048     if ( argc < 2 ) {
    00049     usage();
    00050     return 1;
    00051     }
    00052     int argpos = 1;
    00053     bool generate_skel    = true;
    00054     bool generate_stub    = true;
    00055
    00056     QString suffix = "cpp";
    00057
    00058     while (argc > 2) {
    00059
    00060     if ( strcmp( argv[argpos], "--no-skel" ) == 0 )
    00061     {
    00062         generate_skel = false;
    00063         for (int i = argpos; i < argc - 1; i++) argv[i] = argv[i+1];
    00064         argc--;
    00065     }
    00066     else if ( strcmp( argv[argpos], "--no-stub" ) == 0 )
    00067     {
    00068         generate_stub = false;
    00069         for (int i = argpos; i < argc - 1; i++) argv[i] = argv[i+1];
    00070         argc--;
    00071     }
    00072     else if ( strcmp( argv[argpos], "--no-signals" ) == 0 )
    00073     {
    00074         // Obsolete: Signal stubs are now always generated.
    00075         // Leave this command line argument intact, so old Makefiles won't break.
    00076         for (int i = argpos; i < argc - 1; i++) argv[i] = argv[i+1];
    00077         argc--;
    00078     }
    00079     else if ( strcmp( argv[argpos], "--c++-suffix" ) == 0)
    00080     {
    00081         if (argc - 1 < argpos) {
    00082         usage();
    00083         exit(1);
    00084         }
    00085         suffix = argv[argpos+1];
    00086         for (int i = argpos; i < argc - 2; i++) argv[i] = argv[i+2];
    00087         argc -= 2;
    00088     } else {
    00089         usage();
    00090         exit(1);
    00091     }
    00092     }
    00093
    00094     QFile in( QFile::decodeName(argv[argpos]) );
    00095     if ( !in.open( IO_ReadOnly ) )
    00096     qFatal("Could not read %s", argv[argpos] );
    00097
    00098     QDomDocument doc;
    00099     doc.setContent( &in );
    00100
    00101     QDomElement de = doc.documentElement();
    00102     Q_ASSERT( de.tagName() == "DCOP-IDL" );
    00103
    00104     QString base( argv[argpos] );
    00105     QString idl = base;
    00106
    00107     int pos = base.findRev( '.' );
    00108     if ( pos != -1 )
    00109     base = base.left( pos );
    00110
    00111     pos = idl.findRev('/');
    00112     if ( pos != -1 )
    00113     idl = idl.mid( pos+1 );
    00114
    00115     if ( generate_skel )
    00116     generateSkel( idl, base + "_skel." + suffix, de );
    00117
    00118     if ( generate_stub ) {
    00119     QString header = base;
    00120     generateStub( idl, header + "_stub.h", de );
    00121     pos = header.findRev('/');
    00122     if ( pos != -1 )
    00123         header = header.mid( pos+1 );
    00124     generateStubImpl( idl, header + "_stub.h", base+".h", base + "_stub." + suffix, de);
    00125     }
    00126
    00127     return 0;
    00128 }

This file is part of the documentation for dcop Library Version 3.4.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Jun 11 20:16:55 2005 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003