casacore
TaQLNodeRep.h
Go to the documentation of this file.
1 //# TaQLNodeRep.h: Representation of a node in the raw TaQL parse tree
2 //# Copyright (C) 2005
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id$
27 
28 #ifndef TABLES_TAQLNODEREP_H
29 #define TABLES_TAQLNODEREP_H
30 
31 //# Includes
32 #include <casacore/casa/aips.h>
33 #include <casacore/tables/TaQL/TaQLNodeResult.h>
34 #include <casacore/tables/TaQL/TaQLStyle.h>
35 #include <casacore/casa/BasicSL/String.h>
36 #include <iosfwd>
37 
38 namespace casacore { //# NAMESPACE CASACORE - BEGIN
39 
40 //# Forward Declaration.
41 class AipsIO;
42 class TaQLNodeVisitor;
43 
44 // <summary>
45 // Representation of a node in the raw TaQL parse tree.
46 // </summary>
47 
48 // <use visibility=local>
49 
50 // <reviewed reviewer="" date="" tests="tTaQLNode">
51 // </reviewed>
52 
53 // <prerequisite>
54 //# Classes you should understand before using this one.
55 // <li> <linkto class=TaQLNode>TaQLNode</linkto>
56 // <li> Note 199 describing
57 // <a href="../notes/199.html">
58 // TaQL</a>
59 // </prerequisite>
60 
61 // <synopsis>
62 // TaQLNode/TaQLNodeRep form an envelope/letter pair.
63 // TaQLNodeRep is the abstract base class for all classes used in the
64 // raw TaQL parse tree
65 // (e.g. <linkto class=TaQLConstNodeRep>TaQLConstNodeRep</linkto>).
66 // </synopsis>
67 
68 // <motivation>
69 // The envelope/letter idiom (aka counted referencing) is a nice means
70 // to pass an object around by value, so to ensure that an object is deleted
71 // in case of an exception.
72 // Furthermore it makes copying an object very cheap and memory
73 // management straightforward.
74 // </motivation>
75 
77 {
78 public:
79  // Define the various derived types (to be stored with AipsIO).
80  //# They are easier to use than an enum.
81  //# Do not change these definitions, since these values are stored in files.
82  // <group>
83  #define TaQLNode_Null char(0)
84  #define TaQLNode_Const char(1)
85  #define TaQLNode_Unary char(2)
86  #define TaQLNode_Binary char(3)
87  #define TaQLNode_Multi char(4)
88  #define TaQLNode_Func char(5)
89  #define TaQLNode_Range char(6)
90  #define TaQLNode_Index char(7)
91  #define TaQLNode_KeyCol char(8)
92  #define TaQLNode_Table char(9)
93  #define TaQLNode_Col char(10)
94  #define TaQLNode_Columns char(11)
95  #define TaQLNode_Join char(12)
96  #define TaQLNode_SortKey char(13)
97  #define TaQLNode_Sort char(14)
98  #define TaQLNode_LimitOff char(15)
99  #define TaQLNode_Giving char(16)
100  #define TaQLNode_UpdExpr char(17)
101  #define TaQLNode_Select char(18)
102  #define TaQLNode_Update char(19)
103  #define TaQLNode_Insert char(20)
104  #define TaQLNode_Delete char(21)
105  #define TaQLNode_Calc char(22)
106  #define TaQLNode_CreTab char(23)
107  #define TaQLNode_ColSpec char(24)
108  #define TaQLNode_RecFld char(25)
109  #define TaQLNode_Unit char(26)
110  #define TaQLNode_Regex char(27)
111  #define TaQLNode_Count char(28)
112  #define TaQLNode_Groupby char(29)
113  #define TaQLNode_AltTab char(30)
114  #define TaQLNode_AddCol char(31)
115  #define TaQLNode_SetKey char(32)
116  #define TaQLNode_RenDrop char(33)
117  #define TaQLNode_AddRow char(34)
118  #define TaQLNode_ConcTab char(35)
119  #define TaQLNode_Show char(36)
120  #define TaQLNode_CopyCol char(37)
121  #define TaQLNode_DropTab char(38)
122  // </group>
123 
124  // Constructor for derived classes specifying the type.
125  explicit TaQLNodeRep (int nodeType);
126 
127  virtual ~TaQLNodeRep();
128 
129  // Get the node type of the derived class.
130  char nodeType() const
131  { return itsNodeType; }
132 
133  // Get the TaQL style.
134  const TaQLStyle& style() const
135  { return itsStyle; }
136 
137  // Visit a node for tree traversal.
138  virtual TaQLNodeResult visit (TaQLNodeVisitor&) const = 0;
139 
140  // Print the object in an ostream.
141  virtual void show (std::ostream& os) const = 0;
142 
143  // Save the object.
144  virtual void save (AipsIO& aio) const = 0;
145 
146  // Check the data type string and return its standard form.
147  static String checkDataType (const String&);
148 
149  // Add escape characters to a table name where needed.
150  String addEscape (const String& str) const;
151 
152 private:
153  // Letter objects cannot be copied.
154  // <group>
157  // </group>
158 
161 };
162 
163 
164 } //# NAMESPACE CASACORE - END
165 
166 #endif
String: the storage and methods of handling collections of characters.
Definition: String.h:225
virtual TaQLNodeResult visit(TaQLNodeVisitor &) const =0
Visit a node for tree traversal.
const TaQLStyle & style() const
Get the TaQL style.
Definition: TaQLNodeRep.h:134
virtual void show(std::ostream &os) const =0
Print the object in an ostream.
TaQLNodeRep(int nodeType)
Constructor for derived classes specifying the type.
TaQLNodeRep & operator=(const TaQLNodeRep &)
char nodeType() const
Get the node type of the derived class.
Definition: TaQLNodeRep.h:130
static String checkDataType(const String &)
Check the data type string and return its standard form.
virtual void save(AipsIO &aio) const =0
Save the object.
TaQLNodeRep(const TaQLNodeRep &)
Letter objects cannot be copied.
String addEscape(const String &str) const
Add escape characters to a table name where needed.
Envelope class to hold the result of a visit to the node tree.
this file contains all the compiler specific defines
Definition: mainpage.dox:28