1 /*=========================================================================
2 
3   Program:   Visualization Toolkit
4   Module:    vtkQtSQLQuery.h
5 
6   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7   All rights reserved.
8   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10      This software is distributed WITHOUT ANY WARRANTY; without even
11      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12      PURPOSE.  See the above copyright notice for more information.
13 
14 =========================================================================*/
15 /*-------------------------------------------------------------------------
16   Copyright 2008 Sandia Corporation.
17   Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
18   the U.S. Government retains certain rights in this software.
19 -------------------------------------------------------------------------*/
20 /**
21  * @class   vtkQtSQLQuery
22  * @brief   query class associated with vtkQtSQLDatabase
23  *
24  *
25  * Implements vtkSQLQuery using an underlying QSQLQuery.
26  */
27 
28 #ifndef vtkQtSQLQuery_h
29 #define vtkQtSQLQuery_h
30 
31 #include "vtkGUISupportQtSQLModule.h" // For export macro
32 #include "vtkSQLQuery.h"
33 
34 class vtkVariant;
35 class vtkQtSQLQueryInternals;
36 
37 class VTKGUISUPPORTQTSQL_EXPORT vtkQtSQLQuery : public vtkSQLQuery
38 {
39 public:
40   static vtkQtSQLQuery* New();
41   vtkTypeMacro(vtkQtSQLQuery, vtkSQLQuery);
42   void PrintSelf(ostream& os, vtkIndent indent) override;
43 
44   /**
45    * Execute the query.  This must be performed
46    * before any field name or data access functions
47    * are used.
48    */
49   bool Execute() override;
50 
51   /**
52    * The number of fields in the query result.
53    */
54   int GetNumberOfFields() override;
55 
56   /**
57    * Return the name of the specified query field.
58    */
59   const char* GetFieldName(int col) override;
60 
61   /**
62    * Return the type of the specified query field, as defined in vtkType.h.
63    */
64   int GetFieldType(int col) override;
65 
66   /**
67    * Advance row, return false if past end.
68    */
69   bool NextRow() override;
70 
71   /**
72    * Return data in current row, field c
73    */
74   vtkVariant DataValue(vtkIdType c) override;
75 
76   /**
77    * Returns true if an error is set, otherwise false.
78    */
79   bool HasError() override;
80 
81   /**
82    * Get the last error text from the query
83    */
84   const char* GetLastErrorText() override;
85 
86 protected:
87   vtkQtSQLQuery();
88   ~vtkQtSQLQuery() override;
89 
90   vtkQtSQLQueryInternals* Internals;
91   friend class vtkQtSQLDatabase;
92 
93 private:
94   // Using the convenience function internally
95   vtkSetStringMacro(LastErrorText);
96 
97   char* LastErrorText;
98 
99   vtkQtSQLQuery(const vtkQtSQLQuery&) = delete;
100   void operator=(const vtkQtSQLQuery&) = delete;
101 };
102 
103 #endif // vtkQtSQLQuery_h
104