Merge branch 'fixes' into main/rendor-staging
[ryzomcore.git] / ryzom / common / src / game_share / interface_flags.cpp
blobc2f6f42b2bc4060698d8858b8504cca28d02e3ad
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #include "stdpch.h"
20 #include "interface_flags.h"
21 // nel
22 #include "nel/misc/string_conversion.h"
24 using namespace std;
25 using namespace NLMISC;
27 namespace INTERFACE_FLAGS
29 // The conversion table
30 const CStringConversion<TInterfaceFlag>::CPair stringTable [] =
32 { "Magic", Magic },
33 { "Combat", Combat },
34 { "Special", Special },
35 { "Commerce", Commerce },
36 { "FaberCreate", FaberCreate },
37 { "FaberRefine", FaberRefine },
38 { "FaberRepair", FaberRepair },
39 { "Tracking", Tracking},
41 { "Unknown", Unknown },
44 CStringConversion<TInterfaceFlag> conversion(stringTable, sizeof(stringTable) / sizeof(stringTable[0]), Unknown);
48 // convert type id to type name string
49 const std::string& toString( TInterfaceFlag type )
51 return conversion.toString(type);
54 // convert type name to type enum value
55 TInterfaceFlag toInterfaceFlag( const std::string& str )
57 return conversion.fromString(str);
60 // convert a skill to an interface flag
61 TInterfaceFlag toInterfaceFlag( SKILLS::ESkills skill )
63 return conversion.fromString( SKILLS::toString(skill) );
66 // convert an interface flag to a skill
67 SKILLS::ESkills toSkill( TInterfaceFlag flag )
69 return SKILLS::toSkill(conversion.toString(flag));
72 } // INTERFACE_FLAGS