M
MathStuf
I am creating a program that uses a lot of enumerations and associated
arrays of strings that look like this:
enum Enum1
{
E1_NONE = -1,
E1_A = 0,
E1_B = 1,
E1_END = 2
}
const string Enum1Str[E1_END]={"Val 1","Val 2"};
I was thinking about creating a derived map<string, int> class to
handle this better, but if I were to do so, I would need the following
methods added to it (though I'm not 100% familiar with iterators, so
the return values for KeyList and ValueList may not be correct):
vector<string>::iterator KeyList();
vector<int>::iterator ValueList();
string KeyOf(int val);
I think if I all I had were simple enumerations such as the one above,
the derived class would be overwhelmingly preferable, but I also have
enumerations as such:
enum Enum2
{
E2_NONE = -1,
E2_A = 0,
E2_B = 1,
E2_C = 2,
E2_D = 3,
// One possibility
E2_E = 4,
E2_END_1 = 5,
// Fork off different options
E2_F = 4,
E2_G = 5,
E2_END_2 = 6,
}
const string Enum2Str1[E2_END_1]={"Ref 1","Ref 2","Ref 3","Ref 4","Ref
5A"};
const string Enum2Str2[E2_END_2]={"Ref 1","Ref 2","Ref 3","Ref 4","Ref
5B","Ref 6B"};
which are there for double duty because sometimes values overlap when
different options are set.
Would it be in my best interest to go with the class and split up the
dual-duty enumerations or find some way to extend the class even
further to allow for multiple "ends" of the allowable options? If that
would be that case, how exactly might I go about doing that? Thanks in
advance.
--MathStuf
arrays of strings that look like this:
enum Enum1
{
E1_NONE = -1,
E1_A = 0,
E1_B = 1,
E1_END = 2
}
const string Enum1Str[E1_END]={"Val 1","Val 2"};
I was thinking about creating a derived map<string, int> class to
handle this better, but if I were to do so, I would need the following
methods added to it (though I'm not 100% familiar with iterators, so
the return values for KeyList and ValueList may not be correct):
vector<string>::iterator KeyList();
vector<int>::iterator ValueList();
string KeyOf(int val);
I think if I all I had were simple enumerations such as the one above,
the derived class would be overwhelmingly preferable, but I also have
enumerations as such:
enum Enum2
{
E2_NONE = -1,
E2_A = 0,
E2_B = 1,
E2_C = 2,
E2_D = 3,
// One possibility
E2_E = 4,
E2_END_1 = 5,
// Fork off different options
E2_F = 4,
E2_G = 5,
E2_END_2 = 6,
}
const string Enum2Str1[E2_END_1]={"Ref 1","Ref 2","Ref 3","Ref 4","Ref
5A"};
const string Enum2Str2[E2_END_2]={"Ref 1","Ref 2","Ref 3","Ref 4","Ref
5B","Ref 6B"};
which are there for double duty because sometimes values overlap when
different options are set.
Would it be in my best interest to go with the class and split up the
dual-duty enumerations or find some way to extend the class even
further to allow for multiple "ends" of the allowable options? If that
would be that case, how exactly might I go about doing that? Thanks in
advance.
--MathStuf