00001 #include <result.h>
00002
00003 namespace result{
00004 DOCIMPL_APPLYXPATH_FUNC_BEGIN()
00005 DOCIMPL_APPLYXPATH_MATCH(extension)
00006 DOCIMPL_APPLYXPATH_MATCH(ext)
00007 DOCIMPL_APPLYXPATH_MATCH(extension_subcl)
00008 DOCIMPL_APPLYXPATH_MATCH(location)
00009 DOCIMPL_APPLYXPATH_FUNC_END()
00010
00011 DOCIMPL_ELEMENT_BEGIN()
00012 DOCIMPL_ELEMENT_PUSH_IF_EQUAL(extension)
00013 DOCIMPL_ELEMENT_PUSH_IF_EQUAL(ext)
00014 DOCIMPL_ELEMENT_PUSH_IF_EQUAL(extension_subcl)
00015 DOCIMPL_ELEMENT_PUSH_IF_EQUAL(location)
00016 DOCIMPL_ELEMENT_END()
00017
00018 DOCIMPL_ELEMENTS_FUNC_BEGIN(extension)
00019 DOCIMPL_ELEMENTS_SUBELEMENT(extension_subcl)
00020 DOCIMPL_ELEMENTS_SUBSEQUENCE(location)
00021 DOCIMPL_ELEMENTS_SUBSEQUENCER(extension_subt, location)
00022 DOCIMPL_ELEMENTS_SUBSEQUENCE(ext)
00023 DOCIMPL_ELEMENTS_FUNC_END()
00024
00025 DOCIMPL_ELEMENTS_FUNC_BEGIN(ext)
00026 DOCIMPL_ELEMENTS_FUNC_END()
00027
00028 DOCIMPL_ELEMENTS_FUNC_BEGIN(extension_subcl)
00029 DOCIMPL_ELEMENTS_FUNC_END()
00030
00031 DOCIMPL_ELEMENTS_FUNC_BEGIN(location)
00032 DOCIMPL_ELEMENTS_FUNC_END()
00033
00034 }
00035 APPLYXPATH_FUNC_BEGIN(result::extension)
00036 APPLYXPATH_ATTRIBUTE(point)
00037 APPLYXPATH_ATTRIBUTE(number)
00038 APPLYXPATH_ATTRIBUTE(id)
00039 APPLYXPATH_ATTRIBUTE(name)
00040 APPLYXPATH_SEQUENCE(location)
00041 APPLYXPATH_SEQUENCE(extension_subt)
00042 APPLYXPATH_SEQUENCE(ext)
00043 APPLYXPATH_ELEMENT(extension_subcl)
00044 APPLYXPATH_FUNC_END()
00045
00046 APPLYXPATH_FUNC_BEGIN(result::extension_subcl)
00047 APPLYXPATH_FUNC_END()
00048
00049 APPLYXPATH_FUNC_BEGIN(result::ext)
00050 APPLYXPATH_ATTRIBUTE(isTrue)
00051 APPLYXPATH_ATTRIBUTE(ents)
00052 APPLYXPATH_FUNC_END()
00053
00054 APPLYXPATH_FUNC_BEGIN(result::location)
00055 APPLYXPATH_ATTRIBUTE(path)
00056 APPLYXPATH_ATTRIBUTE(path1)
00057 APPLYXPATH_FUNC_END()
00058
00059
00060
00061 TO_XML_FUNC_BEGIN(result::extension,extension)
00062 TO_XML_ATTRIBUTE(point)
00063 TO_XML_ATTRIBUTE(number)
00064 TO_XML_ATTRIBUTE(id)
00065 TO_XML_ATTRIBUTE(name)
00066 TO_XML_HAS_ELEMENTS_BEGIN()
00067 TO_XML_ELEMENT(extension_subcl)
00068 TO_XML_SEQUENCE(location)
00069 TO_XML_SEQUENCER(extension_subt,extension_subt)
00070 TO_XML_SEQUENCE(ext)
00071 TO_XML_HAS_ELEMENTS_END()
00072 TO_XML_FUNC_END()
00073
00074 TO_XML_FUNC_BEGIN(result::ext,ext)
00075 TO_XML_ATTRIBUTE(isTrue)
00076 TO_XML_ATTRIBUTE(ents)
00077 TO_XML_HAS_NO_ELEMENTS()
00078 TO_XML_FUNC_END()
00079
00080 TO_XML_FUNC_BEGIN(result::extension_subcl,extension_subcl)
00081 TO_XML_HAS_NO_ELEMENTS()
00082 TO_XML_FUNC_END()
00083
00084 TO_XML_FUNC_BEGIN(result::location,location)
00085 TO_XML_ATTRIBUTE(path)
00086 TO_XML_ATTRIBUTE(path1)
00087 TO_XML_HAS_NO_ELEMENTS()
00088 TO_XML_FUNC_END()
00089
00090
00091
00092 void xpath_iterator<result::extension>::ApplyByPath(XPath::const_iterator xp, XPath::const_iterator xe, xpath_iterator_functor& f) {
00093 if(value == NULL)
00094 return;
00095 if(xp == xe) {
00096 f.apply(*this);
00097 return;
00098 }
00099 if(xp->type == XP_ATTR) {
00100 if(xp->text == "point" || xp->text == "*") {
00101 xpath_iterator<xstring> it(this, &value->_point);
00102 f.apply(it);
00103 }
00104 if(xp->text == "number" || xp->text == "*") {
00105 xpath_iterator<xdouble> it(this, &value->_number);
00106 f.apply(it);
00107 }
00108 if(xp->text == "id" || xp->text == "*") {
00109 xpath_iterator<xstring> it(this, &value->_id);
00110 f.apply(it);
00111 }
00112 if(xp->text == "name" || xp->text == "*") {
00113 xpath_iterator<xstring> it(this, &value->_name);
00114 f.apply(it);
00115 }
00116 return;
00117 }
00118 if(xp->type == XP_ELEMENT) {
00119 XPath::const_iterator xpp = xp;
00120 if(xpp != xe)
00121 xpp++;
00122 else
00123 return;
00124 if(xp->text == "location" || xp->text == "*") {
00125 typeof(value->locations.begin()) i = value->locations.begin(), ie = value->locations.end();
00126 if(xpp != xe) {
00127 xpath_iterator<result::location> it(this, NULL);
00128 for(;i != ie;i++) {
00129 it.setValue(*i);
00130 it.ApplyByPath(xpp, xe, f);
00131 }
00132 } else {
00133 xpath_iterator<result::location> it(this, NULL);
00134 for(;i != ie;i++){
00135 it.setValue(*i);
00136 f.apply(it);
00137 }
00138 }
00139 }
00140 if(xp->text == "extension_subt" || xp->text == "*") {
00141 typeof(value->extension_subts.begin()) i = value->extension_subts.begin(), ie = value->extension_subts.end();
00142 if(xpp != xe) {
00143 xpath_iterator<result::extension_subt> it(this, NULL);
00144 for(;i != ie;i++) {
00145 it.setValue(*i);
00146 it.ApplyByPath(xpp, xe, f);
00147 }
00148 } else {
00149 xpath_iterator<result::extension_subt> it(this, NULL);
00150 for(;i != ie;i++){
00151 it.setValue(*i);
00152 f.apply(it);
00153 }
00154 }
00155 }
00156 if(xp->text == "ext" || xp->text == "*") {
00157 typeof(value->exts.begin()) i = value->exts.begin(), ie = value->exts.end();
00158 if(xpp != xe) {
00159 xpath_iterator<result::ext> it(this, NULL);
00160 for(;i != ie;i++) {
00161 it.setValue(*i);
00162 it.ApplyByPath(xpp, xe, f);
00163 }
00164 } else {
00165 xpath_iterator<result::ext> it(this, NULL);
00166 for(;i != ie;i++){
00167 it.setValue(*i);
00168 f.apply(it);
00169 }
00170 }
00171 }
00172 if(xp->text == "extension_subcl" || xp->text == "*") {
00173 xpath_iterator<result::extension_subcl> it(this, value->extension_subcls);
00174 it.ApplyByPath(xpp, xe, f);
00175 }
00176 if(xp->text == ".." && parent != NULL)
00177 parent->ApplyByPath(xpp, xe, f);
00178 }
00179 }
00180
00181 void xpath_iterator<result::extension>::getValueByPath(XPath::const_iterator xp, XPath::const_iterator xe, XPathResult& res) {
00182 if(value == NULL)
00183 return;
00184 if(xp == xe) {
00185 res.push_back(value);
00186 return;
00187 }
00188 if(xp->type == XP_ATTR) {
00189 if(xp->text == "point" || xp->text == "*")
00190 res.push_back(&(value->_point));
00191 if(xp->text == "number" || xp->text == "*")
00192 res.push_back(&(value->_number));
00193 if(xp->text == "id" || xp->text == "*")
00194 res.push_back(&(value->_id));
00195 if(xp->text == "name" || xp->text == "*")
00196 res.push_back(&(value->_name));
00197 return;
00198 }
00199 if(xp->type == XP_ELEMENT) {
00200 XPath::const_iterator xpp = xp;
00201 if(xpp != xe)
00202 xpp++;
00203 else
00204 return;
00205 if(xp->text == "location" || xp->text == "*") {
00206 typeof(value->locations.begin()) i = value->locations.begin(), ie = value->locations.end();
00207 if(xpp != xe) {
00208 xpath_iterator<result::location> it(this, NULL);
00209 for(;i != ie;i++) {
00210 it.setValue(*i);
00211 it.getValueByPath(xpp, xe, res);
00212 }
00213 } else {
00214 for(;i != ie;i++)
00215 res.push_back(*i);
00216 }
00217 }
00218 if(xp->text == "extension_subt" || xp->text == "*") {
00219 typeof(value->extension_subts.begin()) i = value->extension_subts.begin(), ie = value->extension_subts.end();
00220 if(xpp != xe) {
00221 xpath_iterator<result::extension_subt> it(this, NULL);
00222 for(;i != ie;i++) {
00223 it.setValue(*i);
00224 it.getValueByPath(xpp, xe, res);
00225 }
00226 } else {
00227 for(;i != ie;i++)
00228 res.push_back(*i);
00229 }
00230 }
00231 if(xp->text == "ext" || xp->text == "*") {
00232 typeof(value->exts.begin()) i = value->exts.begin(), ie = value->exts.end();
00233 if(xpp != xe) {
00234 xpath_iterator<result::ext> it(this, NULL);
00235 for(;i != ie;i++) {
00236 it.setValue(*i);
00237 it.getValueByPath(xpp, xe, res);
00238 }
00239 } else {
00240 for(;i != ie;i++)
00241 res.push_back(*i);
00242 }
00243 }
00244 if(xp->text == "extension_subcl" || xp->text == "*") {
00245 xpath_iterator<result::extension_subcl> it(this, value->extension_subcls);
00246 it.getValueByPath(xpp, xe, res);
00247 }
00248 if(xp->text == ".." && parent != NULL)
00249 parent->getValueByPath(xpp, xe, res);
00250 }
00251 }
00252
00253 bool xpath_iterator<result::extension>::checkPathCondition(XPath::const_iterator xp, XPath::const_iterator xe) {
00254 if(value == NULL)
00255 return false;
00256 if(xp == xe)
00257 return true;
00258 if(xp->type == XP_ATTR) {
00259 if(xp->text == "*")
00260 return true;
00261 if(xp->text == "point")
00262 return true;
00263 if(xp->text == "number")
00264 return true;
00265 if(xp->text == "id")
00266 return true;
00267 if(xp->text == "name")
00268 return true;
00269 return false;
00270 }
00271 if(xp->type == XP_ELEMENT) {
00272 XPath::const_iterator xpp = xp;
00273 if(xpp != xe)
00274 xpp++;
00275 else
00276 return false;
00277 if(xp->text == "location" || xp->text == "*") {
00278 typeof(value->locations.begin()) i = value->locations.begin(), ie = value->locations.end();
00279 if(xpp != xe) {
00280 xpath_iterator<result::location> it(this, NULL);
00281 for(;i != ie;i++) {
00282 it.setValue(*i);
00283 if(it.checkPathCondition(xpp, xe))
00284 return true;
00285 }
00286 } else
00287 return !(i == ie);
00288 }
00289 if(xp->text == "extension_subt" || xp->text == "*") {
00290 typeof(value->extension_subts.begin()) i = value->extension_subts.begin(), ie = value->extension_subts.end();
00291 if(xpp != xe) {
00292 xpath_iterator<result::extension_subt> it(this, NULL);
00293 for(;i != ie;i++) {
00294 it.setValue(*i);
00295 if(it.checkPathCondition(xpp, xe))
00296 return true;
00297 }
00298 } else
00299 return !(i == ie);
00300 }
00301 if(xp->text == "ext" || xp->text == "*") {
00302 typeof(value->exts.begin()) i = value->exts.begin(), ie = value->exts.end();
00303 if(xpp != xe) {
00304 xpath_iterator<result::ext> it(this, NULL);
00305 for(;i != ie;i++) {
00306 it.setValue(*i);
00307 if(it.checkPathCondition(xpp, xe))
00308 return true;
00309 }
00310 } else
00311 return !(i == ie);
00312 }
00313 if(xp->text == "extension_subcl" || xp->text == "*") {
00314 xpath_iterator<result::extension_subcl> it(this, value->extension_subcls);
00315 return it.checkPathCondition(xpp, xe);
00316 }
00317 if(xp->text == ".." && parent != NULL)
00318 return parent->checkPathCondition(xpp, xe);
00319 return false;
00320 }
00321 return false;
00322 }
00323
00324 void xpath_iterator<result::extension>::to_xml(std::ostream& out) {
00325 if(value)
00326 ::to_xml(*value, NULL, out);
00327 }
00328
00329 void xpath_iterator<result::ext>::ApplyByPath(XPath::const_iterator xp, XPath::const_iterator xe, xpath_iterator_functor& f) {
00330 if(value == NULL)
00331 return;
00332 if(xp == xe) {
00333 f.apply(*this);
00334 return;
00335 }
00336 if(xp->type == XP_ATTR) {
00337 if(xp->text == "isTrue" || xp->text == "*") {
00338 xpath_iterator<xboolean> it(this, &value->_isTrue);
00339 f.apply(it);
00340 }
00341 if(xp->text == "ents" || xp->text == "*") {
00342 xpath_iterator<xENTITIES> it(this, &value->_ents);
00343 f.apply(it);
00344 }
00345 return;
00346 }
00347 if(xp->type == XP_ELEMENT) {
00348 XPath::const_iterator xpp = xp;
00349 if(xpp != xe)
00350 xpp++;
00351 else
00352 return;
00353 if(xp->text == ".." && parent != NULL)
00354 parent->ApplyByPath(xpp, xe, f);
00355 }
00356 }
00357
00358 void xpath_iterator<result::ext>::getValueByPath(XPath::const_iterator xp, XPath::const_iterator xe, XPathResult& res) {
00359 if(value == NULL)
00360 return;
00361 if(xp == xe) {
00362 res.push_back(value);
00363 return;
00364 }
00365 if(xp->type == XP_ATTR) {
00366 if(xp->text == "isTrue" || xp->text == "*")
00367 res.push_back(&(value->_isTrue));
00368 if(xp->text == "ents" || xp->text == "*")
00369 res.push_back(&(value->_ents));
00370 return;
00371 }
00372 if(xp->type == XP_ELEMENT) {
00373 XPath::const_iterator xpp = xp;
00374 if(xpp != xe)
00375 xpp++;
00376 else
00377 return;
00378 if(xp->text == ".." && parent != NULL)
00379 parent->getValueByPath(xpp, xe, res);
00380 }
00381 }
00382
00383 bool xpath_iterator<result::ext>::checkPathCondition(XPath::const_iterator xp, XPath::const_iterator xe) {
00384 if(value == NULL)
00385 return false;
00386 if(xp == xe)
00387 return true;
00388 if(xp->type == XP_ATTR) {
00389 if(xp->text == "*")
00390 return true;
00391 if(xp->text == "isTrue")
00392 return true;
00393 if(xp->text == "ents")
00394 return true;
00395 return false;
00396 }
00397 if(xp->type == XP_ELEMENT) {
00398 XPath::const_iterator xpp = xp;
00399 if(xpp != xe)
00400 xpp++;
00401 else
00402 return false;
00403 if(xp->text == ".." && parent != NULL)
00404 return parent->checkPathCondition(xpp, xe);
00405 return false;
00406 }
00407 return false;
00408 }
00409
00410 void xpath_iterator<result::ext>::to_xml(std::ostream& out) {
00411 if(value)
00412 ::to_xml(*value, NULL, out);
00413 }
00414
00415 void xpath_iterator<result::extension_subcl>::ApplyByPath(XPath::const_iterator xp, XPath::const_iterator xe, xpath_iterator_functor& f) {
00416 if(value == NULL)
00417 return;
00418 if(xp == xe) {
00419 f.apply(*this);
00420 return;
00421 }
00422 if(xp->type == XP_ELEMENT) {
00423 XPath::const_iterator xpp = xp;
00424 if(xpp != xe)
00425 xpp++;
00426 else
00427 return;
00428 if(xp->text == ".." && parent != NULL)
00429 parent->ApplyByPath(xpp, xe, f);
00430 }
00431 }
00432
00433 void xpath_iterator<result::extension_subcl>::getValueByPath(XPath::const_iterator xp, XPath::const_iterator xe, XPathResult& res) {
00434 if(value == NULL)
00435 return;
00436 if(xp == xe) {
00437 res.push_back(value);
00438 return;
00439 }
00440 if(xp->type == XP_ELEMENT) {
00441 XPath::const_iterator xpp = xp;
00442 if(xpp != xe)
00443 xpp++;
00444 else
00445 return;
00446 if(xp->text == ".." && parent != NULL)
00447 parent->getValueByPath(xpp, xe, res);
00448 }
00449 }
00450
00451 bool xpath_iterator<result::extension_subcl>::checkPathCondition(XPath::const_iterator xp, XPath::const_iterator xe) {
00452 if(value == NULL)
00453 return false;
00454 if(xp == xe)
00455 return true;
00456 if(xp->type == XP_ELEMENT) {
00457 XPath::const_iterator xpp = xp;
00458 if(xpp != xe)
00459 xpp++;
00460 else
00461 return false;
00462 if(xp->text == ".." && parent != NULL)
00463 return parent->checkPathCondition(xpp, xe);
00464 return false;
00465 }
00466 return false;
00467 }
00468
00469 void xpath_iterator<result::extension_subcl>::to_xml(std::ostream& out) {
00470 if(value)
00471 ::to_xml(*value, NULL, out);
00472 }
00473
00474 void xpath_iterator<result::location>::ApplyByPath(XPath::const_iterator xp, XPath::const_iterator xe, xpath_iterator_functor& f) {
00475 if(value == NULL)
00476 return;
00477 if(xp == xe) {
00478 f.apply(*this);
00479 return;
00480 }
00481 if(xp->type == XP_ATTR) {
00482 if(xp->text == "path" || xp->text == "*") {
00483 xpath_iterator<xstring> it(this, &value->_path);
00484 f.apply(it);
00485 }
00486 if(xp->text == "path1" || xp->text == "*") {
00487 xpath_iterator<xstring> it(this, &value->_path1);
00488 f.apply(it);
00489 }
00490 return;
00491 }
00492 if(xp->type == XP_ELEMENT) {
00493 XPath::const_iterator xpp = xp;
00494 if(xpp != xe)
00495 xpp++;
00496 else
00497 return;
00498 if(xp->text == ".." && parent != NULL)
00499 parent->ApplyByPath(xpp, xe, f);
00500 }
00501 }
00502
00503 void xpath_iterator<result::location>::getValueByPath(XPath::const_iterator xp, XPath::const_iterator xe, XPathResult& res) {
00504 if(value == NULL)
00505 return;
00506 if(xp == xe) {
00507 res.push_back(value);
00508 return;
00509 }
00510 if(xp->type == XP_ATTR) {
00511 if(xp->text == "path" || xp->text == "*")
00512 res.push_back(&(value->_path));
00513 if(xp->text == "path1" || xp->text == "*")
00514 res.push_back(&(value->_path1));
00515 return;
00516 }
00517 if(xp->type == XP_ELEMENT) {
00518 XPath::const_iterator xpp = xp;
00519 if(xpp != xe)
00520 xpp++;
00521 else
00522 return;
00523 if(xp->text == ".." && parent != NULL)
00524 parent->getValueByPath(xpp, xe, res);
00525 }
00526 }
00527
00528 bool xpath_iterator<result::location>::checkPathCondition(XPath::const_iterator xp, XPath::const_iterator xe) {
00529 if(value == NULL)
00530 return false;
00531 if(xp == xe)
00532 return true;
00533 if(xp->type == XP_ATTR) {
00534 if(xp->text == "*")
00535 return true;
00536 if(xp->text == "path")
00537 return true;
00538 if(xp->text == "path1")
00539 return true;
00540 return false;
00541 }
00542 if(xp->type == XP_ELEMENT) {
00543 XPath::const_iterator xpp = xp;
00544 if(xpp != xe)
00545 xpp++;
00546 else
00547 return false;
00548 if(xp->text == ".." && parent != NULL)
00549 return parent->checkPathCondition(xpp, xe);
00550 return false;
00551 }
00552 return false;
00553 }
00554
00555 void xpath_iterator<result::location>::to_xml(std::ostream& out) {
00556 if(value)
00557 ::to_xml(*value, NULL, out);
00558 }
00559