Ejemplo n.º 1
0
    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;
    }
Ejemplo n.º 2
0
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 "";
}
Ejemplo n.º 3
0
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;
      }
Ejemplo n.º 4
0
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);
                  }
            }
      }
Ejemplo n.º 5
0
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());
                  }
            }
      }