diff modules/unicode/generator/make-unicode/unicode.hpp @ 562:b6c6d98054d9

Unicode: add export macros
author David Demelier <markand@malikania.fr>
date Tue, 21 Jun 2016 14:27:37 +0200
parents f48bb09bccc7
children
line wrap: on
line diff
--- a/modules/unicode/generator/make-unicode/unicode.hpp	Tue Jun 21 14:23:45 2016 +0200
+++ b/modules/unicode/generator/make-unicode/unicode.hpp	Tue Jun 21 14:27:37 2016 +0200
@@ -26,6 +26,39 @@
  * \warning These files are auto-generated!
  */
 
+/**
+ * \page unicode Basic unicode management.
+ *
+ * ## Export macros
+ *
+ * You must define `UNICODE_DLL` globally and `UNICODE_BUILDING_DLL` when compiling the library if you want a DLL, alternatively you can provide
+ * your own `UNICODE_EXPORT` macro instead.
+ */
+
+/**
+ * \cond UNICODE_HIDDEN_SYMBOLS
+ */
+
+#if !defined(UNICODE_EXPORT)
+#   if defined(UNICODE_DLL)
+#       if defined(_WIN32)
+#           if defined(UNICODE_BUILDING_DLL)
+#               define UNICODE_EXPORT __declspec(dllexport)
+#           else
+#               define UNICODE_EXPORT __declspec(dllimport)
+#           endif
+#       else
+#           define UNICODE_EXPORT
+#       endif
+#   else
+#       define UNICODE_EXPORT
+#   endif
+#endif
+
+/**
+ * \endcond
+ */
+
 #include <stdexcept>
 #include <string>
 
@@ -40,7 +73,7 @@
  * \param point the unicode code point
  * \param res the output buffer
  */
-void encode(char32_t point, char res[5]) noexcept;
+UNICODE_EXPORT void encode(char32_t point, char res[5]) noexcept;
 
 /**
  * Decode the multibyte buffer into an unicode code point.
@@ -48,7 +81,7 @@
  * \param c the code point destination
  * \param res the multibyte string.
  */
-void decode(char32_t &c, const char *res) noexcept;
+UNICODE_EXPORT void decode(char32_t &c, const char *res) noexcept;
 
 /**
  * Get the number of bytes for the first multi byte character from a
@@ -60,7 +93,7 @@
  * \param c the first multi byte character
  * \return the number of bytes [1-4] or -1 if invalid
  */
-int nbytesUtf8(char c) noexcept;
+UNICODE_EXPORT int nbytesUtf8(char c) noexcept;
 
 /**
  * Get the number of bytes for the unicode point.
@@ -68,7 +101,7 @@
  * \param point the unicode point
  * \return the number of bytes [1-4] or -1 if invalid
  */
-int nbytesPoint(char32_t point) noexcept;
+UNICODE_EXPORT int nbytesPoint(char32_t point) noexcept;
 
 /**
  * Get real number of character in a string.
@@ -77,7 +110,7 @@
  * \return the length
  * \throw std::invalid_argument on invalid sequence
  */
-unsigned length(const std::string &str);
+UNICODE_EXPORT unsigned length(const std::string &str);
 
 /**
  * Iterate over all real characters in the UTF-8 string.
@@ -113,7 +146,7 @@
  * \return the UTF-8 string
  * \throw std::invalid_argument on invalid sequence
  */
-std::string toUtf8(const std::u32string &array);
+UNICODE_EXPORT std::string toUtf8(const std::u32string &array);
 
 /**
  * Convert a UTF-8 string to UTF-32 string.
@@ -122,7 +155,7 @@
  * \return the UTF-32 string
  * \throw std::invalid_argument on invalid sequence
  */
-std::u32string toUtf32(const std::string &str);
+UNICODE_EXPORT std::u32string toUtf32(const std::string &str);
 
 /**
  * Check if the unicode character is space.
@@ -130,7 +163,7 @@
  * \param c the character
  * \return true if space
  */
-bool isspace(char32_t c) noexcept;
+UNICODE_EXPORT bool isspace(char32_t c) noexcept;
 
 /**
  * Check if the unicode character is digit.
@@ -138,7 +171,7 @@
  * \param c the character
  * \return true if digit
  */
-bool isdigit(char32_t c) noexcept;
+UNICODE_EXPORT bool isdigit(char32_t c) noexcept;
 
 /**
  * Check if the unicode character is alpha category.
@@ -146,7 +179,7 @@
  * \param c the character
  * \return true if alpha
  */
-bool isalpha(char32_t c) noexcept;
+UNICODE_EXPORT bool isalpha(char32_t c) noexcept;
 
 /**
  * Check if the unicode character is upper case.
@@ -154,7 +187,7 @@
  * \param c the character
  * \return true if upper case
  */
-bool isupper(char32_t c) noexcept;
+UNICODE_EXPORT bool isupper(char32_t c) noexcept;
 
 /**
  * Check if the unicode character is lower case.
@@ -162,7 +195,7 @@
  * \param c the character
  * \return true if lower case
  */
-bool islower(char32_t c) noexcept;
+UNICODE_EXPORT bool islower(char32_t c) noexcept;
 
 /**
  * Check if the unicode character is title case.
@@ -170,7 +203,7 @@
  * \param c the character
  * \return true if title case
  */
-bool istitle(char32_t c) noexcept;
+UNICODE_EXPORT bool istitle(char32_t c) noexcept;
 
 /**
  * Convert to upper case.
@@ -178,7 +211,7 @@
  * \param c the character
  * \return the upper case character
  */
-char32_t toupper(char32_t c) noexcept;
+UNICODE_EXPORT char32_t toupper(char32_t c) noexcept;
 
 /**
  * Convert to lower case.
@@ -186,7 +219,7 @@
  * \param c the character
  * \return the lower case character
  */
-char32_t tolower(char32_t c) noexcept;
+UNICODE_EXPORT char32_t tolower(char32_t c) noexcept;
 
 /**
  * Convert to title case.
@@ -194,7 +227,7 @@
  * \param c the character
  * \return the title case character
  */
-char32_t totitle(char32_t c) noexcept;
+UNICODE_EXPORT char32_t totitle(char32_t c) noexcept;
 
 /**
  * Convert the UTF-32 string to upper case.