Support for wildcard queries

Provides support for persistent wildcard file requests, as described in
#96
Also moved CanonicalizePath into common code (poly::fs)
This commit is contained in:
x1nixmzeng
2015-02-13 23:41:19 +00:00
parent 3d980dd294
commit 4f7761c5e2
13 changed files with 327 additions and 144 deletions

View File

@@ -15,6 +15,9 @@
#include "poly/config.h"
#include "poly/string.h"
#include <vector>
#include <iterator>
namespace poly {
namespace fs {
@@ -35,6 +38,44 @@ struct FileInfo {
};
std::vector<FileInfo> ListFiles(const std::wstring& path);
std::string CanonicalizePath(const std::string& original_path);
class WildcardFlags
{
public:
bool
FromStart: 1,
ToEnd : 1,
WithCase : 1; // Unused for now
WildcardFlags();
WildcardFlags(bool start, bool end);
static WildcardFlags FIRST;
static WildcardFlags LAST;
};
class WildcardRule
{
public:
WildcardRule(std::string str_match, const WildcardFlags &flags);
bool Check(std::string& str) const;
private:
std::string match;
WildcardFlags rules;
};
class WildcardEngine
{
public:
void SetRule(const std::string &pattern);
bool Match(const std::string &str) const;
private:
std::vector<WildcardRule> rules;
void PreparePattern(const std::string &pattern);
};
} // namespace fs
} // namespace poly