Skip to content

Commit

Permalink
fixup! Make internal classes LIBZIM_API.
Browse files Browse the repository at this point in the history
  • Loading branch information
mgautierfr committed Jun 14, 2024
1 parent d325882 commit 4d536ce
Show file tree
Hide file tree
Showing 19 changed files with 48 additions and 27 deletions.
1 change: 1 addition & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ endif

if get_option('default_library') == 'shared'
public_conf.set('LIBZIM_EXPORT_DLL', true)
add_project_arguments('-DLIBZIM_EXPORT_PRIVATE_DLL', language: 'cpp')
endif

zstd_dep = dependency('libzstd', static:static_linkage, default_options:['werror=false'])
Expand Down
3 changes: 2 additions & 1 deletion src/_dirent.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@
#include <exception>

#include "zim_types.h"
#include "config.h"

namespace zim
{
class Buffer;
class InvalidSize : public std::exception {};
class LIBZIM_API Dirent
class LIBZIM_PRIVATE_API Dirent
{
protected:
uint16_t mimeType;
Expand Down
2 changes: 1 addition & 1 deletion src/buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

namespace zim {

class LIBZIM_API Buffer {
class LIBZIM_PRIVATE_API Buffer {
public: // types
typedef std::shared_ptr<const char> DataPtr;

Expand Down
2 changes: 1 addition & 1 deletion src/buffer_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

namespace zim {

class LIBZIM_API BufferReader : public Reader {
class LIBZIM_PRIVATE_API BufferReader : public Reader {
public:
BufferReader(const Buffer& source)
: source(source) {}
Expand Down
2 changes: 1 addition & 1 deletion src/cluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespace zim
class Reader;
class IStreamReader;

class LIBZIM_API Cluster : public std::enable_shared_from_this<Cluster> {
class LIBZIM_PRIVATE_API Cluster : public std::enable_shared_from_this<Cluster> {
typedef std::vector<offset_t> BlobOffsets;
typedef std::vector<std::unique_ptr<const Reader>> BlobReaders;

Expand Down
4 changes: 2 additions & 2 deletions src/compression.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ struct LZMA_INFO {
};


struct LIBZIM_API ZSTD_INFO {
struct LIBZIM_API stream_t
struct LIBZIM_PRIVATE_API ZSTD_INFO {
struct LIBZIM_PRIVATE_API stream_t
{
const unsigned char* next_in;
size_t avail_in;
Expand Down
10 changes: 10 additions & 0 deletions src/config.h.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
#ifndef ZIM_CONFIG_H
#define ZIM_CONFIG_H

#if defined(_MSC_VER) && defined(LIBZIM_EXPORT_PRIVATE_DLL)
#define LIBZIM_PRIVATE_API __declspec(dllexport)
#else
#define LIBZIM_PRIVATE_API
#endif

#mesondefine VERSION

Expand All @@ -20,3 +28,5 @@
#mesondefine ENV64BIT

#mesondefine ENV32BIT

#endif // ZIM_CONFIG_H
3 changes: 2 additions & 1 deletion src/dirent_accessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include "zim_types.h"
#include "lrucache.h"
#include "config.h"

#include <memory>
#include <mutex>
Expand All @@ -42,7 +43,7 @@ class DirentReader;
*
*/

class LIBZIM_API DirectDirentAccessor
class LIBZIM_PRIVATE_API DirectDirentAccessor
{
public: // functions
DirectDirentAccessor(std::shared_ptr<DirentReader> direntReader,
Expand Down
2 changes: 1 addition & 1 deletion src/direntreader.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace zim
// Unlke FileReader and MemoryReader (which read data from a file and memory,
// respectively), DirentReader is a helper class that reads Dirents (rather
// than from a Dirent).
class LIBZIM_API DirentReader
class LIBZIM_PRIVATE_API DirentReader
{
public: // functions
explicit DirentReader(std::shared_ptr<const Reader> zimReader)
Expand Down
4 changes: 3 additions & 1 deletion src/file_compound.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
#include "file_part.h"
#include "zim_types.h"
#include "debug.h"
#include "config.h"

#include <map>
#include <memory>
#include <vector>
Expand All @@ -48,7 +50,7 @@ struct less_range
}
};

class LIBZIM_API FileCompound : private std::map<Range, FilePart*, less_range> {
class LIBZIM_PRIVATE_API FileCompound : private std::map<Range, FilePart*, less_range> {
typedef std::map<Range, FilePart*, less_range> ImplType;

public: // types
Expand Down
6 changes: 3 additions & 3 deletions src/file_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace zim {

class FileCompound;

class LIBZIM_API BaseFileReader : public Reader {
class LIBZIM_PRIVATE_API BaseFileReader : public Reader {
public: // functions
BaseFileReader(offset_t offset, zsize_t size)
: _offset(offset), _size(size) {}
Expand All @@ -45,7 +45,7 @@ class LIBZIM_API BaseFileReader : public Reader {
zsize_t _size;
};

class LIBZIM_API FileReader : public BaseFileReader {
class LIBZIM_PRIVATE_API FileReader : public BaseFileReader {
public: // types
typedef std::shared_ptr<const DEFAULTFS::FD> FileHandle;

Expand All @@ -66,7 +66,7 @@ class LIBZIM_API FileReader : public BaseFileReader {
FileHandle _fhandle;
};

class LIBZIM_API MultiPartFileReader : public BaseFileReader {
class LIBZIM_PRIVATE_API MultiPartFileReader : public BaseFileReader {
public:
explicit MultiPartFileReader(std::shared_ptr<const FileCompound> source);
~MultiPartFileReader() {};
Expand Down
4 changes: 3 additions & 1 deletion src/fileheader.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

#include <zim/zim.h>
#include <zim/uuid.h>
#include "config.h"

#include <limits>

// max may be defined as a macro by window includes
Expand All @@ -33,7 +35,7 @@
namespace zim
{
class Reader;
class LIBZIM_API Fileheader
class LIBZIM_PRIVATE_API Fileheader
{
public:
static const uint32_t zimMagic;
Expand Down
5 changes: 3 additions & 2 deletions src/fs_windows.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#define ZIM_FS_WINDOWS_H_

#include "zim_types.h"
#include "config.h"

#include <memory>

Expand All @@ -34,7 +35,7 @@ using path_t = const std::string&;

struct ImplFD;

class LIBZIM_API FD {
class LIBZIM_PRIVATE_API FD {
public:
typedef HANDLE fd_t;
private:
Expand All @@ -55,7 +56,7 @@ class LIBZIM_API FD {
bool close();
};

struct LIBZIM_API FS {
struct LIBZIM_PRIVATE_API FS {
using FD = zim::windows::FD;
static std::string join(path_t base, path_t name);
static std::unique_ptr<wchar_t[]> toWideChar(path_t path);
Expand Down
2 changes: 1 addition & 1 deletion src/istreamreader.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ namespace zim
// }
// }
//
class LIBZIM_API IStreamReader
class LIBZIM_PRIVATE_API IStreamReader
{
public: // functions
virtual ~IStreamReader() = default;
Expand Down
14 changes: 7 additions & 7 deletions src/tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,27 +37,27 @@ namespace Xapian {
#endif // ENABLE_XAPIAN
namespace zim {
bool isCompressibleMimetype(const std::string& mimetype);
uint32_t LIBZIM_API countWords(const std::string& text);
void LIBZIM_API microsleep(int microseconds);
uint32_t LIBZIM_PRIVATE_API countWords(const std::string& text);
void LIBZIM_PRIVATE_API microsleep(int microseconds);

std::tuple<char, std::string> LIBZIM_API parseLongPath(const std::string& longPath);
std::tuple<char, std::string> LIBZIM_PRIVATE_API parseLongPath(const std::string& longPath);

// Parse a illustration path ("Illustration_<width>x<height>@1") to a size.
unsigned int LIBZIM_API parseIllustrationPathToSize(const std::string& s);
unsigned int LIBZIM_PRIVATE_API parseIllustrationPathToSize(const std::string& s);

/** Return a random number from range [0, max]
*
* This function is threadsafe
**/
uint32_t LIBZIM_API randomNumber(uint32_t max);
uint32_t LIBZIM_PRIVATE_API randomNumber(uint32_t max);

std::vector<std::string> split(const std::string & str,
const std::string & delims=" *-");

std::map<std::string, int> read_valuesmap(const std::string& s);

using MimeCounterType = std::map<const std::string, zim::entry_index_type>;
MimeCounterType LIBZIM_API parseMimetypeCounter(const std::string& counterData);
MimeCounterType LIBZIM_PRIVATE_API parseMimetypeCounter(const std::string& counterData);

template<class Filter>
entry_index_type countMimeType(const std::string& counterData, Filter filter) {
Expand All @@ -72,7 +72,7 @@ namespace zim {

// Xapian based tools
#if defined(ENABLE_XAPIAN)
std::string LIBZIM_API removeAccents(const std::string& text);
std::string LIBZIM_PRIVATE_API removeAccents(const std::string& text);
bool getDbFromAccessInfo(Item::DirectAccessInfo accessInfo, Xapian::Database& database);
#endif
}
Expand Down
2 changes: 1 addition & 1 deletion src/writer/_dirent.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ namespace zim
enum : char {DIRECT, REDIRECT, RESOLVED} tag;
} PACKED;

class LIBZIM_API Dirent
class LIBZIM_PRIVATE_API Dirent
{
static const uint16_t redirectMimeType = 0xffff;
static const uint32_t version = 0;
Expand Down
3 changes: 2 additions & 1 deletion src/writer/cluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <zim/writer/item.h>
#include "../zim_types.h"
#include "../debug.h"
#include "config.h"

namespace zim {

Expand All @@ -38,7 +39,7 @@ namespace writer {
using writer_t = std::function<void(const Blob& data)>;
class ContentProvider;

class LIBZIM_API Cluster {
class LIBZIM_PRIVATE_API Cluster {
typedef std::vector<offset_t> Offsets;
typedef std::vector<std::unique_ptr<ContentProvider>> ClusterProviders;

Expand Down
4 changes: 3 additions & 1 deletion src/xapian/htmlparse.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#define OMEGA_INCLUDED_HTMLPARSE_H

#include <zim/zim.h>
#include "config.h"

#include <string>
#include <map>

Expand All @@ -31,7 +33,7 @@ using std::map;

namespace zim {

class LIBZIM_API HtmlParser {
class LIBZIM_PRIVATE_API HtmlParser {
map<string, string> parameters;
protected:
void decode_entities(string &s);
Expand Down
2 changes: 1 addition & 1 deletion src/xapian/myhtmlparse.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

namespace zim {

class LIBZIM_API MyHtmlParser : public HtmlParser {
class LIBZIM_PRIVATE_API MyHtmlParser : public HtmlParser {
public:
bool in_script_tag;
bool in_style_tag;
Expand Down

0 comments on commit 4d536ce

Please sign in to comment.