1
0
Fork 0
mirror of https://github.com/KingDuckZ/dindexer.git synced 2024-11-25 00:53:43 +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>
namespace g2r {
std::string convert ( const std::string& parGlob );
std::string convert ( const std::string& parGlob, bool parCaseSensitive=true );
} //namespace g2r
#endif

View file

@ -24,8 +24,8 @@ namespace g2r {
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);
return render_ast(glob_ast);
return render_ast(glob_ast, parCaseSensitive);
}
} //namespace g2r

View file

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

View file

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