I've had a problem for the past couple days and can't seem to find a solution. I am passing in a wstring and a custom Orthography object. The wstring being passed in is checked against the wstrings from a vector array of custom CharacterMatch objects that my Orthography object has. When it finds a match, I am wanting it to append the output wstring from the CharacterMatch object. I hope I'm not being too confusing and I am unsure how much code you guys would need to see for it to make sense.
Basically it checks each character from the inputted string and checks it against the input values of my CharacterMatch object. When a match is found, it is meant to return the matching output and append it to m_Results.
A bit of tweaking has gotten it to work so long as I only either type in one character or several of the same characters. But the moment I try two different characters, it triggers the error. Stepping through the program shows the GetOutput() adding the appropriate character to the m_Results just fine. It is just when it loops around to the second character and that character is different from the first.
Also, the [0] at the end of the line:
if (wstrInput[i] == orthography.GetCharacterMatches()[j].GetInput()[0])
is temporary. Right now I am just trying one character for one character so I can get away with only checking the first index because right now I am only working with one character wstrings. I'll work up to multi-character versions of this when I get this working. Also, I get red lines under == if I don't have the [0] at the end of that line. I'm not sure why, though.
Here is my function:
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
|
vector<wstring> Parser::CustomOrthography(const wstring& wstrInput, const Orthography& orthography)
{
// Set the size of the vector array to 1 (m_iCount)
m_iCount = 1;
m_Results.resize(m_iCount);
// Set the first item in the vector array to an empty string
m_Results[0] = L"";
for (int i = 0; i < wstrInput.size(); i++)
{
// For each character, need to go through the orthography's character matches
for (int j = 0; j < orthography.GetCharacterMatches().size(); j++)
{
if (wstrInput[i] == orthography.GetCharacterMatches()[j].GetInput()[0])
{
m_Results[i] += orthography.GetCharacterMatches()[j].GetOutput();
continue;
}
}
}
return m_Results;
}
|
The error occurs at this line:
m_Results[i] += orthography.GetCharacterMatches()[j].GetOutput();
This may sound like a lot of rambling but I hope I was able to convey what is going on. Like I said, I've been stuck on this for a while now and can't seem to get past it. I'm hoping a fresh set of eyes can see what I'm missing :).