From d534a56d95bca7bdd812be024d9eacba4734e2b7 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Fri, 9 Nov 2012 17:20:11 +0000 Subject: Many changes: tabconv'd the C++ code, added a license, BSD, and docs. --- c++-libbu++/src/gatsc/main.cpp | 99 ++++++++++++++++++++++-------------------- 1 file changed, 53 insertions(+), 46 deletions(-) (limited to 'c++-libbu++/src/gatsc') diff --git a/c++-libbu++/src/gatsc/main.cpp b/c++-libbu++/src/gatsc/main.cpp index 2bac3fd..e07fe82 100644 --- a/c++-libbu++/src/gatsc/main.cpp +++ b/c++-libbu++/src/gatsc/main.cpp @@ -1,3 +1,10 @@ +/* + * Copyright (C) 2007-2012 Xagasoft, All rights reserved. + * + * This file is part of the libgats library and is released under the + * terms of the license contained in the file LICENSE. + */ + #include #include #include @@ -11,63 +18,63 @@ using namespace Bu; class Options : public OptParser { public: - Options( int argc, char *argv[] ) : - bCompile( true ) - { - addHelpBanner("Gats Compiler\nUsage: gatsc [options] [input]\n"); + Options( int argc, char *argv[] ) : + bCompile( true ) + { + addHelpBanner("Gats Compiler\nUsage: gatsc [options] [input]\n"); - addOption( sInput, 'i', "input", "Specify input file."); - addOption( sOutput, 'o', "output", "Specify output file."); + addOption( sInput, 'i', "input", "Specify input file."); + addOption( sOutput, 'o', "output", "Specify output file."); - addOption( bCompile, 'd', "decompile", - "Convert binary gats to text gats."); + addOption( bCompile, 'd', "decompile", + "Convert binary gats to text gats."); - addHelpOption('h', "help", "This Help"); + addHelpOption('h', "help", "This Help"); - setNonOption( slot( this, &Options::setInput ) ); + setNonOption( slot( this, &Options::setInput ) ); - setOverride("decompile", false ); + setOverride("decompile", false ); - parse( argc, argv ); - } + parse( argc, argv ); + } - int setInput( StrArray aParam ) - { - sInput = aParam[0]; - return 0; - } + int setInput( StrArray aParam ) + { + sInput = aParam[0]; + return 0; + } - bool bCompile; - String sInput; - String sOutput; + bool bCompile; + String sInput; + String sOutput; }; int main( int argc, char *argv[] ) { - Options opt( argc, argv ); - - if( opt.sInput.isEmpty() ) - { - sio << "You must specify an input." << sio.nl << sio.nl; - return 1; - } - - if( opt.sOutput.isEmpty() ) - { - opt.sOutput.set( opt.sInput.begin(), opt.sInput.find('.') ); - opt.sOutput += ".gats"; - } - - if( opt.bCompile ) - { - File fIn( opt.sInput, File::Read ); - File fOut( opt.sOutput, File::WriteNew ); - Gats::GatsStream gs( fOut ); - Gats::Object *pObj = Gats::Object::strToGats( fIn.readAll() ); - gs.writeObject( pObj ); - delete pObj; - } - - return 0; + Options opt( argc, argv ); + + if( opt.sInput.isEmpty() ) + { + sio << "You must specify an input." << sio.nl << sio.nl; + return 1; + } + + if( opt.sOutput.isEmpty() ) + { + opt.sOutput.set( opt.sInput.begin(), opt.sInput.find('.') ); + opt.sOutput += ".gats"; + } + + if( opt.bCompile ) + { + File fIn( opt.sInput, File::Read ); + File fOut( opt.sOutput, File::WriteNew ); + Gats::GatsStream gs( fOut ); + Gats::Object *pObj = Gats::Object::strToGats( fIn.readAll() ); + gs.writeObject( pObj ); + delete pObj; + } + + return 0; } -- cgit v1.2.3