casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
TBXMLDriver.h
Go to the documentation of this file.
00001 //# TBXMLDriver.h: Driver for converting table data into an XML String.
00002 //# Copyright (C) 2005
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //#
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //#
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be addressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 //# $Id: $
00027 #ifndef TBXMLDRIVER_H_
00028 #define TBXMLDRIVER_H_
00029 
00030 /*
00031 #include <casa/BasicSL/String.h>
00032 #include <tables/Tables/Table.h>
00033 
00034 #include <casa/namespace.h>
00035 
00036 // <summary>
00037 // Driver for converting table data into an XML String.
00038 // </summary>
00039 //
00040 // <synopsis>
00041 // TBXMLDriver, initially used in the CasaJNI code for the Java table browser,
00042 // is an interface to read from a table on disk and return XML which
00043 // holds the requested data.  There is one public method which takes a
00044 // command in string form and returns the XML result.  There is infrastructure
00045 // to access remote tables, but it is not implemented.
00046 // </synopsis>
00047 
00048 /* Examples of commands:
00049  *     
00050  * To load rows from the table:
00051  *      send.table.query # SELECT FROM /casa/table/ <START = 0 number = 1000>
00052  * where # is the length of the string starting from the next character.
00053  * 
00054  * To load rows from given fields in the table:
00055  *      send.table.query # SELECT FIELD1,FIELD2 FROM /casa/table/
00056  *      <START = 0 number = 1000>
00057  * where # is the length of the string starting from the next character.
00058  * 
00059  * For the previous two commands, for array data only the shape is returned
00060  * for arrays with dimension > 2.  To return the full array data, use
00061  * send.table.full instead of send.table.query.
00062  * 
00063  * To view a data array:
00064  *      send.table.array #<ARRAYINFO>
00065  *          <QUERY> SELECT FROM /casa/table/ </QUERY>
00066  *          <ROW> 5 </ROW> <COLUMN> 5 </COLUMN> <TYPE> TpArrayInt </TYPE> 
00067  *      </ARRAYINFO>
00068  * where # is the length of the string starting from the next character.
00069  * 
00070  * To update data in the table:
00071  *      send.table.updat #<QUERY> SELECT FROM /casa/table/ </QUERY>
00072  *      <COMMAND>
00073  *          <UPDATE row = 5 col = 5 val = "newValue" >
00074  *      </COMMAND>
00075  * where # is the length of the string starting from the next character.
00076  * 
00077  * To update data in an array cell:
00078  *      send.table.updat #<QUERY> SELECT FROM /casa/table/ </QUERY>
00079  *      <COMMAND>
00080  *          <ARRAYUPDATE row = 5 col = 5 >
00081  *              <ARRAYCELLUPDATE coordinates = [ 4 2 ] val = "newValue" >
00082  *          </ARRAYUPDATE>
00083  *      </COMMAND>
00084  * where # is the length of the string starting from the next character.
00085  * 
00086  * To insert rows:
00087  *      send.table.updat #<QUERY> SELECT FROM /casa/table/ </QUERY>
00088  *      <COMMAND>
00089  *          <ADDROW>
00090  *          <ADDROW>
00091  *      </COMMAND>
00092  * where # is the length of the string starting from the next character.
00093  * 
00094  * To delete rows:
00095  *      send.table.updat #<QUERY> SELECT FROM /casa/table/ </QUERY>
00096  *      <COMMAND>
00097  *          <DELROW 10 >
00098  *          <DELROW 5 >
00099  *      </COMMAND
00100  *      
00101  */
00102 
00103 /*
00104 class TBXMLDriver {
00105 public:
00106     // Takes a command in pseudo-TaQL format and returns XML in pseduo-VOTable
00107     // format.  For command examples, see TBXMLDriver.h code comments.
00108     static String dowork(const char* buff);
00109 
00110 private:
00111     // Indicates whether debug information should be printed or not.
00112     static const bool showdebug;
00113     
00114     // Buffer size.
00115     static const int BUF_SIZE = 2048;
00116     
00117     // Packet size.
00118     static const int PacketSize = 4096;
00119     
00120     // Creates the XML representation of a VOTable from the given parameters.
00121     static String createVOTab(String tablename, int totalrows,
00122                              Vector<String> colnames, Vector<String> datatype,
00123                              String records, String keyword, Bool insRowOk,
00124                              Bool delRowOk, String columnkeywords);
00125     
00126     // Creates the XML representation of a keyword from the given parameters.
00127     static String createKeyword(TableRecord &trec, int a);
00128     
00129     // Sends the given String.
00130     static int SendData(int fd, const String &hits);
00131     
00132     // Makes the return result from the given String.
00133     static char* mkReturnResult(const String &hits);
00134     
00135     // Sets up communication.
00136     static Bool setupComm(Int &fd);
00137     
00138     // Reads input into the given char*.
00139     static int readn(int fd, char *ptr, int nbytes);
00140     
00141     // Writes output to the given char*.
00142     static int writen(int fd, char *ptr, int nbytes);
00143 };
00144 */
00145 
00146 #endif /* TBXMLDRIVER_H_*/