VTK
dox/IO/PostgreSQL/vtkPostgreSQLQuery.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkPostgreSQLQuery.h
00005 
00006   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00007   All rights reserved.
00008   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00009 
00010      This software is distributed WITHOUT ANY WARRANTY; without even
00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00012      PURPOSE.  See the above copyright notice for more information.
00013 
00014 =========================================================================*/
00015 /*-------------------------------------------------------------------------
00016   Copyright 2008 Sandia Corporation.
00017   Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
00018   the U.S. Government retains certain rights in this software.
00019 -------------------------------------------------------------------------*/
00038 #ifndef __vtkPostgreSQLQuery_h
00039 #define __vtkPostgreSQLQuery_h
00040 
00041 #include "vtkIOPostgreSQLModule.h" // For export macro
00042 #include "vtkSQLQuery.h"
00043 
00044 class vtkPostgreSQLDatabase;
00045 class vtkVariant;
00046 class vtkVariantArray;
00047 class vtkPostgreSQLQueryPrivate;
00048 
00049 class VTKIOPOSTGRESQL_EXPORT vtkPostgreSQLQuery : public vtkSQLQuery
00050 {
00051 public:
00052   static vtkPostgreSQLQuery* New();
00053   void PrintSelf( ostream& os, vtkIndent indent );
00054   vtkTypeMacro(vtkPostgreSQLQuery, vtkSQLQuery);
00055 
00058   bool Execute();
00059 
00061   int GetNumberOfFields();
00062 
00064   const char* GetFieldName( int i );
00065 
00068   int GetFieldType( int i );
00069 
00071   bool NextRow();
00072 
00074   bool HasError();
00075 
00077 
00078   bool BeginTransaction();
00079   bool RollbackTransaction();
00080   bool CommitTransaction();
00082 
00084   vtkVariant DataValue( vtkIdType c );
00085 
00087   const char* GetLastErrorText();
00088 
00090   virtual vtkStdString EscapeString( vtkStdString s, bool addSurroundingQuotes = true );
00091 
00094   int GetNumberOfRows();
00095 
00096 protected:
00097   vtkPostgreSQLQuery();
00098   ~vtkPostgreSQLQuery();
00099 
00100   vtkSetStringMacro(LastErrorText);
00101 
00102   bool IsColumnBinary(int whichColumn);
00103   const char *GetColumnRawData(int whichColumn);
00104 
00105   bool TransactionInProgress;
00106   char *LastErrorText;
00107   int CurrentRow;
00108 
00109   vtkPostgreSQLQueryPrivate *QueryInternals;
00110 
00111   void DeleteQueryResults();
00112 
00113   //BTX
00114   friend class vtkPostgreSQLDatabase;
00115   //ETX
00116 
00117 private:
00118   vtkPostgreSQLQuery( const vtkPostgreSQLQuery& ); // Not implemented.
00119   void operator = ( const vtkPostgreSQLQuery& ); // Not implemented.
00120 };
00121 
00122 #endif // __vtkPostgreSQLQuery_h
00123