Describe the new on_snoop callback
[lsnes.git] / fieldsplit.cpp
blob76767a6cdf5515bcd2635661bce9ce6b01169f63
1 #include "lsnes.hpp"
2 #include "fieldsplit.hpp"
3 #include <iostream>
5 fieldsplitter::fieldsplitter(const std::string& _line) throw(std::bad_alloc)
7 line = _line;
8 position = 0;
11 fieldsplitter::operator bool() throw()
13 return (position < line.length());
16 fieldsplitter::operator std::string() throw(std::bad_alloc)
18 size_t nextp, oldp = position;
19 nextp = line.find_first_of("|", position);
20 if(nextp > line.length()) {
21 position = line.length();
22 return line.substr(oldp);
23 } else {
24 position = nextp + 1;
25 return line.substr(oldp, nextp - oldp);