Skip to content

Commit 6651484

Browse files
committed
libxml++: Export classes selectively
This will make the code avoid exporting items such that things are tied to a particular Visual Studio and STL version, and eliminate warnings C4251, C4273 and C4275 from the build.
1 parent c09b1c4 commit 6651484

19 files changed

+310
-95
lines changed

libxml++/document.h

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,23 +62,24 @@ enum class XmlEntityType
6262
/**
6363
* Represents an XML document in the DOM model.
6464
*/
65-
class LIBXMLPP_API Document : public NonCopyable
65+
class Document : public NonCopyable
6666
{
6767
//Ensure that libxml is properly initialised:
68-
class Init
68+
class LIBXMLPP_API Init
6969
{
7070
public:
7171
Init();
7272
~Init() noexcept;
7373
};
7474

75-
friend class SaxParser;
75+
friend LIBXMLPP_API class SaxParser;
7676

7777
public:
7878
/** Create a new document.
7979
* @param version XML version.
8080
* @throws xmlpp::internal_error If memory allocation fails.
8181
*/
82+
LIBXMLPP_API
8283
explicit Document(const ustring& version = "1.0");
8384

8485
/** Create a new C++ wrapper for an xmlDoc struct.
@@ -87,17 +88,19 @@ class LIBXMLPP_API Document : public NonCopyable
8788
* @param doc A pointer to an xmlDoc struct. Must not be <tt>nullptr</tt>.
8889
* @throws xmlpp::internal_error If @a doc is <tt>nullptr</tt>.
8990
*/
90-
explicit Document(_xmlDoc* doc);
91+
LIBXMLPP_API explicit Document(_xmlDoc* doc);
9192

92-
~Document() override;
93+
LIBXMLPP_API ~Document() override;
9394

9495
/** @return The encoding used in the source from which the document has been loaded.
9596
*/
97+
LIBXMLPP_API
9698
ustring get_encoding() const;
9799

98100
/** Get the internal subset of this document.
99101
* @returns A pointer to the DTD, or <tt>nullptr</tt> if not found.
100102
*/
103+
LIBXMLPP_API
101104
Dtd* get_internal_subset() const;
102105

103106
/** Create the internal subset of this document.
@@ -106,6 +109,7 @@ class LIBXMLPP_API Document : public NonCopyable
106109
* @param external_id The external (PUBLIC) ID, or an empty string.
107110
* @param system_id The system ID, or an empty string.
108111
*/
112+
LIBXMLPP_API
109113
void set_internal_subset(const ustring& name,
110114
const ustring& external_id,
111115
const ustring& system_id);
@@ -114,12 +118,14 @@ class LIBXMLPP_API Document : public NonCopyable
114118
* This function does @b not create a default root node if it doesn't exist.
115119
* @return A pointer to the root node if it exists, <tt>nullptr</tt> otherwise.
116120
*/
121+
LIBXMLPP_API
117122
Element* get_root_node();
118123

119124
/** Return the root node.
120125
* This function does @b not create a default root node if it doesn't exist.
121126
* @return A pointer to the root node if it exists, <tt>nullptr</tt> otherwise.
122127
*/
128+
LIBXMLPP_API
123129
const Element* get_root_node() const;
124130

125131
/** Create the root element node.
@@ -134,6 +140,7 @@ class LIBXMLPP_API Document : public NonCopyable
134140
* @throws xmlpp::internal_error If memory allocation fails.
135141
* @throws xmlpp::exception If a new namespace node cannot be created.
136142
*/
143+
LIBXMLPP_API
137144
Element* create_root_node(const ustring& name,
138145
const ustring& ns_uri = ustring(),
139146
const ustring& ns_prefix = ustring() );
@@ -148,6 +155,7 @@ class LIBXMLPP_API Document : public NonCopyable
148155
* @return A pointer to the new root node
149156
* @throws xmlpp::exception If the node can't be copied.
150157
*/
158+
LIBXMLPP_API
151159
Element* create_root_node_by_import(const Node* node,
152160
bool recursive = true);
153161

@@ -156,6 +164,7 @@ class LIBXMLPP_API Document : public NonCopyable
156164
* @returns The new comment node.
157165
* @throws xmlpp::internal_error
158166
*/
167+
LIBXMLPP_API
159168
CommentNode* add_comment(const ustring& content);
160169

161170
/** Append a new processing instruction node.
@@ -167,6 +176,7 @@ class LIBXMLPP_API Document : public NonCopyable
167176
* @returns The new processing instruction node.
168177
* @throws xmlpp::internal_error
169178
*/
179+
LIBXMLPP_API
170180
ProcessingInstructionNode* add_processing_instruction(
171181
const ustring& name, const ustring& content);
172182

@@ -175,6 +185,7 @@ class LIBXMLPP_API Document : public NonCopyable
175185
* @param encoding If not provided, UTF-8 is used
176186
* @throws xmlpp::exception
177187
*/
188+
LIBXMLPP_API
178189
void write_to_file(const std::string& filename, const ustring& encoding = ustring());
179190

180191
/** Write the document to a file.
@@ -184,13 +195,15 @@ class LIBXMLPP_API Document : public NonCopyable
184195
* @param encoding If not provided, UTF-8 is used
185196
* @throws xmlpp::exception
186197
*/
198+
LIBXMLPP_API
187199
void write_to_file_formatted(const std::string& filename, const ustring& encoding = ustring());
188200

189201
/** Write the document to the memory.
190202
* @param encoding If not provided, UTF-8 is used
191203
* @returns The written document.
192204
* @throws xmlpp::exception
193205
*/
206+
LIBXMLPP_API
194207
ustring write_to_string(const ustring& encoding = ustring());
195208

196209
/** Write the document to the memory.
@@ -200,6 +213,7 @@ class LIBXMLPP_API Document : public NonCopyable
200213
* @returns The written document.
201214
* @throws xmlpp::exception
202215
*/
216+
LIBXMLPP_API
203217
ustring write_to_string_formatted(const ustring& encoding = ustring());
204218

205219
/** Write the document to a std::ostream.
@@ -210,6 +224,7 @@ class LIBXMLPP_API Document : public NonCopyable
210224
* @warning This method is much less efficient than write_to_string if you want to dump the
211225
* document to a buffer or the standard output. Writing to a fstream is almost as fast as write_to_file
212226
*/
227+
LIBXMLPP_API
213228
void write_to_stream(std::ostream& output, const ustring& encoding = ustring());
214229

215230
/** Write the document to a std::ostream.
@@ -221,6 +236,7 @@ class LIBXMLPP_API Document : public NonCopyable
221236
* @throws xmlpp::internal_error
222237
* @warning See write_to_stream
223238
*/
239+
LIBXMLPP_API
224240
void write_to_stream_formatted(std::ostream & output, const ustring& encoding = ustring());
225241

226242
/** Add an Entity declaration to the document.
@@ -232,8 +248,11 @@ class LIBXMLPP_API Document : public NonCopyable
232248
* is the replacement value.
233249
* @throws xmlpp::internal_error
234250
*/
235-
virtual void set_entity_declaration(const ustring& name, XmlEntityType type,
236-
const ustring& publicId, const ustring& systemId,
251+
LIBXMLPP_API
252+
virtual void set_entity_declaration(const ustring& name,
253+
XmlEntityType type,
254+
const ustring& publicId,
255+
const ustring& systemId,
237256
const ustring& content);
238257

239258
/** Perform XInclude substitution on the XML document.
@@ -255,25 +274,30 @@ class LIBXMLPP_API Document : public NonCopyable
255274
* @returns The number of substitutions.
256275
* @throws xmlpp::exception
257276
*/
277+
LIBXMLPP_API
258278
int process_xinclude(bool generate_xinclude_nodes = true, bool fixup_base_uris = true);
259279

260280
///Access the underlying libxml implementation.
261-
_xmlDoc* cobj() noexcept;
281+
LIBXMLPP_API _xmlDoc* cobj() noexcept;
262282

263283
///Access the underlying libxml implementation.
264-
const _xmlDoc* cobj() const noexcept;
284+
LIBXMLPP_API const _xmlDoc* cobj() const noexcept;
265285

266286
protected:
267287
/** Retrieve an Entity.
268288
* The entity can be from an external subset or internally declared.
269289
* @param name The name of the entity to get.
270290
* @returns A pointer to the libxml2 entity structure, or <tt>nullptr</tt> if not found.
271291
*/
292+
LIBXMLPP_API
272293
_xmlEntity* get_entity(const ustring& name);
273294

274295
private:
296+
LIBXMLPP_API
275297
void do_write_to_file(const std::string& filename, const ustring& encoding, bool format);
298+
LIBXMLPP_API
276299
ustring do_write_to_string(const ustring& encoding, bool format);
300+
LIBXMLPP_API
277301
void do_write_to_stream(std::ostream& output, const ustring& encoding, bool format);
278302

279303
static Init init_;

libxml++/dtd.h

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ namespace xmlpp
2727
/** Represents an XML DTD for validating XML files.
2828
* DTD = %Document Type Definition
2929
*/
30-
class LIBXMLPP_API Dtd : public NonCopyable
30+
class Dtd : public NonCopyable
3131
{
3232
public:
33-
Dtd();
33+
LIBXMLPP_API Dtd();
3434

3535
/** Create a Dtd from the underlying libxml DTD element.
3636
* @param dtd A pointer to the libxml DTD element.
@@ -43,6 +43,7 @@ class LIBXMLPP_API Dtd : public NonCopyable
4343
* needed, unless it belongs to a Document, in which case it's deleted
4444
* when the Document is deleted.
4545
*/
46+
LIBXMLPP_API
4647
explicit Dtd(_xmlDtd* dtd, bool take_ownership = false);
4748

4849
/** Create a Dtd and parse an external subset (DTD file) immediately.
@@ -52,6 +53,7 @@ class LIBXMLPP_API Dtd : public NonCopyable
5253
* @param filename The URL of the DTD.
5354
* @throws xmlpp::parse_error
5455
*/
56+
LIBXMLPP_API
5557
explicit Dtd(const std::string& filename);
5658

5759
/** Create a Dtd and parse an external subset (DTD file) immediately.
@@ -62,9 +64,10 @@ class LIBXMLPP_API Dtd : public NonCopyable
6264
* @param system The URL of the DTD.
6365
* @throws xmlpp::parse_error
6466
*/
67+
LIBXMLPP_API
6568
Dtd(const ustring& external, const ustring& system);
6669

67-
~Dtd() override;
70+
LIBXMLPP_API ~Dtd() override;
6871

6972
/** Parse an external subset (DTD file).
7073
* If another DTD has been parsed before, that DTD is replaced by the new one
@@ -75,6 +78,7 @@ class LIBXMLPP_API Dtd : public NonCopyable
7578
* @param filename The URL of the DTD.
7679
* @throws xmlpp::parse_error
7780
*/
81+
LIBXMLPP_API
7882
void parse_file(const std::string& filename);
7983

8084
/** Parse an external subset (DTD file).
@@ -87,6 +91,7 @@ class LIBXMLPP_API Dtd : public NonCopyable
8791
* @param system The URL of the DTD.
8892
* @throws xmlpp::parse_error
8993
*/
94+
LIBXMLPP_API
9095
void parse_subset(const ustring& external, const ustring& system);
9196

9297
/** Parse a DTD from a string.
@@ -98,6 +103,7 @@ class LIBXMLPP_API Dtd : public NonCopyable
98103
* @param contents The DTD as a string.
99104
* @throws xmlpp::parse_error
100105
*/
106+
LIBXMLPP_API
101107
void parse_memory(const ustring& contents);
102108

103109
/** Parse a DTD from a stream.
@@ -109,22 +115,22 @@ class LIBXMLPP_API Dtd : public NonCopyable
109115
* @param in The stream.
110116
* @throws xmlpp::parse_error
111117
*/
112-
void parse_stream(std::istream& in);
118+
LIBXMLPP_API void parse_stream(std::istream& in);
113119

114-
ustring get_name() const;
115-
ustring get_external_id() const;
116-
ustring get_system_id() const;
120+
LIBXMLPP_API ustring get_name() const;
121+
LIBXMLPP_API ustring get_external_id() const;
122+
LIBXMLPP_API ustring get_system_id() const;
117123

118124
/** Access the underlying libxml implementation.
119125
*/
120-
_xmlDtd* cobj() noexcept;
126+
LIBXMLPP_API _xmlDtd* cobj() noexcept;
121127

122128
/** Access the underlying libxml implementation.
123129
*/
124-
const _xmlDtd* cobj() const noexcept;
130+
LIBXMLPP_API const _xmlDtd* cobj() const noexcept;
125131

126132
protected:
127-
void release_underlying();
133+
LIBXMLPP_API void release_underlying();
128134

129135
private:
130136
struct Impl;

libxml++/exceptions/exception.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,17 @@ namespace xmlpp
3636

3737
/** Base class for all xmlpp exceptions.
3838
*/
39-
class LIBXMLPP_API exception : public std::exception
39+
class exception : public std::exception
4040
{
4141
public:
42+
LIBXMLPP_API
4243
explicit exception(const ustring& message);
43-
~exception() noexcept override;
44+
LIBXMLPP_API ~exception() noexcept override;
4445

45-
const char* what() const noexcept override;
46+
LIBXMLPP_API const char* what() const noexcept override;
4647

47-
virtual void raise() const;
48-
virtual exception* clone() const;
48+
LIBXMLPP_API virtual void raise() const;
49+
LIBXMLPP_API virtual exception* clone() const;
4950

5051
private:
5152
ustring message_;

libxml++/exceptions/internal_error.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,15 @@
2424

2525
namespace xmlpp {
2626

27-
class LIBXMLPP_API internal_error : public exception
27+
class internal_error : public exception
2828
{
2929
public:
30+
LIBXMLPP_API
3031
explicit internal_error(const ustring& message);
31-
~internal_error() noexcept override;
32+
LIBXMLPP_API ~internal_error() noexcept override;
3233

33-
void raise() const override;
34-
exception* clone() const override;
34+
LIBXMLPP_API void raise() const override;
35+
LIBXMLPP_API exception* clone() const override;
3536
};
3637

3738
} // namespace xmlpp

libxml++/exceptions/parse_error.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,15 @@ namespace xmlpp
2727

2828
/** This exception will be thrown when the parser encounters an error in the XML document.
2929
*/
30-
class LIBXMLPP_API parse_error : public exception
30+
class parse_error : public exception
3131
{
3232
public:
33+
LIBXMLPP_API
3334
explicit parse_error(const ustring& message);
34-
~parse_error() noexcept override;
35+
LIBXMLPP_API ~parse_error() noexcept override;
3536

36-
void raise() const override;
37-
exception* clone() const override;
37+
LIBXMLPP_API void raise() const override;
38+
LIBXMLPP_API exception* clone() const override;
3839
};
3940

4041
} // namespace xmlpp

libxml++/exceptions/validity_error.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,15 @@ namespace xmlpp
2727

2828
/** This exception will be thrown when the parser encounters a validity error in the XML document.
2929
*/
30-
class LIBXMLPP_API validity_error : public parse_error
30+
class validity_error : public parse_error
3131
{
3232
public:
33+
LIBXMLPP_API
3334
explicit validity_error(const ustring& message);
34-
~validity_error() noexcept override;
35+
LIBXMLPP_API ~validity_error() noexcept override;
3536

36-
void raise() const override;
37-
exception* clone() const override;
37+
LIBXMLPP_API void raise() const override;
38+
LIBXMLPP_API exception* clone() const override;
3839
};
3940

4041
} // namespace xmlpp

libxml++/exceptions/wrapped_exception.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,15 @@ namespace xmlpp
3535
*
3636
* @newin{2,40}
3737
*/
38-
class LIBXMLPP_API wrapped_exception : public exception
38+
class wrapped_exception : public exception
3939
{
4040
public:
41+
LIBXMLPP_API
4142
explicit wrapped_exception(std::exception_ptr exception_ptr);
42-
~wrapped_exception() noexcept override;
43+
LIBXMLPP_API ~wrapped_exception() noexcept override;
4344

44-
void raise() const override;
45-
exception* clone() const override;
45+
LIBXMLPP_API void raise() const override;
46+
LIBXMLPP_API exception* clone() const override;
4647

4748
private:
4849
std::exception_ptr exception_ptr_;

0 commit comments

Comments
 (0)