Welcome to the NetCologne GmbH open source mirroring service!

This machine mirrors various open-source projects. 20 Gbit/s uplink.

If there are any issues or you want another project mirrored, please contact mirror-service -=AT=- netcologne DOT de !

command_line.cxx Source File
Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

command_line.cxx

Go to the documentation of this file.
00001 //  $Id: command_line.cxx,v 1.6 2003/01/11 16:11:36 grumbel Exp $
00002 //
00003 //  Construo - A wire-frame construction gamee
00004 //  Copyright (C) 2002 Ingo Ruhnke <grumbel@gmx.de>
00005 //
00006 //  This program is free software; you can redistribute it and/or
00007 //  modify it under the terms of the GNU General Public License
00008 //  as published by the Free Software Foundation; either version 2
00009 //  of the License, or (at your option) any later version.
00010 //
00011 //  This program is distributed in the hope that it will be useful,
00012 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //  GNU General Public License for more details.
00015 //
00016 //  You should have received a copy of the GNU General Public License
00017 //  along with this program; if not, write to the Free Software
00018 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00019 
00020 #include <config.h>
00021 #include <iostream>
00022 #include <stdio.h>
00023 #include "settings.hxx"
00024 #include "command_line.hxx"
00025 
00026 void
00027 CommandLine::error (const std::string& msg)
00028 {
00029   std::cout << "CommandLine parse failure!" << std::endl;
00030   std::cout << "CommandLine: " << msg << std::endl;
00031   exit(EXIT_FAILURE);
00032 }
00033 
00034 void
00035 CommandLine::parse (int argc, char** argv)
00036 {
00037   for (int i = 1; i < argc; ++i) // Skip Programm name
00038     {
00039       //std::cout << "Arg: " << argv[i] << std::endl;
00040 
00041       if (argv[i][0] == '-') // Argument is an option
00042         {
00043           if (strcmp(argv[i], "--fullscreen") == 0
00044               || strcmp(argv[i], "-f") == 0)
00045             {
00046               settings.fullscreen = true;
00047             }
00048           else if (strcmp(argv[i], "--version") == 0
00049                    || strcmp(argv[i], "-v") == 0)
00050             {
00051               print_version ();
00052               exit (EXIT_SUCCESS);              
00053             }
00054           else if (strcmp(argv[i], "--help") == 0
00055               || strcmp(argv[i], "-h") == 0)
00056             {
00057               print_help ();
00058               exit (EXIT_SUCCESS);
00059             }
00060           else if (strcmp(argv[i], "--disable-alphablending") == 0)
00061             {
00062               settings.alphablending = false;
00063             }
00064           else if (strcmp(argv[i], "--disable-antialiasing") == 0)
00065             {
00066               settings.antialiasing = false;
00067             }
00068           else if (strcmp(argv[i], "--disable-doublebuffer") == 0
00069               || strcmp(argv[i], "-d") == 0)
00070             {
00071               settings.doublebuffer = false;
00072             }
00073           else if (strcmp(argv[i], "-g") == 0
00074                    || strcmp(argv[i], "--geometry") == 0)
00075             {
00076               if (++i < argc)
00077                 {
00078                   char c;
00079                   if (sscanf(argv[i], "%d%c%d", 
00080                              &settings.screen_width, &c, &settings.screen_height) != 3 && c != 'x')
00081                     {
00082                       error ("geometry string must WIDTHxHEIGHT");
00083                     }                
00084                 }
00085               else
00086                 {
00087                   error ("-g/--geometry is missing an argument");
00088                 }
00089             }
00090           else
00091             {
00092               error (std::string("Unknown option: ") + argv[i]);
00093             }
00094         }
00095       else
00096         {
00097           if (!settings.startup_file.empty())
00098             {
00099               error ("Only one filename can be given");
00100             }
00101           else
00102             {
00103               settings.startup_file = argv[i];
00104             }
00105         }
00106     }
00107 }
00108 
00109 void
00110 CommandLine::print_help ()
00111 {
00112   std::cout << "Construo "VERSION"\n\n"
00113             << "Usage: construo [OPTIONS] [FILENAME]\n\n"
00114             << "  -h, --help                  display this help text\n"
00115             << "  -v,--version                Print version number of the programm\n"
00116             << "  -f, --fullscreen            switch to fullscreen mode if available\n"
00117             << "  -d, --disable-doublebuffer  disable the double buffer (might cause flicker)\n"
00118             << "  -g, --geometry WIDTHxHEIGHT switch resolution to WIDTH and HEIGHT\n"
00119             << "  --disable-antialiasing      Switch into non antialiased mode\n"
00120             << "  --disable-alphablending     Switch into non alphablended mode\n"
00121             << std::endl;
00122 }
00123 
00124 void
00125 CommandLine::print_version ()
00126 {
00127   std::cout << "Construo "VERSION"\n"
00128             << "Written by Ingo Ruhnke <grumbel@gmx.de>\n\n"
00129             << "Copyright (C) 2002 Ingo Ruhnke <grumbel@gmx.de>\n"
00130             << "This is free software; see the source for copying conditions.  There is NO\n"
00131             << "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE\n";
00132 }
00133 
00134 /* EOF */
00135   

Generated on Thu Jul 24 10:24:29 2003 for Construo by doxygen1.3-rc3