Skip to content

Commit

Permalink
add __declspec(dllexport) to class
Browse files Browse the repository at this point in the history
fix build library issue on Windows
  • Loading branch information
xiaoyifang committed Apr 13, 2023
1 parent 5798d02 commit 469b1f6
Show file tree
Hide file tree
Showing 15 changed files with 54 additions and 35 deletions.
2 changes: 1 addition & 1 deletion include/zim/archive.h
Expand Up @@ -53,7 +53,7 @@ namespace zim
*
* All methods of archive may throw an `ZimFileFormatError` if the file is invalid.
*/
class Archive
class ZIM_LIB Archive
{
public:
template<EntryOrder order> class EntryRange;
Expand Down
2 changes: 1 addition & 1 deletion include/zim/blob.h
Expand Up @@ -35,7 +35,7 @@ namespace zim
*
* All `Blob`'s methods are threadsafe.
*/
class Blob
class ZIM_LIB Blob
{
public: // types
using DataPtr = std::shared_ptr<const char>;
Expand Down
2 changes: 1 addition & 1 deletion include/zim/entry.h
Expand Up @@ -36,7 +36,7 @@ namespace zim
*
* All `Entry`'s methods are threadsafe.
*/
class Entry
class ZIM_LIB Entry
{
public:
explicit Entry(std::shared_ptr<FileImpl> file_, entry_index_type idx_);
Expand Down
22 changes: 14 additions & 8 deletions include/zim/error.h
Expand Up @@ -20,29 +20,35 @@
#ifndef ZIM_ERROR_H
#define ZIM_ERROR_H

#if defined _WIN32 || defined __CYGWIN__
#define ZIM_LIB __declspec(dllexport)
#else
#define ZIM_LIB
#endif

#include <stdexcept>
#include <sstream>
#include <typeinfo>

namespace zim
{
class ZimFileFormatError : public std::runtime_error
class ZIM_LIB ZimFileFormatError : public std::runtime_error
{
public:
explicit ZimFileFormatError(const std::string& msg)
: std::runtime_error(msg)
{ }
};

class InvalidType: public std::logic_error
class ZIM_LIB InvalidType: public std::logic_error
{
public:
explicit InvalidType(const std::string& msg)
: std::logic_error(msg)
{}
};

class EntryNotFound : public std::runtime_error
class ZIM_LIB EntryNotFound : public std::runtime_error
{
public:
explicit EntryNotFound(const std::string& msg)
Expand All @@ -54,7 +60,7 @@ namespace zim
*
* Most exceptions actually thrown are inheriting this exception.
*/
class CreatorError : public std::runtime_error
class ZIM_LIB CreatorError : public std::runtime_error
{
public:
explicit CreatorError(const std::string& message)
Expand All @@ -63,7 +69,7 @@ namespace zim
};

/* Exception thrown when a entry cannot be added to the Creator.*/
class InvalidEntry : public CreatorError
class ZIM_LIB InvalidEntry : public CreatorError
{
public:
explicit InvalidEntry(const std::string& message)
Expand All @@ -81,7 +87,7 @@ namespace zim
* If a incoherence has been detected in those implementations a
* `IncoherentImplementationError` will be thrown.
*/
class IncoherentImplementationError : public CreatorError
class ZIM_LIB IncoherentImplementationError : public CreatorError
{
public:
explicit IncoherentImplementationError(const std::string& message)
Expand Down Expand Up @@ -113,7 +119,7 @@ namespace zim
* }
* ```
*/
class AsyncError : public CreatorError
class ZIM_LIB AsyncError : public CreatorError
{
public:
explicit AsyncError(const std::exception_ptr exception)
Expand Down Expand Up @@ -149,7 +155,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 ZIM_LIB CreatorStateError : public CreatorError
{
public:
explicit CreatorStateError()
Expand Down
2 changes: 1 addition & 1 deletion include/zim/item.h
Expand Up @@ -35,7 +35,7 @@ namespace zim
*
* All `Item`'s methods are threadsafe.
*/
class Item
class ZIM_LIB Item
{
public: // types
typedef std::pair<std::string, offset_type> DirectAccessInfo;
Expand Down
8 changes: 4 additions & 4 deletions include/zim/search.h
Expand Up @@ -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 ZIM_LIB Searcher
{
public:
/** Searcher constructor.
Expand Down Expand Up @@ -115,7 +115,7 @@ class Searcher
* It describe what have to be searched and how.
* A Query is "database" independent.
*/
class Query
class ZIM_LIB Query
{
public:
/** Query constructor.
Expand Down Expand Up @@ -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 ZIM_LIB Search
{
public:
Search(Search&& s);
Expand Down Expand Up @@ -195,7 +195,7 @@ class Search
*
* It mainly allows to get a iterator.
*/
class SearchResultSet
class ZIM_LIB SearchResultSet
{
public:
typedef SearchIterator iterator;
Expand Down
2 changes: 1 addition & 1 deletion include/zim/search_iterator.h
Expand Up @@ -32,7 +32,7 @@ namespace zim
{
class SearchResultSet;

class SearchIterator : public std::iterator<std::bidirectional_iterator_tag, Entry>
class ZIM_LIB SearchIterator : public std::iterator<std::bidirectional_iterator_tag, Entry>
{
friend class zim::SearchResultSet;
public:
Expand Down
6 changes: 3 additions & 3 deletions include/zim/suggestion.h
Expand Up @@ -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 ZIM_LIB SuggestionSearcher
{
public:
/** SuggestionSearcher constructor.
Expand Down Expand Up @@ -95,7 +95,7 @@ class SuggestionSearcher
/**
* A SuggestionSearch represent a particular suggestion search, based on a `SuggestionSearcher`.
*/
class SuggestionSearch
class ZIM_LIB SuggestionSearch
{
public:
SuggestionSearch(SuggestionSearch&& s);
Expand Down Expand Up @@ -147,7 +147,7 @@ class SuggestionSearch
*
* It mainly allows to get a iterator either based on an MSetIterator or a RangeIterator.
*/
class SuggestionResultSet
class ZIM_LIB SuggestionResultSet
{
public:
typedef SuggestionIterator iterator;
Expand Down
4 changes: 2 additions & 2 deletions include/zim/suggestion_iterator.h
Expand Up @@ -31,7 +31,7 @@ class SuggestionResultSet;
class SuggestionItem;
class SearchIterator;

class SuggestionIterator : public std::iterator<std::bidirectional_iterator_tag, SuggestionItem>
class ZIM_LIB SuggestionIterator : public std::iterator<std::bidirectional_iterator_tag, SuggestionItem>
{
typedef Archive::iterator<EntryOrder::titleOrder> RangeIterator;
friend class SuggestionResultSet;
Expand Down Expand Up @@ -81,7 +81,7 @@ class SuggestionIterator : public std::iterator<std::bidirectional_iterator_tag,
#endif // LIBZIM_WITH_XAPIAN
};

class SuggestionItem
class ZIM_LIB SuggestionItem
{
public: // methods
SuggestionItem(std::string title, std::string path, std::string snippet = "")
Expand Down
8 changes: 6 additions & 2 deletions include/zim/tools.h
Expand Up @@ -21,7 +21,11 @@
#define ZIM_TOOLS_H

#include <zim/zim_config.h>

#if defined _WIN32 || defined __CYGWIN__
#define ZIM_LIB __declspec(dllexport)
#else
#define ZIM_LIB
#endif

namespace zim {
#if defined(LIBZIM_WITH_XAPIAN)
Expand All @@ -32,7 +36,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);
ZIM_LIB void setICUDataDirectory(const std::string& path);

#endif
}
Expand Down
6 changes: 5 additions & 1 deletion include/zim/uuid.h
Expand Up @@ -26,7 +26,11 @@
#include <algorithm>
#include <cstring>
#include <string>

#if defined _WIN32 || defined __CYGWIN__
#define ZIM_LIB __declspec(dllexport)
#else
#define ZIM_LIB
#endif
namespace zim
{
struct Uuid
Expand Down
8 changes: 4 additions & 4 deletions include/zim/writer/contentProvider.h
Expand Up @@ -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 ZIM_LIB ContentProvider {
public:
virtual ~ContentProvider() = default;
/**
Expand Down Expand Up @@ -81,7 +81,7 @@ namespace zim
/**
* StringProvider provide the content stored in a string.
*/
class StringProvider : public ContentProvider {
class ZIM_LIB StringProvider : public ContentProvider {
public:
/**
* Create a provider using a string as content.
Expand All @@ -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 ZIM_LIB SharedStringProvider : public ContentProvider {
public:
/**
* Create a provider using a string as content.
Expand All @@ -130,7 +130,7 @@ namespace zim
/**
* FileProvider provide the content stored in file.
*/
class FileProvider : public ContentProvider {
class ZIM_LIB FileProvider : public ContentProvider {
public:
/**
* Create a provider using file as content.
Expand Down
2 changes: 1 addition & 1 deletion include/zim/writer/creator.h
Expand Up @@ -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 ZIM_LIB Creator
{
public:
/**
Expand Down
10 changes: 5 additions & 5 deletions include/zim/writer/item.h
Expand Up @@ -47,7 +47,7 @@ namespace zim
* (But default `Item::getIndexData` returns a default implementation
* for IndexData which works for html content.)
*/
class IndexData {
class ZIM_LIB IndexData {
public:
using GeoPosition = std::tuple<bool, double, double>;
virtual ~IndexData() = default;
Expand Down Expand Up @@ -124,7 +124,7 @@ namespace zim
* libzim provides `BasicItem`, `StringItem` and `FileItem`
* to simplify (or avoid) this reimplementation.
*/
class Item
class ZIM_LIB Item
{
public:
/**
Expand Down Expand Up @@ -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 ZIM_LIB BasicItem : public Item
{
public:
/**
Expand Down Expand Up @@ -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<StringItem>
class ZIM_LIB StringItem : public BasicItem, public std::enable_shared_from_this<StringItem>
{
public:
/**
Expand Down Expand Up @@ -296,7 +296,7 @@ namespace zim
/**
* A `FileItem` is a full implemented item where the content is file.
*/
class FileItem : public BasicItem
class ZIM_LIB FileItem : public BasicItem
{
public:
/**
Expand Down
5 changes: 5 additions & 0 deletions include/zim/zim.h
Expand Up @@ -33,6 +33,11 @@
#define DEPRECATED
#endif

#if defined _WIN32 || defined __CYGWIN__
#define ZIM_LIB __declspec(dllexport)
#else
#define ZIM_LIB
#endif

#include <zim/zim_config.h>

Expand Down

0 comments on commit 469b1f6

Please sign in to comment.