root/trunk/src/shared/Database/QueryResult.h @ 44

Revision 44, 2.1 kB (checked in by yumileroy, 17 years ago)

[svn] * Merge Temp dev SVN with Assembla.
* Changes include:

  • Implementation of w12x's Outdoor PvP and Game Event Systems.
  • Temporary removal of IRC Chat Bot (until infinite loop when disabled is fixed).
  • All mangos -> trinity (to convert your mangos_string table, please run mangos_string_to_trinity_string.sql).
  • Improved Config cleanup.
  • And many more changes.

Original author: Seline
Date: 2008-10-14 11:57:03-05:00

Line 
1/*
2 * Copyright (C) 2008 Trinity <http://www.trinitycore.org/>
3 *
4 * Thanks to the original authors: MaNGOS <http://www.mangosproject.org/>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#if !defined(QUERYRESULT_H)
22#define QUERYRESULT_H
23
24class TRINITY_DLL_SPEC QueryResult
25{
26    public:
27        QueryResult(uint64 rowCount, uint32 fieldCount)
28            : mFieldCount(fieldCount), mRowCount(rowCount) {}
29
30        virtual ~QueryResult() {}
31
32        virtual bool NextRow() = 0;
33
34        typedef std::map<uint32, std::string> FieldNames;
35
36        uint32 GetField_idx(const std::string &name) const
37        {
38            for(FieldNames::const_iterator iter = GetFiedNames().begin(); iter != GetFiedNames().end(); ++iter)
39            {
40                if(iter->second == name)
41                    return iter->first;
42            }
43            assert(false && "unknown field name");
44            return uint32(-1);
45        }
46
47        Field *Fetch() const { return mCurrentRow; }
48
49        const Field & operator [] (int index) const { return mCurrentRow[index]; }
50
51        const Field & operator [] (const std::string &name) const
52        {
53            return mCurrentRow[GetField_idx(name)];
54        }
55
56        uint32 GetFieldCount() const { return mFieldCount; }
57        uint64 GetRowCount() const { return mRowCount; }
58        FieldNames const& GetFiedNames() const {return mFieldNames; }
59
60    protected:
61        Field *mCurrentRow;
62        uint32 mFieldCount;
63        uint64 mRowCount;
64        FieldNames mFieldNames;
65};
66#endif
Note: See TracBrowser for help on using the browser.