void Parser::parseSeqNonNotes() { qDebug() << "Parser::parseSeqNonNotes() value:" << qPrintable(lex.symValue()); MeasureBeginFlags mbfl; MeasureEndFlags mefl; while (isNonNote(lex.symType())) { if (lex.symType() == CLEF) { mbfl.firstOfSystem = true; mefl.lastOfSystem = true; lex.getSym(); } else if (lex.symType() == KEY) lex.getSym(); // ignore else if (lex.symType() == TSIG) parseTSig(); else if (lex.symType() == PART) parsePart(mbfl, mefl); else if (lex.symType() == BAR) parseBar(mefl); } // First end the previous measure if (!measures.isEmpty()) { measures.last().mef = mefl; } // Then start a new measure, if necessary if (isNote(lex.symType())) { MeasureDescription md; md.mbf = mbfl; measures.append(md); } }
void RequestParser::parseMultipart(const Item& aItem, MultiPart& aMultiPart) { getString(aItem, "media-type", true, aMultiPart.theMediaType); getCharset(aMultiPart.theMediaType, aMultiPart.theCharset); getString(aItem, "boundary", false, aMultiPart.theBoundary); Item lParts = aItem.getObjectValue("parts"); if (!lParts.isNull()) { if (lParts.isAtomic() || !lParts.isJSONItem() || lParts.getJSONItemKind() != store::StoreConsts::jsonArray) raiseTypeError("parts", lParts.getType().getLocalName(), "array"); else { uint64_t lSize = lParts.getArraySize(); for(uint32_t i = 1; i <= lSize; ++i) { Item lMember = lParts.getArrayValue(i); if (lMember.isAtomic() || !lMember.isJSONItem() || lMember.getJSONItemKind() != store::StoreConsts::jsonObject) raiseTypeError("part",lMember.getType().getLocalName(), "object"); Part lPart; parsePart(lMember, lPart); aMultiPart.theParts.push_back(lPart); } } } }
void Parser::parseMultipart(RequestImpl *req, DataBuffer data, const std::string &boundary) { DataBuffer head, tail; while (!data.empty()) { if (data.split(boundary, head, tail) && !head.empty()) { if (head.endsWith(RETURN_RN_STRING)) { head = head.trimn(0, 2); } else if (head.endsWith(RETURN_N_STRING)) { head = head.trimn(0, 1); } else { throw std::runtime_error("malformed multipart message"); } if (head.startsWith(RETURN_RN_STRING)) { head = head.trimn(2, 0); } else if (head.startsWith(RETURN_N_STRING)) { head = head.trimn(1, 0); } else { throw std::runtime_error("malformed multipart message"); } } if (!head.empty()) { parsePart(req, head); } if (tail.startsWith(MINUS_PREFIX_STRING)) { break; } data = tail; } }