Andy, you sort of know what I am working on so hopefully my explanation of what I am doing will make sense :).
I've created a character class that is basically a collection of two wstrings.
Then I've created an orthography class that holds a string for the orthography name and a vector that holds the character class objects.
Then what I'm trying to do in my program is create a vector that holds orthography objects. Then once I get that working, I'll work on a way to store the objects to a file so they can be saved and retrieved. I initially thought to go the route of using the map class for this but after toying around with it a bit, it wouldn't work because there is no way for there to be totally unique keys whether they are based on one wstring or the other.
I think I have the rough code of my character and orthography classes lined out and I'm sure they will need a few more tweaks and additions. I'll post them below. Where I'm running into trouble is trying to create a new orthography object and put it into the vector. I have a window that takes in text and uses it to create the orthography object by using the text for the object's name.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
case IDB_SUBMIT_ORTHOGRAPHY:
// Get the text from the input textbox
GetWindowTextW(hOrthographyInput, input, 256);
// Make sure there isn't already an orthography with this name
for (int i = 0; i < g_Orthographies.size(); i++)
{
if (input == g_Orthographies[i].GetName())
// TODO: ERROR CODE!!!
return true;
}
// Resize the vector array to accomodate the new orthography
g_Orthographies.resize(g_Orthographies.size() + 1);
// Create a new orthography and put it in the vector array
// Having trouble with the line below...syntax is wrong somehow
g_Orthographies[g_Orthographies.size() - 1] = new Orthography(input);
return true;
|
And here is my CharacterMatch class header code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
class CharacterMatch
{
public:
// Constructor(s)/Destructor
CharacterMatch();
CharacterMatch(wstring name, wstring wInput, wstring wOutput);
~CharacterMatch();
// Accessor functions
wstring GetName();
wstring GetInput();
wstring GetOutput();
private:
// Members
wstring m_Name;
wstring m_Input;
wstring m_Output;
};
|
And here is my orthography header and cpp code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
class Orthography
{
public:
// Constructor(s)/Destructor
Orthography();
Orthography(wstring name);
~Orthography();
// Accessor functions
wstring GetName();
int GetNumberOfCharacterMatches();
vector<CharacterMatch> GetCharacterMatches();
// Class functions
void AddCharacterMatch(CharacterMatch match);
private:
// Members
wstring m_Name;
int m_NumberOfCharacterMatches;
vector<CharacterMatch> m_CharacterMatches;
};
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
// Constructor
Orthography::Orthography()
{
}
Orthography::Orthography(wstring name)
{
m_Name = name;
}
// Destructor
Orthography::~Orthography()
{
}
// Accessor Functions
wstring Orthography::GetName()
{
return m_Name;
}
int Orthography::GetNumberOfCharacterMatches()
{
return m_NumberOfCharacterMatches;
}
vector<CharacterMatch> Orthography::GetCharacterMatches()
{
return m_CharacterMatches;
}
void Orthography::AddCharacterMatch(CharacterMatch match)
{
// TODO: Create match comparison to avoid duplicate entries.
// Increase the number of character matches
m_NumberOfCharacterMatches++;
// Resize the vector array
m_CharacterMatches.resize(m_NumberOfCharacterMatches);
// Put the new character match into the orthography
m_CharacterMatches[m_NumberOfCharacterMatches - 1] = match;
}
|
Bear in mind that I haven't been able to test this yet so there may be more issues that need to be addressed.