本文整理汇总了C++中ArgumentList::End方法的典型用法代码示例。如果您正苦于以下问题:C++ ArgumentList::End方法的具体用法?C++ ArgumentList::End怎么用?C++ ArgumentList::End使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArgumentList
的用法示例。
在下文中一共展示了ArgumentList::End方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ProcessCommandLine
int FITSHeaderProcess::ProcessCommandLine( const StringList& argv ) const
{
ArgumentList arguments =
ExtractArguments( argv, ArgumentItemMode::AsViews,
ArgumentOption::AllowWildcards|ArgumentOption::NoPreviews );
FITSHeaderInstance instance( this );
bool launchInterface = false;
int count = 0;
for ( ArgumentList::const_iterator i = arguments.Begin(); i != arguments.End(); ++i )
{
const Argument& arg = *i;
if ( arg.IsNumeric() )
throw Error( "Unknown numeric argument: " + arg.Token() );
else if ( arg.IsString() )
throw Error( "Unknown string argument: " + arg.Token() );
else if ( arg.IsSwitch() )
throw Error( "Unknown switch argument: " + arg.Token() );
else if ( arg.IsLiteral() )
throw Error( "Unknown argument: " + arg.Token() );
else if ( arg.IsItemList() )
{
++count;
if ( arg.Items().IsEmpty() )
{
Console().WriteLn( "No view(s) found: " + arg.Token() );
continue;
}
for ( StringList::const_iterator j = arg.Items().Begin(); j != arg.Items().End(); ++j )
{
View v = View::ViewById( *j );
if ( v.IsNull() )
throw Error( "No such view: " + *j );
instance.LaunchOn( v );
}
}
}
if ( launchInterface )
instance.LaunchInterface();
else if ( count == 0 )
{
if ( ImageWindow::ActiveWindow().IsNull() )
throw Error( "There is no active image window." );
instance.LaunchOnCurrentWindow();
}
return 0;
}
示例2: ProcessCommandLine
int PreferencesProcess::ProcessCommandLine( const StringList& argv ) const
{
ArgumentList arguments = ExtractArguments( argv, ArgumentItemMode::NoItems );
PreferencesInstance instance( this );
bool launchInterface = false;
for ( ArgumentList::const_iterator i = arguments.Begin(); i != arguments.End(); ++i )
{
const Argument& arg = *i;
if ( arg.IsNumeric() )
{
throw Error( "Unknown numeric argument: " + arg.Token() );
}
else if ( arg.IsString() )
{
throw Error( "Unknown string argument: " + arg.Token() );
}
else if ( arg.IsSwitch() )
{
throw Error( "Unknown switch argument: " + arg.Token() );
}
else if ( arg.IsLiteral() )
{
if ( arg.Id() == "-interface" )
launchInterface = true;
else if ( arg.Id() == "-help" )
{
ShowHelp();
return 0;
}
else
throw Error( "Unknown argument: " + arg.Token() );
}
else if ( arg.IsItemList() )
throw Error( "Invalid non-parametric argument: " + arg.Token() );
}
if ( launchInterface || arguments.IsEmpty() )
instance.LaunchInterface();
else
instance.LaunchGlobal();
return 0;
}
示例3: ProcessCommandLine
int MaskedStretchProcess::ProcessCommandLine( const StringList& argv ) const
{
ArgumentList arguments =
ExtractArguments( argv, ArgumentItemMode::AsViews, ArgumentOption::AllowWildcards );
MaskedStretchInstance instance( this );
bool launchInterface = false;
int count = 0;
for ( ArgumentList::const_iterator i = arguments.Begin(); i != arguments.End(); ++i )
{
const Argument& arg = *i;
if ( arg.IsNumeric() )
{
if ( arg.Id() == "b" || arg.Id() == "-background" )
{
double b = arg.NumericValue();
if ( b < TheMSTargetBackgroundParameter->MinimumValue() ||
b > TheMSTargetBackgroundParameter->MaximumValue() )
throw Error( "Target background parameter out of range" );
instance.p_targetBackground = b;
}
else if ( arg.Id() == "n" || arg.Id() == "-iterations" )
{
int n = TruncInt( arg.NumericValue() );
if ( n < int( TheMSNumberOfIterationsParameter->MinimumValue() ) ||
n > int( TheMSNumberOfIterationsParameter->MaximumValue() ) )
throw Error( "Number of iterations parameter out of range" );
instance.p_numberOfIterations = n;
}
else
throw Error( "Unknown numeric argument: " + arg.Token() );
}
else if ( arg.IsString() )
{
if ( arg.Id() == "m" || arg.Id() == "-mask-type" )
{
if ( arg.StringValue() == "I" || arg.StringValue() == "intensity" )
instance.p_maskType = MSMaskType::Intensity;
else if ( arg.StringValue() == "V" || arg.StringValue() == "value" )
instance.p_maskType = MSMaskType::Value;
}
else
throw Error( "Unknown string argument: " + arg.Token() );
}
else if ( arg.IsSwitch() )
{
throw Error( "Unknown switch argument: " + arg.Token() );
}
else if ( arg.IsLiteral() )
{
if ( arg.Id() == "-interface" )
launchInterface = true;
else if ( arg.Id() == "-help" )
{
ShowHelp();
return 0;
}
else
throw Error( "Unknown argument: " + arg.Token() );
}
else if ( arg.IsItemList() )
{
++count;
if ( arg.Items().IsEmpty() )
{
Console().WriteLn( "No view(s) found: " + arg.Token() );
continue;
}
for ( StringList::const_iterator j = arg.Items().Begin(); j != arg.Items().End(); ++j )
{
View v = View::ViewById( *j );
if ( v.IsNull() )
throw Error( "No such view: " + *j );
instance.LaunchOn( v );
}
}
}
if ( launchInterface )
instance.LaunchInterface();
else if ( count == 0 )
{
if ( ImageWindow::ActiveWindow().IsNull() )
throw Error( "There is no active image window." );
instance.LaunchOnCurrentView();
}
return 0;
}
示例4: Error
PixInsightX11Installer::PixInsightX11Installer( int argc, const char** argv )
{
// Install PixInsight by default.
m_task = InstallTask;
// Assume that we get a path to the executable file (possibly a relative
// path) in argv[0]. This is standard in all known unices.
m_executablePath = Unquoted( String::UTF8ToUTF16( argv[0] ) ).Trimmed();
// Base directory where we are running.
m_baseDir = File::FullPath( File::ExtractDirectory( m_executablePath ) );
if ( m_baseDir.EndsWith( '/' ) )
m_baseDir.Delete( m_baseDir.UpperBound() );
// Default source installation directory.
m_sourceDir = m_baseDir + "/PixInsight";
// Default application installation directory.
m_installDir = "/opt/PixInsight";
// Default desktop entry installation directory.
m_installDesktopDir = "/usr/share/applications";
if ( !File::DirectoryExists( m_installDesktopDir ) )
m_installDesktopDir = "/usr/local/share/applications"; // FreeBSD
// Default application icons installation directory.
m_installIconsDir = "/usr/share/icons/hicolor";
if ( !File::DirectoryExists( m_installIconsDir ) )
m_installIconsDir = "/usr/local/share/icons/hicolor"; // FreeBSD
// By default, we create a launcher script on /bin so one can say just
// PixInsight from a terminal.
m_createBinLauncher = true;
// By default, we do not backup a previous installation.
m_removePrevious = true;
// Assume we are running on an UTF-8 POSIX-compliant system.
StringList inputArgs;
for ( int i = 1; i < argc; ++i )
inputArgs.Add( IsoString( argv[i] ).UTF8ToUTF16() );
// Parse the list of command-line arguments.
ArgumentList arguments = ExtractArguments( inputArgs, ArgumentItemMode::NoItems );
// Iterate and interpret command-line arguments.
for ( ArgumentList::const_iterator i = arguments.Begin(); i != arguments.End(); ++i )
{
if ( i->IsNumeric() )
{
throw Error( "Unknown numeric argument: " + i->Token() );
}
else if ( i->IsString() )
{
if ( i->Id() == "-source-dir" || i->Id() == "s" )
m_sourceDir = i->StringValue();
else if ( i->Id() == "-install-dir" || i->Id() == "i" )
m_installDir = i->StringValue();
else if ( i->Id() == "-install-desktop-dir" )
m_installDesktopDir = i->StringValue();
else if ( i->Id() == "-install-icons-dir" )
m_installIconsDir = i->StringValue();
else
throw Error( "Unknown string argument: " + i->Token() );
}
else if ( i->IsSwitch() )
{
if ( i->Id() == "-remove" || i->Id() == "r" )
m_removePrevious = i->SwitchState();
else if ( i->Id() == "-bin-launcher" )
m_createBinLauncher = i->SwitchState();
else
throw Error( "Unknown switch argument: " + i->Token() );
}
else if ( i->IsLiteral() )
{
if ( i->Id() == "-remove" || i->Id() == "r" )
m_removePrevious = true;
else if ( i->Id() == "-no-remove" || i->Id() == "r" ) // also support the --no-xxx idiom
m_removePrevious = false;
else if ( i->Id() == "-bin-launcher" )
m_createBinLauncher = true;
else if ( i->Id() == "-no-bin-launcher" )
m_createBinLauncher = false;
else if ( i->Id() == "-uninstall" || i->Id() == "u" )
m_task = UninstallTask;
else if ( i->Id() == "-version" )
m_task = ShowVersionTask;
else if ( i->Id() == "-help" )
m_task = ShowHelpTask;
else
throw Error( "Unknown argument: " + i->Token() );
}
else if ( i->IsItemList() )
{
throw Error( "Unexpected non-parametric argument: " + i->Token() );
}
}
// Sanitize working directories.
//.........这里部分代码省略.........
示例5: ProcessCommandLine
int ColorManagementSetupProcess::ProcessCommandLine( const StringList& argv ) const
{
ArgumentList arguments = ExtractArguments( argv, ArgumentItemMode::NoItems );
ColorManagementSetupInstance instance( this );
bool launchInterface = false;
for ( ArgumentList::const_iterator i = arguments.Begin(); i != arguments.End(); ++i )
{
const Argument& arg = *i;
if ( arg.IsNumeric() )
{
throw Error( "Unknown numeric argument: " + arg.Token() );
}
else if ( arg.IsString() )
{
if ( arg.Id() == "rgb-profile" )
{
instance.defaultRGBProfile = arg.StringValue();
instance.defaultRGBProfile.Trim();
if ( instance.defaultRGBProfile.IsEmpty() )
throw Error( "Empty RGB profile: " + arg.Token() );
}
else if ( arg.Id() == "grayscale-profile" )
{
instance.defaultGrayProfile = arg.StringValue();
instance.defaultGrayProfile.Trim();
if ( instance.defaultGrayProfile.IsEmpty() )
throw Error( "Empty grayscale profile: " + arg.Token() );
}
else if ( arg.Id() == "proofing-profile" )
{
instance.proofingProfile = arg.StringValue();
instance.proofingProfile.Trim();
if ( instance.proofingProfile.IsEmpty() )
throw Error( "Empty proofing profile: " + arg.Token() );
}
else if ( arg.Id() == "rendering-intent" || arg.Id() == "proofing-intent" )
{
pcl_enum intent;
if ( arg.StringValue() == "perceptual" )
intent = CMSDefaultRenderingIntent::Perceptual;
else if ( arg.StringValue() == "saturation" )
intent = CMSDefaultRenderingIntent::Saturation;
else if ( arg.StringValue() == "relative" || arg.StringValue() == "relativeColorimetric" )
intent = CMSDefaultRenderingIntent::RelativeColorimetric;
else if ( arg.StringValue() == "absolute" || arg.StringValue() == "absoluteColorimetric" )
intent = CMSDefaultRenderingIntent::AbsoluteColorimetric;
else
throw Error( "Invalid rendering intent: " + arg.Token() );
if ( arg.Id() == "rendering-intent" )
instance.defaultRenderingIntent = intent;
else
instance.proofingIntent = intent;
}
else if ( arg.Id() == "on-profile-mismatch" )
{
if ( arg.StringValue() == "ask" )
instance.onProfileMismatch = CMSOnProfileMismatch::AskUser;
else if ( arg.StringValue() == "keep" )
instance.onProfileMismatch = CMSOnProfileMismatch::KeepEmbedded;
else if ( arg.StringValue() == "convert" )
instance.onProfileMismatch = CMSOnProfileMismatch::ConvertToDefault;
else if ( arg.StringValue() == "discard" )
instance.onProfileMismatch = CMSOnProfileMismatch::DiscardEmbedded;
else if ( arg.StringValue() == "disable" )
instance.onProfileMismatch = CMSOnProfileMismatch::DisableCM;
else
throw Error( "Invalid profile mismatch policy: " + arg.Token() );
}
else if ( arg.Id() == "on-missing-profile" )
{
if ( arg.StringValue() == "ask" )
instance.onMissingProfile = CMSOnMissingProfile::AskUser;
else if ( arg.StringValue() == "default" )
instance.onMissingProfile = CMSOnMissingProfile::AssignDefault;
else if ( arg.StringValue() == "ignore" )
instance.onMissingProfile = CMSOnMissingProfile::LeaveUntagged;
else if ( arg.StringValue() == "disable" )
instance.onMissingProfile = CMSOnMissingProfile::DisableCM;
else
throw Error( "Invalid missing profile policy: " + arg.Token() );
}
else if ( arg.Id() == "gamut-warning-color" )
{
instance.gamutWarningColor = RGBAColor( arg.StringValue() );
}
else
throw Error( "Unknown string argument: " + arg.Token() );
}
else if ( arg.IsSwitch() )
{
if ( arg.Id() == "embed-rgb" )
instance.defaultEmbedProfilesInRGBImages = arg.SwitchState();
else if ( arg.Id() == "embed-grayscale" )
instance.defaultEmbedProfilesInGrayscaleImages = arg.SwitchState();
else if ( arg.Id() == "proofing-bpc" )
instance.useProofingBPC = arg.SwitchState();
//.........这里部分代码省略.........
示例6: ProcessCommandLine
int ReadoutOptionsProcess::ProcessCommandLine( const StringList& argv ) const
{
ArgumentList arguments = ExtractArguments( argv, ArgumentItemMode::NoItems );
ReadoutOptions options;
bool launchInterface = false;
for ( ArgumentList::const_iterator i = arguments.Begin(); i != arguments.End(); ++i )
{
const Argument& arg = *i;
if ( arg.IsNumeric() )
{
if ( arg.Id() == "s" || arg.Id() == "size" )
{
int sz = int( arg.NumericValue() );
if ( (sz & 1) == 0 || sz < 1 || sz > ReadoutOptions::MaxProbeSize )
throw Error( "Invalid readout probe size: " + arg.Token() );
options.SetProbeSize( sz );
}
else if ( arg.Id() == "ps" || arg.Id() == "preview-size" )
{
int sz = int( arg.NumericValue() );
if ( (sz & 1) == 0 || sz < ReadoutOptions::MinPreviewSize || sz > ReadoutOptions::MaxPreviewSize )
throw Error( "Invalid readout preview size: " + arg.Token() );
options.SetPreviewSize( sz );
}
else if ( arg.Id() == "pz" || arg.Id() == "preview-zoom" )
{
int sz = int( arg.NumericValue() );
if ( sz < 1 || sz > ReadoutOptions::MaxPreviewZoomFactor )
throw Error( "Invalid readout preview zoom factor: " + arg.Token() );
options.SetPreviewZoomFactor( sz );
}
else if ( arg.Id() == "r" || arg.Id() == "real" )
{
options.SetReal();
int n = int( arg.NumericValue() );
if ( n < 0 || n > ReadoutOptions::MaxPrecision )
throw Error( "Invalid readout real precision: " + arg.Token() );
options.SetPrecision( n );
}
else if ( arg.Id() == "i" || arg.Id() == "integer" )
{
options.SetInteger();
double n = arg.NumericValue();
if ( n < 1 || n > uint32_max )
throw Error( "Invalid integer readout range: " + arg.Token() );
options.SetIntegerRange( unsigned( n ) );
}
else
throw Error( "Unknown numeric argument: " + arg.Token() );
}
else if ( arg.IsString() )
throw Error( "Unknown string argument: " + arg.Token() );
else if ( arg.IsSwitch() )
{
if ( arg.Id() == "alpha" )
options.EnableAlphaChannel( arg.SwitchState() );
else if ( arg.Id() == "mask" )
options.EnableMaskChannel( arg.SwitchState() );
else if ( arg.Id() == "preview" )
options.EnablePreview( arg.SwitchState() );
else if ( arg.Id() == "preview-center" )
options.EnablePreviewCenter( arg.SwitchState() );
else if ( arg.Id() == "broadcast" )
options.EnableBroadcast( arg.SwitchState() );
else
throw Error( "Unknown switch argument: " + arg.Token() );
}
else if ( arg.IsLiteral() )
{
if ( arg.Id() == "m" || arg.Id() == "mean" )
options.SetMode( ReadoutMode::Mean );
else if ( arg.Id() == "n" || arg.Id() == "median" )
options.SetMode( ReadoutMode::Median );
else if ( arg.Id() == "M" || arg.Id() == "max" || arg.Id() == "maximum" )
options.SetMode( ReadoutMode::Maximum );
else if ( arg.Id() == "N" || arg.Id() == "min" || arg.Id() == "minimum" )
options.SetMode( ReadoutMode::Minimum );
else if ( arg.Id() == "rgb" || arg.Id() == "RGB" )
options.SetData( ReadoutData::RGBK );
else if ( arg.Id() == "rgbl" || arg.Id() == "RGBL" )
options.SetData( ReadoutData::RGBL );
else if ( arg.Id() == "rgby" || arg.Id() == "RGBY" )
options.SetData( ReadoutData::RGBY );
else if ( arg.Id() == "xyz" || arg.Id() == "XYZ" )
options.SetData( ReadoutData::CIEXYZ );
else if ( arg.Id() == "lab" || arg.Id() == "Lab" )
options.SetData( ReadoutData::CIELab );
else if ( arg.Id() == "lch" || arg.Id() == "Lch" )
options.SetData( ReadoutData::CIELch );
else if ( arg.Id() == "hsv" || arg.Id() == "HSV" )
options.SetData( ReadoutData::HSV );
else if ( arg.Id() == "hsi" || arg.Id() == "HSI" || arg.Id() == "HSL" )
options.SetData( ReadoutData::HSI );
else if ( arg.Id() == "i8" )
{
options.SetInteger();
options.SetIntegerRange( 255 );
//.........这里部分代码省略.........
示例7: ProcessCommandLine
int FluxCalibrationProcess::ProcessCommandLine( const StringList& argv ) const
{
ArgumentList arguments =
ExtractArguments( argv, ArgumentItemMode::AsViews, ArgumentOption::AllowWildcards );
FluxCalibrationInstance instance( this );
bool launchInterface = false;
int count = 0;
for ( ArgumentList::const_iterator i = arguments.Begin(); i != arguments.End(); ++i )
{
const Argument& arg = *i;
if ( arg.IsNumeric() )
{
if ( arg.Id() == "l" || arg.Id() == "-wavelength" )
instance.p_wavelength = arg.NumericValue();
else if ( arg.Id() == "tr" || arg.Id() == "-transmissivity" )
instance.p_transmissivity = arg.NumericValue();
else if ( arg.Id() == "w" || arg.Id() == "-filter-width" )
instance.p_filterWidth = arg.NumericValue();
else if ( arg.Id() == "a" || arg.Id() == "-aperture" )
instance.p_aperture = arg.NumericValue();
else if ( arg.Id() == "o" || arg.Id() == "-central-obstruction" )
instance.p_centralObstruction = arg.NumericValue();
else if ( arg.Id() == "t" || arg.Id() == "-exposure-time" )
instance.p_exposureTime = arg.NumericValue();
else if ( arg.Id() == "e" || arg.Id() == "-atmospheric-extinction" )
instance.p_atmosphericExtinction = arg.NumericValue();
else if ( arg.Id() == "G" || arg.Id() == "-sensor-gain" )
instance.p_sensorGain = arg.NumericValue();
else if ( arg.Id() == "qe" || arg.Id() == "-quantum-efficiency" )
instance.p_quantumEfficiency = arg.NumericValue();
else
throw Error( "Unknown numeric argument: " + arg.Token() );
}
else if ( arg.IsString() )
{
throw Error( "Unknown string argument: " + arg.Token() );
}
else if ( arg.IsSwitch() )
{
throw Error( "Unknown switch argument: " + arg.Token() );
}
else if ( arg.IsLiteral() )
{
// These are standard parameters that all processes should provide.
if ( arg.Id() == "-interface" )
launchInterface = true;
else if ( arg.Id() == "-help" )
{
ShowHelp();
return 0;
}
else
throw Error( "Unknown argument: " + arg.Token() );
}
else if ( arg.IsItemList() )
{
++count;
if ( arg.Items().IsEmpty() )
{
Console().WriteLn( "No view(s) found: " + arg.Token() );
throw;
}
for ( StringList::const_iterator j = arg.Items().Begin(); j != arg.Items().End(); ++j )
{
View v = View::ViewById( *j );
if ( v.IsNull() )
throw Error( "No such view: " + *j );
instance.LaunchOn( v );
}
}
}
if ( launchInterface )
instance.LaunchInterface();
else if ( count == 0 )
{
if ( ImageWindow::ActiveWindow().IsNull() )
throw Error( "There is no active image window." );
instance.LaunchOnCurrentView();
}
return 0;
}
示例8: ProcessCommandLine
int BinarizeProcess::ProcessCommandLine( const StringList& argv ) const
{
ArgumentList arguments =
ExtractArguments( argv, ArgumentItemMode::AsViews, ArgumentOption::AllowWildcards );
BinarizeInstance instance( this );
bool launchInterface = false;
int count = 0;
for ( ArgumentList::const_iterator i = arguments.Begin(); i != arguments.End(); ++i )
{
const Argument& arg = *i;
if ( arg.IsNumeric() )
{
if ( arg.Id() == "t" || arg.Id() == "threshold" )
{
instance.level[0] = instance.level[1] = instance.level[2] = ArgumentThresholdValue( arg );
instance.isGlobal = true;
}
else if ( arg.Id() == "tR" || arg.Id() == "thresholdR" )
{
instance.level[0] = ArgumentThresholdValue( arg );
instance.isGlobal = false;
}
else if ( arg.Id() == "tG" || arg.Id() == "thresholdG" )
{
instance.level[1] = ArgumentThresholdValue( arg );
instance.isGlobal = false;
}
else if ( arg.Id() == "tB" || arg.Id() == "thresholdB" )
{
instance.level[2] = ArgumentThresholdValue( arg );
instance.isGlobal = false;
}
else
throw Error( "Unknown numeric argument: " + arg.Token() );
}
else if ( arg.IsString() )
throw Error( "Unknown string argument: " + arg.Token() );
else if ( arg.IsSwitch() )
throw Error( "Unknown switch argument: " + arg.Token() );
else if ( arg.IsLiteral() )
{
if ( arg.Id() == "-interface" )
launchInterface = true;
else if ( arg.Id() == "-help" )
{
ShowHelp();
return 0;
}
else
throw Error( "Unknown argument: " + arg.Token() );
}
else if ( arg.IsItemList() )
{
++count;
if ( arg.Items().IsEmpty() )
{
Console().WriteLn( "No view(s) found: " + arg.Token() );
continue;
}
for ( StringList::const_iterator j = arg.Items().Begin(); j != arg.Items().End(); ++j )
{
View v = View::ViewById( *j );
if ( v.IsNull() )
throw Error( "No such view: " + *j );
instance.LaunchOn( v );
}
}
}
if ( launchInterface )
instance.LaunchInterface();
else if ( count == 0 )
{
if ( ImageWindow::ActiveWindow().IsNull() )
throw Error( "There is no active image window." );
instance.LaunchOnCurrentView();
}
return 0;
}
示例9: instance
int B3EProcess::ProcessCommandLine( const StringList& argv ) const
{
ArgumentList arguments =
ExtractArguments( argv, ArgumentItemMode::AsViews, ArgumentOption::AllowWildcards );
B3EInstance instance( this );
bool launchInterface = false;
int count = 0;
for ( ArgumentList::const_iterator i = arguments.Begin(); i != arguments.End(); ++i )
{
const Argument& arg = *i;
if ( arg.IsNumeric() )
{
throw Error( "Unknown numeric argument: " + arg.Token() );
}
else if ( arg.IsString() )
{
throw Error( "Unknown string argument: " + arg.Token() );
}
else if ( arg.IsSwitch() )
{
throw Error( "Unknown switch argument: " + arg.Token() );
}
else if ( arg.IsLiteral() )
{
// These are standard parameters that all processes should provide.
if ( arg.Id() == "-interface" )
launchInterface = true;
else if ( arg.Id() == "-help" )
{
ShowHelp();
return 0;
}
else
throw Error( "Unknown argument: " + arg.Token() );
}
else if ( arg.IsItemList() )
{
++count;
if ( arg.Items().IsEmpty() )
{
Console().WriteLn( "No view(s) found: " + arg.Token() );
throw;
}
for ( StringList::const_iterator j = arg.Items().Begin(); j != arg.Items().End(); ++j )
{
View v = View::ViewById( *j );
if ( v.IsNull() )
throw Error( "No such view: " + *j );
instance.LaunchOn( v );
}
}
}
if ( launchInterface )
instance.LaunchInterface();
else if ( count == 0 )
{
if ( ImageWindow::ActiveWindow().IsNull() )
throw Error( "There is no active image window." );
instance.LaunchOnCurrentView();
}
return 0;
}
示例10: ProcessCommandLine
int LocalHistogramEqualizationProcess::ProcessCommandLine( const StringList& argv ) const
{
ArgumentList arguments =
ExtractArguments( argv, ArgumentItemMode::AsViews, ArgumentOption::AllowWildcards );
LocalHistogramEqualizationInstance instance( this );
bool launchInterface = false;
int count = 0;
for ( ArgumentList::const_iterator i = arguments.Begin(); i != arguments.End(); ++i )
{
const Argument& arg = *i;
if ( arg.IsNumeric() )
{
if (arg.Id() == "r" || arg.Id() == "-radius") instance.radius = (int)arg.NumericValue();
else if (arg.Id() == "l" || arg.Id() == "-limit") instance.slopeLimit = arg.NumericValue();
else if (arg.Id() == "a" || arg.Id() == "-amount") instance.amount = arg.NumericValue();
else if (arg.Id() == "h" || arg.Id() == "-hist")
{
int bins = (int)arg.NumericValue();
if (bins == 8) instance.histogramBins = LHEHistogramBins::Bit8;
else if (bins == 10) instance.histogramBins = LHEHistogramBins::Bit10;
else if (bins == 12) instance.histogramBins = LHEHistogramBins::Bit12;
else throw Error( "Invalid value for '-h' argument. Allowed values are 8, 10 or 12" );
}
else throw Error( "Unknown numeric argument: " + arg.Token() );
}
else if ( arg.IsString() )
{
throw Error( "Unknown string argument: " + arg.Token() );
}
else if ( arg.IsSwitch() )
{
if (arg.Id() == "c" || arg.Id() == "-circular") instance.circularKernel = arg.SwitchState();
else throw Error( "Unknown switch argument: " + arg.Token() );
}
else if ( arg.IsLiteral() )
{
if (arg.Id() == "c" || arg.Id() == "-circular") instance.circularKernel = true;
// These are standard parameters that all processes should provide.
else if ( arg.Id() == "-interface" )
launchInterface = true;
else if ( arg.Id() == "-help" )
{
ShowHelp();
return 0;
}
else
throw Error( "Unknown argument: " + arg.Token() );
}
else if ( arg.IsItemList() )
{
++count;
if ( arg.Items().IsEmpty() )
{
Console().WriteLn( "No view(s) found: " + arg.Token() );
throw;
}
for ( StringList::const_iterator j = arg.Items().Begin(); j != arg.Items().End(); ++j )
{
View v = View::ViewById( *j );
if ( v.IsNull() )
throw Error( "No such view: " + *j );
instance.LaunchOn( v );
}
}
}
if ( launchInterface )
instance.LaunchInterface();
else if ( count == 0 )
{
if ( ImageWindow::ActiveWindow().IsNull() )
throw Error( "There is no active image window." );
instance.LaunchOnCurrentView();
}
return 0;
}
示例11: ProcessCommandLine
int LinearFitProcess::ProcessCommandLine( const StringList& argv ) const
{
ArgumentList arguments =
ExtractArguments( argv, ArgumentItemMode::AsViews, ArgumentOption::AllowWildcards );
LinearFitInstance instance( this );
bool launchInterface = false;
int count = 0;
for ( ArgumentList::const_iterator i = arguments.Begin(); i != arguments.End(); ++i )
{
const Argument& arg = *i;
if ( arg.IsNumeric() )
{
if ( arg.Id() == "r0" || arg.Id() == "reject-low" )
{
CHECK_IN_NORM_RANGE;
instance.rejectLow = arg.NumericValue();
}
else if ( arg.Id() == "r1" || arg.Id() == "reject-high" )
{
CHECK_IN_NORM_RANGE;
instance.rejectHigh = arg.NumericValue();
}
else
throw Error( "Unknown numeric argument: " + arg.Token() );
}
else if ( arg.IsString() )
{
if ( arg.Id() == "v" || arg.Id() == "reference-view" )
instance.referenceViewId = arg.StringValue();
else
throw Error( "Unknown string argument: " + arg.Token() );
}
else if ( arg.IsSwitch() )
{
throw Error( "Unknown switch argument: " + arg.Token() );
}
else if ( arg.IsLiteral() )
{
if ( arg.Id() == "-interface" )
launchInterface = true;
else if ( arg.Id() == "-help" )
{
ShowHelp();
return 0;
}
else
throw Error( "Unknown argument: " + arg.Token() );
}
else if ( arg.IsItemList() )
{
++count;
if ( arg.Items().IsEmpty() )
{
Console().WriteLn( "No view(s) found: " + arg.Token() );
throw;
}
for ( StringList::const_iterator j = arg.Items().Begin(); j != arg.Items().End(); ++j )
{
View v = View::ViewById( *j );
if ( v.IsNull() )
throw Error( "No such view: " + *j );
if ( v.FullId() != IsoString( instance.referenceViewId ).Trimmed() )
instance.LaunchOn( v );
else
Console().WarningLn( "<end><cbr>** Skipping reference view: " + v.FullId() );
}
}
}
if ( launchInterface )
instance.LaunchInterface();
else if ( count == 0 )
{
if ( ImageWindow::ActiveWindow().IsNull() )
throw Error( "There is no active image window." );
instance.LaunchOnCurrentView();
}
return 0;
}
示例12: ProcessCommandLine
int AssignICCProfileProcess::ProcessCommandLine( const StringList& argv ) const
{
ArgumentList arguments =
ExtractArguments( argv,
ArgumentItemMode::AsViews,
ArgumentOption::AllowWildcards|ArgumentOption::NoPreviews );
AssignICCProfileInstance instance( this );
bool launchInterface = false;
int count = 0;
for ( ArgumentList::const_iterator i = arguments.Begin(); i != arguments.End(); ++i )
{
const Argument& arg = *i;
if ( arg.IsNumeric() )
throw Error( "Unknown numeric argument: " + arg.Token() );
else if ( arg.IsString() )
{
if ( arg.Id() == "profile" )
{
instance.targetProfile = arg.StringValue();
instance.targetProfile.Trim();
if ( instance.targetProfile.IsEmpty() )
throw Error( "Empty profile identifier: " + arg.Token() );
}
else if ( arg.Id() == "filename" )
{
String filename = arg.StringValue();
filename.Trim();
if ( filename.IsEmpty() )
throw Error( "Empty file name: " + arg.Token() );
instance.targetProfile.Clear();
StringList dirs = ICCProfile::ProfileDirectories();
for ( StringList::const_iterator i = dirs.Begin(); i != dirs.End(); ++i )
{
String path = *i + '/' + filename;
if ( File::Exists( path ) )
{
ICCProfile icc( path );
if ( icc.IsProfile() )
{
instance.targetProfile = icc.Description();
break;
}
}
}
if ( instance.targetProfile.IsEmpty() )
throw Error( "The specified file name does not correspond to a valid ICC profile: " + filename );
}
else
throw Error( "Unknown string argument: " + arg.Token() );
}
else if ( arg.IsSwitch() )
{
if ( arg.Id() == "default" )
instance.mode = arg.SwitchState() ? AssignMode::AssignDefaultProfile : AssignMode::AssignNewProfile;
else if ( arg.Id() == "untag" )
instance.mode = arg.SwitchState() ? AssignMode::LeaveUntagged : AssignMode::AssignNewProfile;
else
throw Error( "Unknown switch argument: " + arg.Token() );
}
else if ( arg.IsLiteral() )
{
if ( arg.Id() == "default" )
instance.mode = AssignMode::AssignDefaultProfile;
else if ( arg.Id() == "untag" )
instance.mode = AssignMode::LeaveUntagged;
else if ( arg.Id() == "-interface" )
launchInterface = true;
else if ( arg.Id() == "-help" )
{
ShowHelp();
return 0;
}
else
throw Error( "Unknown argument: " + arg.Token() );
}
else if ( arg.IsItemList() )
{
++count;
if ( arg.Items().IsEmpty() )
{
Console().WriteLn( "No view(s) found: " + arg.Token() );
continue;
}
for ( StringList::const_iterator j = arg.Items().Begin(); j != arg.Items().End(); ++j )
{
View v = View::ViewById( *j );
if ( v.IsNull() )
throw Error( "No such view: " + *j );
instance.LaunchOn( v );
}
}
//.........这里部分代码省略.........
示例13: ProcessCommandLine
int ICCProfileTransformationProcess::ProcessCommandLine( const StringList& argv ) const
{
ArgumentList arguments =
ExtractArguments( argv,
ArgumentItemMode::AsViews,
ArgumentOption::AllowWildcards|ArgumentOption::NoPreviews );
ICCProfileTransformationInstance instance( this );
bool launchInterface = false;
int count = 0;
for ( ArgumentList::const_iterator i = arguments.Begin(); i != arguments.End(); ++i )
{
const Argument& arg = *i;
if ( arg.IsNumeric() )
{
throw Error( "Unknown numeric argument: " + arg.Token() );
}
else if ( arg.IsString() )
{
if ( arg.Id() == "profile" )
{
instance.targetProfile = arg.StringValue();
instance.targetProfile.Trim();
if ( instance.targetProfile.IsEmpty() )
throw Error( "Empty profile identifier: " + arg.Token() );
}
else if ( arg.Id() == "filename" )
{
String filename = arg.StringValue();
filename.Trim();
if ( filename.IsEmpty() )
throw Error( "Empty file name: " + arg.Token() );
instance.targetProfile.Clear();
StringList dirs = ICCProfile::ProfileDirectories();
for ( StringList::const_iterator i = dirs.Begin(); i != dirs.End(); ++i )
{
String path = *i + '/' + filename;
if ( File::Exists( path ) )
{
ICCProfile icc( path );
if ( icc.IsProfile() )
{
instance.targetProfile = icc.Description();
break;
}
}
}
if ( instance.targetProfile.IsEmpty() )
throw Error( "The specified file name does not correspond to a valid ICC profile: " + filename );
}
else if ( arg.Id() == "rendering-intent" )
{
if ( arg.StringValue() == "perceptual" )
instance.renderingIntent = ICCTRenderingIntent::Perceptual;
else if ( arg.StringValue() == "saturation" )
instance.renderingIntent = ICCTRenderingIntent::Saturation;
else if ( arg.StringValue() == "relative" || arg.StringValue() == "relative-colorimetric" )
instance.renderingIntent = ICCTRenderingIntent::RelativeColorimetric;
else if ( arg.StringValue() == "absolute" || arg.StringValue() == "absolute-colorimetric" )
instance.renderingIntent = ICCTRenderingIntent::AbsoluteColorimetric;
else
throw Error( "Invalid rendering intent: " + arg.Token() );
}
else
throw Error( "Unknown string argument: " + arg.Token() );
}
else if ( arg.IsSwitch() )
{
if ( arg.Id() == "to-default-profile" )
instance.toDefaultProfile = arg.SwitchState();
else if ( arg.Id() == "black-point-compensation" )
instance.useBlackPointCompensation = arg.SwitchState();
else if ( arg.Id() == "floating-point-transform" )
instance.useFloatingPointTransformation = arg.SwitchState();
else
throw Error( "Unknown switch argument: " + arg.Token() );
}
else if ( arg.IsLiteral() )
{
if ( arg.Id() == "to-default-profile" )
instance.toDefaultProfile = true;
else if ( arg.Id() == "black-point-compensation" )
instance.useBlackPointCompensation = true;
else if ( arg.Id() == "floating-point-transform" )
instance.useFloatingPointTransformation = true;
else if ( arg.Id() == "-interface" )
launchInterface = true;
else if ( arg.Id() == "-help" )
{
ShowHelp();
return 0;
}
else
throw Error( "Unknown argument: " + arg.Token() );
//.........这里部分代码省略.........