cmtkCommandLineKeyToActionSingle.cxx

Go to the documentation of this file.
00001 /*
00002 //
00003 //  Copyright 1997-2009 Torsten Rohlfing
00004 //  Copyright 2004-2009 SRI International
00005 //
00006 //  This file is part of the Computational Morphometry Toolkit.
00007 //
00008 //  http://www.nitrc.org/projects/cmtk/
00009 //
00010 //  The Computational Morphometry Toolkit is free software: you can
00011 //  redistribute it and/or modify it under the terms of the GNU General Public
00012 //  License as published by the Free Software Foundation, either version 3 of
00013 //  the License, or (at your option) any later version.
00014 //
00015 //  The Computational Morphometry Toolkit is distributed in the hope that it
00016 //  will be useful, but WITHOUT ANY WARRANTY; without even the implied
00017 //  warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 //  GNU General Public License for more details.
00019 //
00020 //  You should have received a copy of the GNU General Public License along
00021 //  with the Computational Morphometry Toolkit.  If not, see
00022 //  <http://www.gnu.org/licenses/>.
00023 //
00024 //  $Revision: 2022 $
00025 //
00026 //  $LastChangedDate: 2010-07-21 15:26:03 -0700 (Wed, 21 Jul 2010) $
00027 //
00028 //  $LastChangedBy: torstenrohlfing $
00029 //
00030 */
00031 
00032 #include "cmtkCommandLine.h"
00033 
00034 mxml_node_t*
00035 cmtk::CommandLine::KeyToActionSingle
00036 ::MakeXML( mxml_node_t *const parent ) const
00037 {
00038   if ( ! (this->m_Properties & PROPS_NOXML) )
00039     {
00040     return this->Superclass::MakeXML( this->m_Action->MakeXML( parent ) );
00041     }
00042   return NULL;
00043 }
00044 
00045 void
00046 cmtk::CommandLine::KeyToActionSingle
00047 ::PrintHelp( const size_t globalIndent ) const
00048 {
00049   std::ostringstream fmt;
00050   this->Superclass::FormatHelp( fmt );
00051 
00052   this->m_Action->PrintHelp( fmt );
00053   StdErr.FormatText( fmt.str(), CommandLine::HelpTextIndent + globalIndent, StdErr.GetLineWidth(), -CommandLine::HelpTextIndent ) << "\n";  
00054 }
00055 
00056 void
00057 cmtk::CommandLine::KeyToActionSingle
00058 ::PrintWikiWithPrefix( const std::string& prefix ) const
00059 {
00060   this->Superclass::PrintWikiWithPrefix( prefix );
00061   
00062   this->m_Action->PrintWiki();
00063   StdOut << "\n";
00064 }
00065 
00066 bool
00067 cmtk::CommandLine::KeyToActionSingle
00068 ::MatchAndExecute( const std::string& key, const size_t argc, const char* argv[], size_t& index )
00069 {
00070   if ( this->MatchLongOption( std::string( key ) ) )
00071     {
00072     this->m_Action->Evaluate( argc, argv, index );
00073     return true;
00074     }
00075   return false;
00076 }
00077 
00078 bool
00079 cmtk::CommandLine::KeyToActionSingle
00080 ::MatchAndExecute( const char keyChar, const size_t argc, const char* argv[], size_t& index )
00081 {
00082   if ( this->m_Key.m_KeyChar == keyChar )
00083     {
00084     this->m_Action->Evaluate( argc, argv, index );
00085     return true;
00086     }
00087 
00088   return false;
00089 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines