bool canHandle(HTTPMethod requestMethod, String requestUri) override { if (_method != HTTP_ANY && _method != requestMethod) { return false; } String uri = removeSlashes(_uri); requestUri = removeSlashes(requestUri); String wildcardStr; wildcardStr += _wildcard; while (1) { String uPath = getPathSegment(uri); String ruPath = getPathSegment(requestUri); if (uPath != ruPath && uPath != wildcardStr) { return false; } uri = removeSlashes(removePathSegment(uri)); requestUri = removeSlashes(removePathSegment(requestUri)); if (!uri.length() && !requestUri.length()) { return true; } if (!uri.length() || !requestUri.length()) { return false; } } return true; }
String getWildCard(String requestUri, String wcUri, int n, char wildcard = '*') { wcUri = removeSlashes(wcUri); requestUri = removeSlashes(requestUri); String wildcardStr; wildcardStr += wildcard; int i = 0; while (1) { String uPath = getPathSegment(wcUri); String ruPath = getPathSegment(requestUri); if (uPath == wildcardStr) { if (i == n) { return ruPath; } i++; } wcUri = removeSlashes(removePathSegment(wcUri)); requestUri = removeSlashes(removePathSegment(requestUri)); if (!wcUri.length() && !requestUri.length()) { return ""; } if (!wcUri.length() || !requestUri.length()) { return ""; } } return ""; }
QList<std::string> makeLyricsListForUI() { QList<std::string> list; const auto *lyrics = preferences.midiImportOperations.getLyrics(); if (!lyrics) return list; const unsigned int symbolLimit = 16; for (const auto &trackLyric: *lyrics) { std::string lyricText; for (const auto &lyric: trackLyric) { const auto &text = removeSlashes(lyric.second); if (isMetaText(text)) continue; if (!lyricText.empty()) lyricText += " "; // visual text delimeter if (lyricText.size() + text.size() > symbolLimit) lyricText += text.substr(0, symbolLimit - lyricText.size()); else lyricText += text; if (lyricText.size() >= symbolLimit - 1) { lyricText += "..."; break; } } list.push_back(lyricText); } return list; }
void addLyricsToScore(const std::multimap<ReducedFraction, std::string> &lyricTrack, const Staff *staffAddTo) { Score *score = staffAddTo->score(); int textCounter = 0; for (const auto &e: lyricTrack) { const auto &tick = e.first; QString str = MidiCharset::convertToCharset(e.second); if (tick == ReducedFraction(0, 1)) { addTitle(score, str, &textCounter); } else { QString text = removeSlashes(str); score->addLyrics(tick.ticks(), staffAddTo->idx(), text); } } }
void addLyricsToScore( const std::multimap<ReducedFraction, std::string> &lyricTrack, const std::vector<std::pair<ReducedFraction, ReducedFraction>> &matchedLyricTimes, const Staff *staffAddTo) { Score *score = staffAddTo->score(); addTitleIfAny(lyricTrack, score); for (const auto &timePair: matchedLyricTimes) { const auto quantizedTime = timePair.first; const auto originalTime = timePair.second; const auto it = lyricTrack.find(originalTime); Q_ASSERT_X(it != lyricTrack.end(), "MidiLyrics::addLyricsToScore", "Lyric time not found"); QString text = MidiCharset::convertToCharset(it->second); if (originalTime != ReducedFraction(0, 1) || !isTitlePrefix(text)) { // not title score->addLyrics(quantizedTime.ticks(), staffAddTo->idx(), removeSlashes(text).toHtmlEscaped()); } } }