Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions cmdline.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@
#include <typeinfo>
#include <cstring>
#include <algorithm>
#ifndef _MSC_VER
#include <cxxabi.h>
#endif
#include <cstdlib>

namespace cmdline{
Expand All @@ -51,7 +53,7 @@ class lexical_cast_t{
std::stringstream ss;
if (!(ss<<arg && ss>>ret && ss.eof()))
throw std::bad_cast();

return ret;
}
};
Expand All @@ -61,7 +63,7 @@ class lexical_cast_t<Target, Source, true>{
public:
static Target cast(const Source &arg){
return arg;
}
}
};

template <typename Source>
Expand Down Expand Up @@ -102,6 +104,7 @@ Target lexical_cast(const Source &arg)
return lexical_cast_t<Target, Source, detail::is_same<Target, Source>::value>::cast(arg);
}

#ifndef _MSC_VER
static inline std::string demangle(const std::string &name)
{
int status=0;
Expand All @@ -110,6 +113,12 @@ static inline std::string demangle(const std::string &name)
free(p);
return ret;
}
#else
static inline std::string demangle(const std::string &name)
{
return name;
}
#endif

template <class T>
std::string readable_typename()
Expand Down Expand Up @@ -560,7 +569,7 @@ class parser{
if (ordered[i]->must())
oss<<ordered[i]->short_description()<<" ";
}

oss<<"[options] ... "<<ftr<<std::endl;
oss<<"options:"<<std::endl;

Expand Down Expand Up @@ -721,7 +730,7 @@ class parser{
actual=read(value);
has=true;
}
catch(const std::exception &e){
catch(const std::exception){
return false;
}
return true;
Expand Down