]> jfr.im git - irc/gameservirc.git/blob - gameserv-2.0/libgameservcore/include/GameServ/Types.h
Finished some work on FilePlayerDAO
[irc/gameservirc.git] / gameserv-2.0 / libgameservcore / include / GameServ / Types.h
1 #ifndef __GS__TYPES_H__
2 #define __GS__TYPES_H__
3
4 #include <string>
5 using std::string;
6 #include <GameServ/GameServException.h>
7 using GameServ::Exceptions::GameServException;
8
9 namespace GameServ
10 {
11 namespace Types
12 {
13
14 //! Holds the exceptions related to types and their conversions
15 namespace Exceptions
16 {
17 //! Generic type exception possibly due to conversion or improper usage
18 class TypeException : public GameServException
19 {
20 public:
21 TypeException(const string &ErrorMsg, const char *pFilename, int SourceLine);
22 TypeException(const string &ErrorMsg);
23 TypeException(void);
24 };
25 }
26
27 class ItemTypes
28 {
29 public:
30 //! Logical ItemType enumerator
31 enum ItemType
32 {
33 Weapon, Armor, Potion, NOTYPE
34 };
35
36 //! Get the name of an item type
37 static string GetName(ItemType itemtype);
38
39 //! Parse the name and return the enumeration value
40 static ItemType Parse(const string &itemtype);
41
42 private:
43 //! Internal struct to hold type information statically in a table
44 typedef struct itemtypeinfo
45 {
46 ItemTypes::ItemType itemtype; //!< The ItemType enumeration value
47 const char *name; //!< The Name of the type
48 } itemtypeinfo;
49
50 static const itemtypeinfo mItemTypeInfoTable[];
51
52 }; // ItemTypes class
53 }
54 }
55 #endif