26#include <ql/errors.hpp>
28#include <boost/algorithm/string/replace.hpp>
29#include <boost/make_shared.hpp>
39Wildcard::Wildcard(
const std::string& pattern,
const bool usePrefixes,
const bool aggressivePrefixes)
40 : pattern_(pattern), usePrefixes_(usePrefixes), aggressivePrefixes_(aggressivePrefixes) {
53 static std::vector<std::string> specialChars = {
"\\",
".",
"+",
"?",
"^",
"$",
"(",
54 ")",
"[",
"]",
"{",
"}",
"|"};
55 for (
auto const& c : specialChars) {
70 return s.substr(0, (*prefixString_).size()) == (*prefixString_);
74 return std::regex_match(s, *
regex_);
83 QL_REQUIRE(
regexString_,
"string '" <<
pattern_ <<
"' is not a regex (usePrefixes = " << std::boolalpha
90 QL_REQUIRE(
prefixString_,
"string '" <<
pattern_ <<
"' is not a prefix (usePrefixes = " << std::boolalpha
96void partitionQuotes(
const set<string>& quoteNames, set<string>& names, set<string>& regexes) {
98 for (
const string& n : quoteNames) {
101 regexes.insert(w.
regex());
107void partitionQuotes(
const set<string>& quoteNames, set<string>& names, set<string>& regexes,
108 std::set<std::string>& prefixes,
const bool aggressivePrefixes) {
110 for (
const string& n : quoteNames) {
114 prefixes.insert(w.
prefix());
116 regexes.insert(w.
regex());
boost::optional< std::string > prefixString_
const std::string & pattern() const
Wildcard(const std::string &pattern, const bool usePrefixes=true, const bool aggressivePrefixes=false)
bool matches(const std::string &s) const
std::size_t wildcardPos() const
boost::optional< std::string > regexString_
QuantLib::ext::shared_ptr< std::regex > regex_
const std::string & prefix() const
const std::string & regex() const
void partitionQuotes(const set< string > "eNames, set< string > &names, set< string > ®exes)
Serializable Credit Default Swap.
utilities for wildcard handling