| 238 | } |
| 239 | |
| 240 | void FastqReader::getLine(string* line){ |
| 241 | int copied = 0; |
| 242 | |
| 243 | int start = mBufUsedLen; |
| 244 | int end = start; |
| 245 | |
| 246 | while(end < mBufDataLen) { |
| 247 | if(mFastqBuf[end] != '\r' && mFastqBuf[end] != '\n') |
| 248 | end++; |
| 249 | else |
| 250 | break; |
| 251 | } |
| 252 | |
| 253 | // this line well contained in this buf, or this is the last buf |
| 254 | if(end < mBufDataLen || bufferFinished()) { |
| 255 | int len = end - start; |
| 256 | line->assign(mFastqBuf+start, len); |
| 257 | |
| 258 | // skip \n or \r |
| 259 | end++; |
| 260 | // handle \r\n |
| 261 | if(end < mBufDataLen-1 && mFastqBuf[end-1]=='\r' && mFastqBuf[end] == '\n') |
| 262 | end++; |
| 263 | |
| 264 | mBufUsedLen = end; |
| 265 | |
| 266 | return ; |
| 267 | } |
| 268 | |
| 269 | // this line is not contained in this buf, we need to read new buf |
| 270 | line->assign(mFastqBuf+start, mBufDataLen - start); |
| 271 | |
| 272 | while(true) { |
| 273 | readToBuf(); |
| 274 | start = 0; |
| 275 | end = 0; |
| 276 | // handle the case that \r or \n in the start of buf |
| 277 | if(line->empty()) { |
| 278 | while(start < mBufDataLen && (mFastqBuf[start] == '\r' || mFastqBuf[start] == '\n')) |
| 279 | start++; |
| 280 | end = start; |
| 281 | } |
| 282 | while(end < mBufDataLen) { |
| 283 | if(mFastqBuf[end] != '\r' && mFastqBuf[end] != '\n') |
| 284 | end++; |
| 285 | else |
| 286 | break; |
| 287 | } |
| 288 | // this line well contained in this buf |
| 289 | if(end < mBufDataLen || bufferFinished()) { |
| 290 | int len = end - start; |
| 291 | line->append(mFastqBuf+start, len); |
| 292 | |
| 293 | // skip \n or \r |
| 294 | end++; |
| 295 | // handle \r\n |
| 296 | if(end < mBufDataLen-1 && mFastqBuf[end] == '\n') |
| 297 | end++; |
nothing calls this directly
no outgoing calls
no test coverage detected