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 #include "stdafx.h"
17 
18 #include <zorba/error.h>
19 
20 #include "diagnostics/xquery_diagnostics.h"
21 #include "types/casting.h"
22 #include "util/ascii_util.h"
23 #include "util/cxx_util.h"
24 #include "util/indent.h"
25 #include "util/stl_util.h"
26 #include "zorbautils/locale.h"
27 
28 #include "expr_visitor.h"
29 #include "ftnode.h"
30 #include "ftnode_visitor.h"
31 
32 using namespace std;
33 using namespace zorba::locale;
34 
35 namespace zorba {
36 
37 ///////////////////////////////////////////////////////////////////////////////
38 
39 
40 SERIALIZE_INTERNAL_METHOD(ftnode)
41 
SERIALIZE_INTERNAL_METHOD(ftmatch_option)42 SERIALIZE_INTERNAL_METHOD(ftmatch_option)
43 
44 SERIALIZE_INTERNAL_METHOD(ftprimary)
45 
46 SERIALIZE_INTERNAL_METHOD(ftpos_filter)
47 
48 SERIALIZE_INTERNAL_METHOD(ftnode_list)
49 
50 SERIALIZABLE_CLASS_VERSIONS(ftand)
51 
52 SERIALIZABLE_CLASS_VERSIONS(ftcontent_filter)
53 
54 SERIALIZABLE_CLASS_VERSIONS(ftcase_option)
55 
56 SERIALIZABLE_CLASS_VERSIONS(ftdiacritics_option)
57 
58 SERIALIZABLE_CLASS_VERSIONS(ftdistance_filter)
59 
60 SERIALIZABLE_CLASS_VERSIONS(ftextension_option)
61 
62 SERIALIZABLE_CLASS_VERSIONS(ftextension_selection)
63 
64 SERIALIZABLE_CLASS_VERSIONS(ftlanguage_option)
65 
66 SERIALIZABLE_CLASS_VERSIONS(ftmatch_options)
67 
68 SERIALIZABLE_CLASS_VERSIONS(ftmild_not)
69 
70 SERIALIZABLE_CLASS_VERSIONS(ftor)
71 
72 SERIALIZABLE_CLASS_VERSIONS(ftorder_filter)
73 
74 SERIALIZABLE_CLASS_VERSIONS(ftprimary_with_options)
75 
76 SERIALIZABLE_CLASS_VERSIONS(ftrange)
77 
78 SERIALIZABLE_CLASS_VERSIONS(ftscope_filter)
79 
80 SERIALIZABLE_CLASS_VERSIONS(ftselection)
81 
82 SERIALIZABLE_CLASS_VERSIONS(ftstem_option)
83 
84 SERIALIZABLE_CLASS_VERSIONS(ftstop_words)
85 
86 SERIALIZABLE_CLASS_VERSIONS(ftstop_word_option)
87 
88 SERIALIZABLE_CLASS_VERSIONS(ftthesaurus_id)
89 
90 SERIALIZABLE_CLASS_VERSIONS(ftthesaurus_option)
91 
92 SERIALIZABLE_CLASS_VERSIONS(ftunary_not)
93 
94 SERIALIZABLE_CLASS_VERSIONS(ftweight)
95 
96 SERIALIZABLE_CLASS_VERSIONS(ftwild_card_option)
97 
98 SERIALIZABLE_CLASS_VERSIONS(ftwindow_filter)
99 
100 SERIALIZABLE_CLASS_VERSIONS(ftwords)
101 
102 SERIALIZABLE_CLASS_VERSIONS(ftwords_times)
103 
104 
105 ////////// Visit macros ///////////////////////////////////////////////////////
106 
107 #define DO_CHILDREN( R )  ( !(R & ft_visit_result::no_children) )
108 #define DO_END_VISIT( R ) ( !(R & ft_visit_result::no_end) )
109 
110 #define BEGIN_VISIT( V )                                \
111   ft_visit_result::type vr0 = (V).begin_visit( *this ); \
112   if ( DO_CHILDREN( vr0 ) ) {
113 
114 #define END_VISIT( V )                                       \
115   }                                                          \
116   if ( !DO_END_VISIT( vr0 ) ) ; else (V).end_visit( *this ); \
117   return vr0
118 
119 #undef  EV_ACCEPT
120 #define EV_ACCEPT( EXPR, V )                          \
121   {                                                   \
122     expr_visitor *const ev = (V).get_expr_visitor();  \
123     if ( ev && (EXPR) ) (EXPR)->accept( *ev );        \
124   }
125 
126 #undef  ACCEPT
127 #define ACCEPT( FTNODE, V ) \
128   if ( !(FTNODE) ) ; else   \
129   vr0 = (ft_visit_result::type)(vr0 | (FTNODE)->accept( V ))
130 
131 #undef  ACCEPT_SEQ
132 #define ACCEPT_SEQ( T, S, V )                 \
133   for ( T::const_iterator i = (S).begin();    \
134         DO_CHILDREN( vr0 ) && i != (S).end(); \
135         ++i )                                 \
136     ACCEPT( *i, V );
137 
138 ////////// PUT() macros ///////////////////////////////////////////////////////
139 
140 #define PUT(OS)                     OS << indent
141 #undef  BEGIN_PUT
142 #define BEGIN_PUT(OS,LABEL)         PUT(OS) << #LABEL
143 #define INDENT_PUT(OS)              OS << " [\n" << inc_indent
144 #define BEGIN_INDENT_PUT(OS,LABEL)  BEGIN_PUT(OS,LABEL); INDENT_PUT(OS)
145 #define OUTDENT_PUT(OS)             OS << dec_indent << indent << "]\n"
146 #undef  END_PUT
147 #define END_PUT(OS)                 return OS
148 #define OUTDENT_END_PUT(OS)         OUTDENT_PUT(OS); END_PUT(OS)
149 
150 #define PUT_LABEL(OS,LABEL) \
151   OS << " " #LABEL "="
152 
153 #define PUT_ATTR_VALUE(OS,LABEL,VALUE) \
154   PUT_LABEL(OS,LABEL) << VALUE
155 
156 #define PUT_ATTR(OS,LABEL) \
157   PUT_ATTR_VALUE(OS,LABEL,LABEL##_)
158 
159 #define PUT_BOOL(OS,LABEL) \
160   PUT_ATTR_VALUE( OS, LABEL, (LABEL##_ ? 'T' : 'F') )
161 
162 #define PUT_EXPR(OS,EXPR) \
163   if ( !(EXPR) ) ; else (EXPR)->put(OS)
164 
165 #define PUT_NODE(OS,NODE) \
166   if ( !(NODE) ) ; else (NODE)->put(OS)
167 
168 #define PUT_SEQ(OS,T,SEQ) \
169   FOR_EACH( T, i, SEQ ) (*i)->put( OS )
170 
171 ///////////////////////////////////////////////////////////////////////////////
172 
173 template<typename PointerType>
174 inline PointerType clone_ptr( PointerType p, expr::substitution_t &s ) {
175   return static_cast<PointerType>( p->clone( s ).release() );
176 }
177 
178 template<>
clone_ptr(expr * p,expr::substitution_t & s)179 inline expr* clone_ptr( expr* p, expr::substitution_t &s ) {
180   return static_cast<expr*>( p->clone( s ) );
181 }
182 
183 template<class RCHandleValueType>
clone_ptr(rchandle<RCHandleValueType> const & p,expr::substitution_t & s)184 inline RCHandleValueType* clone_ptr( rchandle<RCHandleValueType> const &p,
185                                      expr::substitution_t &s ) {
186   return static_cast<RCHandleValueType*>( p->clone( s ).release() );
187 }
188 
189 template<typename PointerType>
clone_ptr_if(PointerType p,expr::substitution_t & s)190 inline PointerType clone_ptr_if( PointerType p, expr::substitution_t &s ) {
191   return p ? clone_ptr( p, s ) : nullptr;
192 }
193 
194 template<class RCHandleValueType>
clone_ptr_if(rchandle<RCHandleValueType> const & p,expr::substitution_t & s)195 inline RCHandleValueType* clone_ptr_if( rchandle<RCHandleValueType> const &p,
196                                         expr::substitution_t &s ) {
197   return p.isNull() ? nullptr : clone_ptr( p, s );
198 }
199 
200 template<class ContainerType>
clone_list(ContainerType const & from,ContainerType * to,expr::substitution_t & s)201 void clone_list( ContainerType const &from, ContainerType *to,
202                  expr::substitution_t &s ) {
203   FOR_EACH( typename ContainerType, i, from )
204     to->push_back( clone_ptr( *i, s ) );
205 }
206 
207 ///////////////////////////////////////////////////////////////////////////////
208 
serialize(serialization::Archiver & ar)209 void ftnode::serialize( serialization::Archiver &ar ) {
210   ar & loc_;
211 }
212 
ftand(QueryLoc const & loc,ftnode_list_t & list)213 ftand::ftand( QueryLoc const &loc, ftnode_list_t &list ) :
214   ftnode_list( loc, list )
215 {
216 }
217 
accept(ftnode_visitor & v)218 ft_visit_result::type ftand::accept( ftnode_visitor &v ) {
219   BEGIN_VISIT( v );
220   ACCEPT_SEQ( ftnode_list_t, get_node_list(), v );
221   END_VISIT( v );
222 }
223 
clone(expr::substitution_t & s) const224 ftnode_t ftand::clone( expr::substitution_t &s ) const {
225   ftnode_list_t copy;
226   clone_list( get_node_list(), &copy, s );
227   return new ftand( get_loc(), copy );
228 }
229 
put(ostream & o) const230 ostream& ftand::put( ostream &o ) const {
231   BEGIN_INDENT_PUT( o, ftand );
232   PUT_SEQ( o, ftnode_list_t, get_node_list() );
233   OUTDENT_END_PUT( o );
234 }
235 
serialize(serialization::Archiver & ar)236 void ftand::serialize( serialization::Archiver &ar ) {
237   serialize_baseclass( ar, (ftnode_list*)this );
238 }
239 
ftcase_option(QueryLoc const & loc,ft_case_mode::type mode)240 ftcase_option::ftcase_option(
241   QueryLoc const &loc,
242   ft_case_mode::type mode
243 ) :
244   ftmatch_option( loc ),
245   mode_( mode )
246 {
247 }
248 
accept(ftnode_visitor & v)249 ft_visit_result::type ftcase_option::accept( ftnode_visitor &v ) {
250   BEGIN_VISIT( v );
251   END_VISIT( v );
252 }
253 
clone(expr::substitution_t &) const254 ftnode_t ftcase_option::clone( expr::substitution_t& ) const {
255   return new ftcase_option( get_loc(), mode_ );
256 }
257 
put(ostream & o) const258 ostream& ftcase_option::put( ostream &o ) const {
259   BEGIN_PUT( o, ftcase_option );
260   PUT_ATTR( o, mode ) << endl;
261   END_PUT( o );
262 }
263 
serialize(serialization::Archiver & ar)264 void ftcase_option::serialize( serialization::Archiver &ar ) {
265   serialize_baseclass( ar, (ftmatch_option*)this );
266   SERIALIZE_ENUM(ft_case_mode::type,mode_);
267 }
268 
ftcontent_filter(QueryLoc const & loc,ft_content_mode::type mode)269 ftcontent_filter::ftcontent_filter(
270   QueryLoc const &loc, ft_content_mode::type mode
271 ) :
272   ftpos_filter( loc ),
273   mode_( mode )
274 {
275 }
276 
accept(ftnode_visitor & v)277 ft_visit_result::type ftcontent_filter::accept( ftnode_visitor &v ) {
278   BEGIN_VISIT( v );
279   END_VISIT( v );
280 }
281 
clone(expr::substitution_t & s) const282 ftnode_t ftcontent_filter::clone( expr::substitution_t &s ) const {
283   return new ftcontent_filter( get_loc(), mode_ );
284 }
285 
serialize(serialization::Archiver & ar)286 void ftcontent_filter::serialize( serialization::Archiver &ar ) {
287   serialize_baseclass( ar, (ftpos_filter*)this );
288   SERIALIZE_ENUM(ft_content_mode::type, mode_);
289 }
290 
put(ostream & o) const291 ostream& ftcontent_filter::put( ostream &o ) const {
292   BEGIN_PUT( o, ftcontent_filter );
293   PUT_ATTR( o, mode ) << endl;
294   END_PUT( o );
295 }
296 
ftdiacritics_option(QueryLoc const & loc,ft_diacritics_mode::type mode)297 ftdiacritics_option::ftdiacritics_option(
298   QueryLoc const &loc,
299   ft_diacritics_mode::type mode
300 ) :
301   ftmatch_option( loc ),
302   mode_( mode )
303 {
304 }
305 
accept(ftnode_visitor & v)306 ft_visit_result::type ftdiacritics_option::accept( ftnode_visitor &v ) {
307   BEGIN_VISIT( v );
308   END_VISIT( v );
309 }
310 
clone(expr::substitution_t &) const311 ftnode_t ftdiacritics_option::clone( expr::substitution_t& ) const {
312   return new ftdiacritics_option( get_loc(), mode_ );
313 }
314 
put(ostream & o) const315 ostream& ftdiacritics_option::put( ostream &o ) const {
316   BEGIN_PUT( o, ftdiacritics_option );
317   PUT_ATTR( o, mode ) << endl;
318   END_PUT( o );
319 }
320 
serialize(serialization::Archiver & ar)321 void ftdiacritics_option::serialize( serialization::Archiver &ar ) {
322   serialize_baseclass( ar, (ftmatch_option*)this );
323   SERIALIZE_ENUM(ft_diacritics_mode::type,mode_);
324 }
325 
ftdistance_filter(QueryLoc const & loc,ftrange * range,ft_unit::type unit)326 ftdistance_filter::ftdistance_filter(
327   QueryLoc const &loc,
328   ftrange *range,
329   ft_unit::type unit
330 ) :
331   ftpos_filter( loc ),
332   range_( range ),
333   unit_( unit )
334 {
335   ZORBA_ASSERT( range_ );
336 }
337 
~ftdistance_filter()338 ftdistance_filter::~ftdistance_filter() {
339   delete range_;
340 }
341 
accept(ftnode_visitor & v)342 ft_visit_result::type ftdistance_filter::accept( ftnode_visitor &v ) {
343   BEGIN_VISIT( v );
344   ACCEPT( range_, v );
345   END_VISIT( v );
346 }
347 
clone(expr::substitution_t & s) const348 ftnode_t ftdistance_filter::clone( expr::substitution_t &s ) const {
349   return new ftdistance_filter( get_loc(), clone_ptr_if( range_, s ), unit_ );
350 }
351 
put(ostream & o) const352 ostream& ftdistance_filter::put( ostream &o ) const {
353   BEGIN_PUT( o, ftcontent_filter );
354   PUT_ATTR( o, unit );
355   INDENT_PUT( o );
356   PUT_NODE( o, range_ );
357   OUTDENT_END_PUT( o );
358 }
359 
serialize(serialization::Archiver & ar)360 void ftdistance_filter::serialize( serialization::Archiver &ar ) {
361   serialize_baseclass( ar, (ftpos_filter*)this );
362   ar & range_;
363   SERIALIZE_ENUM(ft_unit::type,unit_);
364 }
365 
ftextension_selection(QueryLoc const & loc,rchandle<PragmaList> const & pragmas,ftselection * selection)366 ftextension_selection::ftextension_selection(
367   QueryLoc const &loc,
368   rchandle<PragmaList> const &pragmas,
369   ftselection *selection
370 ) :
371   ftprimary( loc ),
372   pragmas_( pragmas ),
373   ftselection_( selection )
374 {
375 }
376 
~ftextension_selection()377 ftextension_selection::~ftextension_selection() {
378   delete ftselection_;
379 }
380 
accept(ftnode_visitor & v)381 ft_visit_result::type ftextension_selection::accept( ftnode_visitor &v ) {
382   BEGIN_VISIT( v );
383   ACCEPT( ftselection_, v );
384   END_VISIT( v );
385 }
386 
clone(expr::substitution_t & s) const387 ftnode_t ftextension_selection::clone( expr::substitution_t &s ) const {
388   return new ftextension_selection(
389     get_loc(), pragmas_, clone_ptr_if( ftselection_, s )
390   );
391 }
392 
put(ostream & o) const393 ostream& ftextension_selection::put( ostream &o ) const {
394   BEGIN_INDENT_PUT( o, ftextension_selection );
395   PUT_NODE( o, ftselection_ );
396   OUTDENT_END_PUT( o );
397 }
398 
serialize(serialization::Archiver & ar)399 void ftextension_selection::serialize( serialization::Archiver &ar ) {
400   serialize_baseclass( ar, (ftprimary*)this );
401   //ar & pragmas_;
402   ar & ftselection_;
403 }
404 
ftextension_option(QueryLoc const & loc,rchandle<QName> const & qname,zstring const & val)405 ftextension_option::ftextension_option(
406   QueryLoc const &loc,
407   rchandle<QName> const &qname,
408   zstring const &val
409 ) :
410   ftmatch_option( loc ),
411   qname_( qname ),
412   val_( val )
413 {
414 }
415 
accept(ftnode_visitor & v)416 ft_visit_result::type ftextension_option::accept( ftnode_visitor &v ) {
417   BEGIN_VISIT( v );
418   END_VISIT( v );
419 }
420 
clone(expr::substitution_t &) const421 ftnode_t ftextension_option::clone( expr::substitution_t& ) const {
422   return new ftextension_option( get_loc(), qname_, val_ );
423 }
424 
put(ostream & o) const425 ostream& ftextension_option::put( ostream &o ) const {
426   BEGIN_PUT( o, ftextension_option )
427   //<< " qname=" << qname_
428     << " val=" << val_ << endl;
429   END_PUT( o );
430 }
431 
serialize(serialization::Archiver & ar)432 void ftextension_option::serialize( serialization::Archiver &ar ) {
433   serialize_baseclass( ar, (ftmatch_option*)this );
434   //ar & qname_;
435   ar & val_;
436 }
437 
ftlanguage_option(QueryLoc const & loc,zstring const & lang)438 ftlanguage_option::ftlanguage_option(
439   QueryLoc const &loc,
440   zstring const &lang
441 ) :
442   ftmatch_option( loc )
443 {
444   if ( !GenericCast::instance()->castableToLanguage( lang ) )
445     throw XQUERY_EXCEPTION(
446       err::XPTY0004,
447       ERROR_PARAMS(
448         ZED( BadType_23o ), lang, ZED( NoCastTo_45o ), "xs:language"
449       ),
450       ERROR_LOC( loc )
451     );
452   if ( !(lang_ = locale::find_lang( lang.c_str() )) )
453     throw XQUERY_EXCEPTION(
454       err::FTST0009, ERROR_PARAMS( lang ), ERROR_LOC( loc )
455     );
456 }
457 
ftlanguage_option(QueryLoc const & loc,iso639_1::type lang)458 ftlanguage_option::ftlanguage_option(
459   QueryLoc const &loc,
460   iso639_1::type lang
461 ) :
462   ftmatch_option( loc ),
463   lang_( lang )
464 {
465 }
466 
serialize(serialization::Archiver & ar)467 void ftlanguage_option::serialize( serialization::Archiver &ar ) {
468   serialize_baseclass( ar, (ftmatch_option*)this );
469   SERIALIZE_ENUM(locale::iso639_1::type,lang_);
470 }
471 
472 
accept(ftnode_visitor & v)473 ft_visit_result::type ftlanguage_option::accept( ftnode_visitor &v ) {
474   BEGIN_VISIT( v );
475   END_VISIT( v );
476 }
477 
clone(expr::substitution_t &) const478 ftnode_t ftlanguage_option::clone( expr::substitution_t& ) const {
479   return new ftlanguage_option( get_loc(), lang_ );
480 }
481 
put(ostream & o) const482 ostream& ftlanguage_option::put( ostream &o ) const {
483   BEGIN_PUT( o, ftlanguage_option );
484   PUT_ATTR( o, lang ) << endl;
485   END_PUT( o );
486 }
487 
serialize(serialization::Archiver & ar)488 void ftmatch_option::serialize( serialization::Archiver &ar ) {
489   serialize_baseclass( ar, (ftnode*)this );
490 }
491 
ftmatch_options(QueryLoc const & loc)492 ftmatch_options::ftmatch_options( QueryLoc const &loc ) :
493   ftnode( loc ),
494   current_extension_options_( &extension_options_ )
495 {
496 }
497 
accept(ftnode_visitor & v)498 ft_visit_result::type ftmatch_options::accept( ftnode_visitor &v ) {
499   BEGIN_VISIT( v );
500   ACCEPT( case_option_, v );
501   ACCEPT( diacritics_option_, v );
502   ACCEPT_SEQ( ftextension_option_list_t, *current_extension_options_, v );
503   ACCEPT( language_option_, v );
504   ACCEPT( stem_option_, v );
505   ACCEPT( stop_word_option_, v );
506   ACCEPT( thesaurus_option_, v );
507   ACCEPT( wild_card_option_, v );
508   END_VISIT( v );
509 }
510 
clone(expr::substitution_t & s) const511 ftnode_t ftmatch_options::clone( expr::substitution_t &s ) const {
512   unique_ptr<ftmatch_options> p( new ftmatch_options( get_loc() ) );
513   if ( case_option_ )
514     p->set_case_option( clone_ptr( case_option_, s ) );
515   if ( diacritics_option_ )
516     p->set_diacritics_option(
517       clone_ptr( diacritics_option_, s )
518     );
519 
520   FOR_EACH( ftextension_option_list_t, i, extension_options_ )
521     p->add_extension_option( clone_ptr( *i, s ) );
522   if ( current_extension_options_ != &extension_options_ )
523     p->set_extension_options( current_extension_options_ );
524 
525   if ( language_option_ )
526     p->set_language_option( clone_ptr( language_option_, s ) );
527   if ( stem_option_ )
528     p->set_stem_option( clone_ptr( stem_option_, s ) );
529   if ( stop_word_option_ )
530     p->set_stop_word_option( clone_ptr( stop_word_option_, s ) );
531   if ( thesaurus_option_ )
532     p->set_thesaurus_option( clone_ptr( thesaurus_option_, s ) );
533   if ( wild_card_option_ )
534     p->set_wild_card_option( clone_ptr( wild_card_option_, s ) );
535   return p.release();
536 }
537 
put(ostream & o) const538 ostream& ftmatch_options::put( ostream &o ) const {
539   BEGIN_INDENT_PUT( o, ftmatch_options );
540   PUT_NODE( o, case_option_ );
541   PUT_NODE( o, diacritics_option_ );
542   PUT_SEQ ( o, ftextension_option_list_t, *current_extension_options_ );
543   PUT_NODE( o, language_option_ );
544   PUT_NODE( o, stem_option_ );
545   PUT_NODE( o, stop_word_option_ );
546   PUT_NODE( o, thesaurus_option_ );
547   PUT_NODE( o, wild_card_option_ );
548   OUTDENT_END_PUT( o );
549 }
550 
serialize(serialization::Archiver & ar)551 void ftmatch_options::serialize( serialization::Archiver &ar ) {
552   serialize_baseclass( ar, (ftnode*)this );
553   ar & case_option_;
554   ar & diacritics_option_;
555   ar & extension_options_;
556   if ( !ar.is_serializing_out() )
557     current_extension_options_ = &extension_options_;
558   ar & language_option_;
559   ar & stem_option_;
560   ar & stop_word_option_;
561   ar & thesaurus_option_;
562   ar & wild_card_option_;
563 }
564 
set_missing_defaults()565 void ftmatch_options::set_missing_defaults() {
566   if ( !case_option_ )
567     case_option_ = new ftcase_option( get_loc() );
568   if ( !diacritics_option_ )
569     diacritics_option_ = new ftdiacritics_option( get_loc() );
570   // extension_option_
571   // language_option_
572   if ( !stem_option_ )
573     stem_option_ = new ftstem_option( get_loc() );
574   if ( !stop_word_option_ )
575     stop_word_option_ = new ftstop_word_option( get_loc() );
576   // thesaurus_option_
577   if ( !wild_card_option_ )
578     wild_card_option_ = new ftwild_card_option( get_loc() );
579 }
580 
ftmild_not(QueryLoc const & loc,ftnode_list_t & list)581 ftmild_not::ftmild_not( QueryLoc const &loc, ftnode_list_t &list ) :
582   ftnode_list( loc, list )
583 {
584 }
585 
accept(ftnode_visitor & v)586 ft_visit_result::type ftmild_not::accept( ftnode_visitor &v ) {
587   BEGIN_VISIT( v );
588   ACCEPT_SEQ( ftnode_list_t, get_node_list(), v );
589   END_VISIT( v );
590 }
591 
clone(expr::substitution_t & s) const592 ftnode_t ftmild_not::clone( expr::substitution_t &s ) const {
593   ftnode_list_t copy;
594   clone_list( get_node_list(), &copy, s );
595   return new ftmild_not( get_loc(), copy );
596 }
597 
put(ostream & o) const598 ostream& ftmild_not::put( ostream &o ) const {
599   BEGIN_INDENT_PUT( o, ftmild_not );
600   PUT_SEQ( o, ftnode_list_t, get_node_list() );
601   OUTDENT_END_PUT( o );
602 }
603 
serialize(serialization::Archiver & ar)604 void ftmild_not::serialize( serialization::Archiver &ar ) {
605   serialize_baseclass( ar, (ftnode_list*)this );
606 }
607 
ftnode_list(QueryLoc const & loc,ftnode_list_t & list)608 ftnode_list::ftnode_list( QueryLoc const &loc, ftnode_list_t &list ) :
609   ftnode( loc )
610 {
611   list_.swap( list );
612 }
613 
~ftnode_list()614 ftnode_list::~ftnode_list() {
615   ztd::delete_ptr_seq( list_ );
616 }
617 
serialize(serialization::Archiver & ar)618 void ftnode_list::serialize( serialization::Archiver &ar ) {
619   serialize_baseclass( ar, (ftnode*)this );
620   ar & list_;
621 }
622 
ftor(QueryLoc const & loc,ftnode_list_t & list)623 ftor::ftor( QueryLoc const &loc, ftnode_list_t &list ) :
624   ftnode_list( loc, list )
625 {
626 }
627 
accept(ftnode_visitor & v)628 ft_visit_result::type ftor::accept( ftnode_visitor &v ) {
629   BEGIN_VISIT( v );
630   ACCEPT_SEQ( ftnode_list_t, get_node_list(), v );
631   END_VISIT( v );
632 }
633 
clone(expr::substitution_t & s) const634 ftnode_t ftor::clone( expr::substitution_t &s ) const {
635   ftnode_list_t copy;
636   clone_list( get_node_list(), &copy, s );
637   return new ftor( get_loc(), copy );
638 }
639 
put(ostream & o) const640 ostream& ftor::put( ostream &o ) const {
641   BEGIN_INDENT_PUT( o, ftor );
642   PUT_SEQ( o, ftnode_list_t, get_node_list() );
643   OUTDENT_END_PUT( o );
644 }
645 
serialize(serialization::Archiver & ar)646 void ftor::serialize( serialization::Archiver &ar ) {
647   serialize_baseclass( ar, (ftnode_list*)this );
648 }
649 
ftorder_filter(QueryLoc const & loc)650 ftorder_filter::ftorder_filter( QueryLoc const &loc ) :
651   ftpos_filter( loc )
652 {
653 }
654 
accept(ftnode_visitor & v)655 ft_visit_result::type ftorder_filter::accept( ftnode_visitor &v ) {
656   BEGIN_VISIT( v );
657   END_VISIT( v );
658 }
659 
clone(expr::substitution_t & s) const660 ftnode_t ftorder_filter::clone( expr::substitution_t &s ) const {
661   return new ftorder_filter( get_loc() );
662 }
663 
put(ostream & o) const664 ostream& ftorder_filter::put( ostream &o ) const {
665   BEGIN_PUT( o, ftorder_filter ) << endl;
666   END_PUT( o );
667 }
668 
serialize(serialization::Archiver & ar)669 void ftorder_filter::serialize( serialization::Archiver &ar ) {
670   serialize_baseclass( ar, (ftpos_filter*)this );
671 }
672 
ftpos_filter(QueryLoc const & loc)673 ftpos_filter::ftpos_filter( QueryLoc const &loc ) :
674   ftnode( loc )
675 {
676 }
677 
serialize(serialization::Archiver & ar)678 void ftpos_filter::serialize( serialization::Archiver &ar ) {
679   serialize_baseclass( ar, (ftnode*)this );
680 }
681 
ftprimary_with_options(QueryLoc const & loc)682 ftprimary_with_options::ftprimary_with_options( QueryLoc const &loc ) :
683   ftnode( loc ),
684   primary_( nullptr ),
685   match_options_( new ftmatch_options( loc ) ),
686   weight_( nullptr )
687 {
688 }
689 
~ftprimary_with_options()690 ftprimary_with_options::~ftprimary_with_options() {
691   delete primary_;
692   delete match_options_;
693   delete weight_;
694 }
695 
accept(ftnode_visitor & v)696 ft_visit_result::type ftprimary_with_options::accept( ftnode_visitor &v ) {
697   BEGIN_VISIT( v );
698   ACCEPT( primary_, v );
699   ACCEPT( match_options_, v );
700   ACCEPT( weight_, v );
701   END_VISIT( v );
702 }
703 
clone(expr::substitution_t & s) const704 ftnode_t ftprimary_with_options::clone( expr::substitution_t &s ) const {
705   unique_ptr<ftprimary_with_options> p(
706     new ftprimary_with_options( get_loc() )
707   );
708   p->set_match_options( clone_ptr( match_options_, s ) );
709   p->set_primary( clone_ptr( primary_, s ) );
710   if ( weight_ )
711     p->set_weight( clone_ptr( weight_, s ) );
712   return p.release();
713 }
714 
put(ostream & o) const715 ostream& ftprimary_with_options::put( ostream &o ) const {
716   BEGIN_INDENT_PUT( o, ftprimary_with_options );
717   PUT_NODE( o, primary_ );
718   PUT_NODE( o, match_options_ );
719   PUT_NODE( o, weight_ );
720   OUTDENT_END_PUT( o );
721 }
722 
ftprimary_with_options(serialization::Archiver & ar)723 ftprimary_with_options::ftprimary_with_options(serialization::Archiver& ar)
724   :
725   ftnode(ar),
726   primary_(NULL),
727   match_options_(NULL),
728   weight_(NULL)
729 {
730 }
731 
serialize(serialization::Archiver & ar)732 void ftprimary_with_options::serialize( serialization::Archiver &ar ) {
733   serialize_baseclass( ar, (ftnode*)this );
734   ar & primary_;
735   ar & match_options_;
736   ar & weight_;
737 }
738 
ftrange(QueryLoc const & loc,ft_range_mode::type mode,expr * const & expr1,expr * expr2)739 ftrange::ftrange(
740   QueryLoc const &loc,
741   ft_range_mode::type mode,
742   expr* const &expr1,
743   expr* expr2
744 ) :
745   ftnode( loc ),
746   mode_( mode ),
747   expr1_( expr1 ),
748   expr2_( expr2 )
749 {
750   ZORBA_ASSERT( expr1_ );
751 }
752 
accept(ftnode_visitor & v)753 ft_visit_result::type ftrange::accept( ftnode_visitor &v ) {
754   BEGIN_VISIT( v );
755   EV_ACCEPT( expr1_, v );
756   EV_ACCEPT( expr2_, v );
757   END_VISIT( v );
758 }
759 
clone(expr::substitution_t & s) const760 ftnode_t ftrange::clone( expr::substitution_t &s ) const {
761   return new ftrange(
762     get_loc(), mode_,
763     clone_ptr( expr1_, s ),
764     clone_ptr_if( expr2_, s )
765   );
766   // TODO: do PlanIter_t's have to be cloned?
767 }
768 
put(ostream & o) const769 ostream& ftrange::put( ostream &o ) const {
770   BEGIN_INDENT_PUT( o, ftrange );
771   PUT_EXPR( o, expr1_ );
772   PUT_EXPR( o, expr2_ );
773   OUTDENT_END_PUT( o );
774 }
775 
serialize(serialization::Archiver & ar)776 void ftrange::serialize( serialization::Archiver &ar ) {
777   serialize_baseclass( ar, (ftnode*)this );
778   SERIALIZE_ENUM(ft_range_mode::type,mode_);
779   //ar & expr1_;
780   //ar & expr2_;
781   ar & iter1_;
782   ar & iter2_;
783 }
784 
ftscope_filter(QueryLoc const & loc,ft_scope::type scope,ft_big_unit::type unit)785 ftscope_filter::ftscope_filter(
786   QueryLoc const &loc, ft_scope::type scope, ft_big_unit::type unit
787 ) :
788   ftpos_filter( loc ),
789   scope_( scope ),
790   unit_( unit )
791 {
792 }
793 
accept(ftnode_visitor & v)794 ft_visit_result::type ftscope_filter::accept( ftnode_visitor &v ) {
795   BEGIN_VISIT( v );
796   END_VISIT( v );
797 }
798 
clone(expr::substitution_t & s) const799 ftnode_t ftscope_filter::clone( expr::substitution_t &s ) const {
800   return new ftscope_filter( get_loc(), scope_, unit_ );
801 }
802 
put(ostream & o) const803 ostream& ftscope_filter::put( ostream &o ) const {
804   BEGIN_PUT( o, ftscope_filter );
805   PUT_ATTR( o, scope );
806   PUT_ATTR( o, unit ) << endl;
807   END_PUT( o );
808 }
809 
serialize(serialization::Archiver & ar)810 void ftscope_filter::serialize( serialization::Archiver &ar ) {
811   serialize_baseclass( ar, (ftpos_filter*)this );
812   SERIALIZE_ENUM(ft_scope::type,scope_);
813   SERIALIZE_ENUM(ft_big_unit::type,unit_);
814 }
815 
ftselection(QueryLoc const & loc,ftnode * ftor,ftpos_filter_list_t const & list)816 ftselection::ftselection(
817   QueryLoc const &loc,
818   ftnode *ftor,
819   ftpos_filter_list_t const &list
820 ) :
821   ftprimary( loc ),
822   ftor_( ftor )
823 {
824   //
825   // From the spec, section 3.6:
826   //
827   //  In a group of multiple adjacent positional filters, FTOrder filters are
828   //  applied first, and then the other positional filters are applied from
829   //  left to right, skipping the FTOrder filters.
830   //
831   // Hence we push the FTOrder filter(s) first followed by the non-FTOrder
832   // filter(s).
833   //
834   FOR_EACH( ftpos_filter_list_t, i, list ) {
835     if ( dynamic_cast<ftorder_filter*>( *i ) )
836       list_.push_back( *i );
837   }
838   FOR_EACH( ftpos_filter_list_t, i, list ) {
839     if ( !dynamic_cast<ftorder_filter*>( *i ) )
840       list_.push_back( *i );
841   }
842 }
843 
~ftselection()844 ftselection::~ftselection() {
845   delete ftor_;
846   ztd::delete_ptr_seq( list_ );
847 }
848 
accept(ftnode_visitor & v)849 ft_visit_result::type ftselection::accept( ftnode_visitor &v ) {
850   BEGIN_VISIT( v );
851   ACCEPT( ftor_, v );
852   ACCEPT_SEQ( ftpos_filter_list_t, list_, v );
853   END_VISIT( v );
854 }
855 
clone(expr::substitution_t & s) const856 ftnode_t ftselection::clone( expr::substitution_t &s ) const {
857   return new ftselection( get_loc(), ftor_->clone( s ).release(), list_ );
858 }
859 
put(ostream & o) const860 ostream& ftselection::put( ostream &o ) const {
861   BEGIN_INDENT_PUT( o, ftselection );
862   PUT_NODE( o, ftor_ );
863   PUT_SEQ( o, ftpos_filter_list_t, list_ );
864   OUTDENT_END_PUT( o );
865 }
866 
serialize(serialization::Archiver & ar)867 void ftselection::serialize( serialization::Archiver &ar ) {
868   serialize_baseclass( ar, (ftprimary*)this );
869   ar & ftor_;
870   ar & list_;
871 }
872 
ftstem_option(QueryLoc const & loc,ft_stem_mode::type mode)873 ftstem_option::ftstem_option(
874   QueryLoc const &loc,
875   ft_stem_mode::type mode
876 ) :
877   ftmatch_option( loc ),
878   mode_( mode )
879 {
880 }
881 
accept(ftnode_visitor & v)882 ft_visit_result::type ftstem_option::accept( ftnode_visitor &v ) {
883   BEGIN_VISIT( v );
884   END_VISIT( v );
885 }
886 
clone(expr::substitution_t &) const887 ftnode_t ftstem_option::clone( expr::substitution_t& ) const {
888   return new ftstem_option( get_loc(), mode_ );
889 }
890 
put(ostream & o) const891 ostream& ftstem_option::put( ostream &o ) const {
892   BEGIN_PUT( o, ftstem_option );
893   PUT_ATTR( o, mode ) << endl;
894   END_PUT( o );
895 }
896 
serialize(serialization::Archiver & ar)897 void ftstem_option::serialize( serialization::Archiver &ar ) {
898   serialize_baseclass( ar, (ftmatch_option*)this );
899   SERIALIZE_ENUM(ft_stem_mode::type,mode_);
900 }
901 
ftstop_words(QueryLoc const & loc,zstring const & uri,list_t const & stop_word_list,ft_stop_words_unex::type mode)902 ftstop_words::ftstop_words(
903   QueryLoc const &loc,
904   zstring const &uri,
905   list_t const &stop_word_list,
906   ft_stop_words_unex::type mode
907 ) :
908   ftnode( loc ),
909   uri_( uri ),
910   list_( stop_word_list ),
911   mode_( mode )
912 {
913   ZORBA_ASSERT( !uri_.empty() || !list_.empty() );
914 }
915 
accept(ftnode_visitor & v)916 ft_visit_result::type ftstop_words::accept( ftnode_visitor &v ) {
917   BEGIN_VISIT( v );
918   END_VISIT( v );
919 }
920 
clone(expr::substitution_t &) const921 ftnode_t ftstop_words::clone( expr::substitution_t& ) const {
922   return new ftstop_words( get_loc(), uri_, list_, mode_ );
923 }
924 
put(ostream & o) const925 ostream& ftstop_words::put( ostream &o ) const {
926   BEGIN_PUT( o, ftstop_words );
927   PUT_ATTR( o, uri );
928   PUT_ATTR( o, mode );
929   PUT_LABEL( o, stop_words ) << flush;
930   FOR_EACH( list_t, i, list_ )
931     o << *i << ' ';
932   o << endl;
933   END_PUT( o );
934 }
935 
serialize(serialization::Archiver & ar)936 void ftstop_words::serialize( serialization::Archiver &ar ) {
937   serialize_baseclass( ar, (ftnode*)this );
938   ar & uri_;
939   ar & list_;
940   SERIALIZE_ENUM(ft_stop_words_unex::type,mode_);
941 }
942 
ftstop_word_option(QueryLoc const & loc,ft_stop_words_mode::type mode)943 ftstop_word_option::ftstop_word_option(
944   QueryLoc const &loc,
945   ft_stop_words_mode::type mode
946 ) :
947   ftmatch_option( loc ),
948   mode_( mode )
949 {
950 }
951 
ftstop_word_option(QueryLoc const & loc,list_t & stop_word_list,ft_stop_words_mode::type mode)952 ftstop_word_option::ftstop_word_option(
953   QueryLoc const &loc,
954   list_t &stop_word_list,
955   ft_stop_words_mode::type mode
956 ) :
957   ftmatch_option( loc ),
958   mode_( mode )
959 {
960   stop_words_.swap( stop_word_list );
961 }
962 
~ftstop_word_option()963 ftstop_word_option::~ftstop_word_option() {
964   ztd::delete_ptr_seq( stop_words_ );
965 }
966 
accept(ftnode_visitor & v)967 ft_visit_result::type ftstop_word_option::accept( ftnode_visitor &v ) {
968   BEGIN_VISIT( v );
969   ACCEPT_SEQ( list_t, stop_words_, v );
970   END_VISIT( v );
971 }
972 
clone(expr::substitution_t & s) const973 ftnode_t ftstop_word_option::clone( expr::substitution_t &s ) const {
974   list_t copy;
975   clone_list( stop_words_, &copy, s );
976   return new ftstop_word_option( get_loc(), copy, mode_ );
977 }
978 
put(ostream & o) const979 ostream& ftstop_word_option::put( ostream &o ) const {
980   BEGIN_PUT( o, ftstop_word_option );
981   PUT_ATTR( o, mode );
982   if ( stop_words_.empty() )
983     o << endl;
984   else {
985     INDENT_PUT( o );
986     PUT_SEQ( o, list_t, stop_words_ );
987     OUTDENT_PUT( o );
988   }
989   END_PUT( o );
990 }
991 
serialize(serialization::Archiver & ar)992 void ftstop_word_option::serialize( serialization::Archiver &ar ) {
993   serialize_baseclass( ar, (ftmatch_option*)this );
994   ar & stop_words_;
995   SERIALIZE_ENUM(ft_stop_words_mode::type,mode_);
996 }
997 
ftthesaurus_id(QueryLoc const & loc,zstring const & uri,zstring const & relationship,ftrange * levels)998 ftthesaurus_id::ftthesaurus_id(
999   QueryLoc const &loc,
1000   zstring const &uri,
1001   zstring const &relationship,
1002   ftrange *levels
1003 ) :
1004   ftnode( loc ),
1005   uri_( uri ),
1006   levels_( levels )
1007 {
1008   ascii::to_lower( relationship, &relationship_ );
1009 }
1010 
~ftthesaurus_id()1011 ftthesaurus_id::~ftthesaurus_id() {
1012   delete levels_;
1013 }
1014 
accept(ftnode_visitor & v)1015 ft_visit_result::type ftthesaurus_id::accept( ftnode_visitor &v ) {
1016   BEGIN_VISIT( v );
1017   ACCEPT( levels_, v );
1018   END_VISIT( v );
1019 }
1020 
clone(expr::substitution_t & s) const1021 ftnode_t ftthesaurus_id::clone( expr::substitution_t &s ) const {
1022   return new ftthesaurus_id(
1023     get_loc(), uri_, relationship_, clone_ptr_if( levels_, s )
1024   );
1025 }
1026 
put(ostream & o) const1027 ostream& ftthesaurus_id::put( ostream &o ) const {
1028   BEGIN_PUT( o, ftthesaurus_id );
1029   PUT_ATTR( o, uri );
1030   PUT_ATTR( o, relationship );
1031   INDENT_PUT( o );
1032   PUT_NODE( o, levels_ );
1033   OUTDENT_END_PUT( o );
1034 }
1035 
serialize(serialization::Archiver & ar)1036 void ftthesaurus_id::serialize( serialization::Archiver &ar ) {
1037   serialize_baseclass( ar, (ftnode*)this );
1038   ar & uri_;
1039   ar & relationship_;
1040   ar & levels_;
1041 }
1042 
ftthesaurus_option(QueryLoc const & loc,ftthesaurus_id * default_tid,thesaurus_id_list_t & list,bool no_thesaurus_arg)1043 ftthesaurus_option::ftthesaurus_option(
1044   QueryLoc const &loc,
1045   ftthesaurus_id *default_tid,
1046   thesaurus_id_list_t &list,
1047   bool no_thesaurus_arg
1048 ) :
1049   ftmatch_option( loc ),
1050   default_tid_( default_tid ),
1051   no_thesaurus_( no_thesaurus_arg )
1052 {
1053   thesaurus_id_list_.swap( list );
1054 }
1055 
~ftthesaurus_option()1056 ftthesaurus_option::~ftthesaurus_option() {
1057   delete default_tid_;
1058   ztd::delete_ptr_seq( thesaurus_id_list_ );
1059 }
1060 
accept(ftnode_visitor & v)1061 ft_visit_result::type ftthesaurus_option::accept( ftnode_visitor &v ) {
1062   BEGIN_VISIT( v );
1063   ACCEPT( default_tid_, v );
1064   ACCEPT_SEQ( thesaurus_id_list_t, thesaurus_id_list_, v );
1065   END_VISIT( v );
1066 }
1067 
clone(expr::substitution_t & s) const1068 ftnode_t ftthesaurus_option::clone( expr::substitution_t &s ) const {
1069   thesaurus_id_list_t copy;
1070   clone_list( thesaurus_id_list_, &copy, s );
1071   return new ftthesaurus_option(
1072     get_loc(), clone_ptr_if( default_tid_, s ), copy, no_thesaurus_
1073   );
1074 }
1075 
put(ostream & o) const1076 ostream& ftthesaurus_option::put( ostream &o ) const {
1077   BEGIN_PUT( o, ftthesaurus_option );
1078   PUT_BOOL( o, no_thesaurus );
1079   INDENT_PUT( o );
1080   PUT_NODE( o, default_tid_ );
1081   PUT_SEQ( o, thesaurus_id_list_t, thesaurus_id_list_ );
1082   OUTDENT_END_PUT( o );
1083 }
1084 
serialize(serialization::Archiver & ar)1085 void ftthesaurus_option::serialize( serialization::Archiver &ar ) {
1086   serialize_baseclass( ar, (ftmatch_option*)this );
1087   ar & default_tid_;
1088   ar & thesaurus_id_list_;
1089   ar & no_thesaurus_;
1090 }
1091 
ftunary_not(QueryLoc const & loc,ftnode * n)1092 ftunary_not::ftunary_not( QueryLoc const &loc, ftnode *n ) :
1093   ftnode( loc ), subnode_( n )
1094 {
1095 }
1096 
~ftunary_not()1097 ftunary_not::~ftunary_not() {
1098   delete subnode_;
1099 }
1100 
accept(ftnode_visitor & v)1101 ft_visit_result::type ftunary_not::accept( ftnode_visitor &v ) {
1102   BEGIN_VISIT( v );
1103   ACCEPT( subnode_, v );
1104   END_VISIT( v );
1105 }
1106 
clone(expr::substitution_t & s) const1107 ftnode_t ftunary_not::clone( expr::substitution_t &s ) const {
1108   return new ftunary_not( get_loc(), subnode_->clone( s ).release() );
1109 }
1110 
put(ostream & o) const1111 ostream& ftunary_not::put( ostream &o ) const {
1112   BEGIN_INDENT_PUT( o, ftunary_not );
1113   PUT_NODE( o, subnode_ );
1114   OUTDENT_END_PUT( o );
1115 }
1116 
serialize(serialization::Archiver & ar)1117 void ftunary_not::serialize( serialization::Archiver &ar ) {
1118   serialize_baseclass( ar, (ftnode*)this );
1119   ar & subnode_;
1120 }
1121 
ftweight(QueryLoc const & loc,expr * const & weight_expr)1122 ftweight::ftweight( QueryLoc const &loc, expr* const &weight_expr ) :
1123   ftnode( loc ), weight_expr_( weight_expr )
1124 {
1125 }
1126 
accept(ftnode_visitor & v)1127 ft_visit_result::type ftweight::accept( ftnode_visitor &v ) {
1128   BEGIN_VISIT( v );
1129   EV_ACCEPT( weight_expr_, v );
1130   END_VISIT( v );
1131 }
1132 
clone(expr::substitution_t & s) const1133 ftnode_t ftweight::clone( expr::substitution_t &s ) const {
1134   return new ftweight( get_loc(), weight_expr_->clone( s ) );
1135 }
1136 
put(ostream & o) const1137 ostream& ftweight::put( ostream &o ) const {
1138   BEGIN_INDENT_PUT( o, ftweight );
1139   PUT_EXPR( o, weight_expr_ );
1140   OUTDENT_END_PUT( o );
1141 }
1142 
serialize(serialization::Archiver & ar)1143 void ftweight::serialize( serialization::Archiver &ar ) {
1144   serialize_baseclass( ar, (ftnode*)this );
1145   //ar & weight_expr_;
1146   ar & weight_iter_;
1147 }
1148 
ftwild_card_option(QueryLoc const & loc,ft_wild_card_mode::type mode)1149 ftwild_card_option::ftwild_card_option(
1150   QueryLoc const &loc,
1151   ft_wild_card_mode::type mode
1152 ) :
1153   ftmatch_option( loc ),
1154   mode_( mode )
1155 {
1156 }
1157 
accept(ftnode_visitor & v)1158 ft_visit_result::type ftwild_card_option::accept( ftnode_visitor &v ) {
1159   BEGIN_VISIT( v );
1160   END_VISIT( v );
1161 }
1162 
clone(expr::substitution_t & s) const1163 ftnode_t ftwild_card_option::clone( expr::substitution_t &s ) const {
1164   return new ftwild_card_option( get_loc(), mode_ );
1165 }
1166 
put(ostream & o) const1167 ostream& ftwild_card_option::put( ostream &o ) const {
1168   BEGIN_PUT( o, ftwild_card_option );
1169   PUT_ATTR( o, mode ) << endl;
1170   END_PUT( o );
1171 }
1172 
serialize(serialization::Archiver & ar)1173 void ftwild_card_option::serialize( serialization::Archiver &ar ) {
1174   serialize_baseclass( ar, (ftmatch_option*)this );
1175   SERIALIZE_ENUM(ft_wild_card_mode::type,mode_);
1176 }
1177 
ftwindow_filter(QueryLoc const & loc,expr * const & window_expr,ft_unit::type unit)1178 ftwindow_filter::ftwindow_filter(
1179   QueryLoc const &loc,
1180   expr* const &window_expr,
1181   ft_unit::type unit )
1182 :
1183   ftpos_filter( loc ),
1184   window_expr_( window_expr ),
1185   unit_( unit )
1186 {
1187   ZORBA_ASSERT( window_expr );
1188 }
1189 
accept(ftnode_visitor & v)1190 ft_visit_result::type ftwindow_filter::accept( ftnode_visitor &v ) {
1191   BEGIN_VISIT( v );
1192   EV_ACCEPT( window_expr_, v );
1193   END_VISIT( v );
1194 }
1195 
clone(expr::substitution_t & s) const1196 ftnode_t ftwindow_filter::clone( expr::substitution_t &s ) const {
1197   return new ftwindow_filter(
1198     get_loc(), window_expr_->clone( s ), unit_
1199   );
1200 }
1201 
put(ostream & o) const1202 ostream& ftwindow_filter::put( ostream &o ) const {
1203   BEGIN_PUT( o, ftwindow_filter );
1204   PUT_ATTR( o, unit );
1205   INDENT_PUT( o );
1206   PUT_EXPR( o, window_expr_ );
1207   OUTDENT_END_PUT( o );
1208 }
1209 
serialize(serialization::Archiver & ar)1210 void ftwindow_filter::serialize( serialization::Archiver &ar ) {
1211   serialize_baseclass( ar, (ftpos_filter*)this );
1212   //ar & window_expr_;
1213   SERIALIZE_ENUM(ft_unit::type,unit_);
1214   ar & window_iter_;
1215 }
1216 
ftwords(QueryLoc const & loc,expr * const & value_expr,ft_anyall_mode::type mode)1217 ftwords::ftwords(
1218   QueryLoc const &loc,
1219   expr* const &value_expr,
1220   ft_anyall_mode::type mode
1221 ) :
1222   ftnode( loc ),
1223   value_expr_( value_expr ),
1224   mode_( mode )
1225 {
1226 }
1227 
accept(ftnode_visitor & v)1228 ft_visit_result::type ftwords::accept( ftnode_visitor &v ) {
1229   BEGIN_VISIT( v );
1230   EV_ACCEPT( value_expr_, v );
1231   END_VISIT( v );
1232 }
1233 
clone(expr::substitution_t & s) const1234 ftnode_t ftwords::clone( expr::substitution_t &s ) const {
1235   return new ftwords( get_loc(), value_expr_->clone( s ), mode_ );
1236 }
1237 
put(ostream & o) const1238 ostream& ftwords::put( ostream &o ) const {
1239   BEGIN_PUT( o, ftwords );
1240   PUT_ATTR( o, mode );
1241   INDENT_PUT( o );
1242   PUT_EXPR( o, value_expr_ );
1243   OUTDENT_END_PUT( o );
1244 }
1245 
serialize(serialization::Archiver & ar)1246 void ftwords::serialize( serialization::Archiver &ar ) {
1247   serialize_baseclass( ar, (ftnode*)this );
1248   SERIALIZE_ENUM( ft_anyall_mode::type, mode_ );
1249   //ar & value_expr_;
1250   ar & value_iter_;
1251 }
1252 
ftwords_times(QueryLoc const & loc,ftwords * ftwords,ftrange * fttimes)1253 ftwords_times::ftwords_times(
1254   QueryLoc const &loc,
1255   ftwords *ftwords,
1256   ftrange *fttimes
1257 ) :
1258   ftprimary( loc ),
1259   ftwords_( ftwords ),
1260   fttimes_( fttimes )
1261 {
1262   ZORBA_ASSERT( ftwords_ );
1263 }
1264 
~ftwords_times()1265 ftwords_times::~ftwords_times() {
1266   delete ftwords_;
1267   delete fttimes_;
1268 }
1269 
accept(ftnode_visitor & v)1270 ft_visit_result::type ftwords_times::accept( ftnode_visitor &v ) {
1271   BEGIN_VISIT( v );
1272   ACCEPT( ftwords_, v );
1273   ACCEPT( fttimes_, v );
1274   END_VISIT( v );
1275 }
1276 
clone(expr::substitution_t & s) const1277 ftnode_t ftwords_times::clone( expr::substitution_t &s ) const {
1278   return new ftwords_times(
1279     get_loc(), clone_ptr( ftwords_, s ), clone_ptr_if( fttimes_, s )
1280   );
1281 }
1282 
put(ostream & o) const1283 ostream& ftwords_times::put( ostream &o ) const {
1284   BEGIN_INDENT_PUT( o, ftwords_times );
1285   PUT_NODE( o, ftwords_ );
1286   PUT_NODE( o, fttimes_ );
1287   OUTDENT_END_PUT( o );
1288 }
1289 
serialize(serialization::Archiver & ar)1290 void ftwords_times::serialize( serialization::Archiver &ar ) {
1291   serialize_baseclass( ar, (ftprimary*)this );
1292   ar & ftwords_;
1293   ar & fttimes_;
1294 }
1295 
1296 ///////////////////////////////////////////////////////////////////////////////
1297 
1298 } // namespace zorba
1299 /* vim:set et sw=2 ts=2: */
1300