All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Select.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file Select.cpp
22 
23  \brief A Select models a query to be used when retrieving data from a data source.
24 */
25 
26 // TerraLib
27 #include "../../common/STLUtils.h"
28 #include "DataSetName.h"
29 #include "Distinct.h"
30 #include "Expression.h"
31 #include "Field.h"
32 #include "FromItem.h"
33 #include "GroupByItem.h"
34 #include "Having.h"
35 #include "OrderByItem.h"
36 #include "PropertyName.h"
37 #include "Select.h"
38 #include "Where.h"
39 
41  : m_fields(0),
42  m_from(0),
43  m_where(0),
44  m_groupBy(0),
45  m_having(0),
46  m_orderBy(0),
47  m_distinct(0),
48  m_limit(0),
49  m_offset(0)
50 {
51 }
52 
54  : m_fields(fds),
55  m_from(f),
56  m_where(w),
57  m_groupBy(0),
58  m_having(0),
59  m_orderBy(o),
60  m_distinct(0),
61  m_limit(0),
62  m_offset(0)
63 {
64 }
65 
67  : m_fields(0),
68  m_from(0),
69  m_where(0),
70  m_groupBy(0),
71  m_having(0),
72  m_orderBy(0),
73  m_distinct(0),
74  m_limit(0),
75  m_offset(0)
76 {
77  m_fields.reset(new Fields(fds));
78 }
79 
80 te::da::Select::Select(const Fields& fds, const From& f)
81  : m_fields(0),
82  m_from(0),
83  m_where(0),
84  m_groupBy(0),
85  m_having(0),
86  m_orderBy(0),
87  m_distinct(0),
88  m_limit(0),
89  m_offset(0)
90 {
91  m_fields.reset(new Fields(fds));
92  m_from.reset(new From(f));
93 }
94 
95 te::da::Select::Select(const Fields& fds, const From& f, const Where& w)
96  : m_fields(0),
97  m_from(0),
98  m_where(0),
99  m_groupBy(0),
100  m_having(0),
101  m_orderBy(0),
102  m_distinct(0),
103  m_limit(0),
104  m_offset(0)
105 {
106  m_fields.reset(new Fields(fds));
107  m_from.reset(new From(f));
108  m_where.reset(new Where(w));
109 }
110 
111 te::da::Select::Select(const Fields& fds, const From& f, const Where& w, const OrderBy& o)
112  : m_fields(0),
113  m_from(0),
114  m_where(0),
115  m_groupBy(0),
116  m_having(0),
117  m_orderBy(0),
118  m_distinct(0),
119  m_limit(0),
120  m_offset(0)
121 {
122  m_fields.reset(new Fields(fds));
123  m_from.reset(new From(f));
124  m_where.reset(new Where(w));
125  m_orderBy.reset(new OrderBy(o));
126 }
127 
129  : m_fields(fds),
130  m_from(f),
131  m_where(0),
132  m_groupBy(0),
133  m_having(0),
134  m_orderBy(o),
135  m_distinct(0),
136  m_limit(0),
137  m_offset(0)
138 {
139 }
140 
141 te::da::Select::Select(const Fields& fds, const From& f, const OrderBy& o)
142  : m_fields(0),
143  m_from(0),
144  m_where(0),
145  m_groupBy(0),
146  m_having(0),
147  m_orderBy(0),
148  m_distinct(0),
149  m_limit(0),
150  m_offset(0)
151 {
152  m_fields.reset(new Fields(fds));
153  m_from.reset(new From(f));
154  m_orderBy.reset(new OrderBy(o));
155 }
156 
157 
159  : m_fields(fds),
160  m_from(f),
161  m_where(w),
162  m_groupBy(gb),
163  m_having(0),
164  m_orderBy(o),
165  m_distinct(0),
166  m_limit(0),
167  m_offset(0)
168 {
169 }
170 
171 te::da::Select::Select(const Fields& fds, const From& f, const Where& w, const GroupBy& gb)
172  : m_fields(0),
173  m_from(0),
174  m_where(0),
175  m_groupBy(0),
176  m_having(0),
177  m_orderBy(0),
178  m_distinct(0),
179  m_limit(0),
180  m_offset(0)
181 {
182  m_fields.reset(new Fields(fds));
183  m_from.reset(new From(f));
184  m_where.reset(new Where(w));
185  m_groupBy.reset(new GroupBy(gb));
186 }
187 
188 te::da::Select::Select(const Fields& fds, const From& f, const Where& w, const GroupBy& gb, const OrderBy& o)
189  : m_fields(0),
190  m_from(0),
191  m_where(0),
192  m_groupBy(0),
193  m_having(0),
194  m_orderBy(0),
195  m_distinct(0),
196  m_limit(0),
197  m_offset(0)
198 {
199  m_fields.reset(new Fields(fds));
200  m_from.reset(new From(f));
201  m_where.reset(new Where(w));
202  m_groupBy.reset(new GroupBy(gb));
203  m_orderBy.reset(new OrderBy(o));
204 }
205 
207  : m_fields(fds),
208  m_from(f),
209  m_where(0),
210  m_groupBy(gb),
211  m_having(0),
212  m_orderBy(o),
213  m_distinct(0),
214  m_limit(0),
215  m_offset(0)
216 {
217 }
218 
219 te::da::Select::Select(const Fields& fds, const From& f, const GroupBy& gb)
220  : m_fields(0),
221  m_from(0),
222  m_where(0),
223  m_groupBy(0),
224  m_having(0),
225  m_orderBy(0),
226  m_distinct(0),
227  m_limit(0),
228  m_offset(0)
229 {
230  m_fields.reset(new Fields(fds));
231  m_from.reset(new From(f));
232  m_groupBy.reset(new GroupBy(gb));
233 }
234 
235 te::da::Select::Select(const Fields& fds, const From& f, const GroupBy& gb, const OrderBy& o)
236  : m_fields(0),
237  m_from(0),
238  m_where(0),
239  m_groupBy(0),
240  m_having(0),
241  m_orderBy(0),
242  m_distinct(0),
243  m_limit(0),
244  m_offset(0)
245 {
246  m_fields.reset(new Fields(fds));
247  m_from.reset(new From(f));
248  m_groupBy.reset(new GroupBy(gb));
249  m_orderBy.reset(new OrderBy(o));
250 }
251 
253  : m_fields(fds),
254  m_from(f),
255  m_where(w),
256  m_groupBy(gb),
257  m_having(h),
258  m_orderBy(o),
259  m_distinct(0),
260  m_limit(0),
261  m_offset(0)
262 {
263 }
264 
265 te::da::Select::Select(const Fields& fds, const From& f, const Where& w, const GroupBy& gb, const Having& h)
266  : m_fields(0),
267  m_from(0),
268  m_where(0),
269  m_groupBy(0),
270  m_having(0),
271  m_orderBy(0),
272  m_distinct(0),
273  m_limit(0),
274  m_offset(0)
275 {
276  m_fields.reset(new Fields(fds));
277  m_from.reset(new From(f));
278  m_where.reset(new Where(w));
279  m_groupBy.reset(new GroupBy(gb));
280  m_having.reset(new Having(h));
281 }
282 
283 te::da::Select::Select(const Fields& fds, const From& f, const Where& w, const GroupBy& gb, const Having& h, const OrderBy& o)
284  : m_fields(0),
285  m_from(0),
286  m_where(0),
287  m_groupBy(0),
288  m_having(0),
289  m_orderBy(0),
290  m_distinct(0),
291  m_limit(0),
292  m_offset(0)
293 {
294  m_fields.reset(new Fields(fds));
295  m_from.reset(new From(f));
296  m_where.reset(new Where(w));
297  m_groupBy.reset(new GroupBy(gb));
298  m_having.reset(new Having(h));
299  m_orderBy.reset(new OrderBy(o));
300 }
301 
303  : m_fields(0),
304  m_from(0),
305  m_where(0),
306  m_groupBy(0),
307  m_having(0),
308  m_orderBy(0),
309  m_distinct(0),
310  m_limit(0),
311  m_offset(0)
312 {
313  m_fields.reset(new Fields);
314  m_fields->push_back(f);
315 }
316 
318  : m_fields(0),
319  m_from(0),
320  m_where(0),
321  m_groupBy(0),
322  m_having(0),
323  m_orderBy(0),
324  m_distinct(0),
325  m_limit(0),
326  m_offset(0)
327 {
328  m_fields.reset(new Fields);
329  m_fields->push_back(new Field(f));
330 }
331 
332 te::da::Select::Select(const std::string& propertyName)
333  : m_fields(0),
334  m_from(0),
335  m_where(0),
336  m_groupBy(0),
337  m_having(0),
338  m_orderBy(0),
339  m_distinct(0),
340  m_limit(0),
341  m_offset(0)
342 {
343  m_fields.reset(new Fields);
344  m_fields->push_back(new Field(propertyName));
345 }
346 
347 te::da::Select::Select(const std::string& propertyName, const std::string& alias)
348  : m_fields(0),
349  m_from(0),
350  m_where(0),
351  m_groupBy(0),
352  m_having(0),
353  m_orderBy(0),
354  m_distinct(0),
355  m_limit(0),
356  m_offset(0)
357 {
358  m_fields.reset(new Fields);
359  m_fields->push_back(new Field(propertyName, alias));
360 }
361 
363  : m_fields(0),
364  m_from(0),
365  m_where(0),
366  m_groupBy(0),
367  m_having(0),
368  m_orderBy(0),
369  m_distinct(0),
370  m_limit(rhs.m_limit),
371  m_offset(rhs.m_offset)
372 {
373  m_fields.reset(rhs.m_fields.get() ? new Fields(*rhs.m_fields) : 0);
374  m_from.reset(rhs.m_from.get() ? new From(*rhs.m_from) : 0);
375  m_where.reset(rhs.m_where.get() ? new Where(*rhs.m_where) : 0);
376  m_groupBy.reset(rhs.m_groupBy.get() ? new GroupBy(*rhs.m_groupBy) : 0);
377  m_having.reset(rhs.m_having.get() ? new Having(*rhs.m_having) : 0);
378  m_orderBy.reset(rhs.m_orderBy.get() ? new OrderBy(*rhs.m_orderBy) : 0);
379  m_distinct.reset(rhs.m_distinct.get() ? new Distinct(*rhs.m_distinct) : 0);
380 }
381 
383  : m_fields(0),
384  m_from(0),
385  m_where(0),
386  m_groupBy(0),
387  m_having(0),
388  m_orderBy(0),
389  m_distinct(0),
390  m_limit(rhs->m_limit),
391  m_offset(rhs->m_offset)
392 {
393  m_fields.reset(rhs->m_fields.get() ? new Fields(*rhs->m_fields) : 0);
394  m_from.reset(rhs->m_from.get() ? new From(*rhs->m_from) : 0);
395  m_where.reset(rhs->m_where.get() ? new Where(*rhs->m_where) : 0);
396  m_groupBy.reset(rhs->m_groupBy.get() ? new GroupBy(*rhs->m_groupBy) : 0);
397  m_having.reset(rhs->m_having.get() ? new Having(*rhs->m_having) : 0);
398  m_orderBy.reset(rhs->m_orderBy.get() ? new OrderBy(*rhs->m_orderBy) : 0);
399  m_distinct.reset(rhs->m_distinct.get() ? new Distinct(*rhs->m_distinct) : 0);
400 }
401 
403 {
404 }
405 
407 {
408  if(this != &rhs)
409  {
410  m_fields.reset(rhs.m_fields.get() ? new Fields(*rhs.m_fields) : 0);
411  m_from.reset(rhs.m_from.get() ? new From(*rhs.m_from) : 0);
412  m_where.reset(rhs.m_where.get() ? new Where(*rhs.m_where) : 0);
413  m_groupBy.reset(rhs.m_groupBy.get() ? new GroupBy(*rhs.m_groupBy) : 0);
414  m_having.reset(rhs.m_having.get() ? new Having(*rhs.m_having) : 0);
415  m_orderBy.reset(rhs.m_orderBy.get() ? new OrderBy(*rhs.m_orderBy) : 0);
416  m_distinct.reset(rhs.m_distinct.get() ? new Distinct(*rhs.m_distinct) : 0);
417  m_limit = rhs.m_limit;
418  m_offset = rhs.m_offset;
419  }
420 
421  return *this;
422 }
423 
425 {
426  return new Select(*this);
427 }
428 
430 {
431  m_fields.reset(new Fields(f));
432  return *this;
433 }
434 
436 {
437  m_fields.reset(f);
438  return *this;
439 }
440 
442 {
443  return *m_fields;
444 }
445 
447 {
448  return *m_fields;
449 }
450 
452 {
453  assert(m_fields.get() != 0);
454 
455  m_fields->push_back(new Field(f));
456 
457  return *this;
458 }
459 
461 {
462  assert(m_fields.get() != 0);
463 
464  m_fields->push_back(f);
465 
466  return *this;
467 }
468 
469 te::da::Select& te::da::Select::operator()(const std::string& propertyName)
470 {
471  assert(m_fields.get() != 0);
472 
473  m_fields->push_back(new Field(propertyName));
474 
475  return *this;
476 }
477 
478 te::da::Select& te::da::Select::operator()(const std::string& propertyName, const std::string& alias)
479 {
480  assert(m_fields.get() != 0);
481 
482  m_fields->push_back(new Field(propertyName, alias));
483 
484  return *this;
485 }
486 
488 {
489  if(m_from.get() == 0)
490  m_from.reset(new From);
491 
492  m_from->push_back(item.clone());
493 
494  return *this;
495 }
496 
498 {
499  if(m_from.get() == 0)
500  m_from.reset(new From);
501 
502  m_from->push_back(item);
503 
504  return *this;
505 }
506 
508 {
509  if(m_from.get() == 0)
510  m_from.reset(new From);
511 
512  m_from->push_back(i1.clone());
513  m_from->push_back(i2.clone());
514 
515  return *this;
516 }
517 
519 {
520  if(m_from.get() == 0)
521  m_from.reset(new From);
522 
523  m_from->push_back(i1);
524  m_from->push_back(i2);
525 
526  return *this;
527 }
528 
530 {
531  if(m_from.get() == 0)
532  m_from.reset(new From);
533 
534  m_from->push_back(i1.clone());
535  m_from->push_back(i2.clone());
536  m_from->push_back(i3.clone());
537 
538  return *this;
539 }
540 
542 {
543  if(m_from.get() == 0)
544  m_from.reset(new From);
545 
546  m_from->push_back(i1);
547  m_from->push_back(i2);
548  m_from->push_back(i3);
549 
550  return *this;
551 }
552 
553 te::da::Select& te::da::Select::from(const std::string& datasetName)
554 {
555  if(m_from.get() == 0)
556  m_from.reset(new From);
557 
558  m_from->push_back(new DataSetName(datasetName));
559 
560  return *this;
561 }
562 
564 {
565  m_from.reset(f);
566  return *this;
567 }
568 
570 {
571  m_from.reset(new From(rhs));
572  return *this;
573 }
574 
576 {
577  return *m_from;
578 }
579 
581 {
582  return *m_from;
583 }
584 
586 {
587  return *this;
588 }
589 
591 {
592  return *this;
593 }
594 
596 {
597  return *this;
598 }
599 
601 {
602  return *this;
603 }
604 
606 {
607  return *this;
608 }
609 
611 {
612  return *this;
613 }
614 
616 {
617  return *this;
618 }
619 
621 {
622  return *this;
623 }
624 
626 {
627  return *this;
628 }
629 
631 {
632  return *this;
633 }
634 
636 {
637  return *this;
638 }
639 
641 {
642  return *this;
643 }
644 
646 {
647  return *this;
648 }
649 
651 {
652  return *this;
653 }
654 
656 {
657  if(m_where.get() == 0)
658  m_where.reset(new Where(e));
659  else
660  m_where->setExp(e);
661 
662  return *this;
663 }
664 
666 {
667  if(m_where.get() == 0)
668  m_where.reset(new Where(e));
669  else
670  m_where->setExp(e.clone());
671 
672  return *this;
673 }
674 
676 {
677  m_where.reset(w);
678  return *this;
679 }
680 
682 {
683  m_where.reset(new Where(rhs));
684  return *this;
685 }
686 
688 {
689  return *m_where;
690 }
691 
693 {
694  return *m_where;
695 }
696 
698 {
699  if(m_groupBy.get() == 0)
700  m_groupBy.reset(new GroupBy);
701 
702  m_groupBy->push_back(new GroupByItem(item));
703 
704  return *this;
705 }
706 
708 {
709  if(m_groupBy.get() == 0)
710  m_groupBy.reset(new GroupBy);
711 
712  m_groupBy->push_back(item);
713 
714  return *this;
715 }
716 
718 {
719  if(m_groupBy.get() == 0)
720  m_groupBy.reset(new GroupBy);
721 
722  m_groupBy->push_back(new GroupByItem(e));
723 
724  return *this;
725 }
726 
727 te::da::Select& te::da::Select::groupBy(const std::string& propertyName)
728 {
729  if(m_groupBy.get() == 0)
730  m_groupBy.reset(new GroupBy);
731 
732  m_groupBy->push_back(new GroupByItem(new PropertyName(propertyName)));
733 
734  return *this;
735 }
736 
738 {
739  m_groupBy.reset(gb);
740  return *this;
741 }
742 
744 {
745  m_groupBy.reset(new GroupBy(rhs));
746  return *this;
747 }
748 
750 {
751  return *m_groupBy;
752 }
753 
755 {
756  return *m_groupBy;
757 }
758 
760 {
761  if(m_having.get() == 0)
762  m_having.reset(new Having(e));
763  else
764  m_having->setExp(e);
765 
766  return *this;
767 }
768 
770 {
771  if(m_having.get() == 0)
772  m_having.reset(new Having(e));
773  else
774  m_having->setExp(e.clone());
775 
776  return *this;
777 }
778 
780 {
781  m_having.reset(h);
782  return *this;
783 }
784 
786 {
787  m_having.reset(new Having(rhs));
788  return *this;
789 }
790 
792 {
793  return *m_having;
794 }
795 
797 {
798  return *m_having;
799 }
800 
802 {
803  if(m_orderBy.get() == 0)
804  m_orderBy.reset(new OrderBy);
805 
806  m_orderBy->push_back(new OrderByItem(item));
807 
808  return *this;
809 }
810 
812 {
813  if(m_orderBy.get() == 0)
814  m_orderBy.reset(new OrderBy);
815 
816  m_orderBy->push_back(item);
817 
818  return *this;
819 }
820 
822 {
823  if(m_orderBy.get() == 0)
824  m_orderBy.reset(new OrderBy);
825 
826  m_orderBy->push_back(new OrderByItem(e, o));
827 
828  return *this;
829 }
830 
831 te::da::Select& te::da::Select::orderBy(const std::string& propertyName, SortOrder o )
832 {
833  if(m_orderBy.get() == 0)
834  m_orderBy.reset(new OrderBy);
835 
836  m_orderBy->push_back(new OrderByItem(new PropertyName(propertyName), o));
837 
838  return *this;
839 }
840 
842 {
843  m_orderBy.reset(o);
844  return *this;
845 }
846 
848 {
849  m_orderBy.reset(new OrderBy(rhs));
850  return *this;
851 }
852 
854 {
855  return *m_orderBy;
856 }
857 
859 {
860  return *m_orderBy;
861 }
862 
864 {
865  if(m_distinct.get() == 0)
866  m_distinct.reset(new Distinct);
867 
868  m_distinct->push_back(e);
869 
870  return *this;
871 }
872 
874 {
875  if(m_distinct.get() == 0)
876  m_distinct.reset(new Distinct);
877 
878  m_distinct->push_back(e.clone());
879 
880  return *this;
881 }
882 
883 te::da::Select& te::da::Select::distinct(const std::string& propertyName)
884 {
885  if(m_distinct.get() == 0)
886  m_distinct.reset(new Distinct);
887 
888  m_distinct->push_back(new PropertyName(propertyName));
889 
890  return *this;
891 }
892 
894 {
895  m_distinct.reset(d);
896  return *this;
897 }
898 
900 {
901  m_distinct.reset(new Distinct(rhs));
902  return *this;
903 }
904 
906 {
907  return *m_distinct;
908 }
909 
911 {
912  return *m_distinct;
913 }
914 
916 {
917  m_limit = l;
918  return *this;
919 }
920 
922 {
923  m_offset = i;
924  return *this;
925 }
926 
928 {
929  m_fields.reset(f);
930 }
931 
933 {
934  return m_fields.get();
935 }
936 
938 {
939  m_from.reset(f);
940 }
941 
943 {
944  return m_from.get();
945 }
946 
948 {
949  m_where.reset(w);
950 }
951 
953 {
954  return m_where.get();
955 }
956 
958 {
959  m_groupBy.reset(g);
960 }
961 
963 {
964  return m_groupBy.get();
965 }
966 
968 {
969  m_having.reset(h);
970 }
971 
973 {
974  return m_having.get();
975 }
976 
978 {
979  m_orderBy.reset(o);
980 }
981 
983 {
984  return m_orderBy.get();
985 }
986 
988 {
989  m_distinct.reset(d);
990 }
991 
993 {
994  return m_distinct.get();
995 }
996 
997 void te::da::Select::setLimit(std::size_t m)
998 {
999  m_limit = m;
1000 }
1001 
1002 std::size_t te::da::Select::getLimit() const
1003 {
1004  return m_limit;
1005 }
1006 
1007 void te::da::Select::setOffset(std::size_t o)
1008 {
1009  m_offset = o;
1010 }
1011 
1012 std::size_t te::da::Select::getOffset() const
1013 {
1014  return m_offset;
1015 }
1016 
1018 {
1019  from(f);
1020  return *this;
1021 }
1022 
1024 {
1025  from(f);
1026  return *this;
1027 }
1028 
1030 {
1031  where(w);
1032  return *this;
1033 }
1034 
1036 {
1037  where(w);
1038  return *this;
1039 }
1040 
1042 {
1043  groupBy(g);
1044  return *this;
1045 }
1046 
1048 {
1049  groupBy(g);
1050  return *this;
1051 }
1052 
1054 {
1055  having(h);
1056  return *this;
1057 }
1058 
1060 {
1061  having(h);
1062  return *this;
1063 }
1064 
1066 {
1067  orderBy(o);
1068  return *this;
1069 }
1070 
1072 {
1073  orderBy(o);
1074  return *this;
1075 }
1076 
A class that can be used to model a filter expression that can be applied to a query.
Definition: Having.h:47
const Distinct * getDistinct() const
It returns the Distinct modifier.
Definition: Select.cpp:992
GroupBy & groupBy()
Definition: Select.cpp:749
boost::ptr_vector< GroupByItem > GroupBy
A class that can be used to model a GROUP BY clause.
Definition: GroupBy.h:37
An abstract class that models a source of data in a query.
const OrderBy * getOrderBy() const
It returns the list of expressions used to sort the output result.
Definition: Select.cpp:982
A class that can be used in a GROUP BY clause.
Definition: GroupByItem.h:50
An abstract class that models a source of data in a query.
Definition: FromItem.h:50
The Field class can be used to model an expression that takes part of the output items of a SELECT...
Definition: Field.h:50
A class that models the name of a dataset used in a From clause.
Definition: DataSetName.h:43
A class that models the name of any property of an object.
const GroupBy * getGroupBy() const
It returns the list of expressions used to condense the result set.
Definition: Select.cpp:962
boost::ptr_vector< Expression > Distinct
A class that models a Distinct clause on a query.
Definition: Distinct.h:37
A class that models the name of any property of an object.
Definition: PropertyName.h:50
A class that models the name of a dataset used in a From clause.
A class that models a Distinct clause on a query.
boost::ptr_vector< OrderByItem > OrderBy
A class that can be used to model an ORDER BY clause.
Definition: OrderBy.h:37
~Select()
Destructor.
Definition: Select.cpp:402
void setLimit(std::size_t m)
It specifies the maximum number of rows to return.
Definition: Select.cpp:997
Select & LeftJoin(FromItem *d2, JoinCondition *c)
Definition: Select.cpp:605
std::size_t m_limit
Definition: Select.h:445
TE_DEFINE_VISITABLE Select()
Default constructor.
Definition: Select.cpp:40
Select & operator()(const Field &f)
Definition: Select.cpp:451
Select & FullOuterJoin(FromItem *d2, JoinCondition *c)
Definition: Select.cpp:625
std::auto_ptr< Where > m_where
Definition: Select.h:440
std::auto_ptr< Having > m_having
Definition: Select.h:442
const From * getFrom() const
It returns the list of source information to be used by the query.
Definition: Select.cpp:942
This is an abstract class that models a query expression.
Definition: Expression.h:47
OrderBy & orderBy()
Definition: Select.cpp:853
void setWhere(Where *w)
It sets the filter codition.
Definition: Select.cpp:947
A Having is a filter expression that can be applied to a query with a group by clause.
std::size_t m_offset
Definition: Select.h:446
std::auto_ptr< GroupBy > m_groupBy
Definition: Select.h:441
Select & NaturalJoin(FromItem *d2, JoinType t)
Definition: Select.cpp:645
Select & InnerJoin(FromItem *d2, JoinCondition *c)
Definition: Select.cpp:595
A condition to be used in a Join clause.
Definition: JoinCondition.h:44
The Field class can be used to model an expression that takes part of the output items of a SELECT...
boost::ptr_vector< Field > Fields
Fields is just a boost::ptr_vector of Field pointers.
Definition: Fields.h:37
JoinType
The type of join in a query.
Definition: Enums.h:49
void setExp(Expression *exp)
Sets the expression.
Definition: Having.cpp:65
Select & CrossJoin(FromItem *d2)
Definition: Select.cpp:635
void setDistinct(Distinct *d)
If Distinct is specified, all duplicate rows are removed from the result set (one row is kept from ea...
Definition: Select.cpp:987
A class that can be used to model a filter expression that can be applied to a query.
Definition: Where.h:47
This is an abstract class that models a query expression.
void setExp(Expression *exp)
Sets the expression.
Definition: Where.cpp:65
std::size_t getOffset() const
It tells the number of rows to skip before starting to return rows.
Definition: Select.cpp:1012
const Fields * getFields() const
It returns the list of output expressions used to form the result set.
Definition: Select.cpp:932
A class that can be used in a GROUP BY clause.
Query * clone() const
It creates a new copy of this query.
Definition: Select.cpp:424
virtual FromItem * clone() const =0
It creates a new copy of this FromItem.
A Select models a query to be used when retrieving data from a data source.
SortOrder
Sort order type: asc or desc.
Definition: Enums.h:38
std::auto_ptr< Fields > m_fields
Definition: Select.h:438
void setGroupBy(GroupBy *g)
It sets the list of expressions used to condense the result set.
Definition: Select.cpp:957
void setOrderBy(OrderBy *o)
It sets the list of expressions used to sort the output result.
Definition: Select.cpp:977
Select & operator=(const Select &rhs)
Definition: Select.cpp:406
A Select models a query to be used when retrieving data from a DataSource.
Definition: Select.h:65
A class that can be used to model a filter expression that can be applied to a query.
boost::ptr_vector< FromItem > From
It models the FROM clause for a query.
Definition: From.h:37
void setOffset(std::size_t o)
It specifies the number of rows to skip before starting to return rows.
Definition: Select.cpp:1007
Having & having()
Definition: Select.cpp:791
From & from()
Definition: Select.cpp:575
Where * getWhere() const
It returns the filter condition.
Definition: Select.cpp:952
std::auto_ptr< From > m_from
Definition: Select.h:439
const Having * getHaving() const
It returns the list of expressions used to eliminate group row that doesn't satisfy the condition...
Definition: Select.cpp:972
std::size_t getLimit() const
It tells the maximum number of rows to return.
Definition: Select.cpp:1002
void setHaving(Having *h)
It sets the list of expressions used to eliminate group row that doesn't satisfy the condition...
Definition: Select.cpp:967
Select & limit(std::size_t l)
Definition: Select.cpp:915
virtual Expression * clone() const =0
It creates a new copy of this expression.
A class that can be used in an ORDER BY clause to sort the items of a resulting query.
A class that can be used in an ORDER BY clause to sort the items of a resulting query.
Definition: OrderByItem.h:53
Distinct & distinct()
Definition: Select.cpp:905
Select & offset(std::size_t i)
Definition: Select.cpp:921
Select & RightJoin(FromItem *d2, JoinCondition *c)
Definition: Select.cpp:615
std::auto_ptr< OrderBy > m_orderBy
Definition: Select.h:443
Select & operator+(const te::da::From &f)
Definition: Select.cpp:1017
A Query is independent from the data source language/dialect.
Definition: Query.h:46
Fields & fields()
Definition: Select.cpp:441
void setFields(Fields *f)
It sets the list of output expressions used to form the result set.
Definition: Select.cpp:927
Where & where()
Definition: Select.cpp:687
Select & Join(FromItem *d2, JoinType t, JoinCondition *c)
Definition: Select.cpp:585
std::auto_ptr< Distinct > m_distinct
Definition: Select.h:444
void setFrom(From *f)
It sets the list of source information.
Definition: Select.cpp:937