1 | // |
---|
2 | // XMLString.h |
---|
3 | // |
---|
4 | // $Id: //poco/1.3/XML/include/Poco/XML/XMLString.h#2 $ |
---|
5 | // |
---|
6 | // Library: XML |
---|
7 | // Package: XML |
---|
8 | // Module: XMLString |
---|
9 | // |
---|
10 | // Definition of the XMLString class. |
---|
11 | // |
---|
12 | // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. |
---|
13 | // and Contributors. |
---|
14 | // |
---|
15 | // Permission is hereby granted, free of charge, to any person or organization |
---|
16 | // obtaining a copy of the software and accompanying documentation covered by |
---|
17 | // this license (the "Software") to use, reproduce, display, distribute, |
---|
18 | // execute, and transmit the Software, and to prepare derivative works of the |
---|
19 | // Software, and to permit third-parties to whom the Software is furnished to |
---|
20 | // do so, all subject to the following: |
---|
21 | // |
---|
22 | // The copyright notices in the Software and this entire statement, including |
---|
23 | // the above license grant, this restriction and the following disclaimer, |
---|
24 | // must be included in all copies of the Software, in whole or in part, and |
---|
25 | // all derivative works of the Software, unless such copies or derivative |
---|
26 | // works are solely in the form of machine-executable object code generated by |
---|
27 | // a source language processor. |
---|
28 | // |
---|
29 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
---|
30 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
---|
31 | // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT |
---|
32 | // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE |
---|
33 | // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, |
---|
34 | // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
---|
35 | // DEALINGS IN THE SOFTWARE. |
---|
36 | // |
---|
37 | |
---|
38 | |
---|
39 | #ifndef XML_XMLString_INCLUDED |
---|
40 | #define XML_XMLString_INCLUDED |
---|
41 | |
---|
42 | |
---|
43 | #include "Poco/XML/XML.h" |
---|
44 | |
---|
45 | |
---|
46 | namespace Poco { |
---|
47 | namespace XML { |
---|
48 | |
---|
49 | |
---|
50 | // |
---|
51 | // The XML parser uses the string classes provided by the C++ |
---|
52 | // standard library (based on the basic_string<> template). |
---|
53 | // In Unicode mode, a std::wstring is used, otherwise |
---|
54 | // a std::string is used. |
---|
55 | // To turn on Unicode mode, #define XML_UNICODE and |
---|
56 | // XML_UNICODE_WCHAR_T when compiling the library. |
---|
57 | // |
---|
58 | // XML_UNICODE XML_UNICODE_WCHAR_T XMLChar XMLString |
---|
59 | // -------------------------------------------------------------- |
---|
60 | // N N char std::string |
---|
61 | // N Y wchar_t std::wstring |
---|
62 | // Y Y wchar_t std::wstring |
---|
63 | // Y N <not supported> |
---|
64 | // |
---|
65 | #if defined(XML_UNICODE_WCHAR_T) |
---|
66 | |
---|
67 | // Unicode - use wchar_t |
---|
68 | typedef wchar_t XMLChar; |
---|
69 | typedef std::wstring XMLString; |
---|
70 | |
---|
71 | std::string fromXMLString(const XMLString& str); |
---|
72 | /// Converts an XMLString into an UTF-8 encoded |
---|
73 | /// string. |
---|
74 | |
---|
75 | XMLString toXMLString(const std::string& str); |
---|
76 | /// Converts an UTF-8 encoded string into an |
---|
77 | /// XMLString |
---|
78 | |
---|
79 | #define XML_LIT(lit) L##lit |
---|
80 | |
---|
81 | #elif defined(XML_UNICODE) |
---|
82 | |
---|
83 | // not supported - leave XMLString undefined |
---|
84 | |
---|
85 | #else |
---|
86 | |
---|
87 | // Characters are UTF-8 encoded |
---|
88 | typedef char XMLChar; |
---|
89 | typedef std::string XMLString; |
---|
90 | |
---|
91 | inline const std::string& fromXMLString(const XMLString& str) |
---|
92 | { |
---|
93 | return str; |
---|
94 | } |
---|
95 | |
---|
96 | inline const XMLString& toXMLString(const std::string& str) |
---|
97 | { |
---|
98 | return str; |
---|
99 | } |
---|
100 | |
---|
101 | #define XML_LIT(lit) lit |
---|
102 | |
---|
103 | #endif |
---|
104 | |
---|
105 | |
---|
106 | } } // namespace Poco::XML |
---|
107 | |
---|
108 | |
---|
109 | #endif // XML_XMLString_INCLUDED |
---|