From: Mikko Rasa Date: Tue, 3 Jan 2023 08:58:57 +0000 (+0200) Subject: Decorate things which should be visible to users of the library X-Git-Url: http://git.tdb.fi/?p=libs%2Fdatafile.git;a=commitdiff_plain;h=500cf73580cf1a4ed472a1e65c68702644283969 Decorate things which should be visible to users of the library --- diff --git a/source/builtinsource.h b/source/builtinsource.h index e81b37f..5224286 100644 --- a/source/builtinsource.h +++ b/source/builtinsource.h @@ -2,11 +2,12 @@ #define MSP_DATAFILE_BUILTINSOURCE_H_ #include "collectionsource.h" +#include "mspdatafile_api.h" namespace Msp { namespace DataFile { -class BuiltinSource: public CollectionSource +class MSPDATAFILE_API BuiltinSource: public CollectionSource { private: struct Object diff --git a/source/collection.h b/source/collection.h index c8470dd..a0717cf 100644 --- a/source/collection.h +++ b/source/collection.h @@ -9,6 +9,7 @@ #include "collectionsource.h" #include "loader.h" #include "meta.h" +#include "mspdatafile_api.h" /* XXX This file is a big mess with too many things in it. However, the dependencies between those things make it difficult to split up. */ @@ -51,7 +52,7 @@ that are not present. Items retrieted from the fallback collection are shared between the collections, and are only deleted when all collections in the chain have been destroyed. */ -class Collection: private NonCopyable +class MSPDATAFILE_API Collection: private NonCopyable { public: /** diff --git a/source/collectionsource.h b/source/collectionsource.h index eeff10a..3aa2190 100644 --- a/source/collectionsource.h +++ b/source/collectionsource.h @@ -4,6 +4,7 @@ #include #include #include +#include "mspdatafile_api.h" namespace Msp { namespace DataFile { @@ -15,7 +16,7 @@ class CollectionItemTypeBase; Provides automatically loadable objects for collections. This is a base class; see DirectorySource and PackSource for concrete classes. */ -class CollectionSource +class MSPDATAFILE_API CollectionSource { public: typedef std::list NameList; diff --git a/source/directorysource.h b/source/directorysource.h index 6549065..07e1664 100644 --- a/source/directorysource.h +++ b/source/directorysource.h @@ -3,6 +3,7 @@ #include #include "collectionsource.h" +#include "mspdatafile_api.h" namespace Msp { namespace DataFile { @@ -10,7 +11,7 @@ namespace DataFile { /** A source that load items from files in a directory. */ -class DirectorySource: public CollectionSource +class MSPDATAFILE_API DirectorySource: public CollectionSource { private: typedef std::map ObjectMap; diff --git a/source/except.h b/source/except.h index 8357c7e..533072e 100644 --- a/source/except.h +++ b/source/except.h @@ -4,11 +4,12 @@ #include #include #include +#include "mspdatafile_api.h" namespace Msp { namespace DataFile { -class data_error: public std::runtime_error +class MSPDATAFILE_API data_error: public std::runtime_error { private: std::string source; @@ -28,7 +29,7 @@ private: }; -class parse_error: public std::runtime_error +class MSPDATAFILE_API parse_error: public std::runtime_error { public: parse_error(const std::string &); @@ -36,7 +37,7 @@ public: }; -class syntax_error: public std::runtime_error +class MSPDATAFILE_API syntax_error: public std::runtime_error { public: syntax_error(const std::string &t); @@ -44,7 +45,7 @@ public: }; -class bad_definition: public std::runtime_error +class MSPDATAFILE_API bad_definition: public std::runtime_error { public: bad_definition(const std::string &w); @@ -52,7 +53,7 @@ public: }; -class nesting_error: public std::logic_error +class MSPDATAFILE_API nesting_error: public std::logic_error { public: nesting_error(const std::string &); @@ -60,7 +61,7 @@ public: }; -class unknown_keyword: public std::runtime_error +class MSPDATAFILE_API unknown_keyword: public std::runtime_error { public: unknown_keyword(const std::string &); @@ -68,7 +69,7 @@ public: }; -class invalid_signature: public std::runtime_error +class MSPDATAFILE_API invalid_signature: public std::runtime_error { public: invalid_signature(const std::string &, const std::string &); @@ -76,7 +77,7 @@ public: }; -class no_collection: public std::runtime_error +class MSPDATAFILE_API no_collection: public std::runtime_error { public: no_collection(const std::type_info &); diff --git a/source/loader.h b/source/loader.h index 3fe26e7..5b96cb0 100644 --- a/source/loader.h +++ b/source/loader.h @@ -6,6 +6,7 @@ #include #include "loaderaction.h" #include "meta.h" +#include "mspdatafile_api.h" #include "parser.h" #include "statement.h" @@ -34,10 +35,10 @@ destructor. See also classes ObjectLoader and CollectionObjectLoader in objectloader.h. */ -class Loader: private NonCopyable +class MSPDATAFILE_API Loader: private NonCopyable { protected: - class ActionMap: public std::map, private NonCopyable + class MSPDATAFILE_API ActionMap: public std::map, private NonCopyable { public: ~ActionMap(); diff --git a/source/mspdatafile_api.h b/source/mspdatafile_api.h new file mode 100644 index 0000000..e0259d3 --- /dev/null +++ b/source/mspdatafile_api.h @@ -0,0 +1,18 @@ +#ifndef MSP_DATAFILE_API_H_ +#define MSP_DATAFILE_API_H_ + +#if defined(_WIN32) +#if defined(MSPDATAFILE_BUILD) +#define MSPDATAFILE_API __declspec(dllexport) +#elif defined(MSPDATAFILE_IMPORT) +#define MSPDATAFILE_API __declspec(dllimport) +#else +#define MSPDATAFILE_API +#endif +#elif defined(__GNUC__) +#define MSPDATAFILE_API __attribute__((visibility("default"))) +#else +#define MSPDATAFILE_API +#endif + +#endif diff --git a/source/packsource.h b/source/packsource.h index d2194e0..e163736 100644 --- a/source/packsource.h +++ b/source/packsource.h @@ -4,6 +4,7 @@ #include #include #include "collectionsource.h" +#include "mspdatafile_api.h" #include "objectloader.h" namespace Msp { @@ -20,7 +21,7 @@ It's possible for a pack file to contain plain collection files as well. When an object from such a file is requested, the entire sub-collection it is stored in is loaded. */ -class PackSource: public CollectionSource +class MSPDATAFILE_API PackSource: public CollectionSource { public: struct FileInfo diff --git a/source/parser.h b/source/parser.h index ed7a037..32a7760 100644 --- a/source/parser.h +++ b/source/parser.h @@ -4,6 +4,7 @@ #include #include #include "input.h" +#include "mspdatafile_api.h" namespace Msp { namespace DataFile { @@ -19,7 +20,7 @@ Frontend for loading datafiles. Handles switching between text and binary formats. A Parser evaluates into a boolean value indicating whether more statements may be read. */ -class Parser: private NonCopyable +class MSPDATAFILE_API Parser: private NonCopyable { private: Input in; diff --git a/source/rawdata.h b/source/rawdata.h index ad26557..c17f907 100644 --- a/source/rawdata.h +++ b/source/rawdata.h @@ -4,13 +4,14 @@ #include #include #include +#include "mspdatafile_api.h" namespace Msp { namespace DataFile { class Collection; -class RawData: public NonCopyable +class MSPDATAFILE_API RawData: public NonCopyable { private: enum Flags diff --git a/source/statement.h b/source/statement.h index a580f37..6a9da04 100644 --- a/source/statement.h +++ b/source/statement.h @@ -2,6 +2,7 @@ #define MSP_DATAFILE_STATEMENT_H_ #include +#include "mspdatafile_api.h" #include "value.h" namespace Msp { @@ -9,7 +10,7 @@ namespace DataFile { struct Token; -struct Statement +struct MSPDATAFILE_API Statement { typedef std::vector Arguments; diff --git a/source/writer.h b/source/writer.h index 5f32786..05ab369 100644 --- a/source/writer.h +++ b/source/writer.h @@ -4,6 +4,7 @@ #include #include #include +#include "mspdatafile_api.h" #include "output.h" namespace Msp { @@ -15,7 +16,7 @@ class WriterMode; /** Frontend for writing data. */ -class Writer: private NonCopyable +class MSPDATAFILE_API Writer: private NonCopyable { private: Output out;