I am working on a senior project and having a question about how to best implement a lookup table for my program. There are several enum class
files that contain enum class
es and an operator<<
overload to output them to std::string
s. We are using boost property tree's to parse a JSON file and the parse cannot convert a string to an enum class
by default. Since we need both the enum classes and the strings at some point in the program it made sense to implement an std::unordered_map
. My issue though is where do I place the lookup table in terms of my files?
Currently our code has 4 enum class files which summarized are
namespace wiregen{
enum class {/* values */}
ostream& operator<<(ostream& os, enum){/*overload code to output enum as a string*/}
}
The enums need to be public as they are used by multiple classes. I currently have them defined and the operator<< overloads defined in the enum header files. My question though is should I place the lookup table in the enum header, make an enum implementation and move the lookup table there, or something else?