Function wildCardMatch

Synopsis

#include <src/easylogging++.h>

static bool wildCardMatch(const char *str, const char *pattern)

Description

Matches wildcards, '*' and '?' only supported.

Str.

Source

Lines 862-884 in src/easylogging++.cc. Line 1078 in src/easylogging++.h.

bool Str::wildCardMatch(const char* str, const char* pattern) {
  while (*pattern) {
    switch (*pattern) {
    case '?':
      if (!*str)
        return false;
      ++str;
      ++pattern;
      break;
    case '*':
      if (wildCardMatch(str, pattern + 1))
        return true;
      if (*str && wildCardMatch(str + 1, pattern))
        return true;
      return false;
    default:
      if (*str++ != *pattern++)
        return false;
      break;
    }
  }
  return !*str && !*pattern;
}





Add Discussion

Log in to comment