gorilla@ubuntu:~/Documents/Programming/Completed_Programs/ConvertEnumToStrings/bin/Debug$ ./ConvertEnumToStrings "/home/gorilla/Documents/test.cpp" "results"
Thank you for running ConvertEnumToStrings.
This program will work with either C or C++ enums.
Before we begin converting enums to strings though,
please take note of the following points:
1. I did not provide support for invalid enums.
2. I also did not provide support for enums which
use variable names in any enumerator assignments.
You must use only const value numbers when you explicitly
assign an enumerator a value. The reason for this is, its
not possible to figure out the internal value of a variable.
3. The only exception to the last part of 2. is when
you specified the type of enum, and its a different
numerical type, such as a char. In this case, the program
will output the numerical representation of whatever char
has been assigned to a given enumerator. You are then free
to convert it back to a char if you want.
4. There are no other restrictions. The program should handle
all other kinds of enums.
Please press Enter to begin.
Thank you. We will now get the converting process underway...
currentEnumName_s is: DAY
We found an enumerator.
currentEnumeratorName_s is: sunday
enumeratorsCounter_ui is: 1
enumeratorsMap_m_si.find("sunday")->second is: 0
We found an enumerator.
We found an enumerator with an assigned value.
currentEnumeratorValue_i is: 0
currentEnumeratorName_s is: monday
currentEnumeratorHasAssignedValue_b is true.
enumeratorsMap_m_si.find("monday")->second is: 0
We found an enumerator.
currentEnumeratorName_s is: tuesday
The current enumerator is not the first and does not have an assigned value.
currentEnumeratorValue_i before incrementing: 0
currentEnumeratorValue_i after incrementing: 1
enumeratorsCounter_ui is: 3
enumeratorsMap_m_si.find("tuesday")->second is: 1
We found an enumerator.
currentEnumeratorName_s is: wednesday
The current enumerator is not the first and does not have an assigned value.
currentEnumeratorValue_i before incrementing: 1
currentEnumeratorValue_i after incrementing: 2
enumeratorsCounter_ui is: 4
enumeratorsMap_m_si.find("wednesday")->second is: 2
We found an enumerator.
currentEnumeratorName_s is: thursday
The current enumerator is not the first and does not have an assigned value.
currentEnumeratorValue_i before incrementing: 2
currentEnumeratorValue_i after incrementing: 3
enumeratorsCounter_ui is: 5
enumeratorsMap_m_si.find("thursday")->second is: 3
We found an enumerator.
currentEnumeratorName_s is: friday
The current enumerator is not the first and does not have an assigned value.
currentEnumeratorValue_i before incrementing: 3
currentEnumeratorValue_i after incrementing: 4
enumeratorsCounter_ui is: 6
enumeratorsMap_m_si.find("friday")->second is: 4
We found an enumerator.
currentEnumeratorName_s is: saturday
The current enumerator is not the first and does not have an assigned value.
currentEnumeratorValue_i before incrementing: 4
currentEnumeratorValue_i after incrementing: 5
enumeratorsCounter_ui is: 7
enumeratorsMap_m_si.find("saturday")->second is: 5
namesOfEnumerators_v_s.size() is: 7
valuesOfEnumerators_v_i.size() is: 7
enumeratorsMap_m_si.size() is: 7
numOfEnumerators_ui is: 7
We found a single-line enum.
currentEnumName_s is: AREYOUAROCK
We found an enumerator with an assigned value.
currentEnumeratorValue_i is: 1
currentEnumeratorName_s is: yes
currentEnumeratorHasAssignedValue_b is true.
enumeratorsMap_m_si.find("yes")->second is: 1
We're at the last enumerator of the single-line enum.
We found an enumerator that has an assigned value.
currentEnumeratorValue_i is: 0
currentEnumeratorHasAssignedValue_b is true.
enumeratorsMap_m_si.find("no")->second is: 0
namesOfEnumerators_v_s.size() is: 2
valuesOfEnumerators_v_i.size() is: 2
enumeratorsMap_m_si.size() is: 2
numOfEnumerators_ui is: 0
currentEnumName_s is: Work
We found an enumerator.
We found an enumerator with an assigned value.
currentEnumeratorValue_i is: 1
currentEnumeratorName_s is: hard
currentEnumeratorHasAssignedValue_b is true.
enumeratorsMap_m_si.find("hard")->second is: 1
We're at the last enumerator of the enum.
The last enumerator of the enum has an assigned value.
currentEnumeratorValue_s is: 2
currentEnumeratorValue_i is: 2
currentEnumeratorName_s is: lazy
currentEnumeratorHasAssignedValue_b is true.
enumeratorsMap_m_si.find("lazy")->second is: 2
namesOfEnumerators_v_s.size() is: 2
valuesOfEnumerators_v_i.size() is: 2
enumeratorsMap_m_si.size() is: 2
numOfEnumerators_ui is: 2
The current line with 'enum' has a comment.
currentEnumName_s is: weirdenum
We found an enumerator.
currentEnumeratorName_s is: weirdenum1
enumeratorsCounter_ui is: 1
enumeratorsMap_m_si.find("weirdenum1")->second is: 0
We found an enumerator.
We found an enumerator with an assigned value.
currentEnumeratorValue_i is: 2
currentEnumeratorName_s is: weirdenum2
currentEnumeratorHasAssignedValue_b is true.
enumeratorsMap_m_si.find("weirdenum2")->second is: 2
We're at the last enumerator of the enum.
The last enumerator of the enum has an assigned value.
currentEnumeratorValue_s is: 0
currentEnumeratorValue_i is: 0
currentEnumeratorName_s is: weirdenum3
currentEnumeratorHasAssignedValue_b is true.
enumeratorsMap_m_si.find("weirdenum3")->second is: 0
namesOfEnumerators_v_s.size() is: 3
valuesOfEnumerators_v_i.size() is: 3
enumeratorsMap_m_si.size() is: 3
numOfEnumerators_ui is: 3
4 enums were found.
They were successfully written to file.
Generated file can be found at: /home/gorilla/Documents/results.h
If you chose to write to a header file, then you
can include the header in your source file, and
call up a function to retrieve the names of all
the enumerations or a specific enumeration you choose.
Otherwise if you wrote to a source file, you will need
to put the implemention in the source file you wrote to.
The generated file provides the following functions inside
a class with the name of 'CnameofenumToStrings':
const vector<string>& getEnumeratorNames();
const vector<int>& getEnumeratorValues();
const string& getNameOfEnum();
const int& getNumOfEnumerators();
const map<string, int>& getEnumeratorsMap();
const string& getEnumeratorValue(nameofenum enumerator);
where 'nameofenum' is replaced with the actual name of the
enum you want to retrieve something from.
The function names are pretty self-explanatory:
getEnumeratorNames() obviously returns a reference
to a vector of the string names of the enumerators in
your enum.
getEnumeratorValues() returns a reference to a vector
of the int values of the enumerators in your enum.
getNameOfEnum() is provided in case you need to retrieve
the string name of the enum for some reason. It returns
a reference to a string.
getNumOfEnumerators() returns a reference to an int containing
the total number of enumerators found in the enum, in case
you need that for some reason.
getEnumeratorsMap() returns a reference to a map<string, int>
containing the string names and int values of the enumerators in an enum.
The int values can be either explicit or implicit, and the type of the enum does
not even have to be int. It can be some other intergal type, but
ConvertEnumToStrings will always return it in int form.
getEnumeratorValue(nameofenum enumerator) returns a
reference to a int containing the value of the enumerator
you passed in the parameter.
Congratulations, and feel free to use this program again anytime.
Press Enter to end this program.