changeset 561:14ac7c28c0ea

Options: add export macros
author David Demelier <markand@malikania.fr>
date Tue, 21 Jun 2016 14:23:45 +0200
parents 8012eb3ef579
children b6c6d98054d9
files modules/options/options.hpp
diffstat 1 files changed, 37 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/modules/options/options.hpp	Tue Jun 21 14:21:01 2016 +0200
+++ b/modules/options/options.hpp	Tue Jun 21 14:23:45 2016 +0200
@@ -1,5 +1,5 @@
 /*
- * options.h -- parse Unix command line options
+ * options.hpp -- parse Unix command line options
  *
  * Copyright (c) 2015 David Demelier <markand@malikania.fr>
  *
@@ -20,10 +20,43 @@
 #define OPTIONS_HPP
 
 /**
- * \file options.h
+ * \file options.hpp
  * \brief Basic Unix options parser.
  */
 
+/**
+ * \page options Options parser.
+ *
+ * ## Export macros
+ *
+ * You must define `OPTIONS_DLL` globally and `OPTIONS_BUILDING_DLL` when compiling the library if you want a DLL, alternatively you can provide
+ * your own `OPTIONS_EXPORT` macro instead.
+ */
+
+/**
+ * \cond OPTIONS_HIDDEN_SYMBOLS
+ */
+
+#if !defined(OPTIONS_EXPORT)
+#   if defined(OPTIONS_DLL)
+#       if defined(_WIN32)
+#           if defined(OPTIONS_BUILDING_DLL)
+#               define OPTIONS_EXPORT __declspec(dllexport)
+#           else
+#               define OPTIONS_EXPORT __declspec(dllimport)
+#           endif
+#       else
+#           define OPTIONS_EXPORT
+#       endif
+#   else
+#       define OPTIONS_EXPORT
+#   endif
+#endif
+
+/**
+ * \endcond
+ */
+
 #include <exception>
 #include <map>
 #include <string>
@@ -130,7 +163,7 @@
  * \throw MissingValue
  * \throw InvalidOption
  */
-Result read(std::vector<std::string> &args, const Options &definition);
+OPTIONS_EXPORT Result read(std::vector<std::string> &args, const Options &definition);
 
 /**
  * Overloaded function for usage with main() arguments.
@@ -143,7 +176,7 @@
  * \throw MissingValue
  * \throw InvalidOption
  */
-Result read(int &argc, char **&argv, const Options &definition);
+OPTIONS_EXPORT Result read(int &argc, char **&argv, const Options &definition);
 
 } // !option