diff --git a/CMakeLists.txt b/CMakeLists.txt index 23da468..89c6361 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,6 +29,7 @@ set(docopt_HEADERS docopt_private.h docopt_util.h docopt_value.h + docopt_api.h ) #============================================================================ diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000..4c81b4c --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,16 @@ +skip_tags: true + +environment: + PYTHON: C:\\Python27-x64 + APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 + +install: + - set PATH=%PYTHON%;%PYTHON%\\Scripts\\;%PATH% + +build: false + +build_script: + - mkdir build && cd build + - cmake -G "Visual Studio 15 2017 Win64" .. + - cmake --build . --config Debug + diff --git a/docopt.h b/docopt.h index 4c40741..e4d494e 100644 --- a/docopt.h +++ b/docopt.h @@ -9,37 +9,13 @@ #ifndef docopt__docopt_h_ #define docopt__docopt_h_ +#include "docopt_api.h" #include "docopt_value.h" #include #include #include -#ifdef DOCOPT_HEADER_ONLY - #define DOCOPT_INLINE inline - #define DOCOPT_API -#else - #define DOCOPT_INLINE - - // With Microsoft Visual Studio, export certain symbols so they - // are available to users of docopt.dll (shared library). The DOCOPT_DLL - // macro should be defined if building a DLL (with Visual Studio), - // and by clients using the DLL. The CMakeLists.txt and the - // docopt-config.cmake it generates handle this. - #ifdef DOCOPT_DLL - // Whoever is *building* the DLL should define DOCOPT_EXPORTS. - // The CMakeLists.txt that comes with docopt does this. - // Clients of docopt.dll should NOT define DOCOPT_EXPORTS. - #ifdef DOCOPT_EXPORTS - #define DOCOPT_API __declspec(dllexport) - #else - #define DOCOPT_API __declspec(dllimport) - #endif - #else - #define DOCOPT_API - #endif -#endif - namespace docopt { // Usage string could not be parsed (ie, the developer did something wrong) @@ -67,7 +43,8 @@ namespace docopt { /// @throws DocoptExitHelp if 'help' is true and the user has passed the '--help' argument /// @throws DocoptExitVersion if 'version' is true and the user has passed the '--version' argument /// @throws DocoptArgumentError if the user's argv did not match the usage patterns - std::map DOCOPT_API docopt_parse(std::string const& doc, + DOCOPT_API + std::map docopt_parse(std::string const& doc, std::vector const& argv, bool help = true, bool version = true, @@ -80,7 +57,8 @@ namespace docopt { /// * DocoptExitHelp - print usage string and terminate (with exit code 0) /// * DocoptExitVersion - print version and terminate (with exit code 0) /// * DocoptArgumentError - print error and usage string and terminate (with exit code -1) - std::map DOCOPT_API docopt(std::string const& doc, + DOCOPT_API + std::map docopt(std::string const& doc, std::vector const& argv, bool help = true, std::string const& version = {}, diff --git a/docopt_api.h b/docopt_api.h new file mode 100644 index 0000000..8d774e9 --- /dev/null +++ b/docopt_api.h @@ -0,0 +1,35 @@ +// +// docopt_api.h +// docopt +// +// + +#ifndef docopt__api_h_ +#define docopt__api_h_ + +#ifdef DOCOPT_HEADER_ONLY + #define DOCOPT_INLINE inline + #define DOCOPT_API +#else + #define DOCOPT_INLINE + + // With Microsoft Visual Studio, export certain symbols so they + // are available to users of docopt.dll (shared library). The DOCOPT_DLL + // macro should be defined if building a DLL (with Visual Studio), + // and by clients using the DLL. The CMakeLists.txt and the + // docopt-config.cmake it generates handle this. + #ifdef DOCOPT_DLL + // Whoever is *building* the DLL should define DOCOPT_EXPORTS. + // The CMakeLists.txt that comes with docopt does this. + // Clients of docopt.dll should NOT define DOCOPT_EXPORTS. + #ifdef DOCOPT_EXPORTS + #define DOCOPT_API __declspec(dllexport) + #else + #define DOCOPT_API __declspec(dllimport) + #endif + #else + #define DOCOPT_API + #endif +#endif + +#endif /* defined(docopt__api_h_) */ \ No newline at end of file diff --git a/docopt_value.h b/docopt_value.h index 829ee55..ce7f280 100644 --- a/docopt_value.h +++ b/docopt_value.h @@ -9,6 +9,8 @@ #ifndef docopt__value_h_ #define docopt__value_h_ +#include "docopt_api.h" + #include #include #include @@ -105,7 +107,7 @@ namespace docopt { }; /// Write out the contents to the ostream - std::ostream& operator<<(std::ostream&, value const&); + DOCOPT_API std::ostream& operator<<(std::ostream&, value const&); } namespace std {