char U2AssemblyReadIterator::nextLetter() { assert(hasNext()); skip(); SAFE_POINT(offsetInCigar < cigar.size(), "CIGAR out of range", 0); if(offsetInToken != cigar.at(offsetInCigar).count) { //staying in the current token offsetInToken++; } else { //current token is finished advanceToNextToken(); offsetInToken = 1; } bool del = isDeletion(); char c = del ? '-' : read.at(offsetInRead); //TODO: hardcoded '-' offsetInRead += !del; //adjust offsetInRead only when going through match token return c; }
U2AssemblyReadIterator::U2AssemblyReadIterator(const QByteArray & read_, QList<U2CigarToken> cigar_, int startPos /* = 0*/) : offsetInRead(0), read(read_), offsetInToken(0), offsetInCigar(0), cigar(cigar_) { for(int i = 0; i < startPos && hasNext();) { skip(); U2CigarToken t = cigar.at(offsetInCigar); if(i + t.count <= startPos) { //we are going to skip the current token if(isMatch()) { offsetInRead += t.count; } i += t.count; offsetInToken += t.count; if(!hasNext()) break; advanceToNextToken(); } else { //landing in the current token offsetInToken = startPos - i; if(isMatch()) { offsetInRead += offsetInToken; } break; } } }
static void getToken(xmlrpc_env * const envP, Tokenizer * const tokP) { /* The token starts where the last one left off */ tokP->begin = tokP->end; advanceToNextToken(tokP); if (*tokP->begin == '\0') { /* End of document */ tokP->end = tokP->begin; tokP->type = typeEof; tokP->size = tokP->end - tokP->begin; } else { tokP->end = tokP->begin; /* initial value */ if (*tokP->begin == '{') { finishDelimiterToken(tokP); tokP->type = typeOpenBrace; } else if (*tokP->begin == '}') { finishDelimiterToken(tokP); tokP->type = typeCloseBrace; } else if (*tokP->begin == '[') { finishDelimiterToken(tokP); tokP->type = typeOpenBracket; } else if (*tokP->begin == ']') { finishDelimiterToken(tokP); tokP->type = typeCloseBracket; } else if (*tokP->begin == ':') { finishDelimiterToken(tokP); tokP->type = typeColon; } else if (*tokP->begin == ',') { finishDelimiterToken(tokP); tokP->type = typeComma; } else if (*tokP->begin == '"') { finishStringToken(envP, tokP); if (!envP->fault_occurred) tokP->type = typeString; } else { if (isWordChar(*tokP->begin)) { finishAlphanumericWordToken(tokP); if (isInteger(tokP->begin, tokP->size)) tokP->type = typeInteger; else if (isFloat(tokP->begin, tokP->size)) tokP->type = typeFloat; else if (xmlrpc_strneq(tokP->begin, "null", tokP->size)) tokP->type = typeNull; else if (xmlrpc_strneq(tokP->begin, "undefined", tokP->size)) tokP->type = typeUndefined; else if(xmlrpc_strneq(tokP->begin, "false", tokP->size)) tokP->type = typeFalse; else if(xmlrpc_strneq(tokP->begin, "true", tokP->size)) tokP->type = typeTrue; else setParseErr(envP, tokP, "Invalid word token -- " "Not a valid integer, floating point " "number, 'null', 'true', or 'false'"); } else { setParseErr(envP, tokP, "Not a valid token -- starts with '%c'; " "a valid token starts with " "one of []{}:,\"-. or digit or letter", *tokP->begin); } } } }