トークン分割 のコメント:
vectorに切り出してくれたほうが便利じゃないっすか?
ランダムアクセスできるから、来るデータの形式が固定なら
コーディングがいろいろ楽になりそうですし。
承りましたー
以下のメソッドを追加:
// 一気に切り出してOutputIteratorに書き出す
template<typename OutputIterator>
OutputIterator split(OutputIterator out) {
while ( next() ) *out++ = token();
return out;
}
--- つかいかた ---
#include "tokenizer.h"
#include <iostream>
#include <iterator>
#include <vector>
int main() {
tokenizer<char> tk(",.");
std::vector<std::string> v;
tk.start("Hello,world.");
tk.split(std::back_inserter(v));
for ( int i = 0; i < v.size(); ++i ) {
std::cout << v[i] << std::endl;
}
}