ManaPlus
itemdb.h
Go to the documentation of this file.
1 /*
2  * The ManaPlus Client
3  * Copyright (C) 2004-2009 The Mana World Development Team
4  * Copyright (C) 2009-2010 The Mana Developers
5  * Copyright (C) 2011-2019 The ManaPlus Developers
6  * Copyright (C) 2019-2021 Andrei Karas
7  *
8  * This file is part of The ManaPlus Client.
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program. If not, see <http://www.gnu.org/licenses/>.
22  */
23 
24 #ifndef RESOURCES_DB_ITEMDB_H
25 #define RESOURCES_DB_ITEMDB_H
26 
28 
29 #include "utils/stringvector.h"
30 
31 #include <map>
32 
33 #include "localconsts.h"
34 
35 class ItemInfo;
36 
40 namespace ItemDB
41 {
42  void load();
43 
44  void unload();
45 
46  void loadXmlFile(const std::string &fileName,
47  int &tagNum,
48  const SkipError skipError);
49 
50  const StringVect &getTags();
51 
52  bool exists(const int id) A_WARN_UNUSED;
53  bool exists(const std::string &name) A_WARN_UNUSED;
54 
55  const ItemInfo &get(const int id) A_WARN_UNUSED;
56  const ItemInfo &get(const std::string &name) A_WARN_UNUSED;
57 
59 
61 
62  // Items database
63  typedef std::map<int, ItemInfo*> ItemInfos;
64  typedef std::map<std::string, ItemInfo*> NamedItemInfos;
65 
67 
68  std::string getNamesStr(const STD_VECTOR<int> &parts);
69 
70 #ifdef UNITTESTS
71  ItemDB::NamedItemInfos &getNamedItemInfosTest();
72 
73  ItemDB::ItemInfos &getItemInfosTest();
74 #endif // UNITTESTS
75 
76  int getTagId(const std::string &tagName) A_WARN_UNUSED;
77 } // namespace ItemDB
78 
79 #endif // RESOURCES_DB_ITEMDB_H
#define A_WARN_UNUSED
Definition: localconsts.h:161
Definition: itemdb.h:41
bool exists(const int id)
Definition: itemdb.cpp:773
void load()
Definition: itemdb.cpp:147
void unload()
Definition: itemdb.cpp:759
int getNumOfHairstyles()
Definition: itemdb.cpp:1192
const StringVect & getTags()
Definition: itemdb.cpp:749
const ItemInfo & getEmpty()
Definition: itemdb.cpp:834
const ItemInfo & get(const int id)
Definition: itemdb.cpp:792
int getTagId(const std::string &tagName)
Definition: itemdb.cpp:754
const ItemDB::ItemInfos & getItemInfos()
Definition: itemdb.cpp:829
std::string getNamesStr(const std::vector< int > &parts)
Definition: itemdb.cpp:1176
std::map< std::string, ItemInfo * > NamedItemInfos
Definition: itemdb.h:64
void loadXmlFile(const std::string &fileName, int &tagNum, const SkipError skipError)
Definition: itemdb.cpp:262
std::map< int, ItemInfo * > ItemInfos
Definition: itemdb.h:63
bool SkipError
Definition: skiperror.h:30
std::vector< std::string > StringVect
Definition: stringvector.h:29
std::string fileName
Definition: testmain.cpp:39