changeset 560:8012eb3ef579

Ini: add export macros
author David Demelier <markand@malikania.fr>
date Tue, 21 Jun 2016 14:21:01 +0200
parents 5554ba5dc1dc
children 14ac7c28c0ea
files modules/ini/ini.hpp
diffstat 1 files changed, 35 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/modules/ini/ini.hpp	Tue Jun 21 13:44:52 2016 +0200
+++ b/modules/ini/ini.hpp	Tue Jun 21 14:21:01 2016 +0200
@@ -29,6 +29,11 @@
  * \page Ini Ini
  * \brief Extended .ini file parser.
  *
+ * ## Export macros
+ *
+ * You must define `INI_DLL` globally and `INI_BUILDING_DLL` when compiling the library if you want a DLL, alternatively you can provide
+ * your own `INI_EXPORT` macro instead.
+ *
  *   - \subpage ini-syntax
  */
 
@@ -103,6 +108,30 @@
  * ````
  */
 
+/**
+ * \cond INI_HIDDEN_SYMBOLS
+ */
+
+#if !defined(INI_EXPORT)
+#   if defined(INI_DLL)
+#       if defined(_WIN32)
+#           if defined(INI_BUILDING_DLL)
+#               define INI_EXPORT __declspec(dllexport)
+#           else
+#               define INI_EXPORT __declspec(dllimport)
+#           endif
+#       else
+#           define INI_EXPORT
+#       endif
+#   else
+#       define INI_EXPORT
+#   endif
+#endif
+
+/**
+ * \endcond
+ */
+
 #include <algorithm>
 #include <cassert>
 #include <exception>
@@ -557,7 +586,7 @@
  * \return the list of tokens
  * \throws Error on errors
  */
-Tokens analyse(std::istreambuf_iterator<char> it, std::istreambuf_iterator<char> end);
+INI_EXPORT Tokens analyse(std::istreambuf_iterator<char> it, std::istreambuf_iterator<char> end);
 
 /**
  * Overloaded function for stream.
@@ -566,7 +595,7 @@
  * \return the list of tokens
  * \throws Error on errors
  */
-Tokens analyse(std::istream &stream);
+INI_EXPORT Tokens analyse(std::istream &stream);
 
 /**
  * Parse the produced tokens.
@@ -576,7 +605,7 @@
  * \return the document
  * \throw Error on errors
  */
-Document parse(const Tokens &tokens, const std::string &path = ".");
+INI_EXPORT Document parse(const Tokens &tokens, const std::string &path = ".");
 
 /**
  * Parse a file.
@@ -585,7 +614,7 @@
  * \return the document
  * \throw Error on errors
  */
-Document readFile(const std::string &filename);
+INI_EXPORT Document readFile(const std::string &filename);
 
 /**
  * Parse a string.
@@ -596,14 +625,14 @@
  * \return the document
  * \throw Error on errors
  */
-Document readString(const std::string &buffer);
+INI_EXPORT Document readString(const std::string &buffer);
 
 /**
  * Show all tokens and their description.
  *
  * \param tokens the tokens
  */
-void dump(const Tokens &tokens);
+INI_EXPORT void dump(const Tokens &tokens);
 
 } // !ini