1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
|
/*=========================================================================
Program: Advanced Normalization Tools
Module: $RCSfile: antsCommandLineOption.cxx,v $
Language: C++
Date: $Date: 2009/01/22 22:48:30 $
Version: $Revision: 1.1 $
Copyright (c) ConsortiumOfANTS. All rights reserved.
See accompanying COPYING.txt or
http://sourceforge.net/projects/advants/files/ANTS/ANTSCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#include "antsCommandLineOption.h"
namespace itk
{
namespace ants
{
CommandLineOption
::CommandLineOption() : m_ShortName( '\0' ),
m_LongName( "" ),
m_Description( "" )
{
this->m_OptionFunctions.clear();
this->m_UsageOptions.clear();
}
void
CommandLineOption
::AddFunction( std::string functionString, char leftDelimiter, char rightDelimiter, unsigned int order )
{
OptionFunctionType::Pointer optionFunction = OptionFunctionType::New();
optionFunction->SetArgOrder( order );
std::string::size_type leftDelimiterPos = functionString.find( leftDelimiter );
std::string::size_type rightDelimiterPos = functionString.find( rightDelimiter );
if( leftDelimiterPos == std::string::npos ||
rightDelimiterPos == std::string::npos )
{
optionFunction->SetName( functionString );
this->m_OptionFunctions.push_front( optionFunction );
}
else
{
OptionFunctionType::ParameterStackType parameters;
optionFunction->SetName( functionString.substr( 0, leftDelimiterPos ) );
std::string::size_type leftPos = leftDelimiterPos;
std::string::size_type rightPos = functionString.find( ',', leftPos + 1 );
while( rightPos != std::string::npos )
{
parameters.push_back( functionString.substr( leftPos + 1, rightPos - leftPos - 1 ) );
leftPos = rightPos;
rightPos = functionString.find( ',', leftPos + 1 );
}
rightPos = rightDelimiterPos;
parameters.push_back( functionString.substr( leftPos + 1, rightPos - leftPos - 1 ) );
optionFunction->SetParameters( parameters );
this->m_OptionFunctions.push_front( optionFunction );
}
this->Modified();
}
void
CommandLineOption
::SetUsageOption( unsigned int i, std::string usage )
{
if( i >= this->m_UsageOptions.size() )
{
this->m_UsageOptions.resize( i + 1 );
}
this->m_UsageOptions[i] = usage;
this->Modified();
}
} // end namespace ants
} // end namespace itk
|