/usr/include/casacore/tables/TaQL/TaQLNode.h is in casacore-dev 2.2.0-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 | //# TaQLNode.h: Envelope class for a node in the raw TaQL parse tree
//# Copyright (C) 2005
//# Associated Universities, Inc. Washington DC, USA.
//#
//# This library is free software; you can redistribute it and/or modify it
//# under the terms of the GNU Library General Public License as published by
//# the Free Software Foundation; either version 2 of the License, or (at your
//# option) any later version.
//#
//# This library is distributed in the hope that it will be useful, but WITHOUT
//# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
//# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
//# License for more details.
//#
//# You should have received a copy of the GNU Library General Public License
//# along with this library; if not, write to the Free Software Foundation,
//# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
//#
//# Correspondence concerning AIPS++ should be addressed as follows:
//# Internet email: aips2-request@nrao.edu.
//# Postal address: AIPS++ Project Office
//# National Radio Astronomy Observatory
//# 520 Edgemont Road
//# Charlottesville, VA 22903-2475 USA
//#
//# $Id$
#ifndef TABLES_TAQLNODE_H
#define TABLES_TAQLNODE_H
//# Includes
#include <casacore/casa/aips.h>
#include <casacore/tables/TaQL/TaQLNodeRep.h>
#include <casacore/tables/TaQL/TaQLStyle.h>
#include <casacore/casa/OS/Mutex.h>
#include <vector>
#include <iostream>
namespace casacore { //# NAMESPACE CASACORE - BEGIN
//# Forward Declaration.
class AipsIO;
class TaQLNodeVisitor;
class TaQLMultiNode;
class TaQLConstNodeRep;
class TaQLRegexNodeRep;
class TaQLMultiNodeRep;
class TaQLQueryNodeRep;
// <summary>
// Envelope class for a node in the raw TaQL parse tree.
// </summary>
// <use visibility=local>
// <reviewed reviewer="" date="" tests="tTaQLNode">
// </reviewed>
// <prerequisite>
//# Classes you should understand before using this one.
// <li> <linkto group=TableGram.h#TableGramFunctions>TableGram</linkto>
// <li> Note 199 describing
// <a href="../notes/199.html">
// TaQL</a>
// </prerequisite>
// <synopsis>
// The result of parsing a TaQL command is stored in TaQLNode objects.
// Each part of the command can have its own specialized
// <linkto class=TaQLNodeRep>TaQLNodeRep</linkto> object, which forms
// the letter in the TaQLNode envelope.
// <br>The actual scanning/parsing of the command is done using flex/bison
// as defined in the TableGram files.
// </synopsis>
// <motivation>
// The letter-envelope idiom (counted pointer) makes if much easier
// to keep track of memory, especially in the case of exceptions.
// </motivation>
class TaQLNode
{
public:
// Default constructor.
TaQLNode()
: itsRep(0) {}
// Construct for given letter. It takes over the pointer.
TaQLNode (TaQLNodeRep* rep)
{ itsRep = TaQLNodeRep::link (rep); }
// Copy constructor (reference semantics).
TaQLNode (const TaQLNode& that)
{ itsRep = TaQLNodeRep::link (that.itsRep); }
// Assignment (reference semantics).
TaQLNode& operator= (const TaQLNode& that)
{ if (this != &that) {
TaQLNodeRep::unlink (itsRep);
itsRep = TaQLNodeRep::link (that.itsRep);
}
return *this;
}
// Get the TaQL style.
const TaQLStyle& style() const
{ return itsRep->style(); }
// Destructor deletes the letter if no more references.
~TaQLNode()
{ TaQLNodeRep::unlink (itsRep); }
// Parse a TaQL command and return the result.
// An exception is thrown in case of parse errors.
static TaQLNode parse (const String& command);
// Does the envelope contain a letter?
Bool isValid() const
{ return itsRep; }
// Return the type of letter.
char nodeType() const
{ return itsRep->nodeType(); }
// Get read access to the letter.
const TaQLNodeRep* getRep() const
{ return itsRep; }
// Let the visitor visit the node.
// If no node, return an empty result.
TaQLNodeResult visit (TaQLNodeVisitor& visitor) const
{ return (itsRep ? itsRep->visit (visitor) : TaQLNodeResult()); }
// Print the node (recursively) in the given stream.
void show (std::ostream& os) const
{ if (itsRep) itsRep->show (os); }
// Save and restore the entire tree.
// <group>
void save (AipsIO& aio) const;
static TaQLNode restore (AipsIO& aio);
// </group>
protected:
TaQLNodeRep* itsRep;
private:
static void clearNodesCreated();
public:
// Helper functions for save/restore of tree.
// <group>
void saveNode (AipsIO& aio) const;
static TaQLNode restoreNode (AipsIO& aio);
static TaQLMultiNode restoreMultiNode (AipsIO& aio);
// </group>
// The object getting the final tree.
static TaQLNode theirNode;
// A list of objects created by the parser and deleted at the end.
static std::vector<TaQLNode*> theirNodesCreated;
// Keep the TaQL style to use.
static TaQLStyle theirStyle;
// Use a mutex to guard the statics.
static Mutex theirMutex;
};
// <summary>
// Envelope class for a node containing a constant value.
// </summary>
// <use visibility=local>
// <reviewed reviewer="" date="" tests="tTaQLNode">
// </reviewed>
// <synopsis>
// This is a specialization of the envelope class
// <linkto class=TaQLNode>TaQLNode</linkto> for a node containing
// a constant value.
// </synopsis>
class TaQLConstNode: public TaQLNode
{
public:
explicit TaQLConstNode (TaQLConstNodeRep* rep);
void setIsTableName();
const String& getString() const;
private:
TaQLConstNodeRep* itsNRep;
};
// <summary>
// Envelope class for a node containing a constant regex value.
// </summary>
// <use visibility=local>
// <reviewed reviewer="" date="" tests="tTaQLNode">
// </reviewed>
// <synopsis>
// This is a specialization of the envelope class
// <linkto class=TaQLNode>TaQLNode</linkto> for a node containing
// a constant regex or pattern value.
// </synopsis>
class TaQLRegexNode: public TaQLNode
{
public:
explicit TaQLRegexNode (TaQLRegexNodeRep* rep);
const String& getString() const;
Bool caseInsensitive() const;
Bool negate() const;
private:
TaQLRegexNodeRep* itsNRep;
};
// <summary>
// Envelope class for a node containing a list of nodes.
// </summary>
// <use visibility=local>
// <reviewed reviewer="" date="" tests="tTaQLNode">
// </reviewed>
// <synopsis>
// This is a specialization of the envelope class
// <linkto class=TaQLNode>TaQLNode</linkto> for a node containing
// a list of nodes.
// </synopsis>
class TaQLMultiNode: public TaQLNode
{
public:
TaQLMultiNode();
explicit TaQLMultiNode (Bool isSetOrArray);
TaQLMultiNode (TaQLMultiNodeRep* rep);
void add (const TaQLNode& node);
void add (TaQLNodeRep* noderep);
void setIsSetOrArray();
void setPPFix (const String& prefix, const String& postfix);
void setSeparator (const String& sep);
void setSeparator (uInt incr, const String& sep);
const TaQLMultiNodeRep* getMultiRep() const
{ return itsNRep; }
private:
TaQLMultiNodeRep* itsNRep;
};
// <summary>
// Envelope class for a node containing a selection command.
// </summary>
// <use visibility=local>
// <reviewed reviewer="" date="" tests="tTaQLNode">
// </reviewed>
// <synopsis>
// This is a specialization of the envelope class
// <linkto class=TaQLNode>TaQLNode</linkto> for a node containing
// a selection command.
// </synopsis>
class TaQLQueryNode: public TaQLNode
{
public:
TaQLQueryNode (TaQLQueryNodeRep* rep);
void setBrackets();
void setNoExecute();
void setFromExecute();
private:
TaQLQueryNodeRep* itsNRep;
};
} //# NAMESPACE CASACORE - END
#endif
|