diff --git a/include/zim/archive.h b/include/zim/archive.h index e14ae7aff..1c6f0f94d 100644 --- a/include/zim/archive.h +++ b/include/zim/archive.h @@ -53,7 +53,7 @@ namespace zim * * All methods of archive may throw an `ZimFileFormatError` if the file is invalid. */ - class Archive + class LIBZIM_API Archive { public: template class EntryRange; diff --git a/include/zim/blob.h b/include/zim/blob.h index 2b0662dd7..23f2fdcad 100644 --- a/include/zim/blob.h +++ b/include/zim/blob.h @@ -35,7 +35,7 @@ namespace zim * * All `Blob`'s methods are threadsafe. */ - class Blob + class LIBZIM_API Blob { public: // types using DataPtr = std::shared_ptr; diff --git a/include/zim/entry.h b/include/zim/entry.h index 6944aa6a3..cbcea78d4 100644 --- a/include/zim/entry.h +++ b/include/zim/entry.h @@ -36,7 +36,7 @@ namespace zim * * All `Entry`'s methods are threadsafe. */ - class Entry + class LIBZIM_API Entry { public: explicit Entry(std::shared_ptr file_, entry_index_type idx_); diff --git a/include/zim/error.h b/include/zim/error.h index fb9a4afd2..25f2b74b3 100644 --- a/include/zim/error.h +++ b/include/zim/error.h @@ -20,13 +20,15 @@ #ifndef ZIM_ERROR_H #define ZIM_ERROR_H +#include "zim.h" + #include #include #include namespace zim { - class ZimFileFormatError : public std::runtime_error + class LIBZIM_API ZimFileFormatError : public std::runtime_error { public: explicit ZimFileFormatError(const std::string& msg) @@ -34,7 +36,7 @@ namespace zim { } }; - class InvalidType: public std::logic_error + class LIBZIM_API InvalidType: public std::logic_error { public: explicit InvalidType(const std::string& msg) @@ -42,7 +44,7 @@ namespace zim {} }; - class EntryNotFound : public std::runtime_error + class LIBZIM_API EntryNotFound : public std::runtime_error { public: explicit EntryNotFound(const std::string& msg) @@ -54,7 +56,7 @@ namespace zim * * Most exceptions actually thrown are inheriting this exception. */ - class CreatorError : public std::runtime_error + class LIBZIM_API CreatorError : public std::runtime_error { public: explicit CreatorError(const std::string& message) @@ -63,7 +65,7 @@ namespace zim }; /* Exception thrown when a entry cannot be added to the Creator.*/ - class InvalidEntry : public CreatorError + class LIBZIM_API InvalidEntry : public CreatorError { public: explicit InvalidEntry(const std::string& message) @@ -81,7 +83,7 @@ namespace zim * If a incoherence has been detected in those implementations a * `IncoherentImplementationError` will be thrown. */ - class IncoherentImplementationError : public CreatorError + class LIBZIM_API IncoherentImplementationError : public CreatorError { public: explicit IncoherentImplementationError(const std::string& message) @@ -113,7 +115,7 @@ namespace zim * } * ``` */ - class AsyncError : public CreatorError + class LIBZIM_API AsyncError : public CreatorError { public: explicit AsyncError(const std::exception_ptr exception) @@ -149,7 +151,7 @@ namespace zim * If the creator is in error state (mostly because a AsyncError has already * being thrown), any call to any method on it will thrown a `CreatorStateError`. */ - class CreatorStateError : public CreatorError + class LIBZIM_API CreatorStateError : public CreatorError { public: explicit CreatorStateError() diff --git a/include/zim/item.h b/include/zim/item.h index 765b78a41..07ec0607a 100644 --- a/include/zim/item.h +++ b/include/zim/item.h @@ -35,7 +35,7 @@ namespace zim * * All `Item`'s methods are threadsafe. */ - class Item + class LIBZIM_API Item { public: // types typedef std::pair DirectAccessInfo; diff --git a/include/zim/search.h b/include/zim/search.h index 2b4cb667f..5f0a84d53 100644 --- a/include/zim/search.h +++ b/include/zim/search.h @@ -53,7 +53,7 @@ class SearchResultSet; * However, Searcher (and subsequent classes) do not maintain a global/share state. * You can create several Searchers and use them in different threads. */ -class Searcher +class LIBZIM_API Searcher { public: /** Searcher constructor. @@ -115,7 +115,7 @@ class Searcher * It describe what have to be searched and how. * A Query is "database" independent. */ -class Query +class LIBZIM_API Query { public: /** Query constructor. @@ -156,7 +156,7 @@ class Query * This is somehow the reunification of a `Searcher` (what to search on) * and a `Query` (what to search for). */ -class Search +class LIBZIM_API Search { public: Search(Search&& s); @@ -195,7 +195,7 @@ class Search * * It mainly allows to get a iterator. */ -class SearchResultSet +class LIBZIM_API SearchResultSet { public: typedef SearchIterator iterator; diff --git a/include/zim/search_iterator.h b/include/zim/search_iterator.h index 5b60ebec1..35ce206ca 100644 --- a/include/zim/search_iterator.h +++ b/include/zim/search_iterator.h @@ -32,7 +32,7 @@ namespace zim { class SearchResultSet; -class SearchIterator : public std::iterator +class LIBZIM_API SearchIterator : public std::iterator { friend class zim::SearchResultSet; public: diff --git a/include/zim/suggestion.h b/include/zim/suggestion.h index c8020ad76..3f534898d 100644 --- a/include/zim/suggestion.h +++ b/include/zim/suggestion.h @@ -52,7 +52,7 @@ class SuggestionDataBase; * However, SuggestionSearcher (and subsequent classes) do not maintain a global/ * share state You can create several Searchers and use them in different threads. */ -class SuggestionSearcher +class LIBZIM_API SuggestionSearcher { public: /** SuggestionSearcher constructor. @@ -95,7 +95,7 @@ class SuggestionSearcher /** * A SuggestionSearch represent a particular suggestion search, based on a `SuggestionSearcher`. */ -class SuggestionSearch +class LIBZIM_API SuggestionSearch { public: SuggestionSearch(SuggestionSearch&& s); @@ -147,7 +147,7 @@ class SuggestionSearch * * It mainly allows to get a iterator either based on an MSetIterator or a RangeIterator. */ -class SuggestionResultSet +class LIBZIM_API SuggestionResultSet { public: typedef SuggestionIterator iterator; diff --git a/include/zim/suggestion_iterator.h b/include/zim/suggestion_iterator.h index 9a39750e2..30ac9563a 100644 --- a/include/zim/suggestion_iterator.h +++ b/include/zim/suggestion_iterator.h @@ -31,7 +31,7 @@ class SuggestionResultSet; class SuggestionItem; class SearchIterator; -class SuggestionIterator : public std::iterator +class LIBZIM_API SuggestionIterator : public std::iterator { typedef Archive::iterator RangeIterator; friend class SuggestionResultSet; @@ -81,7 +81,7 @@ class SuggestionIterator : public std::iterator - +#include "zim.h" namespace zim { #if defined(LIBZIM_WITH_XAPIAN) @@ -32,7 +32,7 @@ namespace zim { * in the library. So android application needs to set * the data directory where ICU can find its data. */ - void setICUDataDirectory(const std::string& path); + LIBZIM_API void setICUDataDirectory(const std::string& path); #endif } diff --git a/include/zim/uuid.h b/include/zim/uuid.h index 6544eca47..4349b0fbc 100644 --- a/include/zim/uuid.h +++ b/include/zim/uuid.h @@ -26,7 +26,7 @@ #include #include #include - +#include "zim.h" namespace zim { struct Uuid diff --git a/include/zim/writer/contentProvider.h b/include/zim/writer/contentProvider.h index b7ef00629..19cd18cb1 100644 --- a/include/zim/writer/contentProvider.h +++ b/include/zim/writer/contentProvider.h @@ -42,7 +42,7 @@ namespace zim * `ContentProvider` is an abstract class in charge of providing the content to * add in the archive to the creator. */ - class ContentProvider { + class LIBZIM_API ContentProvider { public: virtual ~ContentProvider() = default; /** @@ -81,7 +81,7 @@ namespace zim /** * StringProvider provide the content stored in a string. */ - class StringProvider : public ContentProvider { + class LIBZIM_API StringProvider : public ContentProvider { public: /** * Create a provider using a string as content. @@ -107,7 +107,7 @@ namespace zim * It is mostly the same thing that `StringProvider` but use a shared_ptr * to avoid copy. */ - class SharedStringProvider : public ContentProvider { + class LIBZIM_API SharedStringProvider : public ContentProvider { public: /** * Create a provider using a string as content. @@ -130,7 +130,7 @@ namespace zim /** * FileProvider provide the content stored in file. */ - class FileProvider : public ContentProvider { + class LIBZIM_API FileProvider : public ContentProvider { public: /** * Create a provider using file as content. diff --git a/include/zim/writer/creator.h b/include/zim/writer/creator.h index 15256a06d..b2cad01dd 100644 --- a/include/zim/writer/creator.h +++ b/include/zim/writer/creator.h @@ -61,7 +61,7 @@ namespace zim * - Any other exception thrown for unknown reason. * By default, creator status is not changed by thrown exception and creation should stop. */ - class Creator + class LIBZIM_API Creator { public: /** diff --git a/include/zim/writer/item.h b/include/zim/writer/item.h index b2db5366b..8d916719b 100644 --- a/include/zim/writer/item.h +++ b/include/zim/writer/item.h @@ -47,7 +47,7 @@ namespace zim * (But default `Item::getIndexData` returns a default implementation * for IndexData which works for html content.) */ - class IndexData { + class LIBZIM_API IndexData { public: using GeoPosition = std::tuple; virtual ~IndexData() = default; @@ -124,7 +124,7 @@ namespace zim * libzim provides `BasicItem`, `StringItem` and `FileItem` * to simplify (or avoid) this reimplementation. */ - class Item + class LIBZIM_API Item { public: /** @@ -230,7 +230,7 @@ namespace zim * `BasicItem` provides a basic implementation for everything about an `Item` * but the actual content of the item. */ - class BasicItem : public Item + class LIBZIM_API BasicItem : public Item { public: /** @@ -262,7 +262,7 @@ namespace zim /** * A `StringItem` is a full implemented item where the content is stored in a string. */ - class StringItem : public BasicItem, public std::enable_shared_from_this + class LIBZIM_API StringItem : public BasicItem, public std::enable_shared_from_this { public: /** @@ -296,7 +296,7 @@ namespace zim /** * A `FileItem` is a full implemented item where the content is file. */ - class FileItem : public BasicItem + class LIBZIM_API FileItem : public BasicItem { public: /** diff --git a/include/zim/zim.h b/include/zim/zim.h index 7cd8984e7..94866c902 100644 --- a/include/zim/zim.h +++ b/include/zim/zim.h @@ -33,6 +33,11 @@ #define DEPRECATED #endif +#if (defined _WIN32 || defined __CYGWIN__) && defined ENABLE_EXPORT_DLL + #define LIBZIM_API __declspec(dllexport) +#else + #define LIBZIM_API +#endif #include diff --git a/meson.build b/meson.build index 851958d81..6dda1c916 100644 --- a/meson.build +++ b/meson.build @@ -37,6 +37,8 @@ static_linkage = static_linkage or get_option('default_library')=='static' lzma_dep = dependency('liblzma', static:static_linkage) if static_linkage add_project_arguments('-DLZMA_API_STATIC', language: 'cpp') +else + private_conf.set('ENABLE_EXPORT_DLL', true) endif zstd_dep = dependency('libzstd', static:static_linkage)