1 /* 2 * Copyright 2006-2008 The FLWOR Foundation. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 #pragma once 17 #ifndef ZORBA_COMPILER_FTNODE_H 18 #define ZORBA_COMPILER_FTNODE_H 19 20 #include <zorba/locale.h> 21 22 #include "common/shared_types.h" 23 #include "compiler/expression/expr_base.h" 24 #include "compiler/expression/ftnode_classes.h" 25 #include "compiler/parser/ft_types.h" 26 #include "compiler/parser/parse_constants.h" 27 #include "compiler/parsetree/parsenodes.h" 28 #include "runtime/base/plan_iterator.h" 29 #include "util/cxx_util.h" 30 #include "zorbatypes/rchandle.h" 31 #include "zorbatypes/zstring.h" 32 33 namespace zorba { 34 35 /////////////////////////////////////////////////////////////////////////////// 36 37 /** 38 * Base class for full-text expression classes. 39 */ 40 class ftnode : public SimpleRCObject { 41 public: 42 SERIALIZABLE_ABSTRACT_CLASS(ftnode) 43 SERIALIZABLE_CLASS_CONSTRUCTOR2(ftnode, SimpleRCObject) 44 void serialize( serialization::Archiver& ); 45 46 virtual ft_visit_result::type accept( ftnode_visitor& ) = 0; 47 virtual ftnode_t clone( expr::substitution_t& ) const = 0; get_loc()48 QueryLoc const& get_loc() const { return loc_; } 49 virtual std::ostream& put( std::ostream& ) const = 0; 50 51 protected: ftnode(QueryLoc const & loc)52 ftnode( QueryLoc const &loc ) : loc_( loc ) { 53 } 54 55 private: 56 QueryLoc loc_; 57 }; 58 59 inline std::ostream& operator<<( std::ostream &o, ftnode const &n ) { 60 return n.put( o ); 61 } 62 63 ////////// FTMatchOptions ///////////////////////////////////////////////////// 64 65 class ftmatch_option : public ftnode { 66 public: 67 SERIALIZABLE_ABSTRACT_CLASS(ftmatch_option) 68 SERIALIZABLE_CLASS_CONSTRUCTOR2(ftmatch_option,ftnode) 69 void serialize( serialization::Archiver& ); 70 71 protected: ftmatch_option(QueryLoc const & loc)72 ftmatch_option( QueryLoc const &loc ) : ftnode( loc ) { } 73 }; 74 75 76 class ftcase_option : public ftmatch_option { 77 public: 78 SERIALIZABLE_CLASS(ftcase_option) 79 SERIALIZABLE_CLASS_CONSTRUCTOR2(ftcase_option,ftmatch_option) 80 void serialize( serialization::Archiver& ); 81 82 ftcase_option( 83 QueryLoc const&, 84 ft_case_mode::type = ft_case_mode::DEFAULT 85 ); 86 87 ft_visit_result::type accept( ftnode_visitor& ); 88 ftnode_t clone( expr::substitution_t& ) const; get_mode()89 ft_case_mode::type get_mode() const { return mode_; } 90 std::ostream& put( std::ostream& ) const; 91 92 private: 93 ft_case_mode::type mode_; 94 }; 95 typedef rchandle<ftcase_option> ftcase_option_t; 96 97 98 class ftdiacritics_option : public ftmatch_option { 99 public: 100 SERIALIZABLE_CLASS(ftdiacritics_option) 101 SERIALIZABLE_CLASS_CONSTRUCTOR2(ftdiacritics_option,ftmatch_option) 102 void serialize( serialization::Archiver& ); 103 104 ftdiacritics_option( 105 QueryLoc const&, 106 ft_diacritics_mode::type = ft_diacritics_mode::DEFAULT 107 ); 108 109 ft_visit_result::type accept( ftnode_visitor& ); 110 ftnode_t clone( expr::substitution_t& ) const; get_mode()111 ft_diacritics_mode::type get_mode() const { return mode_; } 112 std::ostream& put( std::ostream& ) const; 113 114 private: 115 ft_diacritics_mode::type mode_; 116 }; 117 typedef rchandle<ftdiacritics_option> ftdiacritics_option_t; 118 119 120 class ftextension_option : public ftmatch_option { 121 public: 122 SERIALIZABLE_CLASS(ftextension_option) 123 SERIALIZABLE_CLASS_CONSTRUCTOR2(ftextension_option,ftmatch_option) 124 void serialize( serialization::Archiver& ); 125 126 ftextension_option( 127 QueryLoc const&, 128 rchandle<QName> const&, 129 zstring const &val 130 ); 131 132 ft_visit_result::type accept( ftnode_visitor& ); 133 ftnode_t clone( expr::substitution_t& ) const; get_qname()134 rchandle<QName> const& get_qname() const { return qname_; } get_val()135 zstring const& get_val() const { return val_; } 136 std::ostream& put( std::ostream& ) const; 137 138 private: 139 rchandle<QName> qname_; 140 zstring val_; 141 }; 142 typedef rchandle<ftextension_option> ftextension_option_t; 143 144 145 class ftlanguage_option : public ftmatch_option { 146 public: 147 SERIALIZABLE_CLASS(ftlanguage_option) 148 SERIALIZABLE_CLASS_CONSTRUCTOR2(ftlanguage_option,ftmatch_option) 149 void serialize( serialization::Archiver& ); 150 151 ftlanguage_option( 152 QueryLoc const&, 153 zstring const &language 154 ); 155 156 ftlanguage_option( 157 QueryLoc const&, 158 locale::iso639_1::type 159 ); 160 161 ft_visit_result::type accept( ftnode_visitor& ); 162 ftnode_t clone( expr::substitution_t& ) const; get_language()163 locale::iso639_1::type get_language() const { return lang_; } 164 std::ostream& put( std::ostream& ) const; 165 166 private: 167 locale::iso639_1::type lang_; 168 }; 169 typedef rchandle<ftlanguage_option> ftlanguage_option_t; 170 171 172 class ftstem_option : public ftmatch_option { 173 public: 174 SERIALIZABLE_CLASS(ftstem_option) 175 SERIALIZABLE_CLASS_CONSTRUCTOR2(ftstem_option,ftmatch_option) 176 void serialize( serialization::Archiver& ); 177 178 ftstem_option( 179 QueryLoc const&, 180 ft_stem_mode::type = ft_stem_mode::DEFAULT 181 ); 182 183 ft_visit_result::type accept( ftnode_visitor& ); 184 ftnode_t clone( expr::substitution_t& ) const; get_mode()185 ft_stem_mode::type get_mode() const { return mode_; } 186 std::ostream& put( std::ostream& ) const; 187 188 private: 189 ft_stem_mode::type mode_; 190 }; 191 typedef rchandle<ftstem_option> ftstem_option_t; 192 193 194 class ftstop_words : public ftnode { 195 public: 196 SERIALIZABLE_CLASS(ftstop_words) 197 SERIALIZABLE_CLASS_CONSTRUCTOR2(ftstop_words,ftnode) 198 void serialize( serialization::Archiver& ); 199 200 typedef std::list<zstring> list_t; 201 202 ftstop_words( 203 QueryLoc const&, 204 zstring const &uri, 205 list_t const&, 206 ft_stop_words_unex::type = ft_stop_words_unex::union_ 207 ); 208 209 ft_visit_result::type accept( ftnode_visitor& ); 210 ftnode_t clone( expr::substitution_t& ) const; get_uri()211 zstring const& get_uri() const { return uri_; } get_list()212 list_t const& get_list() const { return list_; } get_mode()213 ft_stop_words_unex::type get_mode() const { return mode_; } 214 std::ostream& put( std::ostream& ) const; 215 set_mode(ft_stop_words_unex::type mode)216 void set_mode( ft_stop_words_unex::type mode ) { 217 mode_ = mode; 218 } 219 220 private: 221 zstring uri_; 222 list_t list_; 223 ft_stop_words_unex::type mode_; 224 }; 225 226 227 class ftstop_word_option : public ftmatch_option { 228 public: 229 SERIALIZABLE_CLASS(ftstop_word_option) 230 SERIALIZABLE_CLASS_CONSTRUCTOR2(ftstop_word_option,ftmatch_option) 231 void serialize( serialization::Archiver& ); 232 233 typedef std::list<ftstop_words*> list_t; 234 235 ftstop_word_option( 236 QueryLoc const&, 237 ft_stop_words_mode::type = ft_stop_words_mode::DEFAULT 238 ); 239 240 ftstop_word_option( 241 QueryLoc const&, 242 list_t&, 243 ft_stop_words_mode::type = ft_stop_words_mode::DEFAULT 244 ); 245 246 ~ftstop_word_option(); 247 248 ft_visit_result::type accept( ftnode_visitor& ); 249 ftnode_t clone( expr::substitution_t& ) const; get_mode()250 ft_stop_words_mode::type get_mode() const { return mode_; } get_stop_words()251 list_t const& get_stop_words() const { return stop_words_; } 252 std::ostream& put( std::ostream& ) const; 253 254 private: 255 list_t stop_words_; 256 ft_stop_words_mode::type mode_; 257 }; 258 typedef rchandle<ftstop_word_option> ftstop_word_option_t; 259 260 261 class ftthesaurus_id : public ftnode { 262 public: 263 SERIALIZABLE_CLASS(ftthesaurus_id) 264 SERIALIZABLE_CLASS_CONSTRUCTOR2_NULL_PARAM1(ftthesaurus_id,ftnode,levels_) 265 void serialize( serialization::Archiver& ); 266 267 ftthesaurus_id( 268 QueryLoc const&, 269 zstring const &uri, 270 zstring const &relationship = "", 271 ftrange *levels = nullptr 272 ); 273 ~ftthesaurus_id(); 274 275 ft_visit_result::type accept( ftnode_visitor& ); 276 ftnode_t clone( expr::substitution_t& ) const; get_uri()277 zstring const& get_uri() const { return uri_; } get_relationship()278 zstring const& get_relationship() const { return relationship_; } get_levels()279 ftrange const* get_levels() const { return levels_; } 280 std::ostream& put( std::ostream& ) const; 281 282 private: 283 zstring uri_; 284 zstring relationship_; 285 ftrange *levels_; 286 }; 287 288 289 class ftthesaurus_option : public ftmatch_option { 290 public: 291 SERIALIZABLE_CLASS(ftthesaurus_option) 292 SERIALIZABLE_CLASS_CONSTRUCTOR2_NULL_PARAM1(ftthesaurus_option,ftmatch_option,default_tid_) 293 void serialize( serialization::Archiver& ); 294 295 typedef std::list<ftthesaurus_id*> thesaurus_id_list_t; 296 297 ftthesaurus_option( 298 QueryLoc const&, 299 ftthesaurus_id *default_tid, 300 thesaurus_id_list_t&, 301 bool no_thesaurus 302 ); 303 ~ftthesaurus_option(); 304 get_default_thesaurus_id()305 ftthesaurus_id const* get_default_thesaurus_id() const { 306 return default_tid_; 307 } get_thesaurus_id_list()308 thesaurus_id_list_t const& get_thesaurus_id_list() const { 309 return thesaurus_id_list_; 310 } 311 312 ft_visit_result::type accept( ftnode_visitor& ); 313 ftnode_t clone( expr::substitution_t& ) const; no_thesaurus()314 bool no_thesaurus() const { return no_thesaurus_; } 315 std::ostream& put( std::ostream& ) const; 316 317 private: 318 ftthesaurus_id *default_tid_; 319 thesaurus_id_list_t thesaurus_id_list_; 320 bool no_thesaurus_; 321 }; 322 typedef rchandle<ftthesaurus_option> ftthesaurus_option_t; 323 324 325 class ftwild_card_option : public ftmatch_option { 326 public: 327 SERIALIZABLE_CLASS(ftwild_card_option) 328 SERIALIZABLE_CLASS_CONSTRUCTOR2(ftwild_card_option,ftmatch_option) 329 void serialize( serialization::Archiver& ); 330 331 ftwild_card_option( 332 QueryLoc const&, 333 ft_wild_card_mode::type = ft_wild_card_mode::DEFAULT 334 ); 335 336 ft_visit_result::type accept( ftnode_visitor& ); 337 ftnode_t clone( expr::substitution_t& ) const; get_mode()338 ft_wild_card_mode::type get_mode() const { return mode_; } 339 std::ostream& put( std::ostream& ) const; 340 341 private: 342 ft_wild_card_mode::type mode_; 343 }; 344 typedef rchandle<ftwild_card_option> ftwild_card_option_t; 345 346 347 class ftmatch_options : public ftnode { 348 public: 349 SERIALIZABLE_CLASS(ftmatch_options) 350 SERIALIZABLE_CLASS_CONSTRUCTOR2(ftmatch_options,ftnode) 351 void serialize( serialization::Archiver& ); 352 353 typedef std::list<ftextension_option_t> ftextension_option_list_t; 354 355 ftmatch_options( QueryLoc const& ); 356 357 ft_visit_result::type accept( ftnode_visitor& ); 358 ftnode_t clone( expr::substitution_t& ) const; 359 get_case_option()360 ftcase_option const* get_case_option() const { 361 return case_option_.getp(); 362 } 363 get_diacritics_option()364 ftdiacritics_option const* get_diacritics_option() const { 365 return diacritics_option_.getp(); 366 } 367 get_extension_options()368 ftextension_option_list_t* get_extension_options() { 369 return extension_options_.empty() ? nullptr : &extension_options_; 370 } 371 get_extension_options()372 ftextension_option_list_t const* get_extension_options() const { 373 return extension_options_.empty() ? nullptr : &extension_options_; 374 } 375 get_language_option()376 ftlanguage_option const* get_language_option() const { 377 return language_option_.getp(); 378 } 379 get_stem_option()380 ftstem_option const* get_stem_option() const { 381 return stem_option_.getp(); 382 } 383 get_stop_word_option()384 ftstop_word_option const* get_stop_word_option() const { 385 return stop_word_option_.getp(); 386 } 387 get_thesaurus_option()388 ftthesaurus_option const* get_thesaurus_option() const { 389 return thesaurus_option_.getp(); 390 } 391 get_wild_card_option()392 ftwild_card_option const* get_wild_card_option() const { 393 return wild_card_option_.getp(); 394 } 395 add_extension_option(ftextension_option * o)396 void add_extension_option( ftextension_option *o ) { 397 extension_options_.push_back( o ); 398 } 399 set_case_option(ftcase_option const * o)400 void set_case_option( ftcase_option const *o ) { 401 case_option_ = o; 402 } 403 set_diacritics_option(ftdiacritics_option const * o)404 void set_diacritics_option( ftdiacritics_option const *o ) { 405 diacritics_option_ = o; 406 } 407 set_extension_options(ftextension_option_list_t const * o)408 void set_extension_options( ftextension_option_list_t const *o ) { 409 current_extension_options_ = o; 410 } 411 set_language_option(ftlanguage_option const * o)412 void set_language_option( ftlanguage_option const *o ) { 413 language_option_ = o; 414 } 415 set_stem_option(ftstem_option const * o)416 void set_stem_option( ftstem_option const *o ) { 417 stem_option_ = o; 418 } 419 set_stop_word_option(ftstop_word_option const * o)420 void set_stop_word_option( ftstop_word_option const *o ) { 421 stop_word_option_ = o; 422 } 423 set_thesaurus_option(ftthesaurus_option const * o)424 void set_thesaurus_option( ftthesaurus_option const *o ) { 425 thesaurus_option_ = o; 426 } 427 set_wild_card_option(ftwild_card_option const * o)428 void set_wild_card_option( ftwild_card_option const *o ) { 429 wild_card_option_ = o; 430 } 431 432 void set_missing_defaults(); 433 434 std::ostream& put( std::ostream& ) const; 435 436 private: 437 ftcase_option_t case_option_; 438 ftdiacritics_option_t diacritics_option_; 439 440 ftextension_option_list_t extension_options_; 441 // 442 // This points either to our own extension_options_ or a different one set by 443 // set_extension_options(). 444 // 445 ftextension_option_list_t const *current_extension_options_; 446 447 ftlanguage_option_t language_option_; 448 ftstem_option_t stem_option_; 449 ftstop_word_option_t stop_word_option_; 450 ftthesaurus_option_t thesaurus_option_; 451 ftwild_card_option_t wild_card_option_; 452 }; 453 454 ////////// Miscellaneous ////////////////////////////////////////////////////// 455 456 class ftweight : public ftnode { 457 public: 458 SERIALIZABLE_CLASS(ftweight) 459 SERIALIZABLE_CLASS_CONSTRUCTOR2(ftweight,ftnode) 460 void serialize( serialization::Archiver& ); 461 462 ftweight( QueryLoc const&, expr* const &weight_expr ); 463 464 ft_visit_result::type accept( ftnode_visitor& ); 465 ftnode_t clone( expr::substitution_t& ) const; get_weight_expr()466 expr** get_weight_expr() { return &weight_expr_; } get_weight_iter()467 PlanIter_t get_weight_iter() const { return weight_iter_; } 468 std::ostream& put( std::ostream& ) const; 469 set_weight_iter(PlanIter_t const & iter)470 void set_weight_iter( PlanIter_t const &iter ) { 471 weight_iter_ = iter; 472 } 473 474 private: 475 expr* weight_expr_; 476 PlanIter_t weight_iter_; 477 }; 478 479 ////////// FTPrimary & FTSelection //////////////////////////////////////////// 480 481 class ftprimary : public ftnode { 482 public: SERIALIZABLE_ABSTRACT_CLASS(ftprimary)483 SERIALIZABLE_ABSTRACT_CLASS(ftprimary) 484 SERIALIZABLE_CLASS_CONSTRUCTOR2(ftprimary,ftnode) 485 void serialize( serialization::Archiver &ar ) { 486 serialize_baseclass( ar, (ftnode*)this ); 487 } 488 489 protected: ftprimary(QueryLoc const & loc)490 ftprimary( QueryLoc const &loc ) : ftnode( loc ) { } 491 }; 492 493 494 class ftprimary_with_options : public ftnode { 495 public: 496 SERIALIZABLE_CLASS(ftprimary_with_options) 497 ftprimary_with_options(serialization::Archiver& ar); 498 void serialize( serialization::Archiver& ); 499 500 ftprimary_with_options( QueryLoc const& ); 501 ~ftprimary_with_options(); 502 503 ft_visit_result::type accept( ftnode_visitor& ); 504 ftnode_t clone( expr::substitution_t& ) const; get_primary()505 ftprimary const* get_primary() const { return primary_; } get_weight()506 ftweight* get_weight() { return weight_; } get_match_options()507 ftmatch_options const* get_match_options() const { return match_options_; } 508 std::ostream& put( std::ostream& ) const; 509 set_match_options(ftmatch_options * o)510 void set_match_options( ftmatch_options *o ) { 511 delete match_options_; 512 match_options_ = o; 513 } 514 set_primary(ftprimary * p)515 void set_primary( ftprimary *p ) { 516 delete primary_; 517 primary_ = p; 518 } 519 set_weight(ftweight * weight)520 void set_weight( ftweight *weight ) { 521 delete weight_; 522 weight_ = weight; 523 } 524 525 private: 526 ftprimary *primary_; 527 ftmatch_options *match_options_; 528 ftweight *weight_; 529 }; 530 531 532 class ftextension_selection : public ftprimary { 533 public: 534 SERIALIZABLE_CLASS(ftextension_selection) 535 SERIALIZABLE_CLASS_CONSTRUCTOR2_NULL_PARAM1(ftextension_selection,ftprimary,ftselection_) 536 void serialize( serialization::Archiver& ); 537 538 ftextension_selection( 539 QueryLoc const&, 540 rchandle<PragmaList> const&, 541 ftselection* 542 ); 543 ~ftextension_selection(); 544 545 ft_visit_result::type accept( ftnode_visitor& ); 546 ftnode_t clone( expr::substitution_t& ) const; get_pragmas()547 rchandle<PragmaList> const& get_pragmas() const { return pragmas_; } get_ftselection()548 ftselection const* get_ftselection() const { return ftselection_; } 549 std::ostream& put( std::ostream& ) const; 550 551 private: 552 rchandle<PragmaList> pragmas_; 553 ftselection *ftselection_; 554 }; 555 556 557 class ftselection : public ftprimary { 558 public: 559 SERIALIZABLE_CLASS(ftselection) 560 SERIALIZABLE_CLASS_CONSTRUCTOR2_NULL_PARAM1(ftselection,ftprimary,ftor_) 561 void serialize( serialization::Archiver& ); 562 563 typedef std::list<ftpos_filter*> ftpos_filter_list_t; 564 565 ftselection( 566 QueryLoc const&, 567 ftnode *ftor, 568 ftpos_filter_list_t const& 569 ); 570 ~ftselection(); 571 572 ft_visit_result::type accept( ftnode_visitor& ); 573 ftnode_t clone( expr::substitution_t& ) const; get_ftpos_filter_list()574 ftpos_filter_list_t const& get_ftpos_filter_list() const { return list_; } get_ftor()575 ftnode const* get_ftor() const { return ftor_; }; 576 std::ostream& put( std::ostream& ) const; 577 578 private: 579 ftnode *ftor_; 580 ftpos_filter_list_t list_; 581 }; 582 583 584 class ftwords_times : public ftprimary { 585 public: 586 SERIALIZABLE_CLASS(ftwords_times) 587 SERIALIZABLE_CLASS_CONSTRUCTOR2_NULL_PARAM2(ftwords_times,ftprimary,ftwords_,fttimes_) 588 void serialize( serialization::Archiver& ); 589 590 ftwords_times( 591 QueryLoc const&, 592 ftwords*, 593 ftrange *times = nullptr 594 ); 595 ~ftwords_times(); 596 597 ft_visit_result::type accept( ftnode_visitor& ); 598 ftnode_t clone( expr::substitution_t& ) const; get_words()599 ftwords const* get_words() const { return ftwords_; } get_times()600 ftrange const* get_times() const { return fttimes_; } 601 std::ostream& put( std::ostream& ) const; 602 603 private: 604 ftwords *ftwords_; 605 ftrange *fttimes_; 606 }; 607 608 //////// FTPosFilter ////////////////////////////////////////////////////////// 609 610 class ftpos_filter : public ftnode { 611 public: 612 SERIALIZABLE_ABSTRACT_CLASS(ftpos_filter) 613 SERIALIZABLE_CLASS_CONSTRUCTOR2(ftpos_filter,ftnode) 614 void serialize( serialization::Archiver& ); 615 616 protected: 617 ftpos_filter( QueryLoc const& ); 618 }; 619 620 621 class ftcontent_filter : public ftpos_filter { 622 public: 623 SERIALIZABLE_CLASS(ftcontent_filter) 624 SERIALIZABLE_CLASS_CONSTRUCTOR2(ftcontent_filter,ftpos_filter) 625 void serialize( serialization::Archiver& ); 626 627 ftcontent_filter( QueryLoc const&, ft_content_mode::type ); 628 629 ft_visit_result::type accept( ftnode_visitor& ); 630 ftnode_t clone( expr::substitution_t& ) const; get_mode()631 ft_content_mode::type get_mode() const { return mode_; } 632 std::ostream& put( std::ostream& ) const; 633 634 private: 635 ft_content_mode::type mode_; 636 }; 637 638 639 class ftdistance_filter : public ftpos_filter { 640 public: 641 SERIALIZABLE_CLASS(ftdistance_filter) 642 SERIALIZABLE_CLASS_CONSTRUCTOR2_NULL_PARAM1(ftdistance_filter,ftpos_filter, range_) 643 void serialize( serialization::Archiver& ); 644 645 ftdistance_filter( QueryLoc const&, ftrange*, ft_unit::type ); 646 ~ftdistance_filter(); 647 648 ft_visit_result::type accept( ftnode_visitor& ); 649 ftnode_t clone( expr::substitution_t& ) const; get_range()650 ftrange const* get_range() const { return range_; } get_unit()651 ft_unit::type get_unit() const { return unit_; } 652 std::ostream& put( std::ostream& ) const; 653 654 private: 655 ftrange *range_; 656 ft_unit::type unit_; 657 }; 658 659 660 class ftorder_filter : public ftpos_filter { 661 public: 662 SERIALIZABLE_CLASS(ftorder_filter) 663 SERIALIZABLE_CLASS_CONSTRUCTOR2(ftorder_filter,ftpos_filter) 664 void serialize( serialization::Archiver& ); 665 666 ftorder_filter( QueryLoc const& ); 667 668 ft_visit_result::type accept( ftnode_visitor& ); 669 ftnode_t clone( expr::substitution_t& ) const; 670 std::ostream& put( std::ostream& ) const; 671 }; 672 673 674 class ftscope_filter : public ftpos_filter { 675 public: 676 SERIALIZABLE_CLASS(ftscope_filter) 677 SERIALIZABLE_CLASS_CONSTRUCTOR2(ftscope_filter,ftpos_filter) 678 void serialize( serialization::Archiver& ); 679 680 ftscope_filter( QueryLoc const&, ft_scope::type, ft_big_unit::type ); 681 682 ft_visit_result::type accept( ftnode_visitor& ); 683 ftnode_t clone( expr::substitution_t& ) const; get_scope()684 ft_scope::type get_scope() const { return scope_; } get_unit()685 ft_big_unit::type get_unit() const { return unit_; } 686 std::ostream& put( std::ostream& ) const; 687 688 private: 689 ft_scope::type scope_; 690 ft_big_unit::type unit_; 691 }; 692 693 694 class ftwindow_filter : public ftpos_filter { 695 public: 696 SERIALIZABLE_CLASS(ftwindow_filter) 697 SERIALIZABLE_CLASS_CONSTRUCTOR2(ftwindow_filter,ftpos_filter) 698 void serialize( serialization::Archiver& ); 699 700 ftwindow_filter( QueryLoc const&, expr* const&, ft_unit::type ); 701 702 ft_visit_result::type accept( ftnode_visitor& ); 703 ftnode_t clone( expr::substitution_t& ) const; get_unit()704 ft_unit::type get_unit() const { return unit_; } get_window_expr()705 expr** get_window_expr() { return &window_expr_; } get_window_iter()706 PlanIter_t get_window_iter() const { return window_iter_; } 707 std::ostream& put( std::ostream& ) const; 708 set_window_iter(PlanIter_t const & iter)709 void set_window_iter( PlanIter_t const &iter ) { 710 window_iter_ = iter; 711 } 712 713 private: 714 expr* window_expr_; 715 ft_unit::type unit_; 716 PlanIter_t window_iter_; 717 }; 718 719 ////////// Boolean operators ////////////////////////////////////////////////// 720 721 /** 722 * This is an abstract base class for nodes that have a list of child nodes, 723 * currently ftand, ftmild_not, and ftor. 724 */ 725 class ftnode_list : public ftnode { 726 public: 727 SERIALIZABLE_ABSTRACT_CLASS(ftnode_list) 728 SERIALIZABLE_CLASS_CONSTRUCTOR2(ftnode_list,ftnode) 729 void serialize( serialization::Archiver& ); 730 731 typedef std::list<ftnode*> ftnode_list_t; 732 733 ~ftnode_list(); 734 get_node_list()735 ftnode_list_t& get_node_list() { return list_; } get_node_list()736 ftnode_list_t const& get_node_list() const { return list_; } 737 738 protected: 739 ftnode_list( QueryLoc const &loc, ftnode_list_t& ); 740 741 private: 742 ftnode_list_t list_; 743 }; 744 745 class ftand : public ftnode_list { 746 public: 747 SERIALIZABLE_CLASS(ftand) 748 SERIALIZABLE_CLASS_CONSTRUCTOR2(ftand,ftnode_list) 749 void serialize( serialization::Archiver& ); 750 751 ftand( QueryLoc const&, ftnode_list_t& ); 752 753 ft_visit_result::type accept( ftnode_visitor& ); 754 ftnode_t clone( expr::substitution_t& ) const; 755 std::ostream& put( std::ostream& ) const; 756 }; 757 758 759 class ftmild_not : public ftnode_list { 760 public: 761 SERIALIZABLE_CLASS(ftmild_not) 762 SERIALIZABLE_CLASS_CONSTRUCTOR2(ftmild_not,ftnode_list) 763 void serialize( serialization::Archiver& ); 764 765 ftmild_not( QueryLoc const&, ftnode_list_t& ); 766 767 ft_visit_result::type accept( ftnode_visitor& ); 768 ftnode_t clone( expr::substitution_t& ) const; 769 std::ostream& put( std::ostream& ) const; 770 }; 771 772 773 class ftor : public ftnode_list { 774 public: 775 SERIALIZABLE_CLASS(ftor) 776 SERIALIZABLE_CLASS_CONSTRUCTOR2(ftor,ftnode_list) 777 void serialize( serialization::Archiver& ); 778 779 ftor( QueryLoc const&, ftnode_list_t& ); 780 781 ft_visit_result::type accept( ftnode_visitor& ); 782 ftnode_t clone( expr::substitution_t& ) const; 783 std::ostream& put( std::ostream& ) const; 784 }; 785 786 787 class ftunary_not : public ftnode { 788 public: 789 SERIALIZABLE_CLASS(ftunary_not) 790 SERIALIZABLE_CLASS_CONSTRUCTOR2_NULL_PARAM1(ftunary_not,ftnode,subnode_) 791 void serialize( serialization::Archiver& ); 792 793 ftunary_not( QueryLoc const&, ftnode *subnode ); 794 ~ftunary_not(); 795 796 ft_visit_result::type accept( ftnode_visitor& ); 797 ftnode_t clone( expr::substitution_t& ) const; get_subnode()798 ftnode const* get_subnode() const { return subnode_; } 799 std::ostream& put( std::ostream& ) const; 800 801 private: 802 ftnode *subnode_; 803 }; 804 805 ////////// Miscellaneous ////////////////////////////////////////////////////// 806 807 class ftrange : public ftnode { 808 public: 809 SERIALIZABLE_CLASS(ftrange) 810 SERIALIZABLE_CLASS_CONSTRUCTOR2(ftrange,ftnode) 811 void serialize( serialization::Archiver& ); 812 813 ftrange( 814 QueryLoc const&, 815 ft_range_mode::type, 816 expr* const &expr1, 817 expr* expr2 = 0 818 ); 819 820 ft_visit_result::type accept( ftnode_visitor& ); 821 ftnode_t clone( expr::substitution_t& ) const; get_expr1()822 expr** get_expr1() { return &expr1_; } get_expr2()823 expr** get_expr2() { return &expr2_; } get_plan_iter1()824 PlanIter_t get_plan_iter1() const { return iter1_; } get_plan_iter2()825 PlanIter_t get_plan_iter2() const { return iter2_; } get_mode()826 ft_range_mode::type get_mode() const { return mode_; } 827 std::ostream& put( std::ostream& ) const; 828 set_plan_iters(PlanIter_t const & iter1,PlanIter_t const & iter2)829 void set_plan_iters( PlanIter_t const &iter1, PlanIter_t const &iter2 ) { 830 iter1_ = iter1; 831 iter2_ = iter2; 832 } 833 834 private: 835 ft_range_mode::type mode_; 836 expr* expr1_; 837 expr* expr2_; 838 PlanIter_t iter1_; 839 PlanIter_t iter2_; 840 }; 841 842 843 class ftwords : public ftnode { 844 public: 845 SERIALIZABLE_CLASS(ftwords) 846 SERIALIZABLE_CLASS_CONSTRUCTOR2(ftwords,ftnode) 847 void serialize( serialization::Archiver& ); 848 849 ftwords( 850 QueryLoc const&, 851 expr* const&, 852 ft_anyall_mode::type = ft_anyall_mode::DEFAULT 853 ); 854 855 ft_visit_result::type accept( ftnode_visitor& ); 856 ftnode_t clone( expr::substitution_t& ) const; get_value_expr()857 expr** get_value_expr() { return &value_expr_; } get_value_iter()858 PlanIter_t get_value_iter() const { return value_iter_; } get_mode()859 ft_anyall_mode::type get_mode() const { return mode_; } 860 std::ostream& put( std::ostream& ) const; 861 set_plan_iter(PlanIter_t const & iter)862 void set_plan_iter( PlanIter_t const &iter ) { 863 value_iter_ = iter; 864 } 865 866 private: 867 expr* value_expr_; 868 ft_anyall_mode::type mode_; 869 PlanIter_t value_iter_; 870 }; 871 872 } /* namespace zorba */ 873 874 #endif /* ZORBA_FTNODE_H */ 875 876 /* 877 * Local variables: 878 * mode: c++ 879 * End: 880 */ 881 /* vim:set et sw=2 ts=2: */ 882