Changeset 975


Ignore:
Timestamp:
Oct 17, 2007, 11:03:37 PM (16 years ago)
Author:
Peter
Message:

adding Option class for argument associated with a file, and fixed minor issues

Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/commandline_test.cc

    r965 r975  
    2424#include "yat/utility/CommandLine.h"
    2525#include "yat/utility/OptionArg.h"
     26#include "yat/utility/OptionFile.h"
    2627#include "yat/utility/OptionSwitch.h"
    2728
     
    6162  }
    6263
     64  CommandLine cmd;
     65  OptionFile file(cmd, "f,file", "description");
     66
    6367  if (!ok)
    6468    *error << "commandline test failed" << std::endl;
  • trunk/yat/utility/CommandLine.cc

    r972 r975  
    135135        }
    136136      }
    137       for_each(options_.begin(),options_.end(),std::mem_fun(&Option::validate));
     137      for_each(options_.begin(),options_.end(),
     138               std::mem_fun(&Option::validate));
    138139    }
    139140    catch (std::runtime_error& e){
    140141      std::stringstream ss;
    141       ss << program_name_ << ": " << e.what() << "\n" << try_help();
     142      ss << program_name_ << ": " << e.what();
    142143      throw std::runtime_error(ss.str());
    143144    }
  • trunk/yat/utility/Makefile.am

    r965 r975  
    2727libutility_la_SOURCES = \
    2828  Alignment.cc ColumnStream.cc CommandLine.cc FileUtil.cc kNNI.cc \
    29   matrix.cc NNI.cc Option.cc OptionSwitch.cc \
     29  matrix.cc NNI.cc Option.cc OptionFile.cc OptionSwitch.cc \
    3030  PCA.cc stl_utility.cc SVD.cc TypeInfo.cc utility.cc vector.cc WeNNI.cc
    3131
     
    3636  Exception.h FileUtil.h Iterator.h iterator_traits.h \
    3737  IteratorWeighted.h kNNI.h matrix.h NNI.h \
    38   Option.h OptionArg.h OptionSwitch.h \
     38  Option.h OptionArg.h OptionFile.h OptionSwitch.h \
    3939  PCA.h stl_utility.h SVD.h TypeInfo.h utility.h vector.h WeNNI.h \
    4040  yat_assert.h
  • trunk/yat/utility/Option.cc

    r974 r975  
    3939  {
    4040    if (flag.empty())
    41       throw std::runtime_error("Option: given flag is empty");
     41      throw std::runtime_error("yat: Option: given flag is empty");
    4242    if (flag.size()==1 || (flag.size()==2 && flag[1]==','))
    4343      short_name_ = flag[0];
  • trunk/yat/utility/OptionArg.h

    r965 r975  
    2929#include <stdexcept>
    3030#include <string>
     31#include <sstream>
    3132
    3233namespace theplu {
     
    6263       \return value
    6364    */
    64     T value(void) { return value_; }
     65    T value(void) const { return value_; }
    6566
    6667  private:
     
    116117    /**
    117118     */
    118     void do_validate(void) const {}
     119    virtual void do_validate(void) const {}
    119120
    120121  };
Note: See TracChangeset for help on using the changeset viewer.