{
+ public:
+ ///
+ /// Creates new filebuf
+ ///
+ basic_filebuf() :
+ buffer_size_(4),
+ buffer_(0),
+ file_(0),
+ own_(true),
+ mode_(std::ios::in | std::ios::out)
+ {
+ setg(0,0,0);
+ setp(0,0);
+ }
+
+ virtual ~basic_filebuf()
+ {
+ if(file_) {
+ ::fclose(file_);
+ file_ = 0;
+ }
+ if(own_ && buffer_)
+ delete [] buffer_;
+ }
+
+ ///
+ /// Same as std::filebuf::open but s is UTF-8 string
+ ///
+ basic_filebuf *open(std::string const &s,std::ios_base::openmode mode)
+ {
+ return open(s.c_str(),mode);
+ }
+ ///
+ /// Same as std::filebuf::open but s is UTF-8 string
+ ///
+ basic_filebuf *open(char const *s,std::ios_base::openmode mode)
+ {
+ if(file_) {
+ sync();
+ ::fclose(file_);
+ file_ = 0;
+ }
+ wchar_t const *smode = get_mode(mode);
+ if(!smode)
+ return 0;
+ wstackstring name;
+ if(!name.convert(s))
+ return 0;
+ #ifdef NOWIDE_FSTREAM_TESTS
+ FILE *f = ::fopen(s,nowide::convert(smode).c_str());
+ #else
+ FILE *f = ::_wfopen(name.c_str(),smode);
+ #endif
+ if(!f)
+ return 0;
+ file_ = f;
+ return this;
+ }
+ ///
+ /// Same as std::filebuf::close()
+ ///
+ basic_filebuf *close()
+ {
+ bool res = sync() == 0;
+ if(file_) {
+ if(::fclose(file_)!=0)
+ res = false;
+ file_ = 0;
+ }
+ return res ? this : 0;
+ }
+ ///
+ /// Same as std::filebuf::is_open()
+ ///
+ bool is_open() const
+ {
+ return file_ != 0;
+ }
+
+ private:
+ void make_buffer()
+ {
+ if(buffer_)
+ return;
+ if(buffer_size_ > 0) {
+ buffer_ = new char [buffer_size_];
+ own_ = true;
+ }
+ }
+ protected:
+
+ virtual std::streambuf *setbuf(char *s,std::streamsize n)
+ {
+ if(!buffer_ && n>=0) {
+ buffer_ = s;
+ buffer_size_ = n;
+ own_ = false;
+ }
+ return this;
+ }
+
+#ifdef NOWIDE_DEBUG_FILEBUF
+
+ void print_buf(char *b,char *p,char *e)
+ {
+ std::cerr << "-- Is Null: " << (b==0) << std::endl;;
+ if(b==0)
+ return;
+ if(e != 0)
+ std::cerr << "-- Total: " << e - b <<" offset from start " << p - b << std::endl;
+ else
+ std::cerr << "-- Total: " << p - b << std::endl;
+
+ std::cerr << "-- [";
+ for(char *ptr = b;ptrprint_state();
+ }
+ ~print_guard()
+ {
+ std::cerr << "Out: " << f << std::endl;
+ self->print_state();
+ }
+ basic_filebuf *self;
+ char const *f;
+ };
+#else
+#endif
+
+ int overflow(int c)
+ {
+#ifdef NOWIDE_DEBUG_FILEBUF
+ print_guard g(this,__FUNCTION__);
+#endif
+ if(!file_)
+ return EOF;
+
+ if(fixg() < 0)
+ return EOF;
+
+ size_t n = pptr() - pbase();
+ if(n > 0) {
+ if(::fwrite(pbase(),1,n,file_) < n)
+ return -1;
+ fflush(file_);
+ }
+
+ if(buffer_size_ > 0) {
+ make_buffer();
+ setp(buffer_,buffer_+buffer_size_);
+ if(c!=EOF)
+ sputc(c);
+ }
+ else if(c!=EOF) {
+ if(::fputc(c,file_)==EOF)
+ return EOF;
+ fflush(file_);
+ }
+ return 0;
+ }
+
+
+ int sync()
+ {
+ return overflow(EOF);
+ }
+
+ int underflow()
+ {
+#ifdef NOWIDE_DEBUG_FILEBUF
+ print_guard g(this,__FUNCTION__);
+#endif
+ if(!file_)
+ return EOF;
+ if(fixp() < 0)
+ return EOF;
+ if(buffer_size_ == 0) {
+ int c = ::fgetc(file_);
+ if(c==EOF) {
+ return EOF;
+ }
+ last_char_ = c;
+ setg(&last_char_,&last_char_,&last_char_ + 1);
+ return c;
+ }
+ make_buffer();
+ size_t n = ::fread(buffer_,1,buffer_size_,file_);
+ setg(buffer_,buffer_,buffer_+n);
+ if(n == 0)
+ return EOF;
+ return std::char_traits::to_int_type(*gptr());
+ }
+
+ int pbackfail(int)
+ {
+ return pubseekoff(-1,std::ios::cur);
+ }
+
+ std::streampos seekoff(std::streamoff off,
+ std::ios_base::seekdir seekdir,
+ std::ios_base::openmode /*m*/)
+ {
+#ifdef NOWIDE_DEBUG_FILEBUF
+ print_guard g(this,__FUNCTION__);
+#endif
+ if(!file_)
+ return EOF;
+ if(fixp() < 0 || fixg() < 0)
+ return EOF;
+ if(seekdir == std::ios_base::cur) {
+ if( ::fseek(file_,off,SEEK_CUR) < 0)
+ return EOF;
+ }
+ else if(seekdir == std::ios_base::beg) {
+ if( ::fseek(file_,off,SEEK_SET) < 0)
+ return EOF;
+ }
+ else if(seekdir == std::ios_base::end) {
+ if( ::fseek(file_,off,SEEK_END) < 0)
+ return EOF;
+ }
+ else
+ return -1;
+ return ftell(file_);
+ }
+ std::streampos seekpos(std::streampos off,std::ios_base::openmode m)
+ {
+ return seekoff(std::streamoff(off),std::ios_base::beg,m);
+ }
+ private:
+ int fixg()
+ {
+ if(gptr()!=egptr()) {
+ std::streamsize off = gptr() - egptr();
+ setg(0,0,0);
+ if(fseek(file_,off,SEEK_CUR) != 0)
+ return -1;
+ }
+ setg(0,0,0);
+ return 0;
+ }
+
+ int fixp()
+ {
+ if(pptr()!=0) {
+ int r = sync();
+ setp(0,0);
+ return r;
+ }
+ return 0;
+ }
+
+ void reset(FILE *f = 0)
+ {
+ sync();
+ if(file_) {
+ fclose(file_);
+ file_ = 0;
+ }
+ file_ = f;
+ }
+
+
+ static wchar_t const *get_mode(std::ios_base::openmode mode)
+ {
+ //
+ // done according to n2914 table 106 27.9.1.4
+ //
+
+ // note can't use switch case as overload operator can't be used
+ // in constant expression
+ if(mode == (std::ios_base::out))
+ return L"w";
+ if(mode == (std::ios_base::out | std::ios_base::app))
+ return L"a";
+ if(mode == (std::ios_base::app))
+ return L"a";
+ if(mode == (std::ios_base::out | std::ios_base::trunc))
+ return L"w";
+ if(mode == (std::ios_base::in))
+ return L"r";
+ if(mode == (std::ios_base::in | std::ios_base::out))
+ return L"r+";
+ if(mode == (std::ios_base::in | std::ios_base::out | std::ios_base::trunc))
+ return L"w+";
+ if(mode == (std::ios_base::in | std::ios_base::out | std::ios_base::app))
+ return L"a+";
+ if(mode == (std::ios_base::in | std::ios_base::app))
+ return L"a+";
+ if(mode == (std::ios_base::binary | std::ios_base::out))
+ return L"wb";
+ if(mode == (std::ios_base::binary | std::ios_base::out | std::ios_base::app))
+ return L"ab";
+ if(mode == (std::ios_base::binary | std::ios_base::app))
+ return L"ab";
+ if(mode == (std::ios_base::binary | std::ios_base::out | std::ios_base::trunc))
+ return L"wb";
+ if(mode == (std::ios_base::binary | std::ios_base::in))
+ return L"rb";
+ if(mode == (std::ios_base::binary | std::ios_base::in | std::ios_base::out))
+ return L"r+b";
+ if(mode == (std::ios_base::binary | std::ios_base::in | std::ios_base::out | std::ios_base::trunc))
+ return L"w+b";
+ if(mode == (std::ios_base::binary | std::ios_base::in | std::ios_base::out | std::ios_base::app))
+ return L"a+b";
+ if(mode == (std::ios_base::binary | std::ios_base::in | std::ios_base::app))
+ return L"a+b";
+ return 0;
+ }
+
+ size_t buffer_size_;
+ char *buffer_;
+ FILE *file_;
+ bool own_;
+ char last_char_;
+ std::ios::openmode mode_;
+ };
+
+ ///
+ /// \brief Convinience typedef
+ ///
+ typedef basic_filebuf filebuf;
+
+ #endif // windows
+
+} // nowide
+
+
+#ifdef NOWIDE_MSVC
+# pragma warning(pop)
+#endif
+
+
+#endif
+
+// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
diff --git a/deps/include/nowide/fstream.hpp b/deps/include/nowide/fstream.hpp
new file mode 100644
index 0000000..dda00d1
--- /dev/null
+++ b/deps/include/nowide/fstream.hpp
@@ -0,0 +1,248 @@
+//
+// Copyright (c) 2012 Artyom Beilis (Tonkikh)
+//
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//
+#ifndef NOWIDE_FSTREAM_INCLUDED_HPP
+#define NOWIDE_FSTREAM_INCLUDED_HPP
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+
+///
+/// \brief This namespace includes implementation of the standard library functios
+/// such that they accept UTF-8 strings on Windows. On other platforms it is just an alias
+/// of std namespace (i.e. not on Windows)
+///
+namespace nowide {
+#if !defined(NOWIDE_WINDOWS) && !defined(NOWIDE_FSTREAM_TESTS) && !defined(NOWIDE_DOXYGEN)
+
+ using std::basic_ifstream;
+ using std::basic_ofstream;
+ using std::basic_fstream;
+ using std::ifstream;
+ using std::ofstream;
+ using std::fstream;
+
+#else
+ ///
+ /// \brief Same as std::basic_ifstream but accepts UTF-8 strings under Windows
+ ///
+ template >
+ class basic_ifstream : public std::basic_istream
+ {
+ public:
+ typedef basic_filebuf internal_buffer_type;
+ typedef std::basic_istream internal_stream_type;
+
+ basic_ifstream() :
+ internal_stream_type(0)
+ {
+ buf_.reset(new internal_buffer_type());
+ std::ios::rdbuf(buf_.get());
+ }
+
+ explicit basic_ifstream(char const *file_name,std::ios_base::openmode mode = std::ios_base::in) :
+ internal_stream_type(0)
+ {
+ buf_.reset(new internal_buffer_type());
+ std::ios::rdbuf(buf_.get());
+ open(file_name,mode);
+ }
+
+ void open(char const *file_name,std::ios_base::openmode mode = std::ios_base::in)
+ {
+ if(!buf_->open(file_name,mode | std::ios_base::in)) {
+ this->setstate(std::ios_base::failbit);
+ }
+ else {
+ this->clear();
+ }
+ }
+ bool is_open()
+ {
+ return buf_->is_open();
+ }
+ bool is_open() const
+ {
+ return buf_->is_open();
+ }
+ void close()
+ {
+ if(!buf_->close())
+ this->setstate(std::ios_base::failbit);
+ else
+ this->clear();
+ }
+
+ internal_buffer_type *rdbuf() const
+ {
+ return buf_.get();
+ }
+ ~basic_ifstream()
+ {
+ buf_->close();
+ }
+
+ private:
+ nowide::scoped_ptr buf_;
+ };
+
+ ///
+ /// \brief Same as std::basic_ofstream but accepts UTF-8 strings under Windows
+ ///
+
+ template >
+ class basic_ofstream : public std::basic_ostream
+ {
+ public:
+ typedef basic_filebuf internal_buffer_type;
+ typedef std::basic_ostream internal_stream_type;
+
+ basic_ofstream() :
+ internal_stream_type(0)
+ {
+ buf_.reset(new internal_buffer_type());
+ std::ios::rdbuf(buf_.get());
+ }
+ explicit basic_ofstream(char const *file_name,std::ios_base::openmode mode = std::ios_base::out) :
+ internal_stream_type(0)
+ {
+ buf_.reset(new internal_buffer_type());
+ std::ios::rdbuf(buf_.get());
+ open(file_name,mode);
+ }
+ void open(char const *file_name,std::ios_base::openmode mode = std::ios_base::out)
+ {
+ if(!buf_->open(file_name,mode | std::ios_base::out)) {
+ this->setstate(std::ios_base::failbit);
+ }
+ else {
+ this->clear();
+ }
+ }
+ bool is_open()
+ {
+ return buf_->is_open();
+ }
+ bool is_open() const
+ {
+ return buf_->is_open();
+ }
+ void close()
+ {
+ if(!buf_->close())
+ this->setstate(std::ios_base::failbit);
+ else
+ this->clear();
+ }
+
+ internal_buffer_type *rdbuf() const
+ {
+ return buf_.get();
+ }
+ ~basic_ofstream()
+ {
+ buf_->close();
+ }
+
+ private:
+ nowide::scoped_ptr buf_;
+ };
+
+ ///
+ /// \brief Same as std::basic_fstream but accepts UTF-8 strings under Windows
+ ///
+
+ template >
+ class basic_fstream : public std::basic_iostream
+ {
+ public:
+ typedef basic_filebuf internal_buffer_type;
+ typedef std::basic_iostream internal_stream_type;
+
+ basic_fstream() :
+ internal_stream_type(0)
+ {
+ buf_.reset(new internal_buffer_type());
+ std::ios::rdbuf(buf_.get());
+ }
+ explicit basic_fstream(char const *file_name,std::ios_base::openmode mode = std::ios_base::out | std::ios_base::in) :
+ internal_stream_type(0)
+ {
+ buf_.reset(new internal_buffer_type());
+ std::ios::rdbuf(buf_.get());
+ open(file_name,mode);
+ }
+ void open(char const *file_name,std::ios_base::openmode mode = std::ios_base::out | std::ios_base::out)
+ {
+ if(!buf_->open(file_name,mode)) {
+ this->setstate(std::ios_base::failbit);
+ }
+ else {
+ this->clear();
+ }
+ }
+ bool is_open()
+ {
+ return buf_->is_open();
+ }
+ bool is_open() const
+ {
+ return buf_->is_open();
+ }
+ void close()
+ {
+ if(!buf_->close())
+ this->setstate(std::ios_base::failbit);
+ else
+ this->clear();
+ }
+
+ internal_buffer_type *rdbuf() const
+ {
+ return buf_.get();
+ }
+ ~basic_fstream()
+ {
+ buf_->close();
+ }
+
+ private:
+ nowide::scoped_ptr buf_;
+ };
+
+
+ ///
+ /// \brief Same as std::filebuf but accepts UTF-8 strings under Windows
+ ///
+ typedef basic_filebuf filebuf;
+ ///
+ /// Same as std::ifstream but accepts UTF-8 strings under Windows
+ ///
+ typedef basic_ifstream ifstream;
+ ///
+ /// Same as std::ofstream but accepts UTF-8 strings under Windows
+ ///
+ typedef basic_ofstream ofstream;
+ ///
+ /// Same as std::fstream but accepts UTF-8 strings under Windows
+ ///
+ typedef basic_fstream fstream;
+
+#endif
+} // nowide
+
+
+
+
+#endif
+// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
diff --git a/deps/include/nowide/iostream.hpp b/deps/include/nowide/iostream.hpp
new file mode 100644
index 0000000..b08c477
--- /dev/null
+++ b/deps/include/nowide/iostream.hpp
@@ -0,0 +1,99 @@
+//
+// Copyright (c) 2012 Artyom Beilis (Tonkikh)
+//
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//
+#ifndef NOWIDE_IOSTREAM_HPP_INCLUDED
+#define NOWIDE_IOSTREAM_HPP_INCLUDED
+
+#include
+#include
+#include
+#include
+#include
+
+#ifdef NOWIDE_MSVC
+# pragma warning(push)
+# pragma warning(disable : 4251)
+#endif
+
+
+
+namespace nowide {
+ #if !defined(NOWIDE_WINDOWS) && !defined(NOWIDE_DOXYGEN)
+ using std::cout;
+ using std::cerr;
+ using std::cin;
+ using std::clog;
+ #else
+
+ /// \cond INTERNAL
+ namespace details {
+ class console_output_buffer;
+ class console_input_buffer;
+
+ class NOWIDE_DECL winconsole_ostream : public std::ostream {
+ winconsole_ostream(winconsole_ostream const &);
+ void operator=(winconsole_ostream const &);
+ public:
+ winconsole_ostream(int fd);
+ ~winconsole_ostream();
+ private:
+ nowide::scoped_ptr d;
+ };
+
+ class NOWIDE_DECL winconsole_istream : public std::istream {
+ winconsole_istream(winconsole_istream const &);
+ void operator=(winconsole_istream const &);
+ public:
+
+ winconsole_istream();
+ ~winconsole_istream();
+ private:
+ struct data;
+ nowide::scoped_ptr d;
+ };
+ } // details
+
+ /// \endcond
+
+ ///
+ /// \brief Same as std::cin, but uses UTF-8
+ ///
+ /// Note, the stream is not synchronized with stdio and not affected by std::ios::sync_with_stdio
+ ///
+ extern NOWIDE_DECL details::winconsole_istream cin;
+ ///
+ /// \brief Same as std::cout, but uses UTF-8
+ ///
+ /// Note, the stream is not synchronized with stdio and not affected by std::ios::sync_with_stdio
+ ///
+ extern NOWIDE_DECL details::winconsole_ostream cout;
+ ///
+ /// \brief Same as std::cerr, but uses UTF-8
+ ///
+ /// Note, the stream is not synchronized with stdio and not affected by std::ios::sync_with_stdio
+ ///
+ extern NOWIDE_DECL details::winconsole_ostream cerr;
+ ///
+ /// \brief Same as std::clog, but uses UTF-8
+ ///
+ /// Note, the stream is not synchronized with stdio and not affected by std::ios::sync_with_stdio
+ ///
+ extern NOWIDE_DECL details::winconsole_ostream clog;
+
+ #endif
+
+} // nowide
+
+
+#ifdef NOWIDE_MSVC
+# pragma warning(pop)
+#endif
+
+
+#endif
+///
+// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
diff --git a/deps/include/nowide/scoped_ptr.hpp b/deps/include/nowide/scoped_ptr.hpp
new file mode 100644
index 0000000..92410e2
--- /dev/null
+++ b/deps/include/nowide/scoped_ptr.hpp
@@ -0,0 +1,93 @@
+#ifndef NOWIDE_SCOPED_PTR_HPP
+#define NOWIDE_SCOPED_PTR_HPP
+
+// (C) Copyright Greg Colvin and Beman Dawes 1998, 1999.
+// Copyright (c) 2001, 2002 Peter Dimov,
+// Copyright (C) 2012 Artyom Beilis
+//
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//
+// http://www.boost.org/libs/smart_ptr/scoped_ptr.htm
+//
+
+#include
+
+namespace nowide
+{
+
+// scoped_ptr mimics a built-in pointer except that it guarantees deletion
+// of the object pointed to, either on destruction of the scoped_ptr or via
+// an explicit reset(). scoped_ptr is a simple solution for simple needs;
+// use shared_ptr or std::auto_ptr if your needs are more complex.
+
+template class scoped_ptr // noncopyable
+{
+private:
+
+ T * px;
+
+ scoped_ptr(scoped_ptr const &);
+ scoped_ptr & operator=(scoped_ptr const &);
+
+ typedef scoped_ptr this_type;
+
+ void operator==( scoped_ptr const& ) const;
+ void operator!=( scoped_ptr const& ) const;
+
+public:
+
+ typedef T element_type;
+
+ explicit scoped_ptr( T * p = 0 ): px( p ) // never throws
+ {
+ }
+
+ ~scoped_ptr() // never throws
+ {
+ delete px;
+ }
+
+ void reset(T * p = 0) // never throws
+ {
+ assert( p == 0 || p != px ); // catch self-reset errors
+ this_type(p).swap(*this);
+ }
+
+ T & operator*() const // never throws
+ {
+ assert( px != 0 );
+ return *px;
+ }
+
+ T * operator->() const // never throws
+ {
+ assert( px != 0 );
+ return px;
+ }
+
+ T * get() const // never throws
+ {
+ return px;
+ }
+
+ operator bool() const
+ {
+ return px!=0;
+ }
+
+ void swap(scoped_ptr & b) // never throws
+ {
+ T * tmp = b.px;
+ b.px = px;
+ px = tmp;
+ }
+};
+
+
+} // namespace nowide
+
+#endif
+// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
+
diff --git a/deps/include/nowide/stackstring.hpp b/deps/include/nowide/stackstring.hpp
new file mode 100644
index 0000000..c93f983
--- /dev/null
+++ b/deps/include/nowide/stackstring.hpp
@@ -0,0 +1,154 @@
+//
+// Copyright (c) 2012 Artyom Beilis (Tonkikh)
+//
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//
+#ifndef NOWIDE_DETAILS_WIDESTR_H_INCLUDED
+#define NOWIDE_DETAILS_WIDESTR_H_INCLUDED
+#include
+#include
+#include
+
+
+namespace nowide {
+
+///
+/// \brief A class that allows to create a temporary wide or narrow UTF strings from
+/// wide or narrow UTF source.
+///
+/// It uses on stack buffer of the string is short enough
+/// and allocated a buffer on the heap if the size of the buffer is too small
+///
+template
+class basic_stackstring {
+public:
+
+ static const size_t buffer_size = BufferSize;
+ typedef CharOut output_char;
+ typedef CharIn input_char;
+
+ basic_stackstring(basic_stackstring const &other) :
+ mem_buffer_(0)
+ {
+ clear();
+ if(other.mem_buffer_) {
+ size_t len = 0;
+ while(other.mem_buffer_[len])
+ len ++;
+ mem_buffer_ = new output_char[len + 1];
+ memcpy(mem_buffer_,other.mem_buffer_,sizeof(output_char) * (len+1));
+ }
+ else {
+ memcpy(buffer_,other.buffer_,buffer_size * sizeof(output_char));
+ }
+ }
+
+ void swap(basic_stackstring &other)
+ {
+ std::swap(mem_buffer_,other.mem_buffer_);
+ for(size_t i=0;i wstackstring;
+///
+/// Convinience typedef
+///
+typedef basic_stackstring stackstring;
+///
+/// Convinience typedef
+///
+typedef basic_stackstring wshort_stackstring;
+///
+/// Convinience typedef
+///
+typedef basic_stackstring short_stackstring;
+
+
+} // nowide
+
+
+#endif
+///
+// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
diff --git a/deps/include/nowide/system.hpp b/deps/include/nowide/system.hpp
new file mode 100644
index 0000000..8083bfc
--- /dev/null
+++ b/deps/include/nowide/system.hpp
@@ -0,0 +1,46 @@
+//
+// Copyright (c) 2012 Artyom Beilis (Tonkikh)
+//
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//
+#ifndef NOWIDE_CSTDLIB_HPP
+#define NOWIDE_CSTDLIB_HPP
+
+#include
+#include
+#include
+
+namespace nowide {
+
+#if !defined(NOWIDE_WINDOWS) && !defined(NOWIDE_DOXYGEN)
+
+using ::system;
+
+#else // Windows
+
+///
+/// Same as std::system but cmd is UTF-8.
+///
+/// If the input is not valid UTF-8, -1 returned and errno set to EINVAL
+///
+inline int system(char const *cmd)
+{
+ if(!cmd)
+ return _wsystem(0);
+ wstackstring wcmd;
+ if(!wcmd.convert(cmd)) {
+ errno = EINVAL;
+ return -1;
+ }
+ return _wsystem(wcmd.c_str());
+}
+
+#endif
+} // nowide
+
+
+#endif
+///
+// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
diff --git a/deps/include/nowide/utf.hpp b/deps/include/nowide/utf.hpp
new file mode 100644
index 0000000..55dc2cc
--- /dev/null
+++ b/deps/include/nowide/utf.hpp
@@ -0,0 +1,469 @@
+//
+// Copyright (c) 2009-2011 Artyom Beilis (Tonkikh)
+//
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//
+#ifndef NOWIDE_UTF_HPP_INCLUDED
+#define NOWIDE_UTF_HPP_INCLUDED
+
+#include
+
+#ifndef NOWIDE_MSVC
+namespace nowide {
+namespace utf {
+ typedef unsigned uint32_t;
+ typedef unsigned short uint16_t;
+ typedef unsigned char uint8_t;
+}
+}
+#else
+#include
+#endif
+
+namespace nowide {
+///
+/// \brief Namespace that holds basic operations on UTF encoded sequences
+///
+/// All functions defined in this namespace do not require linking with Boost.Locale library
+///
+namespace utf {
+ /// \cond INTERNAL
+ #ifdef __GNUC__
+ # define NOWIDE_LIKELY(x) __builtin_expect((x),1)
+ # define NOWIDE_UNLIKELY(x) __builtin_expect((x),0)
+ #else
+ # define NOWIDE_LIKELY(x) (x)
+ # define NOWIDE_UNLIKELY(x) (x)
+ #endif
+ /// \endcond
+
+ ///
+ /// \brief The integral type type that can hold a Unicode code point
+ ///
+ typedef uint32_t code_point;
+
+ ///
+ /// \brief Special constant that defines illegal code point
+ ///
+ static const code_point illegal = 0xFFFFFFFFu;
+
+ ///
+ /// \brief Special constant that defines incomplete code point
+ ///
+ static const code_point incomplete = 0xFFFFFFFEu;
+
+ ///
+ /// \brief the function checks if \a v is a valid code point
+ ///
+ inline bool is_valid_codepoint(code_point v)
+ {
+ if(v>0x10FFFF)
+ return false;
+ if(0xD800 <=v && v<= 0xDFFF) // surragates
+ return false;
+ return true;
+ }
+
+ #ifdef NOWIDE_DOXYGEN
+ ///
+ /// \brief UTF Traits class - functions to convert UTF sequences to and from Unicode code points
+ ///
+ template
+ struct utf_traits {
+ ///
+ /// The type of the character
+ ///
+ typedef CharType char_type;
+ ///
+ /// Read one code point from the range [p,e) and return it.
+ ///
+ /// - If the sequence that was read is incomplete sequence returns \ref incomplete,
+ /// - If illegal sequence detected returns \ref illegal
+ ///
+ /// Requirements
+ ///
+ /// - Iterator is valid input iterator
+ ///
+ /// Postconditions
+ ///
+ /// - p points to the last consumed character
+ ///
+ template
+ static code_point decode(Iterator &p,Iterator e);
+
+ ///
+ /// Maximal width of valid sequence in the code units:
+ ///
+ /// - UTF-8 - 4
+ /// - UTF-16 - 2
+ /// - UTF-32 - 1
+ ///
+ static const int max_width;
+ ///
+ /// The width of specific code point in the code units.
+ ///
+ /// Requirement: value is a valid Unicode code point
+ /// Returns value in range [1..max_width]
+ ///
+ static int width(code_point value);
+
+ ///
+ /// Get the size of the trail part of variable length encoded sequence.
+ ///
+ /// Returns -1 if C is not valid lead character
+ ///
+ static int trail_length(char_type c);
+ ///
+ /// Returns true if c is trail code unit, always false for UTF-32
+ ///
+ static bool is_trail(char_type c);
+ ///
+ /// Returns true if c is lead code unit, always true of UTF-32
+ ///
+ static bool is_lead(char_type c);
+
+ ///
+ /// Convert valid Unicode code point \a value to the UTF sequence.
+ ///
+ /// Requirements:
+ ///
+ /// - \a value is valid code point
+ /// - \a out is an output iterator should be able to accept at least width(value) units
+ ///
+ /// Returns the iterator past the last written code unit.
+ ///
+ template
+ static Iterator encode(code_point value,Iterator out);
+ ///
+ /// Decodes valid UTF sequence that is pointed by p into code point.
+ ///
+ /// If the sequence is invalid or points to end the behavior is undefined
+ ///
+ template
+ static code_point decode_valid(Iterator &p);
+ };
+
+ #else
+
+ template
+ struct utf_traits;
+
+ template
+ struct utf_traits {
+
+ typedef CharType char_type;
+
+ static int trail_length(char_type ci)
+ {
+ unsigned char c = ci;
+ if(c < 128)
+ return 0;
+ if(NOWIDE_UNLIKELY(c < 194))
+ return -1;
+ if(c < 224)
+ return 1;
+ if(c < 240)
+ return 2;
+ if(NOWIDE_LIKELY(c <=244))
+ return 3;
+ return -1;
+ }
+
+ static const int max_width = 4;
+
+ static int width(code_point value)
+ {
+ if(value <=0x7F) {
+ return 1;
+ }
+ else if(value <=0x7FF) {
+ return 2;
+ }
+ else if(NOWIDE_LIKELY(value <=0xFFFF)) {
+ return 3;
+ }
+ else {
+ return 4;
+ }
+ }
+
+ static bool is_trail(char_type ci)
+ {
+ unsigned char c=ci;
+ return (c & 0xC0)==0x80;
+ }
+
+ static bool is_lead(char_type ci)
+ {
+ return !is_trail(ci);
+ }
+
+ template
+ static code_point decode(Iterator &p,Iterator e)
+ {
+ if(NOWIDE_UNLIKELY(p==e))
+ return incomplete;
+
+ unsigned char lead = *p++;
+
+ // First byte is fully validated here
+ int trail_size = trail_length(lead);
+
+ if(NOWIDE_UNLIKELY(trail_size < 0))
+ return illegal;
+
+ //
+ // Ok as only ASCII may be of size = 0
+ // also optimize for ASCII text
+ //
+ if(trail_size == 0)
+ return lead;
+
+ code_point c = lead & ((1<<(6-trail_size))-1);
+
+ // Read the rest
+ unsigned char tmp;
+ switch(trail_size) {
+ case 3:
+ if(NOWIDE_UNLIKELY(p==e))
+ return incomplete;
+ tmp = *p++;
+ if (!is_trail(tmp))
+ return illegal;
+ c = (c << 6) | ( tmp & 0x3F);
+ case 2:
+ if(NOWIDE_UNLIKELY(p==e))
+ return incomplete;
+ tmp = *p++;
+ if (!is_trail(tmp))
+ return illegal;
+ c = (c << 6) | ( tmp & 0x3F);
+ case 1:
+ if(NOWIDE_UNLIKELY(p==e))
+ return incomplete;
+ tmp = *p++;
+ if (!is_trail(tmp))
+ return illegal;
+ c = (c << 6) | ( tmp & 0x3F);
+ }
+
+ // Check code point validity: no surrogates and
+ // valid range
+ if(NOWIDE_UNLIKELY(!is_valid_codepoint(c)))
+ return illegal;
+
+ // make sure it is the most compact representation
+ if(NOWIDE_UNLIKELY(width(c)!=trail_size + 1))
+ return illegal;
+
+ return c;
+
+ }
+
+ template
+ static code_point decode_valid(Iterator &p)
+ {
+ unsigned char lead = *p++;
+ if(lead < 192)
+ return lead;
+
+ int trail_size;
+
+ if(lead < 224)
+ trail_size = 1;
+ else if(NOWIDE_LIKELY(lead < 240)) // non-BMP rare
+ trail_size = 2;
+ else
+ trail_size = 3;
+
+ code_point c = lead & ((1<<(6-trail_size))-1);
+
+ switch(trail_size) {
+ case 3:
+ c = (c << 6) | ( static_cast(*p++) & 0x3F);
+ case 2:
+ c = (c << 6) | ( static_cast(*p++) & 0x3F);
+ case 1:
+ c = (c << 6) | ( static_cast(*p++) & 0x3F);
+ }
+
+ return c;
+ }
+
+
+
+ template
+ static Iterator encode(code_point value,Iterator out)
+ {
+ if(value <= 0x7F) {
+ *out++ = static_cast(value);
+ }
+ else if(value <= 0x7FF) {
+ *out++ = static_cast((value >> 6) | 0xC0);
+ *out++ = static_cast((value & 0x3F) | 0x80);
+ }
+ else if(NOWIDE_LIKELY(value <= 0xFFFF)) {
+ *out++ = static_cast((value >> 12) | 0xE0);
+ *out++ = static_cast(((value >> 6) & 0x3F) | 0x80);
+ *out++ = static_cast((value & 0x3F) | 0x80);
+ }
+ else {
+ *out++ = static_cast((value >> 18) | 0xF0);
+ *out++ = static_cast(((value >> 12) & 0x3F) | 0x80);
+ *out++ = static_cast(((value >> 6) & 0x3F) | 0x80);
+ *out++ = static_cast((value & 0x3F) | 0x80);
+ }
+ return out;
+ }
+ }; // utf8
+
+ template
+ struct utf_traits {
+ typedef CharType char_type;
+
+ // See RFC 2781
+ static bool is_first_surrogate(uint16_t x)
+ {
+ return 0xD800 <=x && x<= 0xDBFF;
+ }
+ static bool is_second_surrogate(uint16_t x)
+ {
+ return 0xDC00 <=x && x<= 0xDFFF;
+ }
+ static code_point combine_surrogate(uint16_t w1,uint16_t w2)
+ {
+ return ((code_point(w1 & 0x3FF) << 10) | (w2 & 0x3FF)) + 0x10000;
+ }
+ static int trail_length(char_type c)
+ {
+ if(is_first_surrogate(c))
+ return 1;
+ if(is_second_surrogate(c))
+ return -1;
+ return 0;
+ }
+ ///
+ /// Returns true if c is trail code unit, always false for UTF-32
+ ///
+ static bool is_trail(char_type c)
+ {
+ return is_second_surrogate(c);
+ }
+ ///
+ /// Returns true if c is lead code unit, always true of UTF-32
+ ///
+ static bool is_lead(char_type c)
+ {
+ return !is_second_surrogate(c);
+ }
+
+ template
+ static code_point decode(It ¤t,It last)
+ {
+ if(NOWIDE_UNLIKELY(current == last))
+ return incomplete;
+ uint16_t w1=*current++;
+ if(NOWIDE_LIKELY(w1 < 0xD800 || 0xDFFF < w1)) {
+ return w1;
+ }
+ if(w1 > 0xDBFF)
+ return illegal;
+ if(current==last)
+ return incomplete;
+ uint16_t w2=*current++;
+ if(w2 < 0xDC00 || 0xDFFF < w2)
+ return illegal;
+ return combine_surrogate(w1,w2);
+ }
+ template
+ static code_point decode_valid(It ¤t)
+ {
+ uint16_t w1=*current++;
+ if(NOWIDE_LIKELY(w1 < 0xD800 || 0xDFFF < w1)) {
+ return w1;
+ }
+ uint16_t w2=*current++;
+ return combine_surrogate(w1,w2);
+ }
+
+ static const int max_width = 2;
+ static int width(code_point u)
+ {
+ return u>=0x10000 ? 2 : 1;
+ }
+ template
+ static It encode(code_point u,It out)
+ {
+ if(NOWIDE_LIKELY(u<=0xFFFF)) {
+ *out++ = static_cast(u);
+ }
+ else {
+ u -= 0x10000;
+ *out++ = static_cast(0xD800 | (u>>10));
+ *out++ = static_cast(0xDC00 | (u & 0x3FF));
+ }
+ return out;
+ }
+ }; // utf16;
+
+
+ template
+ struct utf_traits {
+ typedef CharType char_type;
+ static int trail_length(char_type c)
+ {
+ if(is_valid_codepoint(c))
+ return 0;
+ return -1;
+ }
+ static bool is_trail(char_type /*c*/)
+ {
+ return false;
+ }
+ static bool is_lead(char_type /*c*/)
+ {
+ return true;
+ }
+
+ template
+ static code_point decode_valid(It ¤t)
+ {
+ return *current++;
+ }
+
+ template
+ static code_point decode(It ¤t,It last)
+ {
+ if(NOWIDE_UNLIKELY(current == last))
+ return nowide::utf::incomplete;
+ code_point c=*current++;
+ if(NOWIDE_UNLIKELY(!is_valid_codepoint(c)))
+ return nowide::utf::illegal;
+ return c;
+ }
+ static const int max_width = 1;
+ static int width(code_point /*u*/)
+ {
+ return 1;
+ }
+ template
+ static It encode(code_point u,It out)
+ {
+ *out++ = static_cast(u);
+ return out;
+ }
+
+ }; // utf32
+
+ #endif
+
+} // utf
+} // nowide
+
+
+#endif
+
+// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
+
diff --git a/deps/include/nowide/windows.hpp b/deps/include/nowide/windows.hpp
new file mode 100644
index 0000000..b9abff4
--- /dev/null
+++ b/deps/include/nowide/windows.hpp
@@ -0,0 +1,39 @@
+//
+// Copyright (c) 2012 Artyom Beilis (Tonkikh)
+//
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//
+#ifndef NOWIDE_WINDOWS_HPP_INCLUDED
+#define NOWIDE_WINDOWS_HPP_INCLUDED
+
+#include
+
+#ifdef NOWIDE_USE_WINDOWS_H
+#include
+#else
+
+//
+// These are function prototypes... Allow to to include windows.h
+//
+extern "C" {
+
+__declspec(dllimport) wchar_t* __stdcall GetEnvironmentStringsW(void);
+__declspec(dllimport) int __stdcall FreeEnvironmentStringsW(wchar_t *);
+__declspec(dllimport) wchar_t* __stdcall GetCommandLineW(void);
+__declspec(dllimport) wchar_t** __stdcall CommandLineToArgvW(wchar_t const *,int *);
+__declspec(dllimport) unsigned long __stdcall GetLastError();
+__declspec(dllimport) void* __stdcall LocalFree(void *);
+__declspec(dllimport) int __stdcall SetEnvironmentVariableW(wchar_t const *,wchar_t const *);
+__declspec(dllimport) unsigned long __stdcall GetEnvironmentVariableW(wchar_t const *,wchar_t *,unsigned long);
+
+}
+
+#endif
+
+
+
+#endif
+///
+// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
diff --git a/deps/include/tclap/Arg.h b/deps/include/tclap/Arg.h
new file mode 100644
index 0000000..b28eef1
--- /dev/null
+++ b/deps/include/tclap/Arg.h
@@ -0,0 +1,692 @@
+// -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*-
+
+/******************************************************************************
+ *
+ * file: Arg.h
+ *
+ * Copyright (c) 2003, Michael E. Smoot .
+ * Copyright (c) 2004, Michael E. Smoot, Daniel Aarno .
+ * All rights reverved.
+ *
+ * See the file COPYING in the top directory of this distribution for
+ * more information.
+ *
+ * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ *****************************************************************************/
+
+
+#ifndef TCLAP_ARGUMENT_H
+#define TCLAP_ARGUMENT_H
+
+#ifdef HAVE_CONFIG_H
+#include
+#else
+#define HAVE_SSTREAM
+#endif
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+#if defined(HAVE_SSTREAM)
+#include
+typedef std::istringstream istringstream;
+#elif defined(HAVE_STRSTREAM)
+#include
+typedef std::istrstream istringstream;
+#else
+#error "Need a stringstream (sstream or strstream) to compile!"
+#endif
+
+#include
+#include
+#include
+#include
+#include
+
+namespace TCLAP {
+
+/**
+ * A virtual base class that defines the essential data for all arguments.
+ * This class, or one of its existing children, must be subclassed to do
+ * anything.
+ */
+class Arg
+{
+ private:
+ /**
+ * Prevent accidental copying.
+ */
+ Arg(const Arg& rhs);
+
+ /**
+ * Prevent accidental copying.
+ */
+ Arg& operator=(const Arg& rhs);
+
+ /**
+ * Indicates whether the rest of the arguments should be ignored.
+ */
+ static bool& ignoreRestRef() { static bool ign = false; return ign; }
+
+ /**
+ * The delimiter that separates an argument flag/name from the
+ * value.
+ */
+ static char& delimiterRef() { static char delim = ' '; return delim; }
+
+ protected:
+
+ /**
+ * The single char flag used to identify the argument.
+ * This value (preceded by a dash {-}), can be used to identify
+ * an argument on the command line. The _flag can be blank,
+ * in fact this is how unlabeled args work. Unlabeled args must
+ * override appropriate functions to get correct handling. Note
+ * that the _flag does NOT include the dash as part of the flag.
+ */
+ std::string _flag;
+
+ /**
+ * A single work namd indentifying the argument.
+ * This value (preceded by two dashed {--}) can also be used
+ * to identify an argument on the command line. Note that the
+ * _name does NOT include the two dashes as part of the _name. The
+ * _name cannot be blank.
+ */
+ std::string _name;
+
+ /**
+ * Description of the argument.
+ */
+ std::string _description;
+
+ /**
+ * Indicating whether the argument is required.
+ */
+ bool _required;
+
+ /**
+ * Label to be used in usage description. Normally set to
+ * "required", but can be changed when necessary.
+ */
+ std::string _requireLabel;
+
+ /**
+ * Indicates whether a value is required for the argument.
+ * Note that the value may be required but the argument/value
+ * combination may not be, as specified by _required.
+ */
+ bool _valueRequired;
+
+ /**
+ * Indicates whether the argument has been set.
+ * Indicates that a value on the command line has matched the
+ * name/flag of this argument and the values have been set accordingly.
+ */
+ bool _alreadySet;
+
+ /**
+ * A pointer to a vistitor object.
+ * The visitor allows special handling to occur as soon as the
+ * argument is matched. This defaults to NULL and should not
+ * be used unless absolutely necessary.
+ */
+ Visitor* _visitor;
+
+ /**
+ * Whether this argument can be ignored, if desired.
+ */
+ bool _ignoreable;
+
+ /**
+ * Indicates that the arg was set as part of an XOR and not on the
+ * command line.
+ */
+ bool _xorSet;
+
+ bool _acceptsMultipleValues;
+
+ /**
+ * Performs the special handling described by the Vistitor.
+ */
+ void _checkWithVisitor() const;
+
+ /**
+ * Primary constructor. YOU (yes you) should NEVER construct an Arg
+ * directly, this is a base class that is extended by various children
+ * that are meant to be used. Use SwitchArg, ValueArg, MultiArg,
+ * UnlabeledValueArg, or UnlabeledMultiArg instead.
+ *
+ * \param flag - The flag identifying the argument.
+ * \param name - The name identifying the argument.
+ * \param desc - The description of the argument, used in the usage.
+ * \param req - Whether the argument is required.
+ * \param valreq - Whether the a value is required for the argument.
+ * \param v - The visitor checked by the argument. Defaults to NULL.
+ */
+ Arg( const std::string& flag,
+ const std::string& name,
+ const std::string& desc,
+ bool req,
+ bool valreq,
+ Visitor* v = NULL );
+
+ public:
+ /**
+ * Destructor.
+ */
+ virtual ~Arg();
+
+ /**
+ * Adds this to the specified list of Args.
+ * \param argList - The list to add this to.
+ */
+ virtual void addToList( std::list& argList ) const;
+
+ /**
+ * Begin ignoring arguments since the "--" argument was specified.
+ */
+ static void beginIgnoring() { ignoreRestRef() = true; }
+
+ /**
+ * Whether to ignore the rest.
+ */
+ static bool ignoreRest() { return ignoreRestRef(); }
+
+ /**
+ * The delimiter that separates an argument flag/name from the
+ * value.
+ */
+ static char delimiter() { return delimiterRef(); }
+
+ /**
+ * The char used as a place holder when SwitchArgs are combined.
+ * Currently set to the bell char (ASCII 7).
+ */
+ static char blankChar() { return (char)7; }
+
+ /**
+ * The char that indicates the beginning of a flag. Defaults to '-', but
+ * clients can define TCLAP_FLAGSTARTCHAR to override.
+ */
+#ifndef TCLAP_FLAGSTARTCHAR
+#define TCLAP_FLAGSTARTCHAR '-'
+#endif
+ static char flagStartChar() { return TCLAP_FLAGSTARTCHAR; }
+
+ /**
+ * The sting that indicates the beginning of a flag. Defaults to "-", but
+ * clients can define TCLAP_FLAGSTARTSTRING to override. Should be the same
+ * as TCLAP_FLAGSTARTCHAR.
+ */
+#ifndef TCLAP_FLAGSTARTSTRING
+#define TCLAP_FLAGSTARTSTRING "-"
+#endif
+ static const std::string flagStartString() { return TCLAP_FLAGSTARTSTRING; }
+
+ /**
+ * The sting that indicates the beginning of a name. Defaults to "--", but
+ * clients can define TCLAP_NAMESTARTSTRING to override.
+ */
+#ifndef TCLAP_NAMESTARTSTRING
+#define TCLAP_NAMESTARTSTRING "--"
+#endif
+ static const std::string nameStartString() { return TCLAP_NAMESTARTSTRING; }
+
+ /**
+ * The name used to identify the ignore rest argument.
+ */
+ static const std::string ignoreNameString() { return "ignore_rest"; }
+
+ /**
+ * Sets the delimiter for all arguments.
+ * \param c - The character that delimits flags/names from values.
+ */
+ static void setDelimiter( char c ) { delimiterRef() = c; }
+
+ /**
+ * Pure virtual method meant to handle the parsing and value assignment
+ * of the string on the command line.
+ * \param i - Pointer the the current argument in the list.
+ * \param args - Mutable list of strings. What is
+ * passed in from main.
+ */
+ virtual bool processArg(int *i, std::vector& args) = 0;
+
+ /**
+ * Operator ==.
+ * Equality operator. Must be virtual to handle unlabeled args.
+ * \param a - The Arg to be compared to this.
+ */
+ virtual bool operator==(const Arg& a) const;
+
+ /**
+ * Returns the argument flag.
+ */
+ const std::string& getFlag() const;
+
+ /**
+ * Returns the argument name.
+ */
+ const std::string& getName() const;
+
+ /**
+ * Returns the argument description.
+ */
+ std::string getDescription() const;
+
+ /**
+ * Indicates whether the argument is required.
+ */
+ virtual bool isRequired() const;
+
+ /**
+ * Sets _required to true. This is used by the XorHandler.
+ * You really have no reason to ever use it.
+ */
+ void forceRequired();
+
+ /**
+ * Sets the _alreadySet value to true. This is used by the XorHandler.
+ * You really have no reason to ever use it.
+ */
+ void xorSet();
+
+ /**
+ * Indicates whether a value must be specified for argument.
+ */
+ bool isValueRequired() const;
+
+ /**
+ * Indicates whether the argument has already been set. Only true
+ * if the arg has been matched on the command line.
+ */
+ bool isSet() const;
+
+ /**
+ * Indicates whether the argument can be ignored, if desired.
+ */
+ bool isIgnoreable() const;
+
+ /**
+ * A method that tests whether a string matches this argument.
+ * This is generally called by the processArg() method. This
+ * method could be re-implemented by a child to change how
+ * arguments are specified on the command line.
+ * \param s - The string to be compared to the flag/name to determine
+ * whether the arg matches.
+ */
+ virtual bool argMatches( const std::string& s ) const;
+
+ /**
+ * Returns a simple string representation of the argument.
+ * Primarily for debugging.
+ */
+ virtual std::string toString() const;
+
+ /**
+ * Returns a short ID for the usage.
+ * \param valueId - The value used in the id.
+ */
+ virtual std::string shortID( const std::string& valueId = "val" ) const;
+
+ /**
+ * Returns a long ID for the usage.
+ * \param valueId - The value used in the id.
+ */
+ virtual std::string longID( const std::string& valueId = "val" ) const;
+
+ /**
+ * Trims a value off of the flag.
+ * \param flag - The string from which the flag and value will be
+ * trimmed. Contains the flag once the value has been trimmed.
+ * \param value - Where the value trimmed from the string will
+ * be stored.
+ */
+ virtual void trimFlag( std::string& flag, std::string& value ) const;
+
+ /**
+ * Checks whether a given string has blank chars, indicating that
+ * it is a combined SwitchArg. If so, return true, otherwise return
+ * false.
+ * \param s - string to be checked.
+ */
+ bool _hasBlanks( const std::string& s ) const;
+
+ /**
+ * Sets the requireLabel. Used by XorHandler. You shouldn't ever
+ * use this.
+ * \param s - Set the requireLabel to this value.
+ */
+ void setRequireLabel( const std::string& s );
+
+ /**
+ * Used for MultiArgs and XorHandler to determine whether args
+ * can still be set.
+ */
+ virtual bool allowMore();
+
+ /**
+ * Use by output classes to determine whether an Arg accepts
+ * multiple values.
+ */
+ virtual bool acceptsMultipleValues();
+
+ /**
+ * Clears the Arg object and allows it to be reused by new
+ * command lines.
+ */
+ virtual void reset();
+};
+
+/**
+ * Typedef of an Arg list iterator.
+ */
+typedef std::list::iterator ArgListIterator;
+
+/**
+ * Typedef of an Arg vector iterator.
+ */
+typedef std::vector::iterator ArgVectorIterator;
+
+/**
+ * Typedef of a Visitor list iterator.
+ */
+typedef std::list::iterator VisitorListIterator;
+
+/*
+ * Extract a value of type T from it's string representation contained
+ * in strVal. The ValueLike parameter used to select the correct
+ * specialization of ExtractValue depending on the value traits of T.
+ * ValueLike traits use operator>> to assign the value from strVal.
+ */
+template void
+ExtractValue(T &destVal, const std::string& strVal, ValueLike vl)
+{
+ static_cast(vl); // Avoid warning about unused vl
+ std::istringstream is(strVal);
+
+ int valuesRead = 0;
+ while ( is.good() ) {
+ if ( is.peek() != EOF )
+#ifdef TCLAP_SETBASE_ZERO
+ is >> std::setbase(0) >> destVal;
+#else
+ is >> destVal;
+#endif
+ else
+ break;
+
+ valuesRead++;
+ }
+
+ if ( is.fail() )
+ throw( ArgParseException("Couldn't read argument value "
+ "from string '" + strVal + "'"));
+
+
+ if ( valuesRead > 1 )
+ throw( ArgParseException("More than one valid value parsed from "
+ "string '" + strVal + "'"));
+
+}
+
+/*
+ * Extract a value of type T from it's string representation contained
+ * in strVal. The ValueLike parameter used to select the correct
+ * specialization of ExtractValue depending on the value traits of T.
+ * StringLike uses assignment (operator=) to assign from strVal.
+ */
+template void
+ExtractValue(T &destVal, const std::string& strVal, StringLike sl)
+{
+ static_cast(sl); // Avoid warning about unused sl
+ SetString(destVal, strVal);
+}
+
+//////////////////////////////////////////////////////////////////////
+//BEGIN Arg.cpp
+//////////////////////////////////////////////////////////////////////
+
+inline Arg::Arg(const std::string& flag,
+ const std::string& name,
+ const std::string& desc,
+ bool req,
+ bool valreq,
+ Visitor* v) :
+ _flag(flag),
+ _name(name),
+ _description(desc),
+ _required(req),
+ _requireLabel("required"),
+ _valueRequired(valreq),
+ _alreadySet(false),
+ _visitor( v ),
+ _ignoreable(true),
+ _xorSet(false),
+ _acceptsMultipleValues(false)
+{
+ if ( _flag.length() > 1 )
+ throw(SpecificationException(
+ "Argument flag can only be one character long", toString() ) );
+
+ if ( _name != ignoreNameString() &&
+ ( _flag == Arg::flagStartString() ||
+ _flag == Arg::nameStartString() ||
+ _flag == " " ) )
+ throw(SpecificationException("Argument flag cannot be either '" +
+ Arg::flagStartString() + "' or '" +
+ Arg::nameStartString() + "' or a space.",
+ toString() ) );
+
+ if ( ( _name.substr( 0, Arg::flagStartString().length() ) == Arg::flagStartString() ) ||
+ ( _name.substr( 0, Arg::nameStartString().length() ) == Arg::nameStartString() ) ||
+ ( _name.find( " ", 0 ) != std::string::npos ) )
+ throw(SpecificationException("Argument name begin with either '" +
+ Arg::flagStartString() + "' or '" +
+ Arg::nameStartString() + "' or space.",
+ toString() ) );
+
+}
+
+inline Arg::~Arg() { }
+
+inline std::string Arg::shortID( const std::string& valueId ) const
+{
+ std::string id = "";
+
+ if ( _flag != "" )
+ id = Arg::flagStartString() + _flag;
+ else
+ id = Arg::nameStartString() + _name;
+
+ if ( _valueRequired )
+ id += std::string( 1, Arg::delimiter() ) + "<" + valueId + ">";
+
+ if ( !_required )
+ id = "[" + id + "]";
+
+ return id;
+}
+
+inline std::string Arg::longID( const std::string& valueId ) const
+{
+ std::string id = "";
+
+ if ( _flag != "" )
+ {
+ id += Arg::flagStartString() + _flag;
+
+ if ( _valueRequired )
+ id += std::string( 1, Arg::delimiter() ) + "<" + valueId + ">";
+
+ id += ", ";
+ }
+
+ id += Arg::nameStartString() + _name;
+
+ if ( _valueRequired )
+ id += std::string( 1, Arg::delimiter() ) + "<" + valueId + ">";
+
+ return id;
+
+}
+
+inline bool Arg::operator==(const Arg& a) const
+{
+ if ( ( _flag != "" && _flag == a._flag ) || _name == a._name)
+ return true;
+ else
+ return false;
+}
+
+inline std::string Arg::getDescription() const
+{
+ std::string desc = "";
+ if ( _required )
+ desc = "(" + _requireLabel + ") ";
+
+// if ( _valueRequired )
+// desc += "(value required) ";
+
+ desc += _description;
+ return desc;
+}
+
+inline const std::string& Arg::getFlag() const { return _flag; }
+
+inline const std::string& Arg::getName() const { return _name; }
+
+inline bool Arg::isRequired() const { return _required; }
+
+inline bool Arg::isValueRequired() const { return _valueRequired; }
+
+inline bool Arg::isSet() const
+{
+ if ( _alreadySet && !_xorSet )
+ return true;
+ else
+ return false;
+}
+
+inline bool Arg::isIgnoreable() const { return _ignoreable; }
+
+inline void Arg::setRequireLabel( const std::string& s)
+{
+ _requireLabel = s;
+}
+
+inline bool Arg::argMatches( const std::string& argFlag ) const
+{
+ if ( ( argFlag == Arg::flagStartString() + _flag && _flag != "" ) ||
+ argFlag == Arg::nameStartString() + _name )
+ return true;
+ else
+ return false;
+}
+
+inline std::string Arg::toString() const
+{
+ std::string s = "";
+
+ if ( _flag != "" )
+ s += Arg::flagStartString() + _flag + " ";
+
+ s += "(" + Arg::nameStartString() + _name + ")";
+
+ return s;
+}
+
+inline void Arg::_checkWithVisitor() const
+{
+ if ( _visitor != NULL )
+ _visitor->visit();
+}
+
+/**
+ * Implementation of trimFlag.
+ */
+inline void Arg::trimFlag(std::string& flag, std::string& value) const
+{
+ int stop = 0;
+ for ( int i = 0; static_cast(i) < flag.length(); i++ )
+ if ( flag[i] == Arg::delimiter() )
+ {
+ stop = i;
+ break;
+ }
+
+ if ( stop > 1 )
+ {
+ value = flag.substr(stop+1);
+ flag = flag.substr(0,stop);
+ }
+
+}
+
+/**
+ * Implementation of _hasBlanks.
+ */
+inline bool Arg::_hasBlanks( const std::string& s ) const
+{
+ for ( int i = 1; static_cast(i) < s.length(); i++ )
+ if ( s[i] == Arg::blankChar() )
+ return true;
+
+ return false;
+}
+
+inline void Arg::forceRequired()
+{
+ _required = true;
+}
+
+inline void Arg::xorSet()
+{
+ _alreadySet = true;
+ _xorSet = true;
+}
+
+/**
+ * Overridden by Args that need to added to the end of the list.
+ */
+inline void Arg::addToList( std::list& argList ) const
+{
+ argList.push_front( const_cast(this) );
+}
+
+inline bool Arg::allowMore()
+{
+ return false;
+}
+
+inline bool Arg::acceptsMultipleValues()
+{
+ return _acceptsMultipleValues;
+}
+
+inline void Arg::reset()
+{
+ _xorSet = false;
+ _alreadySet = false;
+}
+
+//////////////////////////////////////////////////////////////////////
+//END Arg.cpp
+//////////////////////////////////////////////////////////////////////
+
+} //namespace TCLAP
+
+#endif
+
diff --git a/deps/include/tclap/ArgException.h b/deps/include/tclap/ArgException.h
new file mode 100644
index 0000000..3411aa9
--- /dev/null
+++ b/deps/include/tclap/ArgException.h
@@ -0,0 +1,200 @@
+// -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*-
+
+/******************************************************************************
+ *
+ * file: ArgException.h
+ *
+ * Copyright (c) 2003, Michael E. Smoot .
+ * All rights reverved.
+ *
+ * See the file COPYING in the top directory of this distribution for
+ * more information.
+ *
+ * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ *****************************************************************************/
+
+
+#ifndef TCLAP_ARG_EXCEPTION_H
+#define TCLAP_ARG_EXCEPTION_H
+
+#include
+#include
+
+namespace TCLAP {
+
+/**
+ * A simple class that defines and argument exception. Should be caught
+ * whenever a CmdLine is created and parsed.
+ */
+class ArgException : public std::exception
+{
+ public:
+
+ /**
+ * Constructor.
+ * \param text - The text of the exception.
+ * \param id - The text identifying the argument source.
+ * \param td - Text describing the type of ArgException it is.
+ * of the exception.
+ */
+ ArgException( const std::string& text = "undefined exception",
+ const std::string& id = "undefined",
+ const std::string& td = "Generic ArgException")
+ : std::exception(),
+ _errorText(text),
+ _argId( id ),
+ _typeDescription(td)
+ { }
+
+ /**
+ * Destructor.
+ */
+ virtual ~ArgException() throw() { }
+
+ /**
+ * Returns the error text.
+ */
+ std::string error() const { return ( _errorText ); }
+
+ /**
+ * Returns the argument id.
+ */
+ std::string argId() const
+ {
+ if ( _argId == "undefined" )
+ return " ";
+ else
+ return ( "Argument: " + _argId );
+ }
+
+ /**
+ * Returns the arg id and error text.
+ */
+ const char* what() const throw()
+ {
+ static std::string ex;
+ ex = _argId + " -- " + _errorText;
+ return ex.c_str();
+ }
+
+ /**
+ * Returns the type of the exception. Used to explain and distinguish
+ * between different child exceptions.
+ */
+ std::string typeDescription() const
+ {
+ return _typeDescription;
+ }
+
+
+ private:
+
+ /**
+ * The text of the exception message.
+ */
+ std::string _errorText;
+
+ /**
+ * The argument related to this exception.
+ */
+ std::string _argId;
+
+ /**
+ * Describes the type of the exception. Used to distinguish
+ * between different child exceptions.
+ */
+ std::string _typeDescription;
+
+};
+
+/**
+ * Thrown from within the child Arg classes when it fails to properly
+ * parse the argument it has been passed.
+ */
+class ArgParseException : public ArgException
+{
+ public:
+ /**
+ * Constructor.
+ * \param text - The text of the exception.
+ * \param id - The text identifying the argument source
+ * of the exception.
+ */
+ ArgParseException( const std::string& text = "undefined exception",
+ const std::string& id = "undefined" )
+ : ArgException( text,
+ id,
+ std::string( "Exception found while parsing " ) +
+ std::string( "the value the Arg has been passed." ))
+ { }
+};
+
+/**
+ * Thrown from CmdLine when the arguments on the command line are not
+ * properly specified, e.g. too many arguments, required argument missing, etc.
+ */
+class CmdLineParseException : public ArgException
+{
+ public:
+ /**
+ * Constructor.
+ * \param text - The text of the exception.
+ * \param id - The text identifying the argument source
+ * of the exception.
+ */
+ CmdLineParseException( const std::string& text = "undefined exception",
+ const std::string& id = "undefined" )
+ : ArgException( text,
+ id,
+ std::string( "Exception found when the values ") +
+ std::string( "on the command line do not meet ") +
+ std::string( "the requirements of the defined ") +
+ std::string( "Args." ))
+ { }
+};
+
+/**
+ * Thrown from Arg and CmdLine when an Arg is improperly specified, e.g.
+ * same flag as another Arg, same name, etc.
+ */
+class SpecificationException : public ArgException
+{
+ public:
+ /**
+ * Constructor.
+ * \param text - The text of the exception.
+ * \param id - The text identifying the argument source
+ * of the exception.
+ */
+ SpecificationException( const std::string& text = "undefined exception",
+ const std::string& id = "undefined" )
+ : ArgException( text,
+ id,
+ std::string("Exception found when an Arg object ")+
+ std::string("is improperly defined by the ") +
+ std::string("developer." ))
+ { }
+
+};
+
+class ExitException {
+public:
+ ExitException(int estat) : _estat(estat) {}
+
+ int getExitStatus() const { return _estat; }
+
+private:
+ int _estat;
+};
+
+} // namespace TCLAP
+
+#endif
+
diff --git a/deps/include/tclap/ArgTraits.h b/deps/include/tclap/ArgTraits.h
new file mode 100644
index 0000000..0b2c18f
--- /dev/null
+++ b/deps/include/tclap/ArgTraits.h
@@ -0,0 +1,87 @@
+// -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*-
+
+/******************************************************************************
+ *
+ * file: ArgTraits.h
+ *
+ * Copyright (c) 2007, Daniel Aarno, Michael E. Smoot .
+ * All rights reverved.
+ *
+ * See the file COPYING in the top directory of this distribution for
+ * more information.
+ *
+ * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ *****************************************************************************/
+
+// This is an internal tclap file, you should probably not have to
+// include this directly
+
+#ifndef TCLAP_ARGTRAITS_H
+#define TCLAP_ARGTRAITS_H
+
+namespace TCLAP {
+
+// We use two empty structs to get compile type specialization
+// function to work
+
+/**
+ * A value like argument value type is a value that can be set using
+ * operator>>. This is the default value type.
+ */
+struct ValueLike {
+ typedef ValueLike ValueCategory;
+ virtual ~ValueLike() {}
+};
+
+/**
+ * A string like argument value type is a value that can be set using
+ * operator=(string). Usefull if the value type contains spaces which
+ * will be broken up into individual tokens by operator>>.
+ */
+struct StringLike {
+ virtual ~StringLike() {}
+};
+
+/**
+ * A class can inherit from this object to make it have string like
+ * traits. This is a compile time thing and does not add any overhead
+ * to the inherenting class.
+ */
+struct StringLikeTrait {
+ typedef StringLike ValueCategory;
+ virtual ~StringLikeTrait() {}
+};
+
+/**
+ * A class can inherit from this object to make it have value like
+ * traits. This is a compile time thing and does not add any overhead
+ * to the inherenting class.
+ */
+struct ValueLikeTrait {
+ typedef ValueLike ValueCategory;
+ virtual ~ValueLikeTrait() {}
+};
+
+/**
+ * Arg traits are used to get compile type specialization when parsing
+ * argument values. Using an ArgTraits you can specify the way that
+ * values gets assigned to any particular type during parsing. The two
+ * supported types are StringLike and ValueLike.
+ */
+template
+struct ArgTraits {
+ typedef typename T::ValueCategory ValueCategory;
+ virtual ~ArgTraits() {}
+ //typedef ValueLike ValueCategory;
+};
+
+#endif
+
+} // namespace
diff --git a/deps/include/tclap/CmdLine.h b/deps/include/tclap/CmdLine.h
new file mode 100644
index 0000000..0fec8d8
--- /dev/null
+++ b/deps/include/tclap/CmdLine.h
@@ -0,0 +1,633 @@
+// -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*-
+
+/******************************************************************************
+ *
+ * file: CmdLine.h
+ *
+ * Copyright (c) 2003, Michael E. Smoot .
+ * Copyright (c) 2004, Michael E. Smoot, Daniel Aarno.
+ * All rights reverved.
+ *
+ * See the file COPYING in the top directory of this distribution for
+ * more information.
+ *
+ * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ *****************************************************************************/
+
+#ifndef TCLAP_CMDLINE_H
+#define TCLAP_CMDLINE_H
+
+#include
+#include
+#include
+#include
+
+#include
+#include
+#include
+#include
+
+#include
+#include
+
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include // Needed for exit(), which isn't defined in some envs.
+
+namespace TCLAP {
+
+template void DelPtr(T ptr)
+{
+ delete ptr;
+}
+
+template void ClearContainer(C &c)
+{
+ typedef typename C::value_type value_type;
+ std::for_each(c.begin(), c.end(), DelPtr);
+ c.clear();
+}
+
+
+/**
+ * The base class that manages the command line definition and passes
+ * along the parsing to the appropriate Arg classes.
+ */
+class CmdLine : public CmdLineInterface
+{
+ protected:
+
+ /**
+ * The list of arguments that will be tested against the
+ * command line.
+ */
+ std::list _argList;
+
+ /**
+ * The name of the program. Set to argv[0].
+ */
+ std::string _progName;
+
+ /**
+ * A message used to describe the program. Used in the usage output.
+ */
+ std::string _message;
+
+ /**
+ * The version to be displayed with the --version switch.
+ */
+ std::string _version;
+
+ /**
+ * The number of arguments that are required to be present on
+ * the command line. This is set dynamically, based on the
+ * Args added to the CmdLine object.
+ */
+ int _numRequired;
+
+ /**
+ * The character that is used to separate the argument flag/name
+ * from the value. Defaults to ' ' (space).
+ */
+ char _delimiter;
+
+ /**
+ * The handler that manages xoring lists of args.
+ */
+ XorHandler _xorHandler;
+
+ /**
+ * A list of Args to be explicitly deleted when the destructor
+ * is called. At the moment, this only includes the three default
+ * Args.
+ */
+ std::list _argDeleteOnExitList;
+
+ /**
+ * A list of Visitors to be explicitly deleted when the destructor
+ * is called. At the moment, these are the Vistors created for the
+ * default Args.
+ */
+ std::list _visitorDeleteOnExitList;
+
+ /**
+ * Object that handles all output for the CmdLine.
+ */
+ CmdLineOutput* _output;
+
+ /**
+ * Should CmdLine handle parsing exceptions internally?
+ */
+ bool _handleExceptions;
+
+ /**
+ * Throws an exception listing the missing args.
+ */
+ void missingArgsException();
+
+ /**
+ * Checks whether a name/flag string matches entirely matches
+ * the Arg::blankChar. Used when multiple switches are combined
+ * into a single argument.
+ * \param s - The message to be used in the usage.
+ */
+ bool _emptyCombined(const std::string& s);
+
+ /**
+ * Perform a delete ptr; operation on ptr when this object is deleted.
+ */
+ void deleteOnExit(Arg* ptr);
+
+ /**
+ * Perform a delete ptr; operation on ptr when this object is deleted.
+ */
+ void deleteOnExit(Visitor* ptr);
+
+private:
+
+ /**
+ * Prevent accidental copying.
+ */
+ CmdLine(const CmdLine& rhs);
+ CmdLine& operator=(const CmdLine& rhs);
+
+ /**
+ * Encapsulates the code common to the constructors
+ * (which is all of it).
+ */
+ void _constructor();
+
+
+ /**
+ * Is set to true when a user sets the output object. We use this so
+ * that we don't delete objects that are created outside of this lib.
+ */
+ bool _userSetOutput;
+
+ /**
+ * Whether or not to automatically create help and version switches.
+ */
+ bool _helpAndVersion;
+
+ public:
+
+ /**
+ * Command line constructor. Defines how the arguments will be
+ * parsed.
+ * \param message - The message to be used in the usage
+ * output.
+ * \param delimiter - The character that is used to separate
+ * the argument flag/name from the value. Defaults to ' ' (space).
+ * \param version - The version number to be used in the
+ * --version switch.
+ * \param helpAndVersion - Whether or not to create the Help and
+ * Version switches. Defaults to true.
+ */
+ CmdLine(const std::string& message,
+ const char delimiter = ' ',
+ const std::string& version = "none",
+ bool helpAndVersion = true);
+
+ /**
+ * Deletes any resources allocated by a CmdLine object.
+ */
+ virtual ~CmdLine();
+
+ /**
+ * Adds an argument to the list of arguments to be parsed.
+ * \param a - Argument to be added.
+ */
+ void add( Arg& a );
+
+ /**
+ * An alternative add. Functionally identical.
+ * \param a - Argument to be added.
+ */
+ void add( Arg* a );
+
+ /**
+ * Add two Args that will be xor'd. If this method is used, add does
+ * not need to be called.
+ * \param a - Argument to be added and xor'd.
+ * \param b - Argument to be added and xor'd.
+ */
+ void xorAdd( Arg& a, Arg& b );
+
+ /**
+ * Add a list of Args that will be xor'd. If this method is used,
+ * add does not need to be called.
+ * \param xors - List of Args to be added and xor'd.
+ */
+ void xorAdd( std::vector& xors );
+
+ /**
+ * Parses the command line.
+ * \param argc - Number of arguments.
+ * \param argv - Array of arguments.
+ */
+ void parse(int argc, const char * const * argv);
+
+ /**
+ * Parses the command line.
+ * \param args - A vector of strings representing the args.
+ * args[0] is still the program name.
+ */
+ void parse(std::vector& args);
+
+ /**
+ *
+ */
+ CmdLineOutput* getOutput();
+
+ /**
+ *
+ */
+ void setOutput(CmdLineOutput* co);
+
+ /**
+ *
+ */
+ std::string& getVersion();
+
+ /**
+ *
+ */
+ std::string& getProgramName();
+
+ /**
+ *
+ */
+ std::list& getArgList();
+
+ /**
+ *
+ */
+ XorHandler& getXorHandler();
+
+ /**
+ *
+ */
+ char getDelimiter();
+
+ /**
+ *
+ */
+ std::string& getMessage();
+
+ /**
+ *
+ */
+ bool hasHelpAndVersion();
+
+ /**
+ * Disables or enables CmdLine's internal parsing exception handling.
+ *
+ * @param state Should CmdLine handle parsing exceptions internally?
+ */
+ void setExceptionHandling(const bool state);
+
+ /**
+ * Returns the current state of the internal exception handling.
+ *
+ * @retval true Parsing exceptions are handled internally.
+ * @retval false Parsing exceptions are propagated to the caller.
+ */
+ bool getExceptionHandling() const;
+
+ /**
+ * Allows the CmdLine object to be reused.
+ */
+ void reset();
+
+};
+
+
+///////////////////////////////////////////////////////////////////////////////
+//Begin CmdLine.cpp
+///////////////////////////////////////////////////////////////////////////////
+
+inline CmdLine::CmdLine(const std::string& m,
+ char delim,
+ const std::string& v,
+ bool help )
+ :
+ _argList(std::list()),
+ _progName("not_set_yet"),
+ _message(m),
+ _version(v),
+ _numRequired(0),
+ _delimiter(delim),
+ _xorHandler(XorHandler()),
+ _argDeleteOnExitList(std::list()),
+ _visitorDeleteOnExitList(std::list()),
+ _output(0),
+ _handleExceptions(true),
+ _userSetOutput(false),
+ _helpAndVersion(help)
+{
+ _constructor();
+}
+
+inline CmdLine::~CmdLine()
+{
+ ClearContainer(_argDeleteOnExitList);
+ ClearContainer(_visitorDeleteOnExitList);
+
+ if ( !_userSetOutput ) {
+ delete _output;
+ _output = 0;
+ }
+}
+
+inline void CmdLine::_constructor()
+{
+ _output = new StdOutput;
+
+ Arg::setDelimiter( _delimiter );
+
+ Visitor* v;
+
+ if ( _helpAndVersion )
+ {
+ v = new HelpVisitor( this, &_output );
+ SwitchArg* help = new SwitchArg("h","help",
+ "Displays usage information and exits.",
+ false, v);
+ add( help );
+ deleteOnExit(help);
+ deleteOnExit(v);
+
+ v = new VersionVisitor( this, &_output );
+ SwitchArg* vers = new SwitchArg("","version",
+ "Displays version information and exits.",
+ false, v);
+ add( vers );
+ deleteOnExit(vers);
+ deleteOnExit(v);
+ }
+
+ v = new IgnoreRestVisitor();
+ SwitchArg* ignore = new SwitchArg(Arg::flagStartString(),
+ Arg::ignoreNameString(),
+ "Ignores the rest of the labeled arguments following this flag.",
+ false, v);
+ add( ignore );
+ deleteOnExit(ignore);
+ deleteOnExit(v);
+}
+
+inline void CmdLine::xorAdd( std::vector& ors )
+{
+ _xorHandler.add( ors );
+
+ for (ArgVectorIterator it = ors.begin(); it != ors.end(); it++)
+ {
+ (*it)->forceRequired();
+ (*it)->setRequireLabel( "OR required" );
+ add( *it );
+ }
+}
+
+inline void CmdLine::xorAdd( Arg& a, Arg& b )
+{
+ std::vector ors;
+ ors.push_back( &a );
+ ors.push_back( &b );
+ xorAdd( ors );
+}
+
+inline void CmdLine::add( Arg& a )
+{
+ add( &a );
+}
+
+inline void CmdLine::add( Arg* a )
+{
+ for( ArgListIterator it = _argList.begin(); it != _argList.end(); it++ )
+ if ( *a == *(*it) )
+ throw( SpecificationException(
+ "Argument with same flag/name already exists!",
+ a->longID() ) );
+
+ a->addToList( _argList );
+
+ if ( a->isRequired() )
+ _numRequired++;
+}
+
+
+inline void CmdLine::parse(int argc, const char * const * argv)
+{
+ // this step is necessary so that we have easy access to
+ // mutable strings.
+ std::vector args;
+ for (int i = 0; i < argc; i++)
+ args.push_back(argv[i]);
+
+ parse(args);
+}
+
+inline void CmdLine::parse(std::vector& args)
+{
+ bool shouldExit = false;
+ int estat = 0;
+
+ try {
+ _progName = args.front();
+ args.erase(args.begin());
+
+ int requiredCount = 0;
+
+ for (int i = 0; static_cast(i) < args.size(); i++)
+ {
+ bool matched = false;
+ for (ArgListIterator it = _argList.begin();
+ it != _argList.end(); it++) {
+ if ( (*it)->processArg( &i, args ) )
+ {
+ requiredCount += _xorHandler.check( *it );
+ matched = true;
+ break;
+ }
+ }
+
+ // checks to see if the argument is an empty combined
+ // switch and if so, then we've actually matched it
+ if ( !matched && _emptyCombined( args[i] ) )
+ matched = true;
+
+ if ( !matched && !Arg::ignoreRest() )
+ throw(CmdLineParseException("Couldn't find match "
+ "for argument",
+ args[i]));
+ }
+
+ if ( requiredCount < _numRequired )
+ missingArgsException();
+
+ if ( requiredCount > _numRequired )
+ throw(CmdLineParseException("Too many arguments!"));
+
+ } catch ( ArgException& e ) {
+ // If we're not handling the exceptions, rethrow.
+ if ( !_handleExceptions) {
+ throw;
+ }
+
+ try {
+ _output->failure(*this,e);
+ } catch ( ExitException &ee ) {
+ estat = ee.getExitStatus();
+ shouldExit = true;
+ }
+ } catch (ExitException &ee) {
+ // If we're not handling the exceptions, rethrow.
+ if ( !_handleExceptions) {
+ throw;
+ }
+
+ estat = ee.getExitStatus();
+ shouldExit = true;
+ }
+
+ if (shouldExit)
+ exit(estat);
+}
+
+inline bool CmdLine::_emptyCombined(const std::string& s)
+{
+ if ( s.length() > 0 && s[0] != Arg::flagStartChar() )
+ return false;
+
+ for ( int i = 1; static_cast(i) < s.length(); i++ )
+ if ( s[i] != Arg::blankChar() )
+ return false;
+
+ return true;
+}
+
+inline void CmdLine::missingArgsException()
+{
+ int count = 0;
+
+ std::string missingArgList;
+ for (ArgListIterator it = _argList.begin(); it != _argList.end(); it++)
+ {
+ if ( (*it)->isRequired() && !(*it)->isSet() )
+ {
+ missingArgList += (*it)->getName();
+ missingArgList += ", ";
+ count++;
+ }
+ }
+ missingArgList = missingArgList.substr(0,missingArgList.length()-2);
+
+ std::string msg;
+ if ( count > 1 )
+ msg = "Required arguments missing: ";
+ else
+ msg = "Required argument missing: ";
+
+ msg += missingArgList;
+
+ throw(CmdLineParseException(msg));
+}
+
+inline void CmdLine::deleteOnExit(Arg* ptr)
+{
+ _argDeleteOnExitList.push_back(ptr);
+}
+
+inline void CmdLine::deleteOnExit(Visitor* ptr)
+{
+ _visitorDeleteOnExitList.push_back(ptr);
+}
+
+inline CmdLineOutput* CmdLine::getOutput()
+{
+ return _output;
+}
+
+inline void CmdLine::setOutput(CmdLineOutput* co)
+{
+ if ( !_userSetOutput )
+ delete _output;
+ _userSetOutput = true;
+ _output = co;
+}
+
+inline std::string& CmdLine::getVersion()
+{
+ return _version;
+}
+
+inline std::string& CmdLine::getProgramName()
+{
+ return _progName;
+}
+
+inline std::list& CmdLine::getArgList()
+{
+ return _argList;
+}
+
+inline XorHandler& CmdLine::getXorHandler()
+{
+ return _xorHandler;
+}
+
+inline char CmdLine::getDelimiter()
+{
+ return _delimiter;
+}
+
+inline std::string& CmdLine::getMessage()
+{
+ return _message;
+}
+
+inline bool CmdLine::hasHelpAndVersion()
+{
+ return _helpAndVersion;
+}
+
+inline void CmdLine::setExceptionHandling(const bool state)
+{
+ _handleExceptions = state;
+}
+
+inline bool CmdLine::getExceptionHandling() const
+{
+ return _handleExceptions;
+}
+
+inline void CmdLine::reset()
+{
+ for( ArgListIterator it = _argList.begin(); it != _argList.end(); it++ )
+ (*it)->reset();
+
+ _progName.clear();
+}
+
+///////////////////////////////////////////////////////////////////////////////
+//End CmdLine.cpp
+///////////////////////////////////////////////////////////////////////////////
+
+
+
+} //namespace TCLAP
+#endif
diff --git a/deps/include/tclap/CmdLineInterface.h b/deps/include/tclap/CmdLineInterface.h
new file mode 100644
index 0000000..1b25e9b
--- /dev/null
+++ b/deps/include/tclap/CmdLineInterface.h
@@ -0,0 +1,150 @@
+
+/******************************************************************************
+ *
+ * file: CmdLineInterface.h
+ *
+ * Copyright (c) 2003, Michael E. Smoot .
+ * Copyright (c) 2004, Michael E. Smoot, Daniel Aarno.
+ * All rights reverved.
+ *
+ * See the file COPYING in the top directory of this distribution for
+ * more information.
+ *
+ * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ *****************************************************************************/
+
+#ifndef TCLAP_COMMANDLINE_INTERFACE_H
+#define TCLAP_COMMANDLINE_INTERFACE_H
+
+#include
+#include
+#include
+#include