Merge lp:~zorba-coders/zorba/bug-1158052 into lp:zorba
- bug-1158052
- Merge into trunk
Status: | Merged | ||||
---|---|---|---|---|---|
Merged at revision: | 11545 | ||||
Proposed branch: | lp:~zorba-coders/zorba/bug-1158052 | ||||
Merge into: | lp:zorba | ||||
Diff against target: |
1611 lines (+342/-569) 16 files modified
ChangeLog (+2/-1) include/zorba/item_factory.h (+7/-14) modules/ExternalModules.conf (+2/-2) modules/com/zorba-xquery/www/modules/http-client.xq.src/http_response_parser.cpp (+1/-1) src/api/itemfactoryimpl.cpp (+91/-109) src/api/itemfactoryimpl.h (+1/-4) src/store/naive/atomic_items.cpp (+3/-3) src/store/naive/simple_item_factory.cpp (+2/-2) src/types/casting.cpp (+3/-11) src/zorbaserialization/serialize_zorba_types.cpp (+6/-26) src/zorbatypes/binary.cpp (+88/-260) src/zorbatypes/binary.h (+126/-116) swig/ItemFactory.h (+4/-11) swig/ItemFactory.i (+2/-5) swig/xqj/ZorbaXQConnection.java (+2/-2) test/api/itemfactory.cpp (+2/-2) |
||||
To merge this branch: | bzr merge lp:~zorba-coders/zorba/bug-1158052 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Chris Hillery | Approve | ||
Paul J. Lucas | Approve | ||
Review via email: mp+170725@code.launchpad.net |
Commit message
Cleaned up both public and internal API.
Description of the change
https:/
https:/
https:/
https:/
https:/
https:/
https:/
https:/
https:/
https:/
Paul J. Lucas (paul-lucas) : | # |
Zorba Build Bot (zorba-buildbot) wrote : | # |
Zorba Build Bot (zorba-buildbot) wrote : | # |
The attempt to merge lp:~zorba-coders/zorba/bug-1158052 into lp:zorba failed. Below is the output from the failed tests.
CMake Error at /home/ceej/
Validation queue job bug-1158052-2013-06-
final status was:
No tests were run - build or configure step must have failed.
Not commiting changes.
Error in read script: /home/ceej/
Zorba Build Bot (zorba-buildbot) wrote : | # |
There are additional revisions which have not been approved in review. Please seek review and approval of these new revisions.
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for merge proposal.
Log at: http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
The attempt to merge lp:~zorba-coders/zorba/bug-1158052 into lp:zorba failed. Below is the output from the failed tests.
CMake Error at /home/ceej/
Validation queue job bug-1158052-2013-06-
final status was:
No tests were run - build or configure step must have failed.
Not commiting changes.
Error in read script: /home/ceej/
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for merge proposal.
Log at: http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
The attempt to merge lp:~zorba-coders/zorba/bug-1158052 into lp:zorba failed. Below is the output from the failed tests.
CMake Error at /home/ceej/
Validation queue job bug-1158052-2013-06-
final status was:
No tests were run - build or configure step must have failed.
Not commiting changes.
Error in read script: /home/ceej/
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for merge proposal.
Log at: http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
The attempt to merge lp:~zorba-coders/zorba/bug-1158052 into lp:zorba failed. Below is the output from the failed tests.
CMake Error at /home/ceej/
Validation queue job bug-1158052-2013-06-
final status was:
5 tests did not succeed - changes not commited.
Error in read script: /home/ceej/
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for merge proposal.
Log at: http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue job bug-1158052-2013-06-
All tests succeeded!
Zorba Build Bot (zorba-buildbot) wrote : | # |
Voting does not meet specified criteria. Required: Approve > 1, Disapprove < 1, Needs Fixing < 1, Pending < 1, Needs Information < 1, Resubmit < 1. Got: 1 Approve.
- 11538. By Paul J. Lucas
-
Merge from trunk.
- 11539. By Paul J. Lucas
-
Merge from trunk.
- 11540. By Paul J. Lucas
-
Merge from trunk.
- 11541. By Chris Hillery
-
Revert to non-core modules from trunks.
Chris Hillery (ceejatec) : | # |
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for the following merge proposals:
https:/
https:/
https:/
https:/
https:/
https:/
https:/
https:/
https:/
https:/
https:/
Progress dashboard at http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for the following merge proposals:
https:/
https:/
https:/
https:/
https:/
https:/
https:/
https:/
https:/
https:/
https:/
Progress dashboard at http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
Voting criteria failed for the following merge proposals:
https:/
Votes: {'Approve': 1, 'Pending': 1}
https:/
Votes: {'Approve': 1, 'Pending': 1}
https:/
Votes: {'Approve': 1, 'Pending': 1}
https:/
Votes: {'Approve': 1, 'Pending': 1}
https:/
Votes: {'Approve': 1, 'Pending': 1}
https:/
Votes: {'Approve': 1, 'Pending': 1}
https:/
Votes: {'Approve': 1, 'Pending': 1}
https:/
Votes: {'Approve': 1, 'Pending': 1}
https:/
Votes: {'Approve': 1, 'Pending': 1}
https:/
Votes: {'Approve': 1, 'Pending': 1}
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue succeeded!
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for the following merge proposals:
https:/
https:/
https:/
https:/
https:/
https:/
https:/
https:/
https:/
https:/
https:/
Progress dashboard at http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue succeeded - proposal merged!
Preview Diff
1 | === modified file 'ChangeLog' | |||
2 | --- ChangeLog 2013-06-28 02:33:07 +0000 | |||
3 | +++ ChangeLog 2013-06-28 04:21:28 +0000 | |||
4 | @@ -32,10 +32,11 @@ | |||
5 | 32 | * Fixed bug #1189798 (Update core module "errors") | 32 | * Fixed bug #1189798 (Update core module "errors") |
6 | 33 | * Fixed bug #1187537 (Eliminate (or at least reduce) use of MAX_PATH) | 33 | * Fixed bug #1187537 (Eliminate (or at least reduce) use of MAX_PATH) |
7 | 34 | * Fixed bug #1180220 (Consolidate redundant path/file public APIs) | 34 | * Fixed bug #1180220 (Consolidate redundant path/file public APIs) |
8 | 35 | * Fixed bug #1158052 (createBase64Binary() API too subtle) | ||
9 | 35 | * Fixed bug #1103115 (Timezone units as hours are wrong) | 36 | * Fixed bug #1103115 (Timezone units as hours are wrong) |
10 | 36 | * Fixed bug #1188280 (casting xs:id to xs:ncname) | 37 | * Fixed bug #1188280 (casting xs:id to xs:ncname) |
11 | 37 | * Fixed bug in casting to xs:NCName | 38 | * Fixed bug in casting to xs:NCName |
13 | 38 | * Check that namespace uri used in default namespace declaration is a valid one | 39 | * Check that the namespace URI used in default namespace declaration is valid |
14 | 39 | * Fixed bug in error conditions for computed PI constructor | 40 | * Fixed bug in error conditions for computed PI constructor |
15 | 40 | * Fixed implementation of fn:deep-equal according to latest W3C spec. | 41 | * Fixed implementation of fn:deep-equal according to latest W3C spec. |
16 | 41 | * Must apply document ordering on the domain expression of a FOR clause, if | 42 | * Must apply document ordering on the domain expression of a FOR clause, if |
17 | 42 | 43 | ||
18 | === modified file 'include/zorba/item_factory.h' | |||
19 | --- include/zorba/item_factory.h 2013-06-18 23:53:59 +0000 | |||
20 | +++ include/zorba/item_factory.h 2013-06-28 04:21:28 +0000 | |||
21 | @@ -141,32 +141,25 @@ | |||
22 | 141 | /** \brief Creates a Base64Binary Item | 141 | /** \brief Creates a Base64Binary Item |
23 | 142 | * see [http://www.w3.org/TR/xmlschema-2/#base64Binary] | 142 | * see [http://www.w3.org/TR/xmlschema-2/#base64Binary] |
24 | 143 | * | 143 | * |
27 | 144 | * @param aBinData a pointer to the base64 encoded data. The data is copied from aBinData. | 144 | * @param aData a pointer to the data. |
28 | 145 | * @param aLength the length of the base64 encoded data. | 145 | * @param aLength the length of the data (in bytes). |
29 | 146 | * @param aIsBase64 If \c true, \a aData is already Base-64 encoded; if | ||
30 | 147 | * \c false, \a aData is binary data that will first be Base-64 encoded. | ||
31 | 146 | * @return The Base64Binary Item. | 148 | * @return The Base64Binary Item. |
32 | 147 | */ | 149 | */ |
33 | 148 | virtual Item | 150 | virtual Item |
35 | 149 | createBase64Binary(const char* aBinData, size_t aLength) = 0; | 151 | createBase64Binary(const char* aData, size_t aLength, bool aIsBase64) = 0; |
36 | 150 | 152 | ||
37 | 151 | /** \brief Creates a Base64Binary Item | 153 | /** \brief Creates a Base64Binary Item |
38 | 152 | * see [http://www.w3.org/TR/xmlschema-2/#base64Binary] | 154 | * see [http://www.w3.org/TR/xmlschema-2/#base64Binary] |
39 | 153 | * | 155 | * |
41 | 154 | * @param aStream A stream containing the Base64 encoded data. The data is copied from aStream imediately. | 156 | * @param aStream A stream containing the Base64 encoded data. |
42 | 157 | * The data is copied from aStream immediately. | ||
43 | 155 | * @return the Base64Binary Item. | 158 | * @return the Base64Binary Item. |
44 | 156 | */ | 159 | */ |
45 | 157 | virtual Item | 160 | virtual Item |
46 | 158 | createBase64Binary(std::istream& aStream) = 0; | 161 | createBase64Binary(std::istream& aStream) = 0; |
47 | 159 | 162 | ||
48 | 160 | /** \brief Creates a Base64Binary Item | ||
49 | 161 | * see [http://www.w3.org/TR/xmlschema-2/#base64Binary] | ||
50 | 162 | * | ||
51 | 163 | * @param aBinData the data in binary form (not encoded). The data is copied from aBinData. | ||
52 | 164 | * @param aLength the length of the binary data | ||
53 | 165 | * @return the Base64Binary Item. | ||
54 | 166 | */ | ||
55 | 167 | virtual Item | ||
56 | 168 | createBase64Binary(const unsigned char* aBinData, size_t aLength) = 0; | ||
57 | 169 | |||
58 | 170 | /** \brief Creates a streamable Base64Binary Item | 163 | /** \brief Creates a streamable Base64Binary Item |
59 | 171 | * see [http://www.w3.org/TR/xmlschema-2/#base64Binary] | 164 | * see [http://www.w3.org/TR/xmlschema-2/#base64Binary] |
60 | 172 | * | 165 | * |
61 | 173 | 166 | ||
62 | === modified file 'modules/ExternalModules.conf' | |||
63 | --- modules/ExternalModules.conf 2013-06-28 00:31:51 +0000 | |||
64 | +++ modules/ExternalModules.conf 2013-06-28 04:21:28 +0000 | |||
65 | @@ -32,14 +32,14 @@ | |||
66 | 32 | data-formatting bzr lp:zorba/data-formatting-module | 32 | data-formatting bzr lp:zorba/data-formatting-module |
67 | 33 | excel bzr lp:zorba/excel-module zorba-2.9 | 33 | excel bzr lp:zorba/excel-module zorba-2.9 |
68 | 34 | info-extraction bzr lp:zorba/info-extraction-module zorba-2.9 | 34 | info-extraction bzr lp:zorba/info-extraction-module zorba-2.9 |
70 | 35 | geo bzr lp:zorba/geo-module zorba-2.9 | 35 | geo bzr lp:zorba/geo-module |
71 | 36 | geoproj bzr lp:zorba/geoproj-module zorba-2.9 | 36 | geoproj bzr lp:zorba/geoproj-module zorba-2.9 |
72 | 37 | graphviz bzr lp:zorba/graphviz-module zorba-2.9 | 37 | graphviz bzr lp:zorba/graphviz-module zorba-2.9 |
73 | 38 | html bzr lp:zorba/html-module zorba-2.9 | 38 | html bzr lp:zorba/html-module zorba-2.9 |
74 | 39 | http-client bzr lp:zorba/http-client-module zorba-2.9 | 39 | http-client bzr lp:zorba/http-client-module zorba-2.9 |
75 | 40 | image bzr lp:zorba/image-module | 40 | image bzr lp:zorba/image-module |
76 | 41 | jdbc bzr lp:zorba/jdbc-module | 41 | jdbc bzr lp:zorba/jdbc-module |
78 | 42 | languages bzr lp:zorba/languages-module zorba-2.9 | 42 | languages bzr lp:zorba/languages-module |
79 | 43 | oracle-nosql-db bzr lp:zorba/oracle-nosql-db-module | 43 | oracle-nosql-db bzr lp:zorba/oracle-nosql-db-module |
80 | 44 | oauth bzr lp:zorba/oauth-module zorba-2.9 | 44 | oauth bzr lp:zorba/oauth-module zorba-2.9 |
81 | 45 | process bzr lp:zorba/process-module | 45 | process bzr lp:zorba/process-module |
82 | 46 | 46 | ||
83 | === modified file 'modules/com/zorba-xquery/www/modules/http-client.xq.src/http_response_parser.cpp' | |||
84 | --- modules/com/zorba-xquery/www/modules/http-client.xq.src/http_response_parser.cpp 2013-06-25 03:55:20 +0000 | |||
85 | +++ modules/com/zorba-xquery/www/modules/http-client.xq.src/http_response_parser.cpp 2013-06-28 04:21:28 +0000 | |||
86 | @@ -329,7 +329,7 @@ | |||
87 | 329 | // changed. This required a Base64 encoding stream since the item factory | 329 | // changed. This required a Base64 encoding stream since the item factory |
88 | 330 | // work only builds base64binary and assumes the data is already encoded. | 330 | // work only builds base64binary and assumes the data is already encoded. |
89 | 331 | String lEncoded = base64::encode(aStream); | 331 | String lEncoded = base64::encode(aStream); |
91 | 332 | return lFactory->createBase64Binary(lEncoded.data(), lEncoded.size()); | 332 | return lFactory->createBase64Binary(lEncoded.data(), lEncoded.size(), true); |
92 | 333 | } | 333 | } |
93 | 334 | 334 | ||
94 | 335 | zorba::Item HttpResponseParser::createXmlItem( std::istream& aStream ) | 335 | zorba::Item HttpResponseParser::createXmlItem( std::istream& aStream ) |
95 | 336 | 336 | ||
96 | === modified file 'src/api/itemfactoryimpl.cpp' | |||
97 | --- src/api/itemfactoryimpl.cpp 2013-06-18 23:53:59 +0000 | |||
98 | +++ src/api/itemfactoryimpl.cpp 2013-06-28 04:21:28 +0000 | |||
99 | @@ -1,12 +1,12 @@ | |||
100 | 1 | /* | 1 | /* |
101 | 2 | * Copyright 2006-2008 The FLWOR Foundation. | 2 | * Copyright 2006-2008 The FLWOR Foundation. |
103 | 3 | * | 3 | * |
104 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
105 | 5 | * you may not use this file except in compliance with the License. | 5 | * you may not use this file except in compliance with the License. |
106 | 6 | * You may obtain a copy of the License at | 6 | * You may obtain a copy of the License at |
108 | 7 | * | 7 | * |
109 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
111 | 9 | * | 9 | * |
112 | 10 | * Unless required by applicable law or agreed to in writing, software | 10 | * Unless required by applicable law or agreed to in writing, software |
113 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
114 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
115 | @@ -45,25 +45,25 @@ | |||
116 | 45 | 45 | ||
117 | 46 | 46 | ||
118 | 47 | namespace zorba { | 47 | namespace zorba { |
120 | 48 | 48 | ||
121 | 49 | ItemFactoryImpl::ItemFactoryImpl() | 49 | ItemFactoryImpl::ItemFactoryImpl() |
122 | 50 | { | 50 | { |
123 | 51 | theItemFactory = GENV_ITEMFACTORY; | 51 | theItemFactory = GENV_ITEMFACTORY; |
124 | 52 | } | 52 | } |
125 | 53 | 53 | ||
126 | 54 | 54 | ||
128 | 55 | ItemFactoryImpl::~ItemFactoryImpl() | 55 | ItemFactoryImpl::~ItemFactoryImpl() |
129 | 56 | { | 56 | { |
130 | 57 | } | 57 | } |
131 | 58 | 58 | ||
132 | 59 | 59 | ||
133 | 60 | Item ItemFactoryImpl::createString(const String& aString) | 60 | Item ItemFactoryImpl::createString(const String& aString) |
134 | 61 | { | 61 | { |
136 | 62 | zstring lString = Unmarshaller::getInternalString(aString); | 62 | zstring lString = Unmarshaller::getInternalString(aString); |
137 | 63 | store::Item_t lItem; | 63 | store::Item_t lItem; |
139 | 64 | 64 | ||
140 | 65 | theItemFactory->createString(lItem, lString); | 65 | theItemFactory->createString(lItem, lString); |
142 | 66 | 66 | ||
143 | 67 | return &*lItem; | 67 | return &*lItem; |
144 | 68 | } | 68 | } |
145 | 69 | 69 | ||
146 | @@ -94,14 +94,14 @@ | |||
147 | 94 | Item ItemFactoryImpl::createAnyURI(const String& aURI) | 94 | Item ItemFactoryImpl::createAnyURI(const String& aURI) |
148 | 95 | { | 95 | { |
149 | 96 | zstring lString = Unmarshaller::getInternalString(aURI); | 96 | zstring lString = Unmarshaller::getInternalString(aURI); |
151 | 97 | 97 | ||
152 | 98 | store::Item_t lItem; | 98 | store::Item_t lItem; |
153 | 99 | theItemFactory->createAnyURI(lItem, lString); | 99 | theItemFactory->createAnyURI(lItem, lString); |
155 | 100 | 100 | ||
156 | 101 | return &*lItem; | 101 | return &*lItem; |
157 | 102 | } | 102 | } |
158 | 103 | 103 | ||
160 | 104 | 104 | ||
161 | 105 | Item ItemFactoryImpl::createDate( const String& aDateValue ) | 105 | Item ItemFactoryImpl::createDate( const String& aDateValue ) |
162 | 106 | { | 106 | { |
163 | 107 | zstring const &lString = Unmarshaller::getInternalString( aDateValue ); | 107 | zstring const &lString = Unmarshaller::getInternalString( aDateValue ); |
164 | @@ -133,19 +133,19 @@ | |||
165 | 133 | zstring const &lNamespace = Unmarshaller::getInternalString( aNamespace ); | 133 | zstring const &lNamespace = Unmarshaller::getInternalString( aNamespace ); |
166 | 134 | zstring const &lPrefix = Unmarshaller::getInternalString( aPrefix ); | 134 | zstring const &lPrefix = Unmarshaller::getInternalString( aPrefix ); |
167 | 135 | zstring const &lLocalname = Unmarshaller::getInternalString( aLocalname ); | 135 | zstring const &lLocalname = Unmarshaller::getInternalString( aLocalname ); |
169 | 136 | 136 | ||
170 | 137 | if (!GenericCast::instance()->castableToNCName(lLocalname.c_str())) | 137 | if (!GenericCast::instance()->castableToNCName(lLocalname.c_str())) |
171 | 138 | { | 138 | { |
173 | 139 | RAISE_ERROR_NO_LOC(err::FORG0001, | 139 | RAISE_ERROR_NO_LOC(err::FORG0001, |
174 | 140 | ERROR_PARAMS(ZED(FORG0001_LocalNotNCName_2), lLocalname)); | 140 | ERROR_PARAMS(ZED(FORG0001_LocalNotNCName_2), lLocalname)); |
175 | 141 | } | 141 | } |
176 | 142 | 142 | ||
177 | 143 | if (lPrefix.size() && !GenericCast::instance()->castableToNCName(lPrefix.c_str())) | 143 | if (lPrefix.size() && !GenericCast::instance()->castableToNCName(lPrefix.c_str())) |
178 | 144 | { | 144 | { |
180 | 145 | RAISE_ERROR_NO_LOC(err::FORG0001, | 145 | RAISE_ERROR_NO_LOC(err::FORG0001, |
181 | 146 | ERROR_PARAMS(ZED(FORG0001_PrefixNotNCName_2), lPrefix)); | 146 | ERROR_PARAMS(ZED(FORG0001_PrefixNotNCName_2), lPrefix)); |
182 | 147 | } | 147 | } |
184 | 148 | 148 | ||
185 | 149 | store::Item_t lItem; | 149 | store::Item_t lItem; |
186 | 150 | theItemFactory->createQName(lItem, lNamespace, lPrefix, lLocalname); | 150 | theItemFactory->createQName(lItem, lNamespace, lPrefix, lLocalname); |
187 | 151 | return &*lItem; | 151 | return &*lItem; |
188 | @@ -161,15 +161,15 @@ | |||
189 | 161 | 161 | ||
190 | 162 | if (!GenericCast::instance()->castableToNCName(lLocalname.c_str())) | 162 | if (!GenericCast::instance()->castableToNCName(lLocalname.c_str())) |
191 | 163 | { | 163 | { |
193 | 164 | RAISE_ERROR_NO_LOC(err::FORG0001, | 164 | RAISE_ERROR_NO_LOC(err::FORG0001, |
194 | 165 | ERROR_PARAMS(ZED(FORG0001_LocalNotNCName_2), lLocalname)); | 165 | ERROR_PARAMS(ZED(FORG0001_LocalNotNCName_2), lLocalname)); |
195 | 166 | } | 166 | } |
197 | 167 | 167 | ||
198 | 168 | store::Item_t lItem; | 168 | store::Item_t lItem; |
199 | 169 | theItemFactory->createQName(lItem, lNamespace, zstring(), lLocalname); | 169 | theItemFactory->createQName(lItem, lNamespace, zstring(), lLocalname); |
200 | 170 | return &*lItem; | 170 | return &*lItem; |
201 | 171 | } | 171 | } |
203 | 172 | 172 | ||
204 | 173 | 173 | ||
205 | 174 | Item | 174 | Item |
206 | 175 | ItemFactoryImpl::createQName(const String& aQNameString) | 175 | ItemFactoryImpl::createQName(const String& aQNameString) |
207 | @@ -180,7 +180,7 @@ | |||
208 | 180 | size_t lOpen = lQNameString.find("{"); | 180 | size_t lOpen = lQNameString.find("{"); |
209 | 181 | size_t lClose = lQNameString.find("}"); | 181 | size_t lClose = lQNameString.find("}"); |
210 | 182 | 182 | ||
212 | 183 | if (lOpen == 0 && lClose != std::string::npos) | 183 | if (lOpen == 0 && lClose != std::string::npos) |
213 | 184 | { | 184 | { |
214 | 185 | zstring const &lNamespace = lQNameString.substr(1, lClose - 1); | 185 | zstring const &lNamespace = lQNameString.substr(1, lClose - 1); |
215 | 186 | zstring const &lLocalname = lQNameString.substr(lClose+1); | 186 | zstring const &lLocalname = lQNameString.substr(lClose+1); |
216 | @@ -188,7 +188,7 @@ | |||
217 | 188 | 188 | ||
218 | 189 | if (!GenericCast::instance()->castableToNCName(lLocalname.c_str())) | 189 | if (!GenericCast::instance()->castableToNCName(lLocalname.c_str())) |
219 | 190 | { | 190 | { |
221 | 191 | RAISE_ERROR_NO_LOC(err::FORG0001, | 191 | RAISE_ERROR_NO_LOC(err::FORG0001, |
222 | 192 | ERROR_PARAMS(ZED(FORG0001_LocalNotNCName_2), lLocalname)); | 192 | ERROR_PARAMS(ZED(FORG0001_LocalNotNCName_2), lLocalname)); |
223 | 193 | } | 193 | } |
224 | 194 | } | 194 | } |
225 | @@ -205,54 +205,36 @@ | |||
226 | 205 | RAISE_ERROR_NO_LOC(err::FORG0001, | 205 | RAISE_ERROR_NO_LOC(err::FORG0001, |
227 | 206 | ERROR_PARAMS(ZED(FORG0001_NameNotNCName_2), lString)); | 206 | ERROR_PARAMS(ZED(FORG0001_NameNotNCName_2), lString)); |
228 | 207 | } | 207 | } |
230 | 208 | 208 | ||
231 | 209 | store::Item_t lItem; | 209 | store::Item_t lItem; |
232 | 210 | theItemFactory->createNCName(lItem, lString); | 210 | theItemFactory->createNCName(lItem, lString); |
233 | 211 | return &*lItem; | 211 | return &*lItem; |
234 | 212 | } | 212 | } |
235 | 213 | 213 | ||
262 | 214 | 214 | ||
263 | 215 | Item ItemFactoryImpl::createBase64Binary(const char* aBinData, size_t aLength) | 215 | Item ItemFactoryImpl::createBase64Binary(const char* aData, size_t aLength, |
264 | 216 | { | 216 | bool aIsBase64) |
265 | 217 | store::Item_t lItem; | 217 | { |
266 | 218 | xs_base64Binary n; | 218 | try { |
267 | 219 | std::string lMessage; | 219 | store::Item_t result; |
268 | 220 | if (xs_base64Binary::parseString(aBinData, aLength, n, lMessage)) | 220 | xs_base64Binary b64( aData, aLength, aIsBase64 ); |
269 | 221 | { | 221 | theItemFactory->createBase64Binary( result, b64 ); |
270 | 222 | theItemFactory->createBase64Binary(lItem, n); | 222 | return &*result; |
271 | 223 | } | 223 | } |
272 | 224 | else | 224 | catch ( std::exception const &e ) { |
273 | 225 | { | 225 | throw ZORBA_EXCEPTION( |
274 | 226 | throw ZORBA_EXCEPTION(zerr::ZSTR0040_TYPE_ERROR, ERROR_PARAMS(lMessage)); | 226 | zerr::ZSTR0040_TYPE_ERROR, ERROR_PARAMS( e.what() ) |
275 | 227 | } | 227 | ); |
276 | 228 | return &*lItem; | 228 | } |
251 | 229 | } | ||
252 | 230 | |||
253 | 231 | |||
254 | 232 | Item ItemFactoryImpl::createBase64Binary(const unsigned char* aBinData, size_t aLength) | ||
255 | 233 | { | ||
256 | 234 | store::Item_t lItem; | ||
257 | 235 | xs_base64Binary n; | ||
258 | 236 | std::string lMessage; | ||
259 | 237 | xs_base64Binary::encode(aBinData, aLength, n); | ||
260 | 238 | theItemFactory->createBase64Binary(lItem, n); | ||
261 | 239 | return &*lItem; | ||
277 | 240 | } | 229 | } |
278 | 241 | 230 | ||
279 | 242 | 231 | ||
280 | 243 | Item ItemFactoryImpl::createBase64Binary(std::istream& aEncodedStream) | 232 | Item ItemFactoryImpl::createBase64Binary(std::istream& aEncodedStream) |
281 | 244 | { | 233 | { |
293 | 245 | std::stringstream lSs; | 234 | std::ostringstream oss; |
294 | 246 | while (aEncodedStream.good()) | 235 | oss << aEncodedStream.rdbuf(); |
295 | 247 | { | 236 | std::string const temp( oss.str() ); |
296 | 248 | char c = aEncodedStream.get(); | 237 | return createBase64Binary( temp.data(), temp.size(), true ); |
286 | 249 | if (aEncodedStream.good()) | ||
287 | 250 | { | ||
288 | 251 | lSs.put(c); | ||
289 | 252 | } | ||
290 | 253 | } | ||
291 | 254 | std::string lContent = lSs.str(); | ||
292 | 255 | return createBase64Binary(lContent.c_str(), lContent.size()); | ||
297 | 256 | } | 238 | } |
298 | 257 | 239 | ||
299 | 258 | 240 | ||
300 | @@ -265,8 +247,8 @@ | |||
301 | 265 | { | 247 | { |
302 | 266 | store::Item_t lItem; | 248 | store::Item_t lItem; |
303 | 267 | theItemFactory->createStreamableBase64Binary( | 249 | theItemFactory->createStreamableBase64Binary( |
306 | 268 | lItem, stream, streamReleaser, seekable, encoded | 250 | lItem, stream, streamReleaser, seekable, encoded |
307 | 269 | ); | 251 | ); |
308 | 270 | return &*lItem; | 252 | return &*lItem; |
309 | 271 | } | 253 | } |
310 | 272 | 254 | ||
311 | @@ -281,8 +263,8 @@ | |||
312 | 281 | { | 263 | { |
313 | 282 | store::Item_t lItem; | 264 | store::Item_t lItem; |
314 | 283 | theItemFactory->createStreamableBase64Binary( | 265 | theItemFactory->createStreamableBase64Binary( |
317 | 284 | lItem, stream, streamReleaser, uri, seekable, encoded | 266 | lItem, stream, streamReleaser, uri, seekable, encoded |
318 | 285 | ); | 267 | ); |
319 | 286 | return &*lItem; | 268 | return &*lItem; |
320 | 287 | } | 269 | } |
321 | 288 | 270 | ||
322 | @@ -293,8 +275,8 @@ | |||
323 | 293 | theItemFactory->createBoolean(lItem, aValue); | 275 | theItemFactory->createBoolean(lItem, aValue); |
324 | 294 | return &*lItem; | 276 | return &*lItem; |
325 | 295 | } | 277 | } |
328 | 296 | 278 | ||
329 | 297 | 279 | ||
330 | 298 | Item ItemFactoryImpl::createDecimalFromLong (unsigned long aValue) | 280 | Item ItemFactoryImpl::createDecimalFromLong (unsigned long aValue) |
331 | 299 | { | 281 | { |
332 | 300 | store::Item_t lItem; | 282 | store::Item_t lItem; |
333 | @@ -302,8 +284,8 @@ | |||
334 | 302 | theItemFactory->createDecimal(lItem, lDecimal); | 284 | theItemFactory->createDecimal(lItem, lDecimal); |
335 | 303 | return &*lItem; | 285 | return &*lItem; |
336 | 304 | } | 286 | } |
339 | 305 | 287 | ||
340 | 306 | 288 | ||
341 | 307 | Item ItemFactoryImpl::createDecimalFromDouble (double aValue) | 289 | Item ItemFactoryImpl::createDecimalFromDouble (double aValue) |
342 | 308 | { | 290 | { |
343 | 309 | store::Item_t lItem; | 291 | store::Item_t lItem; |
344 | @@ -357,7 +339,7 @@ | |||
345 | 357 | } | 339 | } |
346 | 358 | return &*lItem; | 340 | return &*lItem; |
347 | 359 | } | 341 | } |
349 | 360 | 342 | ||
350 | 361 | 343 | ||
351 | 362 | Item ItemFactoryImpl::createLong ( long long aLong ) | 344 | Item ItemFactoryImpl::createLong ( long long aLong ) |
352 | 363 | { | 345 | { |
353 | @@ -366,7 +348,7 @@ | |||
354 | 366 | theItemFactory->createLong(lItem, aLong); | 348 | theItemFactory->createLong(lItem, aLong); |
355 | 367 | return &*lItem; | 349 | return &*lItem; |
356 | 368 | } | 350 | } |
358 | 369 | 351 | ||
359 | 370 | 352 | ||
360 | 371 | Item ItemFactoryImpl::createInt ( int aInt ) | 353 | Item ItemFactoryImpl::createInt ( int aInt ) |
361 | 372 | { | 354 | { |
362 | @@ -378,7 +360,7 @@ | |||
363 | 378 | 360 | ||
364 | 379 | return &*lItem; | 361 | return &*lItem; |
365 | 380 | } | 362 | } |
367 | 381 | 363 | ||
368 | 382 | 364 | ||
369 | 383 | Item ItemFactoryImpl::createShort ( short aShort ) | 365 | Item ItemFactoryImpl::createShort ( short aShort ) |
370 | 384 | { | 366 | { |
371 | @@ -388,8 +370,8 @@ | |||
372 | 388 | 370 | ||
373 | 389 | return &*lItem; | 371 | return &*lItem; |
374 | 390 | } | 372 | } |
377 | 391 | 373 | ||
378 | 392 | 374 | ||
379 | 393 | Item ItemFactoryImpl::createByte ( char aValue ) | 375 | Item ItemFactoryImpl::createByte ( char aValue ) |
380 | 394 | { | 376 | { |
381 | 395 | store::Item_t lItem; | 377 | store::Item_t lItem; |
382 | @@ -398,8 +380,8 @@ | |||
383 | 398 | 380 | ||
384 | 399 | return &*lItem; | 381 | return &*lItem; |
385 | 400 | } | 382 | } |
388 | 401 | 383 | ||
389 | 402 | 384 | ||
390 | 403 | Item ItemFactoryImpl::createDateTime(short aYear, short aMonth, short aDay, | 385 | Item ItemFactoryImpl::createDateTime(short aYear, short aMonth, short aDay, |
391 | 404 | short aHour, short aMinute, double aSecond, | 386 | short aHour, short aMinute, double aSecond, |
392 | 405 | int aTimezone) | 387 | int aTimezone) |
393 | @@ -468,7 +450,7 @@ | |||
394 | 468 | return &*lItem; | 450 | return &*lItem; |
395 | 469 | } | 451 | } |
396 | 470 | 452 | ||
398 | 471 | 453 | ||
399 | 472 | Item ItemFactoryImpl::createDouble ( const String& aValue ) | 454 | Item ItemFactoryImpl::createDouble ( const String& aValue ) |
400 | 473 | { | 455 | { |
401 | 474 | zstring lString = Unmarshaller::getInternalString( aValue ); | 456 | zstring lString = Unmarshaller::getInternalString( aValue ); |
402 | @@ -498,17 +480,17 @@ | |||
403 | 498 | Item ItemFactoryImpl::createDuration( | 480 | Item ItemFactoryImpl::createDuration( |
404 | 499 | short aYears, | 481 | short aYears, |
405 | 500 | short aMonths, | 482 | short aMonths, |
407 | 501 | short aDays, | 483 | short aDays, |
408 | 502 | short aHours, | 484 | short aHours, |
409 | 503 | short aMinutes, | 485 | short aMinutes, |
410 | 504 | double aSeconds ) | 486 | double aSeconds ) |
411 | 505 | { | 487 | { |
412 | 506 | store::Item_t lItem; | 488 | store::Item_t lItem; |
414 | 507 | 489 | ||
415 | 508 | theItemFactory->createDuration(lItem, | 490 | theItemFactory->createDuration(lItem, |
416 | 509 | aYears, aMonths, aDays, | 491 | aYears, aMonths, aDays, |
417 | 510 | aHours, aMinutes, aSeconds); | 492 | aHours, aMinutes, aSeconds); |
419 | 511 | 493 | ||
420 | 512 | return &*lItem; | 494 | return &*lItem; |
421 | 513 | } | 495 | } |
422 | 514 | 496 | ||
423 | @@ -551,7 +533,7 @@ | |||
424 | 551 | try { | 533 | try { |
425 | 552 | xs_float const lFloat(lString); | 534 | xs_float const lFloat(lString); |
426 | 553 | theItemFactory->createFloat(lItem, lFloat); | 535 | theItemFactory->createFloat(lItem, lFloat); |
428 | 554 | } | 536 | } |
429 | 555 | catch ( std::exception const& ) { | 537 | catch ( std::exception const& ) { |
430 | 556 | // ignore | 538 | // ignore |
431 | 557 | } | 539 | } |
432 | @@ -567,7 +549,7 @@ | |||
433 | 567 | return &*lItem; | 549 | return &*lItem; |
434 | 568 | } | 550 | } |
435 | 569 | 551 | ||
437 | 570 | 552 | ||
438 | 571 | Item ItemFactoryImpl::createHexBinary( const char* aHexData, size_t aSize, | 553 | Item ItemFactoryImpl::createHexBinary( const char* aHexData, size_t aSize, |
439 | 572 | bool aIsEncoded ) | 554 | bool aIsEncoded ) |
440 | 573 | { | 555 | { |
441 | @@ -586,7 +568,7 @@ | |||
442 | 586 | } | 568 | } |
443 | 587 | return &*lItem; | 569 | return &*lItem; |
444 | 588 | } | 570 | } |
446 | 589 | 571 | ||
447 | 590 | 572 | ||
448 | 591 | Item ItemFactoryImpl::createNonNegativeInteger ( unsigned long long aValue ) | 573 | Item ItemFactoryImpl::createNonNegativeInteger ( unsigned long long aValue ) |
449 | 592 | { | 574 | { |
450 | @@ -623,41 +605,41 @@ | |||
451 | 623 | store::Item_t lItem; | 605 | store::Item_t lItem; |
452 | 624 | 606 | ||
453 | 625 | theItemFactory->createGDay(lItem, lString.c_str(), lString.size()); | 607 | theItemFactory->createGDay(lItem, lString.c_str(), lString.size()); |
455 | 626 | 608 | ||
456 | 627 | return &*lItem; | 609 | return &*lItem; |
457 | 628 | } | 610 | } |
459 | 629 | 611 | ||
460 | 630 | 612 | ||
461 | 631 | Item ItemFactoryImpl::createGDay ( short aDay ) | 613 | Item ItemFactoryImpl::createGDay ( short aDay ) |
462 | 632 | { | 614 | { |
463 | 633 | store::Item_t lItem; | 615 | store::Item_t lItem; |
464 | 634 | 616 | ||
465 | 635 | theItemFactory->createGDay(lItem, aDay ); | 617 | theItemFactory->createGDay(lItem, aDay ); |
467 | 636 | 618 | ||
468 | 637 | return &*lItem; | 619 | return &*lItem; |
469 | 638 | } | 620 | } |
472 | 639 | 621 | ||
473 | 640 | 622 | ||
474 | 641 | Item ItemFactoryImpl::createGMonth ( short aMonth ) | 623 | Item ItemFactoryImpl::createGMonth ( short aMonth ) |
475 | 642 | { | 624 | { |
476 | 643 | store::Item_t lItem; | 625 | store::Item_t lItem; |
477 | 644 | 626 | ||
478 | 645 | theItemFactory->createGMonth(lItem, aMonth ); | 627 | theItemFactory->createGMonth(lItem, aMonth ); |
480 | 646 | 628 | ||
481 | 647 | return &*lItem; | 629 | return &*lItem; |
482 | 648 | } | 630 | } |
483 | 649 | 631 | ||
485 | 650 | 632 | ||
486 | 651 | Item ItemFactoryImpl::createGMonth ( const String& aValue ) | 633 | Item ItemFactoryImpl::createGMonth ( const String& aValue ) |
487 | 652 | { | 634 | { |
488 | 653 | zstring lString = Unmarshaller::getInternalString(aValue); | 635 | zstring lString = Unmarshaller::getInternalString(aValue); |
489 | 654 | store::Item_t lItem; | 636 | store::Item_t lItem; |
491 | 655 | 637 | ||
492 | 656 | theItemFactory->createGMonth(lItem, lString.c_str(), lString.size()); | 638 | theItemFactory->createGMonth(lItem, lString.c_str(), lString.size()); |
494 | 657 | 639 | ||
495 | 658 | return &*lItem; | 640 | return &*lItem; |
496 | 659 | } | 641 | } |
498 | 660 | 642 | ||
499 | 661 | 643 | ||
500 | 662 | Item ItemFactoryImpl::createGMonthDay(const String& aValue) | 644 | Item ItemFactoryImpl::createGMonthDay(const String& aValue) |
501 | 663 | { | 645 | { |
502 | @@ -665,7 +647,7 @@ | |||
503 | 665 | store::Item_t lItem; | 647 | store::Item_t lItem; |
504 | 666 | 648 | ||
505 | 667 | theItemFactory->createGMonthDay(lItem, lString.c_str(), lString.size()); | 649 | theItemFactory->createGMonthDay(lItem, lString.c_str(), lString.size()); |
507 | 668 | 650 | ||
508 | 669 | return &*lItem; | 651 | return &*lItem; |
509 | 670 | } | 652 | } |
510 | 671 | 653 | ||
511 | @@ -675,10 +657,10 @@ | |||
512 | 675 | store::Item_t lItem; | 657 | store::Item_t lItem; |
513 | 676 | 658 | ||
514 | 677 | theItemFactory->createGMonthDay(lItem, aMonth, aDay ); | 659 | theItemFactory->createGMonthDay(lItem, aMonth, aDay ); |
516 | 678 | 660 | ||
517 | 679 | return &*lItem; | 661 | return &*lItem; |
518 | 680 | } | 662 | } |
520 | 681 | 663 | ||
521 | 682 | 664 | ||
522 | 683 | Item ItemFactoryImpl::createGYear(const String& aValue) | 665 | Item ItemFactoryImpl::createGYear(const String& aValue) |
523 | 684 | { | 666 | { |
524 | @@ -686,7 +668,7 @@ | |||
525 | 686 | store::Item_t lItem; | 668 | store::Item_t lItem; |
526 | 687 | 669 | ||
527 | 688 | theItemFactory->createGYear(lItem, lString.c_str(), lString.size() ); | 670 | theItemFactory->createGYear(lItem, lString.c_str(), lString.size() ); |
529 | 689 | 671 | ||
530 | 690 | return &*lItem; | 672 | return &*lItem; |
531 | 691 | } | 673 | } |
532 | 692 | 674 | ||
533 | @@ -696,10 +678,10 @@ | |||
534 | 696 | store::Item_t lItem; | 678 | store::Item_t lItem; |
535 | 697 | 679 | ||
536 | 698 | theItemFactory->createGYear(lItem, aYear ); | 680 | theItemFactory->createGYear(lItem, aYear ); |
538 | 699 | 681 | ||
539 | 700 | return &*lItem; | 682 | return &*lItem; |
540 | 701 | } | 683 | } |
542 | 702 | 684 | ||
543 | 703 | 685 | ||
544 | 704 | Item ItemFactoryImpl::createGYearMonth ( const String& aValue ) | 686 | Item ItemFactoryImpl::createGYearMonth ( const String& aValue ) |
545 | 705 | { | 687 | { |
546 | @@ -707,17 +689,17 @@ | |||
547 | 707 | store::Item_t lItem; | 689 | store::Item_t lItem; |
548 | 708 | 690 | ||
549 | 709 | theItemFactory->createGYearMonth(lItem, lString.c_str(), lString.size()); | 691 | theItemFactory->createGYearMonth(lItem, lString.c_str(), lString.size()); |
551 | 710 | 692 | ||
552 | 711 | return &*lItem; | 693 | return &*lItem; |
553 | 712 | } | 694 | } |
554 | 713 | 695 | ||
556 | 714 | 696 | ||
557 | 715 | Item ItemFactoryImpl::createGYearMonth ( short aYear, short aMonth ) | 697 | Item ItemFactoryImpl::createGYearMonth ( short aYear, short aMonth ) |
558 | 716 | { | 698 | { |
559 | 717 | store::Item_t lItem; | 699 | store::Item_t lItem; |
560 | 718 | 700 | ||
561 | 719 | theItemFactory->createGYearMonth(lItem, aYear, aMonth ); | 701 | theItemFactory->createGYearMonth(lItem, aYear, aMonth ); |
563 | 720 | 702 | ||
564 | 721 | return &*lItem; | 703 | return &*lItem; |
565 | 722 | } | 704 | } |
566 | 723 | 705 | ||
567 | @@ -728,17 +710,17 @@ | |||
568 | 728 | store::Item_t lItem; | 710 | store::Item_t lItem; |
569 | 729 | 711 | ||
570 | 730 | theItemFactory->createTime(lItem, lString.c_str(), lString.size() ); | 712 | theItemFactory->createTime(lItem, lString.c_str(), lString.size() ); |
572 | 731 | 713 | ||
573 | 732 | return &*lItem; | 714 | return &*lItem; |
574 | 733 | } | 715 | } |
576 | 734 | 716 | ||
577 | 735 | 717 | ||
578 | 736 | Item ItemFactoryImpl::createTime ( short aHour, short aMinute, double aSecond ) | 718 | Item ItemFactoryImpl::createTime ( short aHour, short aMinute, double aSecond ) |
579 | 737 | { | 719 | { |
580 | 738 | store::Item_t lItem; | 720 | store::Item_t lItem; |
581 | 739 | 721 | ||
582 | 740 | theItemFactory->createTime(lItem, aHour, aMinute, aSecond ); | 722 | theItemFactory->createTime(lItem, aHour, aMinute, aSecond ); |
584 | 741 | 723 | ||
585 | 742 | return &*lItem; | 724 | return &*lItem; |
586 | 743 | } | 725 | } |
587 | 744 | 726 | ||
588 | @@ -753,7 +735,7 @@ | |||
589 | 753 | theItemFactory->createTime(lItem, aHour, aMinute, aSecond, aTimezone ); | 735 | theItemFactory->createTime(lItem, aHour, aMinute, aSecond, aTimezone ); |
590 | 754 | return &*lItem; | 736 | return &*lItem; |
591 | 755 | } | 737 | } |
593 | 756 | 738 | ||
594 | 757 | 739 | ||
595 | 758 | Item ItemFactoryImpl::createUnsignedByte(const unsigned char aValue) | 740 | Item ItemFactoryImpl::createUnsignedByte(const unsigned char aValue) |
596 | 759 | { | 741 | { |
597 | @@ -761,19 +743,19 @@ | |||
598 | 761 | theItemFactory->createUnsignedByte(lItem, aValue); | 743 | theItemFactory->createUnsignedByte(lItem, aValue); |
599 | 762 | return &*lItem; | 744 | return &*lItem; |
600 | 763 | } | 745 | } |
602 | 764 | 746 | ||
603 | 765 | 747 | ||
604 | 766 | Item ItemFactoryImpl::createUnsignedInt(unsigned int aValue) | 748 | Item ItemFactoryImpl::createUnsignedInt(unsigned int aValue) |
605 | 767 | { | 749 | { |
606 | 768 | store::Item_t lItem; | 750 | store::Item_t lItem; |
608 | 769 | 751 | ||
609 | 770 | if ( aValue <= UINT32_MAX ) { | 752 | if ( aValue <= UINT32_MAX ) { |
610 | 771 | theItemFactory->createUnsignedInt(lItem, aValue); | 753 | theItemFactory->createUnsignedInt(lItem, aValue); |
611 | 772 | } | 754 | } |
612 | 773 | 755 | ||
613 | 774 | return &*lItem; | 756 | return &*lItem; |
614 | 775 | } | 757 | } |
616 | 776 | 758 | ||
617 | 777 | 759 | ||
618 | 778 | Item ItemFactoryImpl::createUnsignedLong(unsigned long long aValue) | 760 | Item ItemFactoryImpl::createUnsignedLong(unsigned long long aValue) |
619 | 779 | { | 761 | { |
620 | @@ -781,7 +763,7 @@ | |||
621 | 781 | theItemFactory->createUnsignedLong(lItem, aValue); | 763 | theItemFactory->createUnsignedLong(lItem, aValue); |
622 | 782 | return &*lItem; | 764 | return &*lItem; |
623 | 783 | } | 765 | } |
625 | 784 | 766 | ||
626 | 785 | 767 | ||
627 | 786 | Item ItemFactoryImpl::createUnsignedShort(unsigned short aValue) | 768 | Item ItemFactoryImpl::createUnsignedShort(unsigned short aValue) |
628 | 787 | { | 769 | { |
629 | @@ -973,7 +955,7 @@ | |||
630 | 973 | 955 | ||
631 | 974 | std::vector<std::pair<Item, Item> >::iterator i = aPairs.begin(); | 956 | std::vector<std::pair<Item, Item> >::iterator i = aPairs.begin(); |
632 | 975 | std::vector<std::pair<Item, Item> >::iterator end = aPairs.end(); | 957 | std::vector<std::pair<Item, Item> >::iterator end = aPairs.end(); |
634 | 976 | for (; i != end; i++) | 958 | for (; i != end; i++) |
635 | 977 | { | 959 | { |
636 | 978 | names.push_back(Unmarshaller::getInternalItem((*i).first)); | 960 | names.push_back(Unmarshaller::getInternalItem((*i).first)); |
637 | 979 | values.push_back(Unmarshaller::getInternalItem((*i).second)); | 961 | values.push_back(Unmarshaller::getInternalItem((*i).second)); |
638 | @@ -1001,7 +983,7 @@ | |||
639 | 1001 | items.reserve(numItems); | 983 | items.reserve(numItems); |
640 | 1002 | std::vector<Item>::iterator ite = aItems.begin(); | 984 | std::vector<Item>::iterator ite = aItems.begin(); |
641 | 1003 | std::vector<Item>::iterator end = aItems.end(); | 985 | std::vector<Item>::iterator end = aItems.end(); |
643 | 1004 | for (; ite != end; ++ite) | 986 | for (; ite != end; ++ite) |
644 | 1005 | { | 987 | { |
645 | 1006 | items.push_back(Unmarshaller::getInternalItem(*ite)); | 988 | items.push_back(Unmarshaller::getInternalItem(*ite)); |
646 | 1007 | } | 989 | } |
647 | 1008 | 990 | ||
648 | === modified file 'src/api/itemfactoryimpl.h' | |||
649 | --- src/api/itemfactoryimpl.h 2013-06-18 23:53:59 +0000 | |||
650 | +++ src/api/itemfactoryimpl.h 2013-06-28 04:21:28 +0000 | |||
651 | @@ -67,14 +67,11 @@ | |||
652 | 67 | createNCName(const String& aValue); | 67 | createNCName(const String& aValue); |
653 | 68 | 68 | ||
654 | 69 | virtual Item | 69 | virtual Item |
656 | 70 | createBase64Binary(const char* aBinData, size_t aLength); | 70 | createBase64Binary(const char* aBinData, size_t aLength, bool aIsBase64); |
657 | 71 | 71 | ||
658 | 72 | virtual Item | 72 | virtual Item |
659 | 73 | createBase64Binary(std::istream& aStream); | 73 | createBase64Binary(std::istream& aStream); |
660 | 74 | 74 | ||
661 | 75 | virtual Item | ||
662 | 76 | createBase64Binary(const unsigned char* aBinData, size_t aLength); | ||
663 | 77 | |||
664 | 78 | virtual Item | 75 | virtual Item |
665 | 79 | createStreamableBase64Binary( | 76 | createStreamableBase64Binary( |
666 | 80 | std::istream &stream, | 77 | std::istream &stream, |
667 | 81 | 78 | ||
668 | === modified file 'src/store/naive/atomic_items.cpp' | |||
669 | --- src/store/naive/atomic_items.cpp 2013-06-18 23:53:59 +0000 | |||
670 | +++ src/store/naive/atomic_items.cpp 2013-06-28 04:21:28 +0000 | |||
671 | @@ -45,6 +45,7 @@ | |||
672 | 45 | #include "tree_id.h" | 45 | #include "tree_id.h" |
673 | 46 | 46 | ||
674 | 47 | #include "util/ascii_util.h" | 47 | #include "util/ascii_util.h" |
675 | 48 | #include "util/base64_util.h" | ||
676 | 48 | #include "util/mem_sizeof.h" | 49 | #include "util/mem_sizeof.h" |
677 | 49 | #include "util/string_util.h" | 50 | #include "util/string_util.h" |
678 | 50 | #include "util/utf8_util.h" | 51 | #include "util/utf8_util.h" |
679 | @@ -3516,8 +3517,7 @@ | |||
680 | 3516 | else | 3517 | else |
681 | 3517 | { | 3518 | { |
682 | 3518 | std::vector<char> encoded; | 3519 | std::vector<char> encoded; |
685 | 3519 | encoded.reserve(theValue.size()); | 3520 | base64::encode( &theValue[0], theValue.size(), &encoded ); |
684 | 3520 | Base64::encode(theValue, encoded); | ||
686 | 3521 | buf.insert(buf.size(), &encoded[0], encoded.size()); | 3521 | buf.insert(buf.size(), &encoded[0], encoded.size()); |
687 | 3522 | } | 3522 | } |
688 | 3523 | } | 3523 | } |
689 | @@ -3778,7 +3778,7 @@ | |||
690 | 3778 | buf.insert(buf.size(), &theValue[0], theValue.size()); | 3778 | buf.insert(buf.size(), &theValue[0], theValue.size()); |
691 | 3779 | else | 3779 | else |
692 | 3780 | { | 3780 | { |
694 | 3781 | std::vector<char> encoded; | 3781 | Base16::value_type encoded; |
695 | 3782 | Base16::encode(theValue, encoded); | 3782 | Base16::encode(theValue, encoded); |
696 | 3783 | buf.insert(buf.size(), &encoded[0], encoded.size()); | 3783 | buf.insert(buf.size(), &encoded[0], encoded.size()); |
697 | 3784 | } | 3784 | } |
698 | 3785 | 3785 | ||
699 | === modified file 'src/store/naive/simple_item_factory.cpp' | |||
700 | --- src/store/naive/simple_item_factory.cpp 2013-06-18 23:53:59 +0000 | |||
701 | +++ src/store/naive/simple_item_factory.cpp 2013-06-28 04:21:28 +0000 | |||
702 | @@ -1128,7 +1128,7 @@ | |||
703 | 1128 | store::Item_t& result, | 1128 | store::Item_t& result, |
704 | 1129 | xs_base64Binary const &value) | 1129 | xs_base64Binary const &value) |
705 | 1130 | { | 1130 | { |
707 | 1131 | const std::vector<char>& data = value.getData(); | 1131 | const std::vector<char>& data = value.data(); |
708 | 1132 | result = new Base64BinaryItem(store::XS_BASE64BINARY, | 1132 | result = new Base64BinaryItem(store::XS_BASE64BINARY, |
709 | 1133 | data.size() != 0 ? &data[0] : 0, | 1133 | data.size() != 0 ? &data[0] : 0, |
710 | 1134 | data.size(), | 1134 | data.size(), |
711 | @@ -1184,7 +1184,7 @@ | |||
712 | 1184 | bool BasicItemFactory::createHexBinary(store::Item_t& result, | 1184 | bool BasicItemFactory::createHexBinary(store::Item_t& result, |
713 | 1185 | xs_hexBinary const &value) | 1185 | xs_hexBinary const &value) |
714 | 1186 | { | 1186 | { |
716 | 1187 | std::vector<char> const &data = value.getData(); | 1187 | std::vector<char> const &data = value.data(); |
717 | 1188 | result = new HexBinaryItem( | 1188 | result = new HexBinaryItem( |
718 | 1189 | store::XS_HEXBINARY, data.empty() ? 0 : &data[0], data.size(), true | 1189 | store::XS_HEXBINARY, data.empty() ? 0 : &data[0], data.size(), true |
719 | 1190 | ); | 1190 | ); |
720 | 1191 | 1191 | ||
721 | === modified file 'src/types/casting.cpp' | |||
722 | --- src/types/casting.cpp 2013-06-19 22:18:54 +0000 | |||
723 | +++ src/types/casting.cpp 2013-06-28 04:21:28 +0000 | |||
724 | @@ -1539,12 +1539,8 @@ | |||
725 | 1539 | T1_TO_T2(b64, hxB) | 1539 | T1_TO_T2(b64, hxB) |
726 | 1540 | { | 1540 | { |
727 | 1541 | size_t s; | 1541 | size_t s; |
734 | 1542 | const char* c = aItem->getBase64BinaryValue(s); | 1542 | char const *const c = aItem->getBase64BinaryValue(s); |
735 | 1543 | xs_base64Binary tmp; | 1543 | xs_base64Binary tmp( c, s, aItem->isEncoded() ); |
730 | 1544 | if (aItem->isEncoded()) | ||
731 | 1545 | xs_base64Binary::parseString(c, s, tmp); | ||
732 | 1546 | else | ||
733 | 1547 | xs_base64Binary::encode(c, s, tmp); | ||
736 | 1548 | aFactory->createHexBinary(result, xs_hexBinary(tmp)); | 1544 | aFactory->createHexBinary(result, xs_hexBinary(tmp)); |
737 | 1549 | } | 1545 | } |
738 | 1550 | 1546 | ||
739 | @@ -1567,11 +1563,7 @@ | |||
740 | 1567 | { | 1563 | { |
741 | 1568 | size_t s; | 1564 | size_t s; |
742 | 1569 | char const *const c = aItem->getHexBinaryValue(s); | 1565 | char const *const c = aItem->getHexBinaryValue(s); |
748 | 1570 | xs_hexBinary tmp; | 1566 | xs_hexBinary tmp( c, s, aItem->isEncoded() ); |
744 | 1571 | if (aItem->isEncoded()) | ||
745 | 1572 | xs_hexBinary::parseString(c, s, tmp); | ||
746 | 1573 | else | ||
747 | 1574 | xs_hexBinary::encode(c, s, tmp); | ||
749 | 1575 | aFactory->createBase64Binary(result, xs_base64Binary(tmp)); | 1567 | aFactory->createBase64Binary(result, xs_base64Binary(tmp)); |
750 | 1576 | } | 1568 | } |
751 | 1577 | 1569 | ||
752 | 1578 | 1570 | ||
753 | === modified file 'src/zorbaserialization/serialize_zorba_types.cpp' | |||
754 | --- src/zorbaserialization/serialize_zorba_types.cpp 2013-06-15 02:57:08 +0000 | |||
755 | +++ src/zorbaserialization/serialize_zorba_types.cpp 2013-06-28 04:21:28 +0000 | |||
756 | @@ -160,7 +160,7 @@ | |||
757 | 160 | ********************************************************************************/ | 160 | ********************************************************************************/ |
758 | 161 | void operator&(Archiver& ar, Base64& obj) | 161 | void operator&(Archiver& ar, Base64& obj) |
759 | 162 | { | 162 | { |
761 | 163 | ar & obj.theData; | 163 | ar & obj.data_; |
762 | 164 | } | 164 | } |
763 | 165 | 165 | ||
764 | 166 | 166 | ||
765 | @@ -169,7 +169,7 @@ | |||
766 | 169 | ********************************************************************************/ | 169 | ********************************************************************************/ |
767 | 170 | void operator&(Archiver& ar, Base16& obj) | 170 | void operator&(Archiver& ar, Base16& obj) |
768 | 171 | { | 171 | { |
770 | 172 | ar & obj.theData; | 172 | ar & obj.data_; |
771 | 173 | } | 173 | } |
772 | 174 | 174 | ||
773 | 175 | 175 | ||
774 | @@ -722,18 +722,8 @@ | |||
775 | 722 | 722 | ||
776 | 723 | size_t s; | 723 | size_t s; |
777 | 724 | const char* c = obj->getHexBinaryValue(s); | 724 | const char* c = obj->getHexBinaryValue(s); |
790 | 725 | if (obj->isEncoded()) | 725 | Base16 tmp( c, s, obj->isEncoded() ); |
791 | 726 | { | 726 | ar & tmp; |
780 | 727 | Base16 tmp; | ||
781 | 728 | Base16::parseString(c, s, tmp); | ||
782 | 729 | ar & tmp; | ||
783 | 730 | } | ||
784 | 731 | else | ||
785 | 732 | { | ||
786 | 733 | Base16 tmp(c, s); | ||
787 | 734 | ar & tmp; | ||
788 | 735 | } | ||
789 | 736 | |||
792 | 737 | ar.set_is_temp_field(false); | 727 | ar.set_is_temp_field(false); |
793 | 738 | 728 | ||
794 | 739 | break; | 729 | break; |
795 | @@ -744,18 +734,8 @@ | |||
796 | 744 | 734 | ||
797 | 745 | size_t s; | 735 | size_t s; |
798 | 746 | const char* c = obj->getBase64BinaryValue(s); | 736 | const char* c = obj->getBase64BinaryValue(s); |
811 | 747 | if (obj->isEncoded()) | 737 | Base64 tmp( c, s, obj->isEncoded() ); |
812 | 748 | { | 738 | ar & tmp; |
801 | 749 | Base64 tmp; | ||
802 | 750 | Base64::parseString(c, s, tmp); | ||
803 | 751 | ar & tmp; | ||
804 | 752 | } | ||
805 | 753 | else | ||
806 | 754 | { | ||
807 | 755 | Base64 tmp(c, s); | ||
808 | 756 | ar & tmp; | ||
809 | 757 | } | ||
810 | 758 | |||
813 | 759 | ar.set_is_temp_field(false); | 739 | ar.set_is_temp_field(false); |
814 | 760 | 740 | ||
815 | 761 | break; | 741 | break; |
816 | 762 | 742 | ||
817 | === modified file 'src/zorbatypes/binary.cpp' | |||
818 | --- src/zorbatypes/binary.cpp 2013-05-08 01:05:04 +0000 | |||
819 | +++ src/zorbatypes/binary.cpp 2013-06-28 04:21:28 +0000 | |||
820 | @@ -36,18 +36,6 @@ | |||
821 | 36 | 36 | ||
822 | 37 | /////////////////////////////////////////////////////////////////////////////// | 37 | /////////////////////////////////////////////////////////////////////////////// |
823 | 38 | 38 | ||
824 | 39 | #define CATCH_BASE64_EXCEPTION() \ | ||
825 | 40 | catch (const base64::exception& e) \ | ||
826 | 41 | { \ | ||
827 | 42 | throw XQUERY_EXCEPTION(err::FORG0001, \ | ||
828 | 43 | ERROR_PARAMS(ZED(FORG0001_Base64BadChar_2), e.invalid_char())); \ | ||
829 | 44 | } \ | ||
830 | 45 | catch (const std::invalid_argument&) \ | ||
831 | 46 | { \ | ||
832 | 47 | throw XQUERY_EXCEPTION(err::FORG0001, \ | ||
833 | 48 | ERROR_PARAMS(ZED(FORG0001_Base64Multiple4))); \ | ||
834 | 49 | } | ||
835 | 50 | |||
836 | 51 | static size_t copy_without_ws( char const *from, size_t from_len, char *to ) { | 39 | static size_t copy_without_ws( char const *from, size_t from_len, char *to ) { |
837 | 52 | char const *const to_orig = to; | 40 | char const *const to_orig = to; |
838 | 53 | for ( char const *const from_end = from + from_len; from < from_end; ++from ) | 41 | for ( char const *const from_end = from + from_len; from < from_end; ++from ) |
839 | @@ -56,106 +44,26 @@ | |||
840 | 56 | return to - to_orig; | 44 | return to - to_orig; |
841 | 57 | } | 45 | } |
842 | 58 | 46 | ||
923 | 59 | 47 | /////////////////////////////////////////////////////////////////////////////// | |
924 | 60 | bool Base64::parseString(char const *s, size_t len, Base64& aBase64) | 48 | |
925 | 61 | { | 49 | #define CATCH_BASE64_EXCEPTION() \ |
926 | 62 | if ( len ) { | 50 | catch ( base64::exception const &e ) { \ |
927 | 63 | try | 51 | throw XQUERY_EXCEPTION( err::FORG0001, \ |
928 | 64 | { | 52 | ERROR_PARAMS( ZED(FORG0001_Base64BadChar_2), e.invalid_char() ) ); \ |
929 | 65 | base64::validate( s, len, base64::dopt_ignore_ws ); | 53 | } \ |
930 | 66 | aBase64.theData.resize( len ); | 54 | catch ( std::invalid_argument const& ) { \ |
931 | 67 | aBase64.theData.resize( | 55 | throw XQUERY_EXCEPTION( err::FORG0001, \ |
932 | 68 | copy_without_ws( s, len, &aBase64.theData[0] ) | 56 | ERROR_PARAMS( ZED(FORG0001_Base64Multiple4) ) ); \ |
933 | 69 | ); | 57 | } |
934 | 70 | } | 58 | |
935 | 71 | catch (...) | 59 | void Base64::decode( istream &is, zstring *to ) { |
856 | 72 | { | ||
857 | 73 | return false; | ||
858 | 74 | } | ||
859 | 75 | } else | ||
860 | 76 | aBase64.theData.clear(); | ||
861 | 77 | return true; | ||
862 | 78 | } | ||
863 | 79 | |||
864 | 80 | |||
865 | 81 | bool Base64::parseString( char const *s, size_t len, Base64 &aBase64, | ||
866 | 82 | string &lErrorMessage ) | ||
867 | 83 | { | ||
868 | 84 | if ( len ) { | ||
869 | 85 | try | ||
870 | 86 | { | ||
871 | 87 | base64::validate( s, len, base64::dopt_ignore_ws ); | ||
872 | 88 | aBase64.theData.resize( len ); | ||
873 | 89 | aBase64.theData.resize( | ||
874 | 90 | copy_without_ws( s, len, &aBase64.theData[0] ) | ||
875 | 91 | ); | ||
876 | 92 | } | ||
877 | 93 | catch (ZorbaException const& e) | ||
878 | 94 | { | ||
879 | 95 | lErrorMessage = e.what(); | ||
880 | 96 | return false; | ||
881 | 97 | } | ||
882 | 98 | } else | ||
883 | 99 | aBase64.theData.clear(); | ||
884 | 100 | return true; | ||
885 | 101 | } | ||
886 | 102 | |||
887 | 103 | |||
888 | 104 | void Base64::encode( zstring const &s, Base64 &to ) | ||
889 | 105 | { | ||
890 | 106 | base64::encode( s.data(), s.size(), &to.theData ); | ||
891 | 107 | } | ||
892 | 108 | |||
893 | 109 | |||
894 | 110 | void Base64::encode( istream &is, Base64 &to ) | ||
895 | 111 | { | ||
896 | 112 | base64::encode( is, &to.theData ); | ||
897 | 113 | } | ||
898 | 114 | |||
899 | 115 | |||
900 | 116 | zstring Base64::encode( istream &is ) | ||
901 | 117 | { | ||
902 | 118 | zstring result; | ||
903 | 119 | base64::encode( is, &result ); | ||
904 | 120 | return result; | ||
905 | 121 | } | ||
906 | 122 | |||
907 | 123 | |||
908 | 124 | void Base64::encode( vector<char> const &from, vector<char> &to ) | ||
909 | 125 | { | ||
910 | 126 | if ( !from.empty() ) | ||
911 | 127 | base64::encode( &from[0], from.size(), &to ); | ||
912 | 128 | } | ||
913 | 129 | |||
914 | 130 | |||
915 | 131 | void Base64::encode( char const *from, size_t from_len, Base64 &to ) | ||
916 | 132 | { | ||
917 | 133 | base64::encode( from, from_len, &to.theData ); | ||
918 | 134 | } | ||
919 | 135 | |||
920 | 136 | |||
921 | 137 | void Base64::decode( istream &is, zstring *to ) | ||
922 | 138 | { | ||
936 | 139 | try { | 60 | try { |
937 | 140 | base64::decode( is, to, base64::dopt_any_len | base64::dopt_ignore_ws ); | 61 | base64::decode( is, to, base64::dopt_any_len | base64::dopt_ignore_ws ); |
938 | 141 | } | 62 | } |
939 | 142 | CATCH_BASE64_EXCEPTION() | 63 | CATCH_BASE64_EXCEPTION() |
940 | 143 | } | 64 | } |
941 | 144 | 65 | ||
956 | 145 | void Base64::decode(vector<char> const &from, vector<char> &to ) | 66 | void Base64::decode( char const *from, size_type from_len, zstring *to ) { |
943 | 146 | { | ||
944 | 147 | if ( !from.empty() ) { | ||
945 | 148 | try { | ||
946 | 149 | base64::decode( | ||
947 | 150 | &from[0], from.size(), &to, | ||
948 | 151 | base64::dopt_any_len | base64::dopt_ignore_ws | ||
949 | 152 | ); | ||
950 | 153 | } | ||
951 | 154 | CATCH_BASE64_EXCEPTION() | ||
952 | 155 | } | ||
953 | 156 | } | ||
954 | 157 | |||
955 | 158 | void Base64::decode( char const *from, size_t from_len, zstring *to ) { | ||
957 | 159 | try { | 67 | try { |
958 | 160 | base64::decode( | 68 | base64::decode( |
959 | 161 | from, from_len, to, base64::dopt_any_len | base64::dopt_ignore_ws | 69 | from, from_len, to, base64::dopt_any_len | base64::dopt_ignore_ws |
960 | @@ -164,150 +72,96 @@ | |||
961 | 164 | CATCH_BASE64_EXCEPTION() | 72 | CATCH_BASE64_EXCEPTION() |
962 | 165 | } | 73 | } |
963 | 166 | 74 | ||
970 | 167 | 75 | Base64::Base64( Base16 const &b16 ) { | |
971 | 168 | Base64::Base64( Base16 const &aBase16 ) | 76 | value_type tmp; |
972 | 169 | { | 77 | hexbinary::decode( &b16.data()[0], b16.size(), &tmp ); |
973 | 170 | vector<char> tmp; | 78 | base64::encode( &tmp[0], tmp.size(), &data_ ); |
968 | 171 | Base16::decode( aBase16.getData(), tmp ); | ||
969 | 172 | Base64::encode( tmp, theData ); | ||
974 | 173 | } | 79 | } |
975 | 174 | 80 | ||
979 | 175 | 81 | Base64& Base64::assign( char const *data, size_type size, bool is_encoded ) { | |
977 | 176 | Base64::Base64( char const *bin_data, size_t len ) | ||
978 | 177 | { | ||
980 | 178 | try { | 82 | try { |
982 | 179 | base64::encode( bin_data, len, &theData ); | 83 | if ( is_encoded ) { |
983 | 84 | base64::validate( data, size, base64::dopt_ignore_ws ); | ||
984 | 85 | data_.resize( size ); | ||
985 | 86 | data_.resize( copy_without_ws( data, size, &data_[0] ) ); | ||
986 | 87 | } else | ||
987 | 88 | base64::encode( data, size, &data_ ); | ||
988 | 89 | return *this; | ||
989 | 180 | } | 90 | } |
990 | 181 | CATCH_BASE64_EXCEPTION() | 91 | CATCH_BASE64_EXCEPTION() |
991 | 182 | } | 92 | } |
992 | 183 | 93 | ||
1039 | 184 | 94 | uint32_t Base64::hash() const { | |
1040 | 185 | 95 | return data_.size() ? ztd::hash_bytes( &data_[0], data_.size() ) : 0; | |
1041 | 186 | bool Base64::equal( Base64 const &aBase64 ) const | 96 | } |
1042 | 187 | { | 97 | |
1043 | 188 | if ( size() != aBase64.size() ) | 98 | bool Base64::parseString( char const *s, size_type size, Base64 &b64 ) { |
1044 | 189 | return false; | 99 | if ( size ) { |
1045 | 190 | return ::strncmp( &theData[0], &aBase64.theData[0], size() ) == 0; | 100 | try { |
1046 | 191 | } | 101 | base64::validate( s, size, base64::dopt_ignore_ws ); |
1047 | 192 | 102 | b64.data_.resize( size ); | |
1048 | 193 | 103 | b64.data_.resize( copy_without_ws( s, size, &b64.data_[0] ) ); | |
1049 | 194 | zstring Base64::str() const | 104 | } |
1050 | 195 | { | 105 | catch ( std::exception const& ) { |
1051 | 196 | zstring result; | 106 | return false; |
1052 | 197 | if ( theData.size() ) | 107 | } |
1053 | 198 | result.assign( &theData[0], theData.size() ); | 108 | } else |
1054 | 199 | return result; | 109 | b64.data_.clear(); |
1055 | 200 | } | 110 | return true; |
1010 | 201 | |||
1011 | 202 | |||
1012 | 203 | zstring Base64::decode() const | ||
1013 | 204 | { | ||
1014 | 205 | zstring result; | ||
1015 | 206 | if ( !theData.empty() ) | ||
1016 | 207 | base64::decode( &theData[0], theData.size(), &result ); | ||
1017 | 208 | return result; | ||
1018 | 209 | } | ||
1019 | 210 | |||
1020 | 211 | |||
1021 | 212 | void Base64::decode( vector<char> &to ) | ||
1022 | 213 | { | ||
1023 | 214 | if ( !theData.empty() ) | ||
1024 | 215 | base64::decode( &theData[0], theData.size(), &to ); | ||
1025 | 216 | } | ||
1026 | 217 | |||
1027 | 218 | |||
1028 | 219 | uint32_t Base64::hash() const | ||
1029 | 220 | { | ||
1030 | 221 | return theData.size() ? ztd::hash_bytes( &theData[0], theData.size() ) : 0; | ||
1031 | 222 | } | ||
1032 | 223 | |||
1033 | 224 | |||
1034 | 225 | ostream& operator<<(ostream& os, const Base64& aBase64) | ||
1035 | 226 | { | ||
1036 | 227 | if ( aBase64.size() ) | ||
1037 | 228 | os.write( &aBase64.getData()[0], aBase64.size() ); | ||
1038 | 229 | return os; | ||
1056 | 230 | } | 111 | } |
1057 | 231 | 112 | ||
1058 | 232 | /////////////////////////////////////////////////////////////////////////////// | 113 | /////////////////////////////////////////////////////////////////////////////// |
1059 | 233 | 114 | ||
1060 | 234 | #define CATCH_HEXBINARY_EXCEPTION() \ | 115 | #define CATCH_HEXBINARY_EXCEPTION() \ |
1065 | 235 | catch (const hexbinary::exception& e) \ | 116 | catch ( hexbinary::exception const &e ) { \ |
1066 | 236 | { \ | 117 | throw XQUERY_EXCEPTION( err::FORG0001, \ |
1067 | 237 | throw XQUERY_EXCEPTION(err::FORG0001, \ | 118 | ERROR_PARAMS( ZED(FORG0001_BadHexDigit_2), e.invalid_char() ) ); \ |
1064 | 238 | ERROR_PARAMS(ZED(FORG0001_BadHexDigit_2), e.invalid_char())); \ | ||
1068 | 239 | } \ | 119 | } \ |
1104 | 240 | catch (const std::invalid_argument&) \ | 120 | catch ( std::invalid_argument const& ) { \ |
1105 | 241 | { \ | 121 | throw XQUERY_EXCEPTION( err::FORG0001, \ |
1106 | 242 | throw XQUERY_EXCEPTION(err::FORG0001, \ | 122 | ERROR_PARAMS(ZED(FORG0001_HexBinaryMustBeEven) ) ); \ |
1107 | 243 | ERROR_PARAMS(ZED(FORG0001_HexBinaryMustBeEven))); \ | 123 | } |
1108 | 244 | } | 124 | |
1109 | 245 | 125 | Base16::Base16( Base64 const &b64 ) { | |
1110 | 246 | Base16::Base16( char const *bin_data, size_t len ) | 126 | value_type temp; |
1111 | 247 | { | 127 | base64::decode( &b64.data()[0], b64.size(), &temp ); |
1112 | 248 | try { | 128 | assign( &temp[0], temp.size(), false ); |
1113 | 249 | hexbinary::encode( bin_data, len, &theData ); | 129 | } |
1114 | 250 | } | 130 | |
1115 | 251 | CATCH_HEXBINARY_EXCEPTION() | 131 | Base16& Base16::assign( char const *data, size_type size, bool is_encoded ) { |
1116 | 252 | } | 132 | if ( !size ) |
1117 | 253 | 133 | data_.clear(); | |
1118 | 254 | Base16::Base16(Base64 const &aBase64) | 134 | else { |
1119 | 255 | { | 135 | try { |
1120 | 256 | vector<char> lOrig; | 136 | if ( is_encoded ) { |
1121 | 257 | Base64::decode(aBase64.getData(), lOrig); | 137 | hexbinary::validate( data, size, hexbinary::dopt_ignore_ws ); |
1122 | 258 | Base16::encode(lOrig, theData); | 138 | data_.resize( size ); |
1123 | 259 | } | 139 | data_.resize( copy_without_ws( data, size, &data_[0] ) ); |
1124 | 260 | 140 | } else | |
1125 | 261 | 141 | hexbinary::encode( data, size, &data_ ); | |
1126 | 262 | bool Base16::parseString(char const *s, size_t len, Base16& aBase16) | 142 | } |
1127 | 263 | { | 143 | CATCH_HEXBINARY_EXCEPTION() |
1128 | 264 | if ( len ) { | 144 | } |
1129 | 265 | try | 145 | return *this; |
1130 | 266 | { | 146 | } |
1131 | 267 | hexbinary::validate( s, len, hexbinary::dopt_ignore_ws ); | 147 | |
1132 | 268 | aBase16.theData.resize( len ); | 148 | bool Base16::parseString( char const *data, size_type size, Base16 &b16 ) { |
1133 | 269 | aBase16.theData.resize( | 149 | if ( !size ) |
1134 | 270 | copy_without_ws( s, len, &aBase16.theData[0] ) | 150 | b16.data_.clear(); |
1135 | 271 | ); | 151 | else { |
1136 | 272 | } | 152 | try { |
1137 | 273 | catch (...) | 153 | hexbinary::validate( data, size, hexbinary::dopt_ignore_ws ); |
1138 | 274 | { | 154 | b16.data_.resize( size ); |
1139 | 155 | b16.data_.resize( copy_without_ws( data, size, &b16.data_[0] ) ); | ||
1140 | 156 | } | ||
1141 | 157 | catch ( std::exception const& ) { | ||
1142 | 275 | return false; | 158 | return false; |
1143 | 276 | } | 159 | } |
1146 | 277 | } else | 160 | } |
1145 | 278 | aBase16.theData.clear(); | ||
1147 | 279 | return true; | 161 | return true; |
1148 | 280 | } | 162 | } |
1149 | 281 | 163 | ||
1179 | 282 | 164 | void Base16::encode( value_type const &from, value_type &to ) { | |
1151 | 283 | void Base16::insertData(char const *s, size_t len) | ||
1152 | 284 | { | ||
1153 | 285 | s = ascii::trim_space( s, &len ); | ||
1154 | 286 | try { | ||
1155 | 287 | hexbinary::encode( s, len, &theData ); | ||
1156 | 288 | } | ||
1157 | 289 | CATCH_HEXBINARY_EXCEPTION() | ||
1158 | 290 | } | ||
1159 | 291 | |||
1160 | 292 | |||
1161 | 293 | bool Base16::equal( Base16 const &other ) const | ||
1162 | 294 | { | ||
1163 | 295 | if ( size() != other.size() ) | ||
1164 | 296 | return false; | ||
1165 | 297 | return ::strncmp( &theData[0], &other.theData[0], theData.size() ) == 0; | ||
1166 | 298 | } | ||
1167 | 299 | |||
1168 | 300 | |||
1169 | 301 | zstring Base16::str() const | ||
1170 | 302 | { | ||
1171 | 303 | if ( size() ) | ||
1172 | 304 | return zstring( &theData[0], size() ); | ||
1173 | 305 | return zstring(); | ||
1174 | 306 | } | ||
1175 | 307 | |||
1176 | 308 | |||
1177 | 309 | void Base16::encode( vector<char> const &from, vector<char> &to ) | ||
1178 | 310 | { | ||
1180 | 311 | if ( !from.empty() ) { | 165 | if ( !from.empty() ) { |
1181 | 312 | try { | 166 | try { |
1182 | 313 | hexbinary::encode( &from[0], from.size(), &to ); | 167 | hexbinary::encode( &from[0], from.size(), &to ); |
1183 | @@ -316,34 +170,8 @@ | |||
1184 | 316 | } | 170 | } |
1185 | 317 | } | 171 | } |
1186 | 318 | 172 | ||
1215 | 319 | void Base16::encode( char const *from, size_t from_len, Base16 &to ) | 173 | uint32_t Base16::hash() const { |
1216 | 320 | { | 174 | return data_.size() ? ztd::hash_bytes( &data_[0], data_.size() ) : 0; |
1189 | 321 | hexbinary::encode( from, from_len, &to.theData ); | ||
1190 | 322 | } | ||
1191 | 323 | |||
1192 | 324 | void Base16::decode( vector<char> const &from, vector<char> &to ) | ||
1193 | 325 | { | ||
1194 | 326 | if ( !from.empty() ) { | ||
1195 | 327 | try { | ||
1196 | 328 | hexbinary::decode( | ||
1197 | 329 | &from[0], from.size(), &to, hexbinary::dopt_ignore_ws | ||
1198 | 330 | ); | ||
1199 | 331 | } | ||
1200 | 332 | CATCH_HEXBINARY_EXCEPTION() | ||
1201 | 333 | } | ||
1202 | 334 | } | ||
1203 | 335 | |||
1204 | 336 | uint32_t Base16::hash() const | ||
1205 | 337 | { | ||
1206 | 338 | return theData.size() ? ztd::hash_bytes( &theData[0], theData.size() ) : 0; | ||
1207 | 339 | } | ||
1208 | 340 | |||
1209 | 341 | |||
1210 | 342 | ostream& operator<<( ostream &os, Base16 const &b16 ) | ||
1211 | 343 | { | ||
1212 | 344 | if ( b16.size() ) | ||
1213 | 345 | os.write( &b16.getData()[0], b16.size() ); | ||
1214 | 346 | return os; | ||
1217 | 347 | } | 175 | } |
1218 | 348 | 176 | ||
1219 | 349 | /////////////////////////////////////////////////////////////////////////////// | 177 | /////////////////////////////////////////////////////////////////////////////// |
1220 | 350 | 178 | ||
1221 | === modified file 'src/zorbatypes/binary.h' | |||
1222 | --- src/zorbatypes/binary.h 2013-03-17 04:02:46 +0000 | |||
1223 | +++ src/zorbatypes/binary.h 2013-06-28 04:21:28 +0000 | |||
1224 | @@ -26,160 +26,170 @@ | |||
1225 | 26 | 26 | ||
1226 | 27 | namespace zorba { | 27 | namespace zorba { |
1227 | 28 | 28 | ||
1228 | 29 | |||
1229 | 30 | class Base16; | 29 | class Base16; |
1230 | 31 | class Base64; | 30 | class Base64; |
1231 | 32 | 31 | ||
1234 | 33 | namespace serialization | 32 | namespace serialization { |
1233 | 34 | { | ||
1235 | 35 | class Archiver; | 33 | class Archiver; |
1238 | 36 | void operator&(Archiver& ar, Base64& obj); | 34 | void operator&( Archiver&, Base64& ); |
1239 | 37 | void operator&(Archiver& ar, Base16& obj); | 35 | void operator&( Archiver&, Base16& ); |
1240 | 38 | } | 36 | } |
1241 | 39 | 37 | ||
1242 | 40 | /////////////////////////////////////////////////////////////////////////////// | 38 | /////////////////////////////////////////////////////////////////////////////// |
1243 | 41 | 39 | ||
1251 | 42 | class Base64 | 40 | class Base64 { |
1245 | 43 | { | ||
1246 | 44 | friend void serialization::operator&(serialization::Archiver&, Base64&); | ||
1247 | 45 | |||
1248 | 46 | private: | ||
1249 | 47 | std::vector<char> theData; // stored encoded | ||
1250 | 48 | |||
1252 | 49 | public: | 41 | public: |
1255 | 50 | static bool parseString( zstring const &s, Base64 &to ) | 42 | typedef std::vector<char> value_type; |
1256 | 51 | { | 43 | typedef value_type::size_type size_type; |
1257 | 44 | |||
1258 | 45 | static bool parseString( char const *data, size_type size, Base64 &to ); | ||
1259 | 46 | |||
1260 | 47 | static bool parseString( zstring const &s, Base64 &to ) { | ||
1261 | 52 | return parseString( s.data(), s.size(), to ); | 48 | return parseString( s.data(), s.size(), to ); |
1262 | 53 | } | 49 | } |
1263 | 54 | 50 | ||
1291 | 55 | static bool parseString(char const *s, size_t aLength, Base64& to); | 51 | static void decode( std::istream&, zstring* ); |
1292 | 56 | 52 | ||
1293 | 57 | static bool parseString( | 53 | static void decode( char const*, size_type, zstring* ); |
1267 | 58 | const char* aString, | ||
1268 | 59 | size_t aLength, | ||
1269 | 60 | Base64& aBase64, | ||
1270 | 61 | std::string& lErrorMessage); | ||
1271 | 62 | |||
1272 | 63 | static zstring encode(std::istream& aStream); | ||
1273 | 64 | |||
1274 | 65 | static void encode(std::istream& aStream, Base64& to); | ||
1275 | 66 | |||
1276 | 67 | static void encode(const zstring& aString, Base64&); | ||
1277 | 68 | |||
1278 | 69 | static void encode(const std::vector<char>&, std::vector<char>&); | ||
1279 | 70 | |||
1280 | 71 | static void encode(char const *from, size_t from_len, Base64 &to); | ||
1281 | 72 | |||
1282 | 73 | static void encode(unsigned char const *from, size_t from_len, Base64& to) { | ||
1283 | 74 | return encode( (char const*)from, from_len, to ); | ||
1284 | 75 | } | ||
1285 | 76 | |||
1286 | 77 | static void decode(const std::vector<char>&, std::vector<char>&); | ||
1287 | 78 | |||
1288 | 79 | static void decode(std::istream& aStream, zstring*); | ||
1289 | 80 | |||
1290 | 81 | static void decode(char const*, size_t, zstring*); | ||
1294 | 82 | 54 | ||
1295 | 83 | public: | 55 | public: |
1313 | 84 | Base64(const Base64& aBase64) | 56 | Base64(); |
1314 | 85 | { | 57 | Base64( Base64 const &b64 ); |
1315 | 86 | theData = aBase64.theData; | 58 | Base64( const char *data, size_type size, bool is_encoded ); |
1316 | 87 | } | 59 | explicit Base64( Base16 const &b16 ); |
1317 | 88 | 60 | ||
1318 | 89 | explicit Base64(const Base16& aBase16); | 61 | size_t alloc_size() const; |
1319 | 90 | 62 | Base64& assign( char const *data, size_type size, bool is_encoded ); | |
1320 | 91 | Base64(char const *bin_data, size_t len); | 63 | value_type const& data() const; |
1321 | 92 | 64 | uint32_t hash() const; | |
1322 | 93 | Base64() { } | 65 | size_type size() const; |
1306 | 94 | |||
1307 | 95 | const std::vector<char>& getData() const { return theData; } | ||
1308 | 96 | |||
1309 | 97 | size_t size() const { return theData.size(); } | ||
1310 | 98 | |||
1311 | 99 | bool equal(const Base64& aBase64) const; | ||
1312 | 100 | |||
1323 | 101 | zstring str() const; | 66 | zstring str() const; |
1324 | 102 | 67 | ||
1334 | 103 | zstring decode() const; | 68 | private: |
1335 | 104 | 69 | value_type data_; // stored encoded | |
1336 | 105 | void decode(std::vector<char>&); | 70 | |
1337 | 106 | 71 | friend void serialization::operator&( serialization::Archiver&, Base64& ); | |
1329 | 107 | uint32_t hash() const; | ||
1330 | 108 | |||
1331 | 109 | size_t alloc_size() const { | ||
1332 | 110 | return ztd::alloc_sizeof( theData ); | ||
1333 | 111 | } | ||
1338 | 112 | }; | 72 | }; |
1339 | 113 | 73 | ||
1340 | 74 | /////////////////////////////////////////////////////////////////////////////// | ||
1341 | 75 | |||
1342 | 76 | inline Base64::Base64() { | ||
1343 | 77 | } | ||
1344 | 78 | |||
1345 | 79 | inline Base64::Base64( Base64 const &b64 ) : data_( b64.data_ ) { | ||
1346 | 80 | } | ||
1347 | 81 | |||
1348 | 82 | inline Base64::Base64( const char *data, size_type size, bool is_encoded ) { | ||
1349 | 83 | assign( data, size, is_encoded ); | ||
1350 | 84 | } | ||
1351 | 85 | |||
1352 | 86 | inline size_t Base64::alloc_size() const { | ||
1353 | 87 | return ztd::alloc_sizeof( data_ ); | ||
1354 | 88 | } | ||
1355 | 89 | |||
1356 | 90 | inline Base64::value_type const& Base64::data() const { | ||
1357 | 91 | return data_; | ||
1358 | 92 | } | ||
1359 | 93 | |||
1360 | 94 | inline Base64::size_type Base64::size() const { | ||
1361 | 95 | return data_.size(); | ||
1362 | 96 | } | ||
1363 | 97 | |||
1364 | 98 | inline zstring Base64::str() const { | ||
1365 | 99 | return size() ? zstring( &data_[0], size() ) : zstring(); | ||
1366 | 100 | } | ||
1367 | 101 | |||
1368 | 114 | inline bool operator==( Base64 const &a, Base64 const &b ) { | 102 | inline bool operator==( Base64 const &a, Base64 const &b ) { |
1370 | 115 | return a.equal( b ); | 103 | return a.size() == b.size() |
1371 | 104 | && std::strncmp( &a.data()[0], &b.data()[0], a.size() ) == 0; | ||
1372 | 116 | } | 105 | } |
1373 | 117 | 106 | ||
1374 | 118 | inline bool operator!=( Base64 const &a, Base64 const &b ) { | 107 | inline bool operator!=( Base64 const &a, Base64 const &b ) { |
1375 | 119 | return !(a == b); | 108 | return !(a == b); |
1376 | 120 | } | 109 | } |
1377 | 121 | 110 | ||
1379 | 122 | std::ostream& operator<<( std::ostream&, Base64 const& ); | 111 | inline std::ostream& operator<<( std::ostream &o, Base64 const &b64 ) { |
1380 | 112 | if ( b64.size() ) | ||
1381 | 113 | o.write( &b64.data()[0], b64.size() ); | ||
1382 | 114 | return o; | ||
1383 | 115 | } | ||
1384 | 123 | 116 | ||
1385 | 124 | /////////////////////////////////////////////////////////////////////////////// | 117 | /////////////////////////////////////////////////////////////////////////////// |
1386 | 125 | 118 | ||
1389 | 126 | class Base16 | 119 | class Base16 { |
1390 | 127 | { | 120 | public: |
1391 | 121 | typedef std::vector<char> value_type; | ||
1392 | 122 | typedef value_type::size_type size_type; | ||
1393 | 123 | |||
1394 | 124 | static bool parseString( char const *data, size_type size, Base16 &to ); | ||
1395 | 125 | |||
1396 | 126 | static bool parseString( zstring const &s, Base16 &to ) { | ||
1397 | 127 | return parseString( s.data(), s.size(), to ); | ||
1398 | 128 | } | ||
1399 | 129 | |||
1400 | 130 | static void encode( value_type const&, value_type& ); | ||
1401 | 131 | |||
1402 | 132 | public: | ||
1403 | 133 | Base16(); | ||
1404 | 134 | Base16( Base16 const &from ); | ||
1405 | 135 | Base16( char const *data, size_type size, bool is_encoded ); | ||
1406 | 136 | explicit Base16( Base64 const& ); | ||
1407 | 137 | |||
1408 | 138 | size_t alloc_size() const; | ||
1409 | 139 | Base16& assign( char const *data, size_type size, bool is_encoded ); | ||
1410 | 140 | value_type const& data() const; | ||
1411 | 141 | uint32_t hash() const; | ||
1412 | 142 | size_type size() const; | ||
1413 | 143 | zstring str() const; | ||
1414 | 144 | |||
1415 | 145 | private: | ||
1416 | 146 | value_type data_; // stored encoded | ||
1417 | 147 | |||
1418 | 128 | friend void serialization::operator&(serialization::Archiver&, Base16&); | 148 | friend void serialization::operator&(serialization::Archiver&, Base16&); |
1419 | 129 | |||
1420 | 130 | private: | ||
1421 | 131 | std::vector<char> theData; // stored encoded | ||
1422 | 132 | |||
1423 | 133 | public: | ||
1424 | 134 | static bool parseString( zstring const &s, Base16 &to ) | ||
1425 | 135 | { | ||
1426 | 136 | return parseString( s.data(), s.size(), to ); | ||
1427 | 137 | } | ||
1428 | 138 | |||
1429 | 139 | static bool parseString( char const *from, size_t from_len, Base16 &to ); | ||
1430 | 140 | |||
1431 | 141 | static void encode( std::vector<char> const&, std::vector<char>& ); | ||
1432 | 142 | |||
1433 | 143 | static void encode( char const *from, size_t from_len, Base16 &to ); | ||
1434 | 144 | |||
1435 | 145 | static void decode( std::vector<char> const&, std::vector<char>& ); | ||
1436 | 146 | |||
1437 | 147 | public: | ||
1438 | 148 | Base16() { } | ||
1439 | 149 | |||
1440 | 150 | Base16( Base16 const &from ) : theData( from.theData ) { } | ||
1441 | 151 | |||
1442 | 152 | Base16( char const *bin_data, size_t len ); | ||
1443 | 153 | |||
1444 | 154 | explicit Base16( Base64 const& ); | ||
1445 | 155 | |||
1446 | 156 | const std::vector<char>& getData() const { return theData; } | ||
1447 | 157 | |||
1448 | 158 | size_t size() const { return theData.size(); } | ||
1449 | 159 | |||
1450 | 160 | bool equal( Base16 const& ) const; | ||
1451 | 161 | |||
1452 | 162 | zstring str() const; | ||
1453 | 163 | |||
1454 | 164 | uint32_t hash() const; | ||
1455 | 165 | |||
1456 | 166 | size_t alloc_size() const { | ||
1457 | 167 | return ztd::alloc_sizeof( theData ); | ||
1458 | 168 | } | ||
1459 | 169 | |||
1460 | 170 | private: | ||
1461 | 171 | void insertData( char const *from, size_t len ); | ||
1462 | 172 | }; | 149 | }; |
1463 | 173 | 150 | ||
1464 | 151 | /////////////////////////////////////////////////////////////////////////////// | ||
1465 | 152 | |||
1466 | 153 | inline Base16::Base16() { | ||
1467 | 154 | } | ||
1468 | 155 | |||
1469 | 156 | inline Base16::Base16( Base16 const &b16 ) : data_( b16.data_ ) { | ||
1470 | 157 | } | ||
1471 | 158 | |||
1472 | 159 | inline Base16::Base16( char const *data, size_type size, bool is_encoded ) { | ||
1473 | 160 | assign( data, size, is_encoded ); | ||
1474 | 161 | } | ||
1475 | 162 | |||
1476 | 163 | inline size_t Base16::alloc_size() const { | ||
1477 | 164 | return ztd::alloc_sizeof( data_ ); | ||
1478 | 165 | } | ||
1479 | 166 | |||
1480 | 167 | inline Base16::value_type const& Base16::data() const { | ||
1481 | 168 | return data_; | ||
1482 | 169 | } | ||
1483 | 170 | |||
1484 | 171 | inline Base16::size_type Base16::size() const { | ||
1485 | 172 | return data_.size(); | ||
1486 | 173 | } | ||
1487 | 174 | |||
1488 | 175 | inline zstring Base16::str() const { | ||
1489 | 176 | return size() ? zstring( &data_[0], size() ) : zstring(); | ||
1490 | 177 | } | ||
1491 | 178 | |||
1492 | 174 | inline bool operator==( Base16 const &a, Base16 const &b ) { | 179 | inline bool operator==( Base16 const &a, Base16 const &b ) { |
1494 | 175 | return a.equal( b ); | 180 | return a.size() == b.size() |
1495 | 181 | && std::strncmp( &a.data()[0], &b.data()[0], a.size() ) == 0; | ||
1496 | 176 | } | 182 | } |
1497 | 177 | 183 | ||
1498 | 178 | inline bool operator!=( Base16 const &a, Base16 const &b ) { | 184 | inline bool operator!=( Base16 const &a, Base16 const &b ) { |
1499 | 179 | return !(a == b); | 185 | return !(a == b); |
1500 | 180 | } | 186 | } |
1501 | 181 | 187 | ||
1503 | 182 | std::ostream& operator<<(std::ostream&s, const Base16& ); | 188 | inline std::ostream& operator<<( std::ostream &o, Base16 const &b16 ) { |
1504 | 189 | if ( b16.size() ) | ||
1505 | 190 | o.write( &b16.data()[0], b16.size() ); | ||
1506 | 191 | return o; | ||
1507 | 192 | } | ||
1508 | 183 | 193 | ||
1509 | 184 | /////////////////////////////////////////////////////////////////////////////// | 194 | /////////////////////////////////////////////////////////////////////////////// |
1510 | 185 | 195 | ||
1511 | 186 | 196 | ||
1512 | === modified file 'swig/ItemFactory.h' | |||
1513 | --- swig/ItemFactory.h 2013-06-18 23:53:59 +0000 | |||
1514 | +++ swig/ItemFactory.h 2013-06-28 04:21:28 +0000 | |||
1515 | @@ -64,11 +64,13 @@ | |||
1516 | 64 | /** \brief Creates a Base64Binary Item | 64 | /** \brief Creates a Base64Binary Item |
1517 | 65 | * see [http://www.w3.org/TR/xmlschema-2/#base64Binary] | 65 | * see [http://www.w3.org/TR/xmlschema-2/#base64Binary] |
1518 | 66 | * | 66 | * |
1520 | 67 | * @param aBinData a pointer to the base64 binary data. | 67 | * @param aData a pointer to the base64 binary data. |
1521 | 68 | * @param aLength the length of the base64 binary data. | 68 | * @param aLength the length of the base64 binary data. |
1522 | 69 | * @param aIsBase64 if \c true, \a aData is already Base-64 encoded; if | ||
1523 | 70 | * \c false, \a aData is raw binary data to be encoded. | ||
1524 | 69 | * @return The Base64Binary Item. | 71 | * @return The Base64Binary Item. |
1525 | 70 | */ | 72 | */ |
1527 | 71 | Item createBase64Binary (const char *aBinData, size_t aLength); | 73 | Item createBase64Binary (const char *aData, size_t aLength, bool aIsBase64); |
1528 | 72 | 74 | ||
1529 | 73 | /** \brief Creates a Base64Binary Item | 75 | /** \brief Creates a Base64Binary Item |
1530 | 74 | * see [http://www.w3.org/TR/xmlschema-2/#base64Binary] | 76 | * see [http://www.w3.org/TR/xmlschema-2/#base64Binary] |
1531 | @@ -78,15 +80,6 @@ | |||
1532 | 78 | */ | 80 | */ |
1533 | 79 | Item createBase64Binary (std::istream &aStream); | 81 | Item createBase64Binary (std::istream &aStream); |
1534 | 80 | 82 | ||
1535 | 81 | /** \brief Creates a Base64Binary Item | ||
1536 | 82 | * see [http://www.w3.org/TR/xmlschema-2/#base64Binary] | ||
1537 | 83 | * | ||
1538 | 84 | * @param aBinData the data in binary form. The data is copied from aBinData. | ||
1539 | 85 | * @param aLength the length of the data | ||
1540 | 86 | * @return the Base64Binary Item. | ||
1541 | 87 | */ | ||
1542 | 88 | Item createBase64Binary (const unsigned char *aBinData, size_t aLength); | ||
1543 | 89 | |||
1544 | 90 | /** \brief Creates a Boolean Item | 83 | /** \brief Creates a Boolean Item |
1545 | 91 | * see [http://www.w3.org/TR/xmlschema-2/#bool] | 84 | * see [http://www.w3.org/TR/xmlschema-2/#bool] |
1546 | 92 | * | 85 | * |
1547 | 93 | 86 | ||
1548 | === modified file 'swig/ItemFactory.i' | |||
1549 | --- swig/ItemFactory.i 2013-06-18 23:53:59 +0000 | |||
1550 | +++ swig/ItemFactory.i 2013-06-28 04:21:28 +0000 | |||
1551 | @@ -22,15 +22,12 @@ | |||
1552 | 22 | return Item( theItemFactory->createAttributeNode (aParent.theItem, aNodeName.theItem, aTypeName.theItem, typedValue )); | 22 | return Item( theItemFactory->createAttributeNode (aParent.theItem, aNodeName.theItem, aTypeName.theItem, typedValue )); |
1553 | 23 | } | 23 | } |
1554 | 24 | 24 | ||
1557 | 25 | Item ItemFactory::createBase64Binary (const char *aBinData, size_t aLength){ | 25 | Item ItemFactory::createBase64Binary (const char *aData, size_t aLength, bool aIsBase64){ |
1558 | 26 | return Item( theItemFactory->createBase64Binary(aBinData, aLength)); | 26 | return Item( theItemFactory->createBase64Binary(aData, aLength, aIsBase64)); |
1559 | 27 | } | 27 | } |
1560 | 28 | Item ItemFactory::createBase64Binary (std::istream &aStream){ | 28 | Item ItemFactory::createBase64Binary (std::istream &aStream){ |
1561 | 29 | return Item( theItemFactory->createBase64Binary(aStream)); | 29 | return Item( theItemFactory->createBase64Binary(aStream)); |
1562 | 30 | } | 30 | } |
1563 | 31 | Item ItemFactory::createBase64Binary (const unsigned char *aBinData, size_t aLength){ | ||
1564 | 32 | return Item( theItemFactory->createBase64Binary(aBinData, aLength)); | ||
1565 | 33 | } | ||
1566 | 34 | Item ItemFactory::createBoolean (bool aValue){ | 31 | Item ItemFactory::createBoolean (bool aValue){ |
1567 | 35 | return Item( theItemFactory->createBoolean(aValue)); | 32 | return Item( theItemFactory->createBoolean(aValue)); |
1568 | 36 | } | 33 | } |
1569 | 37 | 34 | ||
1570 | === modified file 'swig/xqj/ZorbaXQConnection.java' | |||
1571 | --- swig/xqj/ZorbaXQConnection.java 2013-02-07 17:24:36 +0000 | |||
1572 | +++ swig/xqj/ZorbaXQConnection.java 2013-06-28 04:21:28 +0000 | |||
1573 | @@ -522,7 +522,7 @@ | |||
1574 | 522 | item = new org.zorbaxquery.api.xqj.ZorbaXQItem(itemFactory.createAnyURI(value), type); | 522 | item = new org.zorbaxquery.api.xqj.ZorbaXQItem(itemFactory.createAnyURI(value), type); |
1575 | 523 | break; | 523 | break; |
1576 | 524 | case XQItemType.XQBASETYPE_BASE64BINARY: | 524 | case XQItemType.XQBASETYPE_BASE64BINARY: |
1578 | 525 | item = new org.zorbaxquery.api.xqj.ZorbaXQItem(itemFactory.createBase64Binary(value, value.length()), type); | 525 | item = new org.zorbaxquery.api.xqj.ZorbaXQItem(itemFactory.createBase64Binary(value, value.length(), true), type); |
1579 | 526 | break; | 526 | break; |
1580 | 527 | case XQItemType.XQBASETYPE_BYTE: | 527 | case XQItemType.XQBASETYPE_BYTE: |
1581 | 528 | item = new org.zorbaxquery.api.xqj.ZorbaXQItem(itemFactory.createByte(value.charAt(0)), type); | 528 | item = new org.zorbaxquery.api.xqj.ZorbaXQItem(itemFactory.createByte(value.charAt(0)), type); |
1582 | @@ -947,7 +947,7 @@ | |||
1583 | 947 | item = new org.zorbaxquery.api.xqj.ZorbaXQItem(itemFactory.createAnyURI(value.toString()), type); | 947 | item = new org.zorbaxquery.api.xqj.ZorbaXQItem(itemFactory.createAnyURI(value.toString()), type); |
1584 | 948 | break; | 948 | break; |
1585 | 949 | case XQItemType.XQBASETYPE_BASE64BINARY: | 949 | case XQItemType.XQBASETYPE_BASE64BINARY: |
1587 | 950 | item = new org.zorbaxquery.api.xqj.ZorbaXQItem(itemFactory.createBase64Binary(value.toString(), (value.toString()).length()), type); | 950 | item = new org.zorbaxquery.api.xqj.ZorbaXQItem(itemFactory.createBase64Binary(value.toString(), (value.toString()).length(), true), type); |
1588 | 951 | break; | 951 | break; |
1589 | 952 | case XQItemType.XQBASETYPE_BYTE: | 952 | case XQItemType.XQBASETYPE_BYTE: |
1590 | 953 | if (value instanceof Byte) { | 953 | if (value instanceof Byte) { |
1591 | 954 | 954 | ||
1592 | === modified file 'test/api/itemfactory.cpp' | |||
1593 | --- test/api/itemfactory.cpp 2013-05-22 16:12:01 +0000 | |||
1594 | +++ test/api/itemfactory.cpp 2013-06-28 04:21:28 +0000 | |||
1595 | @@ -168,14 +168,14 @@ | |||
1596 | 168 | CHECK_NOT_IMPLEMENTED (lItem, getBooleanValue() ); | 168 | CHECK_NOT_IMPLEMENTED (lItem, getBooleanValue() ); |
1597 | 169 | 169 | ||
1598 | 170 | /** Base64Binary */ | 170 | /** Base64Binary */ |
1600 | 171 | lItem = lFactory->createBase64Binary("", 0); | 171 | lItem = lFactory->createBase64Binary("", 0, false); |
1601 | 172 | UNIT_ASSERT ( checkType(lItem.getType(), "base64Binary") ); | 172 | UNIT_ASSERT ( checkType(lItem.getType(), "base64Binary") ); |
1602 | 173 | UNIT_ASSERT ( lItem.isAtomic() ); | 173 | UNIT_ASSERT ( lItem.isAtomic() ); |
1603 | 174 | UNIT_ASSERT ( lItem.getStringValue() == "" ); | 174 | UNIT_ASSERT ( lItem.getStringValue() == "" ); |
1604 | 175 | UNIT_ASSERT ( lItem.getStringValue().length() == 0 ); | 175 | UNIT_ASSERT ( lItem.getStringValue().length() == 0 ); |
1605 | 176 | UNIT_ASSERT ( !lItem.getAtomizationValue().isNull() ); | 176 | UNIT_ASSERT ( !lItem.getAtomizationValue().isNull() ); |
1606 | 177 | 177 | ||
1608 | 178 | lItem = lFactory->createBase64Binary("cmxjZ3R4c3JidnllcmVuZG91aWpsbXV5Z2NhamxpcmJkaWFhbmFob2VsYXVwZmJ1Z2dmanl2eHlzYmhheXFtZXR0anV2dG1q", 96); | 178 | lItem = lFactory->createBase64Binary("cmxjZ3R4c3JidnllcmVuZG91aWpsbXV5Z2NhamxpcmJkaWFhbmFob2VsYXVwZmJ1Z2dmanl2eHlzYmhheXFtZXR0anV2dG1q", 96, true); |
1609 | 179 | UNIT_ASSERT ( checkType(lItem.getType(), "base64Binary") ); | 179 | UNIT_ASSERT ( checkType(lItem.getType(), "base64Binary") ); |
1610 | 180 | UNIT_ASSERT ( lItem.isAtomic() ); | 180 | UNIT_ASSERT ( lItem.isAtomic() ); |
1611 | 181 | UNIT_ASSERT ( lItem.getStringValue() == "cmxjZ3R4c3JidnllcmVuZG91aWpsbXV5Z2NhamxpcmJkaWFhbmFob2VsYXVwZmJ1Z2dmanl2eHlzYmhheXFtZXR0anV2dG1q" ); | 181 | UNIT_ASSERT ( lItem.getStringValue() == "cmxjZ3R4c3JidnllcmVuZG91aWpsbXV5Z2NhamxpcmJkaWFhbmFob2VsYXVwZmJ1Z2dmanl2eHlzYmhheXFtZXR0anV2dG1q" ); |
Validation queue starting for merge proposal. zorbatest. lambda. nu:8080/ remotequeue/ bug-1158052- 2013-06- 21T01-46- 49.193Z/ log.html
Log at: http://