lsnes/fieldsplit.cpp
Ilari Liusvaara f170c7bab2 Major reorganization of command handling
Make commands objects instead of functions calling each other.

Now there is '?' command that can display command list and help about
individual command. Also the command handling is more distributed into
places where it belongs.
2011-09-14 20:06:36 +03:00

27 lines
564 B
C++

#include "lsnes.hpp"
#include "fieldsplit.hpp"
#include <iostream>
fieldsplitter::fieldsplitter(const std::string& _line) throw(std::bad_alloc)
{
line = _line;
position = 0;
}
fieldsplitter::operator bool() throw()
{
return (position < line.length());
}
fieldsplitter::operator std::string() throw(std::bad_alloc)
{
size_t nextp, oldp = position;
nextp = line.find_first_of("|", position);
if(nextp > line.length()) {
position = line.length();
return line.substr(oldp);
} else {
position = nextp + 1;
return line.substr(oldp, nextp - oldp);
}
}