-
Notifications
You must be signed in to change notification settings - Fork 148
DLL-inteface for operator<< (MSVC compatibility) #114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 2 commits
def54d4
915e57e
c36c797
27a3c75
682acc2
591799b
578ec0f
eb69580
56d671a
2f5d711
77c0318
e2fa032
d5da55c
125faf3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,37 +9,13 @@ | |
#ifndef docopt__docopt_h_ | ||
#define docopt__docopt_h_ | ||
|
||
#include "docopt_api.h" | ||
#include "docopt_value.h" | ||
|
||
#include <map> | ||
#include <vector> | ||
#include <string> | ||
|
||
#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<std::string, value> DOCOPT_API docopt_parse(std::string const& doc, | ||
DOCOPT_API | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm a little nervous about swapping the order of these (the return type and the annotation). Was this intentional? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. __declspec(dllexport)/__declspec(dllimport) should be of left-side */& (MSVC specfic). This change for one-style with operator<< |
||
std::map<std::string, value> docopt_parse(std::string const& doc, | ||
std::vector<std::string> 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<std::string, value> DOCOPT_API docopt(std::string const& doc, | ||
DOCOPT_API | ||
std::map<std::string, value> docopt(std::string const& doc, | ||
std::vector<std::string> const& argv, | ||
bool help = true, | ||
std::string const& version = {}, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// | ||
// docopt.h | ||
// docopt | ||
// | ||
// Created by Dmitriy Vetutnev on 2019-09-05. | ||
// Copyright (c) 2019 Dmitriy Vetutnev. All rights reserved. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we remove the attribution and copyright here? I don't think we necessarily need any copyright attribution outside of the top one. (In other words, I'm not asking you to change it match the docopt.h header, just leave only the lines 1-4 and delete 5 and 6). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, this lines removed |
||
// | ||
|
||
#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_) */ |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,8 @@ | |
#ifndef docopt__value_h_ | ||
#define docopt__value_h_ | ||
|
||
#include "docopt_api.h" | ||
|
||
#include <stdexcept> | ||
#include <string> | ||
#include <vector> | ||
|
@@ -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&, const value&); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please change back to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, changed |
||
} | ||
|
||
namespace std { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain why you're doing this? I don't necessarily oppose it but would like to understand the justification. (Especially because you labeled this as something to do with GCC, which shouldn't be an issue).
One reason I like the "docopt::" in the definitions is that it catches bugs (if a function gets defined that didn't have a declaration).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, use previous style