bethyw.cpp
/*
 *TODO::
  Parse the years command line argument. Years is either a four digit year 
  value, or two four digit year values separated by a hyphen (i.e. either 
  YYYY or YYYY-ZZZZ).

  This should be parsed as two integers and inserted into a std::tuple,
  representing the start and end year (inclusive). If one or both values are 0,
  then there is no filter to be applied. If no year argument is given return
  <0,0> (i.e. to import all years). You will have to search
  the web for how to construct std::tuple objects! 

  @param args
    Parsed program arguments

  @return
    A std::tuple containing two unsigned ints


  @throws
    std::invalid_argument if the argument contains an invalid years value with
    the message: Invalid input for years argument
*/
:
Parse the years command line argument. Years is either a four digit year
value, or two four digit year values separated by a hyphen .

This should be parsed as two integers and inserted into a std::tuple,
representing the start and end year (inclusive). If one or both values are 0,
then there is no filter to be applied. If no year argument is given return
<0,0> . You will have to search
the web for how to construct std::tuple objects!

@param args
Parsed program arguments

@return
A std::tuple containing two unsigned ints

@throws
std::invalid_argument if the argument contains an invalid years value with
the message: Invalid input for years argument
: Parse the years command line argument . Years is either a four digit year value or two four digit year values separated by a hyphen . This should be parsed as two integers and inserted into a std :: tuple representing the start and end year ( inclusive ) . If one or both values are 0 then there is no filter to be applied . If no year argument is given return <0 0 > . You will have to search the web for how to construct std :: tuple objects! @param args Parsed program arguments @return A std :: tuple containing two unsigned ints @throws std :: invalid_argument if the argument contains an invalid years value with the message : Invalid input for years argument
std::tuple<unsigned int, unsigned int> BethYw::parseYearsArg(cxxopts::ParseResult& args){
    if(args.count("years") == 0)
        return std::tuple<unsigned int, unsigned int> {0,0};
    auto yearsArgs = args["years"].as<std::string>();
    if(yearsArgs.empty()){
        return std::make_tuple(0,0);
    }
    if(yearsArgs.find("-") == std::string::npos){
        unsigned int year = BethYw::validateYear(yearsArgs);
        return std::make_tuple(year,year);
    }
    std::size_t pos = yearsArgs.find("-");
    std::string first = yearsArgs.substr(0,pos);
    std::string second = yearsArgs.substr(pos+1,yearsArgs.size());
    unsigned int firstYear = BethYw::validateYear(first);
    unsigned int secondYear = BethYw::validateYear(second);
    return std::make_tuple(firstYear,secondYear);
}
std :: tuple < unsigned int , unsigned int > BethYw :: parseYearsArg ( cxxopts :: ParseResult & args ) { if ( args . count ( " " ) == 0 ) return std :: tuple < unsigned int , unsigned int > { 0 , 0 } ; auto yearsArgs = args [ " " ] . as < std :: string > ( ) ; if ( yearsArgs . empty ( ) ) { return std :: make_tuple ( 0 , 0 ) ; } if ( yearsArgs . find ( " " ) == std :: string :: npos ) { unsigned int year = BethYw :: validateYear ( yearsArgs ) ; return std :: make_tuple ( year , year ) ; } std :: size_t pos = yearsArgs . find ( " " ) ; std :: string first = yearsArgs . substr ( 0 , pos ) ; std :: string second = yearsArgs . substr ( pos + 1 , yearsArgs . size ( ) ) ; unsigned int firstYear = BethYw :: validateYear ( first ) ; unsigned int secondYear = BethYw :: validateYear ( second ) ; return std :: make_tuple ( firstYear , secondYear ) ; }
TODO::
Parse the years command line argument.
TODO :: Parse the years command line argument .
//setting the 2 given years