casacore
Loading...
Searching...
No Matches
TableParseUtil.h
Go to the documentation of this file.
1// # TableParseUtil.h: Convenience functions for TableParse classes
2// # Copyright (C) 1994-2022
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: casa-feedback@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#ifndef TABLES_TABLEPARSEUTIL_H
27#define TABLES_TABLEPARSEUTIL_H
28
29// # Includes
30#include <casacore/casa/aips.h>
31#include <casacore/tables/Tables/Table.h>
32#include <vector>
33
34namespace casacore { // # NAMESPACE CASACORE - BEGIN
35
36// # Forward declarations
37class TableParseQuery;
38
39// <summary>
40// Convenience functions for TableParse classes
41// </summary>
42
43// <use visibility=local>
44
45// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
46// </reviewed>
47
48// <synopsis>
49// This file contains several static helper functions for TableParse.
50// They handle splitting a name into its shorthand, column and/or keyword
51// parts. A name can be given as
52// <src>shorthand.column::key.subkey1.subkey2...</src>
53// where each part is optional.
54// It also has functions to find the given table, column and keyword.
55// </synopsis>
56
57namespace TableParseUtil {
58// Make a Table object for given name, seqnr or so.
59// If <src>alwaysOpen=False</src> the table will only be looked up,
60// but not opened if not found. This is meant for concatenated tables
61// in TaQLNodeHandler.
62Table getTable(Int tabnr, const String& name, const Table& ftab,
63 const std::vector<const Table*>& tempTables,
64 const std::vector<TableParseQuery*>& stack, Bool alwaysOpen = True);
65
66// Open the parent table of a subtable.
67Table openParentTable(const String& fullName, const String& subTableName,
68 const std::vector<const Table*>& tempTables,
69 const std::vector<TableParseQuery*>& stack);
70
71// Split a name into its parts (shorthand, column and field names).
72// A name can be given as
73// <src>[shorthand][column][::key1.key2.key3...]</src> where the
74// square brackets indicate optional parts. Note that a single name given
75// before :: is interpreted as a shorthand unless preceded by a period.
76// <br>True is returned if the name contains a keyword part.
77// In that case fieldNames contains the keyword name and the possible
78// subfields. The possible shorthand and the column name are
79// filled in if it is a column keyword.
80// If the name contains a column, fieldNames is filled with the subfields
81// of the column (for the case where the column contains records).
82// <br>If isKeyword is True, the first part of name is a keyword,
83// even if no :: is given.
84// If allowNoKey is True, a single :: is allowed, otherwise the name is invalid.
85// If the name is invalid, exceptions are only thrown if checkError=True.
86// Otherwise the name is treated as a normal name without keyword.
87Bool splitName(String& shorthand, String& columnName, Vector<String>& fieldNames,
88 const String& name, Bool checkError, Bool isKeyword, Bool allowNoKey);
89
90// Define a field with the given data type in the Record.
91void setRecFld(RecordInterface& rec, const String& name, const String& dtype,
92 const ValueHolder& vh);
93
94// Get the type string. If empty, it is made from the given
95// data type.
96String getTypeString(const String& typeStr, DataType type);
97
98// Find the names of all stored columns in a table.
100
101// Make an array from the contents of a column in a subquery.
103} // namespace TableParseUtil
104
105} // namespace casacore
106
107#endif
String: the storage and methods of handling collections of characters.
Definition String.h:355
String getTypeString(const String &typeStr, DataType type)
Get the type string.
Bool splitName(String &shorthand, String &columnName, Vector< String > &fieldNames, const String &name, Bool checkError, Bool isKeyword, Bool allowNoKey)
Split a name into its parts (shorthand, column and field names).
Table openParentTable(const String &fullName, const String &subTableName, const std::vector< const Table * > &tempTables, const std::vector< TableParseQuery * > &stack)
Open the parent table of a subtable.
TableExprNode getColSet(const Table &table)
Make an array from the contents of a column in a subquery.
Block< String > getStoredColumns(const Table &tab)
Find the names of all stored columns in a table.
void setRecFld(RecordInterface &rec, const String &name, const String &dtype, const ValueHolder &vh)
Define a field with the given data type in the Record.
Table getTable(Int tabnr, const String &name, const Table &ftab, const std::vector< const Table * > &tempTables, const std::vector< TableParseQuery * > &stack, Bool alwaysOpen=True)
Make a Table object for given name, seqnr or so.
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
String name() const
Return the name of the field.
RecordInterface()
The default constructor creates an empty record with a variable structure.
int Int
Definition aipstype.h:48
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
const Bool True
Definition aipstype.h:41