Clone of Bael'Zharon's Respite @ https://github.com/boardwalk/bzr

Property.cpp 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. * Bael'Zharon's Respite
  3. * Copyright (C) 2014 Daniel Skorupski
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; withuot even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along
  15. * with this program; if not, write to the Free Software Foundation, Inc.,
  16. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  17. */
  18. #include "Property.h"
  19. #include <unordered_map>
  20. #define ENTRY(key, value) {value, #key},
  21. static const unordered_map<uint32_t, string> kBoolProperties
  22. {
  23. #include "properties/BoolProperty.inc"
  24. };
  25. static const unordered_map<uint32_t, string> kStringProperties
  26. {
  27. #include "properties/StringProperty.inc"
  28. };
  29. static const unordered_map<uint32_t, string> kIntProperties
  30. {
  31. #include "properties/IntProperty.inc"
  32. };
  33. static const unordered_map<uint32_t, string> kInt64Properties
  34. {
  35. #include "properties/Int64Property.inc"
  36. };
  37. static const unordered_map<uint32_t, string> kFloatProperties
  38. {
  39. #include "properties/FloatProperty.inc"
  40. };
  41. static const unordered_map<uint32_t, string> kPositionProperties
  42. {
  43. #include "properties/PositionProperty.inc"
  44. };
  45. static const unordered_map<uint32_t, string> kIIDProperties
  46. {
  47. #include "properties/IIDProperty.inc"
  48. };
  49. static const unordered_map<uint32_t, string> kDIDProperties
  50. {
  51. #include "properties/DIDProperty.inc"
  52. };
  53. static const unordered_map<uint32_t, string> kSkillProperties
  54. {
  55. #include "properties/SkillProperty.inc"
  56. };
  57. static const unordered_map<uint32_t, string> kAttributeProperties
  58. {
  59. #include "properties/AttributeProperty.inc"
  60. };
  61. static const unordered_map<uint32_t, string> kAttribute2ndProperties
  62. {
  63. #include "properties/Attribute2ndProperty.inc"
  64. };
  65. static const string kUnknown = "(unknown)";
  66. #define IMPLEMENT_GET(t) \
  67. const string& get##t##PropertyName(t##Property property) \
  68. { \
  69. auto it = k##t##Properties.find(static_cast<uint32_t>(property)); \
  70. if(it == k##t##Properties.end()) \
  71. { \
  72. return kUnknown; \
  73. } \
  74. return it->second; \
  75. }
  76. IMPLEMENT_GET(Bool)
  77. IMPLEMENT_GET(String)
  78. IMPLEMENT_GET(Int)
  79. IMPLEMENT_GET(Int64)
  80. IMPLEMENT_GET(Float)
  81. IMPLEMENT_GET(Position)
  82. IMPLEMENT_GET(IID)
  83. IMPLEMENT_GET(DID)
  84. IMPLEMENT_GET(Skill)
  85. IMPLEMENT_GET(Attribute)
  86. IMPLEMENT_GET(Attribute2nd)