10 bool operator()(char byte)const
15 case '\r': // fall through
26 bool operator()(char byte)const
31 case '\t': // fall through
42 bool operator()(cstr line)const
48 template<class DELIMITER=IsCRLF,
49 class TRIM=IsWhiteSpace,
50 class LINESKIP=IsEmpty>
53 binary::IReader &reader_;
54 unsigned int lineCount_;
55 std::vector<char> buf_;
59 LineReader(binary::IReader &reader)
60 : reader_(reader), lineCount_(0), isEnd_(false)
81 unsigned int getLineCount()const
96 while(char byte=reader_.getChar()){
97 if(DELIMITER()(byte)){
100 buf_.push_back(byte);
103 while(char byte=reader_.getChar()){
104 if(DELIMITER()(byte)){
107 buf_.push_back(byte);
123 if(front>=buf_.size()){
126 if(!TRIM()(buf_[front])){
132 size_t back=buf_.size()-1;
133 for(; back>=0; --back){
134 if(!TRIM()(buf_[back])){
139 return cstr(&buf_[0]+front, &buf_[0]+back+1);
143 template<class DELIMITER=IsWhiteSpace>
149 LineSplitter(cstr line)
158 const char *current=line_.begin();
159 for(; current!=line_.end();){
160 for(; current!=line_.end(); ++current){
161 if(!DELIMITER()(*current)){
167 for(; current!=line_.end(); ++current){
168 if(DELIMITER()(*current)){
181 line_=cstr(tail+1, line_.end());
182 return cstr(head, tail);
187 return atoi(get().begin());
192 return static_cast<float>(atof(get().begin()));
199 return Vector2(x, y);
207 return Vector3(x, y, z);
216 return Vector4(x, y, z, w);
225 return fRGBA(r, g, b, a);
234 return bRGBA(r, g, b, a);
239 const char *begin=line_.begin();
240 for(; begin!=line_.end(); ++begin){
246 assert(begin<=line_.end());
248 const char *c=begin+1;
249 for(; c!=line_.end(); ++c){
255 cstr token=cstr(begin, c);
258 line_=cstr(c+1, line_.end());