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; }
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(); else if ( arg.Id() == "default-proofing" ) instance.defaultProofingEnabled = arg.SwitchState(); else if ( arg.Id() == "default-gamut-check" ) instance.defaultGamutCheckEnabled = arg.SwitchState(); else throw Error( "Unknown switch argument: " + arg.Token() ); } else if ( arg.IsLiteral() ) { if ( arg.Id() == "enable" ) instance.enabled = true; else if ( arg.Id() == "disable" ) instance.enabled = false; if ( arg.Id() == "embed-rgb" ) instance.defaultEmbedProfilesInRGBImages = true; else if ( arg.Id() == "embed-grayscale" ) instance.defaultEmbedProfilesInGrayscaleImages = true; else if ( arg.Id() == "-load" ) instance.LoadCurrentSettings(); 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() ) throw Error( "Invalid non-parametric argument: " + arg.Token() ); } if ( launchInterface || arguments.IsEmpty() ) instance.LaunchInterface(); else instance.LaunchGlobal(); return 0; }
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 ); } else if ( arg.Id() == "i10" ) { options.SetInteger(); options.SetIntegerRange( 1023 ); } else if ( arg.Id() == "i12" ) { options.SetInteger(); options.SetIntegerRange( 4095 ); } else if ( arg.Id() == "i14" ) { options.SetInteger(); options.SetIntegerRange( 16383 ); } else if ( arg.Id() == "i16" ) { options.SetInteger(); options.SetIntegerRange( 65535 ); } else if ( arg.Id() == "i32" ) { options.SetInteger(); options.SetIntegerRange( 4294967295ul ); } else if ( arg.Id() == "alpha" ) options.EnableAlphaChannel(); else if ( arg.Id() == "mask" ) options.EnableMaskChannel(); else if ( arg.Id() == "preview" ) options.EnablePreview(); else if ( arg.Id() == "preview-center" ) options.EnablePreviewCenter(); else if ( arg.Id() == "broadcast" ) options.EnableBroadcast(); else if ( arg.Id() == "-load" ) options = ReadoutOptions::GetCurrentOptions(); 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() ) throw Error( "Invalid non-parametric argument: " + arg.Token() ); } ReadoutOptionsInstance instance( this ); instance.SetOptions( options ); if ( launchInterface || arguments.IsEmpty() ) instance.LaunchInterface(); else instance.LaunchGlobal(); return 0; }