GMForceInline SupernaturalString ParseCommandLine(SupernaturalString cmdString) // tokenizes a string and executes the associated commands
{
// TODO: Do some search optimization, maybe figure out a means of generating a 'position' value for the std::map ops
SupernaturalString cmd;
bool keepGoing = true;
CVarDBIter iter;
size_t i = 0;
do
{
char temp = cmd.at(i);
if((temp != '\n') && (temp != ' '))
{
std::cout << temp << std::endl;
cmd.push_back(temp);
std::cout << cmd;
++i;
}
else
{
keepGoing = false;
break;
}
} while(keepGoing);
iter = mappedVars.find(cmd);
if(iter != mappedVars.end())
{
return mappedVars[cmd].AsString();
}
return string("Unknown variable " + cmdString);
}
And on a side note, if anyone has any useful articles or design advice for debug consoles as a whole I'd love to get my hands on 'em :)
Gaaah! Index out of bounds?! Why?
I'm working on a quick-and-dirty debug console for my pet engine/software engineering testbed and for some rather peculiar reason std::string::at() keeps throwing out-of-bounds excpetions in this little code segment. Would anyone have any tips or help in determining where the problem is? I suspect it's in the delimiting conditional, but some debug work by me yielded that temp always shows up as a whitespace even when the character it *should* be isn't. I can confirm that the passed-in command string is valid.
Quote:Original post by SiCrane
Well the obvious reason would be if the string doesn't contain a '\n' or a ' '.
Quote:I can confirm that the passed-in command string is valid.
I did think of that one, but I also would agree that the problem is probably something really stupidly simple XD
What is a "SupernaturalString" and why are you checking a locally created string rather than the parameter string? which is empty and causing the error.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement