Changeset 1630 for trunk/yat


Ignore:
Timestamp:
Nov 17, 2008, 11:11:32 PM (12 years ago)
Author:
Peter
Message:

re-using convert function and correcting docs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/yat/utility/OptionArg.h

    r1629 r1630  
    2727#include "CommandLine.h"
    2828#include "Exception.h"
     29#include "utility.h"
    2930
    3031#include <string>
     
    5253       \brief Constructor
    5354       
    54        \param cmd Commandline Option is associated with \param name
    55        string such as "help" for --help, "h" for -h or "h,help" for
    56        having both short and long option name \param desc string used
    57        in help display \param required If true option must be found in
    58        commandline or exception is thrown in validation \param arg
    59        string to be used in help output such as `TARGET' in
    60        `--target=TARGET'. See print3().
     55       \param cmd Commandline Option is associated with
     56       \param name string such as "help" for --help, "h" for -h or
     57       "h,help" for having both short and long option name
     58       \param desc string used in help display
     59       \param required If true option must be found in commandline or
     60       exception is thrown in validation
     61       \param arg string to be used in help output such as `TARGET' in
     62       `--target=TARGET'. See print3(). New in yat 0.5.
    6163    */
    6264    OptionArg(CommandLine& cmd, std::string name, std::string desc,
     
    125127    void assign(T1& lhs, std::string rhs )
    126128    {
    127       std::stringstream ss(rhs);
    128       ss >> lhs;
    129       bool fail = ss.fail();
    130       std::string str;
    131       ss >> str;
    132       if (fail || str.size()) {
     129      try {
     130        lhs = convert<T1>(rhs);
     131      }
     132      catch (std::runtime_error& e) {
    133133        std::stringstream sstr(rhs);
    134134        sstr << ": invalid argument";
Note: See TracChangeset for help on using the changeset viewer.