casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TBXMLDriver.h
Go to the documentation of this file.
1 //# TBXMLDriver.h: Driver for converting table data into an XML String.
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 #ifndef TBXMLDRIVER_H_
28 #define TBXMLDRIVER_H_
29 
30 /*
31 #include <casa/BasicSL/String.h>
32 #include <tables/Tables/Table.h>
33 
34 // <summary>
35 // Driver for converting table data into an XML String.
36 // </summary>
37 //
38 // <synopsis>
39 // TBXMLDriver, initially used in the CasaJNI code for the Java table browser,
40 // is an interface to read from a table on disk and return XML which
41 // holds the requested data. There is one public method which takes a
42 // command in string form and returns the XML result. There is infrastructure
43 // to access remote tables, but it is not implemented.
44 // </synopsis>
45 
46 /* Examples of commands:
47  *
48  * To load rows from the table:
49  * send.table.query # SELECT FROM /casa/table/ <START = 0 number = 1000>
50  * where # is the length of the string starting from the next character.
51  *
52  * To load rows from given fields in the table:
53  * send.table.query # SELECT FIELD1,FIELD2 FROM /casa/table/
54  * <START = 0 number = 1000>
55  * where # is the length of the string starting from the next character.
56  *
57  * For the previous two commands, for array data only the shape is returned
58  * for arrays with dimension > 2. To return the full array data, use
59  * send.table.full instead of send.table.query.
60  *
61  * To view a data array:
62  * send.table.array #<ARRAYINFO>
63  * <QUERY> SELECT FROM /casa/table/ </QUERY>
64  * <ROW> 5 </ROW> <COLUMN> 5 </COLUMN> <TYPE> TpArrayInt </TYPE>
65  * </ARRAYINFO>
66  * where # is the length of the string starting from the next character.
67  *
68  * To update data in the table:
69  * send.table.updat #<QUERY> SELECT FROM /casa/table/ </QUERY>
70  * <COMMAND>
71  * <UPDATE row = 5 col = 5 val = "newValue" >
72  * </COMMAND>
73  * where # is the length of the string starting from the next character.
74  *
75  * To update data in an array cell:
76  * send.table.updat #<QUERY> SELECT FROM /casa/table/ </QUERY>
77  * <COMMAND>
78  * <ARRAYUPDATE row = 5 col = 5 >
79  * <ARRAYCELLUPDATE coordinates = [ 4 2 ] val = "newValue" >
80  * </ARRAYUPDATE>
81  * </COMMAND>
82  * where # is the length of the string starting from the next character.
83  *
84  * To insert rows:
85  * send.table.updat #<QUERY> SELECT FROM /casa/table/ </QUERY>
86  * <COMMAND>
87  * <ADDROW>
88  * <ADDROW>
89  * </COMMAND>
90  * where # is the length of the string starting from the next character.
91  *
92  * To delete rows:
93  * send.table.updat #<QUERY> SELECT FROM /casa/table/ </QUERY>
94  * <COMMAND>
95  * <DELROW 10 >
96  * <DELROW 5 >
97  * </COMMAND
98  *
99  */
100 
101 /*
102 class TBXMLDriver {
103 public:
104  // Takes a command in pseudo-TaQL format and returns XML in pseduo-VOTable
105  // format. For command examples, see TBXMLDriver.h code comments.
106  static casacore::String dowork(const char* buff);
107 
108 private:
109  // Indicates whether debug information should be printed or not.
110  static const bool showdebug;
111 
112  // Buffer size.
113  static const int BUF_SIZE = 2048;
114 
115  // Packet size.
116  static const int PacketSize = 4096;
117 
118  // Creates the XML representation of a VOTable from the given parameters.
119  static casacore::String createVOTab(casacore::String tablename, int totalrows,
120  casacore::Vector<casacore::String> colnames, casacore::Vector<casacore::String> datatype,
121  casacore::String records, casacore::String keyword, casacore::Bool insRowOk,
122  casacore::Bool delRowOk, casacore::String columnkeywords);
123 
124  // Creates the XML representation of a keyword from the given parameters.
125  static casacore::String createKeyword(casacore::TableRecord &trec, int a);
126 
127  // Sends the given String.
128  static int SendData(int fd, const casacore::String &hits);
129 
130  // Makes the return result from the given String.
131  static char* mkReturnResult(const casacore::String &hits);
132 
133  // Sets up communication.
134  static casacore::Bool setupComm(casacore::Int &fd);
135 
136  // Reads input into the given char*.
137  static int readn(int fd, char *ptr, int nbytes);
138 
139  // Writes output to the given char*.
140  static int writen(int fd, char *ptr, int nbytes);
141 };
142 */
143 
144 #endif /* TBXMLDRIVER_H_*/