DatabaseResult.h
Go to the documentation of this file.
1 /*
2  //
3 // BEGIN SONGBIRD GPL
4 //
5 // This file is part of the Songbird web player.
6 //
7 // Copyright(c) 2005-2008 POTI, Inc.
8 // http://songbirdnest.com
9 //
10 // This file may be licensed under the terms of of the
11 // GNU General Public License Version 2 (the "GPL").
12 //
13 // Software distributed under the License is distributed
14 // on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
15 // express or implied. See the GPL for the specific language
16 // governing rights and limitations.
17 //
18 // You should have received a copy of the GPL along with this
19 // program. If not, go to http://www.gnu.org/licenses/gpl.html
20 // or write to the Free Software Foundation, Inc.,
21 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 //
23 // END SONGBIRD GPL
24 //
25  */
26 
32 #ifndef __DATABASE_RESULT_H__
33 #define __DATABASE_RESULT_H__
34 
35 // INCLUDES ===================================================================
36 #include "sbIDatabaseResult.h"
37 
38 #include <deque>
39 #include <vector>
40 #include <map>
41 
42 #include <prlock.h>
43 
44 #include <nscore.h>
45 #include <nsStringGlue.h>
46 
47 // DEFINES ====================================================================
48 #define SONGBIRD_DATABASERESULT_CONTRACTID \
49  "@songbirdnest.com/Songbird/DatabaseResult;1"
50 #define SONGBIRD_DATABASERESULT_CLASSNAME \
51  "Songbird Database Result Interface"
52 #define SONGBIRD_DATABASERESULT_CID \
53 { /* 9079e1b1-01e9-4cb8-9f2a-08fdf69597cf */ \
54  0x9079e1b1, \
55  0x1e9, \
56  0x4cb8, \
57  {0x9f, 0x2a, 0x8, 0xfd, 0xf6, 0x95, 0x97, 0xcf} \
58 }
59 // CLASSES ====================================================================
61 {
62 friend class CDatabaseQuery;
63 friend class QueryProcessorThread;
64 public:
65  explicit CDatabaseResult(PRBool aRequiresLocking = PR_FALSE);
66  virtual ~CDatabaseResult();
67 
69  NS_DECL_SBIDATABASERESULT
70 
71  nsresult AddRow(const std::vector<nsString> &vCellValues);
72  nsresult DeleteRow(PRUint32 dbRow);
73 
74  nsresult SetColumnNames(const std::vector<nsString> &vColumnNames);
75  nsresult SetColumnName(PRUint32 dbColumn, const nsString &strColumnName);
76 
77  nsresult SetRowCell(PRUint32 dbRow, PRUint32 dbCell, const nsString &strCellValue);
78  nsresult SetRowCells(PRUint32 dbRow, const std::vector<nsString> &vCellValues);
79 
80  PRUint32 GetColumnIndexFromName(const nsAString &strColumnName);
82 
83 protected:
84  typedef std::vector<nsString> dbcolumnnames_t;
85  typedef std::deque< std::vector<nsString> > dbrowcells_t;
86  typedef std::map<nsString, PRUint32> dbcolumnresolvemap_t;
87 
88  PRPackedBool m_RequiresLocking;
89 
90  PRLock *m_pLock;
91 
95 };
96 
97 #endif // __DATABASE_RESULT_H__
98 
std::deque< std::vector< nsString > > dbrowcells_t
dbrowcells_t m_RowCells
dbcolumnresolvemap_t m_ColumnResolveMap
nsresult SetColumnName(PRUint32 dbColumn, const nsString &strColumnName)
nsresult SetColumnNames(const std::vector< nsString > &vColumnNames)
virtual ~CDatabaseResult()
nsresult SetRowCell(PRUint32 dbRow, PRUint32 dbCell, const nsString &strCellValue)
void RebuildColumnResolveMap()
std::map< nsString, PRUint32 > dbcolumnresolvemap_t
nsresult DeleteRow(PRUint32 dbRow)
nsresult SetRowCells(PRUint32 dbRow, const std::vector< nsString > &vCellValues)
NS_DECL_ISUPPORTS NS_DECL_SBIDATABASERESULT nsresult AddRow(const std::vector< nsString > &vCellValues)
CDatabaseResult(PRBool aRequiresLocking=PR_FALSE)
An object containing the results of a database SELECT query.
std::vector< nsString > dbcolumnnames_t
friend class QueryProcessorThread
PRPackedBool m_RequiresLocking
dbcolumnnames_t m_ColumnNames
PRUint32 GetColumnIndexFromName(const nsAString &strColumnName)