1
0
Fork 0
mirror of https://github.com/KingDuckZ/dindexer.git synced 2024-11-29 01:33:46 +00:00

Move case sensitivity option into glob2regex.

This commit is contained in:
King_DuckZ 2016-05-18 10:17:05 +02:00
parent bc1ff586c0
commit 5da1d41ddf
4 changed files with 8 additions and 5 deletions

View file

@ -22,7 +22,7 @@
#include <string> #include <string>
namespace g2r { namespace g2r {
std::string convert ( const std::string& parGlob ); std::string convert ( const std::string& parGlob, bool parCaseSensitive=true );
} //namespace g2r } //namespace g2r
#endif #endif

View file

@ -24,8 +24,8 @@ namespace g2r {
namespace { namespace {
} //unnamed namespace } //unnamed namespace
std::string convert (const std::string& parGlob) { std::string convert (const std::string& parGlob, bool parCaseSensitive) {
const auto glob_ast = make_ast(parGlob); const auto glob_ast = make_ast(parGlob);
return render_ast(glob_ast); return render_ast(glob_ast, parCaseSensitive);
} }
} //namespace g2r } //namespace g2r

View file

@ -19,6 +19,7 @@
#include <boost/spirit/include/karma.hpp> #include <boost/spirit/include/karma.hpp>
#include <boost/spirit/include/phoenix_stl.hpp> #include <boost/spirit/include/phoenix_stl.hpp>
#include <sstream> #include <sstream>
#include <ciso646>
namespace ka = boost::spirit::karma; namespace ka = boost::spirit::karma;
@ -63,9 +64,11 @@ namespace g2r {
} }
} //unnamed namespace } //unnamed namespace
std::string render_ast (const GlobExpression& parAst) { std::string render_ast (const GlobExpression& parAst, bool parCaseSensitive) {
RegexGen<boost::spirit::ostream_iterator> gramm; RegexGen<boost::spirit::ostream_iterator> gramm;
std::ostringstream oss; std::ostringstream oss;
if (not parCaseSensitive)
oss << "(?i)";
oss << ka::format(gramm, parAst); oss << ka::format(gramm, parAst);
oss << '$'; oss << '$';
return oss.str(); return oss.str();

View file

@ -23,7 +23,7 @@
#include <string> #include <string>
namespace g2r { namespace g2r {
std::string render_ast ( const GlobExpression& parAst ); std::string render_ast ( const GlobExpression& parAst, bool parCaseSensitive );
} //namespace g2r } //namespace g2r
#endif #endif