mirror of
https://github.com/pdf2htmlEX/pdf2htmlEX.git
synced 2024-12-22 13:00:08 +00:00
fix argparse for char
This commit is contained in:
parent
4a908db655
commit
8205cd5bc7
@ -24,9 +24,16 @@ using std::unordered_map;
|
||||
using std::make_pair;
|
||||
using std::ostringstream;
|
||||
|
||||
void read_value(const char * arg, std::string * location)
|
||||
bool read_value(const char * arg, char * location)
|
||||
{
|
||||
*location = arg[0];
|
||||
return (arg[1] == 0);
|
||||
}
|
||||
|
||||
bool read_value(const char * arg, std::string * location)
|
||||
{
|
||||
*location = std::string(arg);
|
||||
return true;
|
||||
}
|
||||
|
||||
void dump_value(std::ostream & out, const std::string & v)
|
||||
|
@ -22,16 +22,14 @@ namespace pdf2htmlEX {
|
||||
|
||||
//helper
|
||||
template<class T>
|
||||
void read_value(const char * arg, T * location)
|
||||
bool read_value(const char * arg, T * location)
|
||||
{
|
||||
std::istringstream sin(arg);
|
||||
if((sin >> (*location)) && (sin.eof()))
|
||||
return;
|
||||
|
||||
throw std::string("Invalid argument: ") + arg;
|
||||
return ((sin >> (*location)) && (sin.eof()));
|
||||
}
|
||||
|
||||
extern void read_value(const char * arg, std::string * location);
|
||||
extern bool read_value(const char * arg, char * location);
|
||||
extern bool read_value(const char * arg, std::string * location);
|
||||
|
||||
template<class T>
|
||||
void dump_value(std::ostream & out, const T & v)
|
||||
@ -126,7 +124,8 @@ void ArgParser::ArgEntry<T, Tv>::parse(const char * arg) const
|
||||
if(!arg)
|
||||
throw std::string("Missing argument of option: --") + name;
|
||||
|
||||
read_value(arg, location);
|
||||
if(!read_value(arg, location))
|
||||
throw std::string("Invalid argument: ") + arg;
|
||||
}
|
||||
|
||||
if(callback)
|
||||
|
Loading…
Reference in New Issue
Block a user