Ignore:
Timestamp:
24/08/10 11:53:16 (21 months ago)
Author:
Freddie Akeroyd
Message:

Adjust to work with new tclap. Refs #244

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/applications/NXconvert/nxconvert.cpp

    r1489 r1516  
    5858    // set up the command line  arguments 
    5959    CmdLine cmd("Convert a NeXus file between different on disk file formats.", 
    60                 ' ', NXCONVERT_VERSION); 
    61     UnlabeledValueArg<string> inFileArg("inputFile", "Name of the input file.", 
    62                                         EMPTY, "inputFile"); 
    63     cmd.add(inFileArg); 
    64     UnlabeledValueArg<string> outFileArg("outputFile", 
    65                                          "Name of the output file.", 
    66                                          EMPTY, "outputFile"); 
    67     cmd.add(outFileArg); 
     60                ' ', NXCONVERT_VERSION, false); 
    6861    SwitchArg xmlArg("x", "xml", "Output file in xml format", false); 
    69     SwitchArg hdf4Arg("4", "hdf4", "Output file in hdf4 format", false); 
    70     SwitchArg hdf5Arg("5", "hdf5", "Output file in hdf5 format", false); 
     62    vector<int> allowedHdf; 
     63    allowedHdf.push_back(4); 
     64    allowedHdf.push_back(5); 
     65    ValuesConstraint<int> allowedHdfC(allowedHdf); 
     66    ValueArg<int> hdfArg("h", "hdf", "Specify HDF version to write", false, 0, &allowedHdfC); 
    7167    SwitchArg defArg("d", "dfn", 
    7268                     "Output definition file used for validating NeXus files", 
     
    7874    allowedXml.push_back("keepws"); 
    7975    allowedXml.push_back("table"); 
     76    ValuesConstraint<string> allowedXmlC(allowedXml); 
    8077    ValueArg<string> xmlSpecialArg("o", "outputxml", 
    8178                                   "Special arguments for xml. keepws defines that the whitespace should be preserved. table specifies a format that is more easiliy imported into spreadsheet programs. Either option forces xml output", 
    82                                    false, "", allowedXml); 
     79                                   false, "", &allowedXmlC); 
    8380    vector<Arg*> outputformats; 
    84     outputformats.push_back(&hdf5Arg); 
     81    outputformats.push_back(&hdfArg); 
    8582    outputformats.push_back(&xmlArg); 
    86     outputformats.push_back(&hdf4Arg); 
    8783    outputformats.push_back(&defArg); 
    8884    outputformats.push_back(&defValueArg); 
     
    9086    cmd.xorAdd(outputformats); 
    9187 
     88    UnlabeledMultiArg<string> FileArgs("Files", "Name of input and output files.", 
     89                                        false, EMPTY); 
     90    cmd.add(FileArgs); 
    9291    // parse the arguments and configure converting the file 
    9392    cmd.parse(argc, argv); 
     
    108107        definition_name = defValueArg.getValue(); 
    109108    } 
    110     if (hdf4Arg.isSet()) { 
    111       nx_format = NX_HDF4; 
    112       nx_write_access |= NXACC_CREATE4; 
    113     } 
    114     if (hdf5Arg.isSet()) { 
    115       nx_format = NX_HDF5; 
    116       nx_write_access |= NXACC_CREATE5; 
     109    if (hdfArg.isSet()) { 
     110      int hdf_type = hdfArg.getValue(); 
     111      if (hdf_type == 4) { 
     112          nx_format = NX_HDF4; 
     113          nx_write_access |= NXACC_CREATE4; 
     114      } else if (hdf_type == 5) { 
     115          nx_format = NX_HDF5; 
     116          nx_write_access |= NXACC_CREATE5; 
     117      } 
    117118    } 
    118119    if (xmlSpecialArg.isSet()) { 
     
    128129      } 
    129130    } 
    130     string inFile(inFileArg.getValue()); 
    131     string outFile(outFileArg.getValue()); 
     131    vector<string> file_args = FileArgs.getValue(); 
     132    string inFile, outFile; 
     133    if (file_args.size() > 0) 
     134    { 
     135        inFile = file_args[0]; 
     136    } 
     137    if (file_args.size() > 1) 
     138    { 
     139        outFile = file_args[1]; 
     140    } 
    132141 
    133142    // do the actual conversion 
Note: See TracChangeset for help on using the changeset viewer.