[Insight-users] Problem with MetaCommand function: SetOptionComplete()

Julien Jomier julien.jomier at kitware.com
Sat Nov 6 15:32:40 EDT 2010


Hi Subrahmanyam,

This is a bug. I just added a report to the bug tracker:

   http://itk.org/Bug/view.php?id=11413

If you want to fix it locally, you can add this line in metaCommand.cxx 
after the line 1825:

   completeString = "";

The issue is that the values are not initialized between tags.

Hope that helps,
Julien

On 06/11/2010 20:04, Subrahmanyam Gorthi wrote:
> Dear All,
>
> I am trying to read the command line arguments using "metaCommand.h"
> available in ITK.
> I am facing problem when I am trying to collect all the information till
> the next tag, using the function:
> void SetOptionComplete(METAIO_STL::string optionName, bool complete);
>
> Please find below a simple example-code that reproduces my problem:
>
> *The command line input is:*
> example.exe -a x1.mhd x2.mhd -o output.mhd -b y1.mhd y2.mhd
>
> *What I expected/wanted as the output from that program is:*
> Output file name: output.mhd
> First list names:  x1.mhd x2.mhd
> Second list names: y1.mhd y2.mhd
>
> *BUT, instead, the output that I got is:*
> Output file name: output.mhd
> First list names:  x1.mhd x2.mhd
> Second list names: x1.mhd x2.mhd y1.mhd y2.mhd
>
> Did I miss something?
> *Can you kindly tell me how I should modify the below code so that
> I could get my desired output, as mentioned above?*
>
> Thank you in advance for your help.
>
> Warm Regards,
> Subrahmanyam Gorthi.
>
> *Here is the code:*
>
> #include<iostream>
> #include <string>
> #include "metaCommand.h"
>
> int main( int argc, char *argv[] )
> {
>    MetaCommand command;
>
>    // Output-file-name
>    command.SetOption("OutputFile1", "o", true, "Output file name");
>    command.AddOptionField("OutputFile1", "fileName1",
> MetaCommand::STRING, true);
>
>    // Input list1
>    command.SetOption("InputList1", "a", true, "This is the first input
> list");
>    command.AddOptionField("InputList1", "list1", MetaCommand::STRING, true);
>    command.SetOptionComplete("InputList1", true);
>
>    // Input list2
>    command.SetOption("InputList2", "b", true, "This is the second input
> list");
>    command.AddOptionField("InputList2", "list2", MetaCommand::STRING, true);
>    command.SetOptionComplete("InputList2", true);
>
>    // Now, Parse the command line
>    if (!command.Parse(argc,argv))
>      {
>      exit( EXIT_FAILURE );
>      }
>
>    std::cout << "Output file name: " <<
> command.GetValueAsString("OutputFile1", "fileName1") << std::endl;
>    std::cout << "First list names: " <<
> command.GetValueAsString("InputList1", "list1") << std::endl;
>    std::cout << "Second list names: " <<
> command.GetValueAsString("InputList2", "list2") << std::endl;
>
>    return EXIT_SUCCESS;
> }
>
>
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.html
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users


More information about the Insight-users mailing list