Move wildcard_string_to_regex() from IfcParse to IfcGeom as it's not really related to parsing IFC at all.

This commit is contained in:
Stinkfist0
2016-05-31 14:04:44 +03:00
parent aa03da20a8
commit c644ffbe5e
3 changed files with 17 additions and 26 deletions
+17 -2
View File
@@ -65,6 +65,7 @@
#include <algorithm>
#include <boost/algorithm/string.hpp>
#include <boost/regex.hpp>
#include <gp_Mat.hxx>
#include <gp_Mat2d.hxx>
@@ -308,7 +309,7 @@ namespace IfcGeom {
{
names_to_include_or_exclude.clear();
foreach(const std::string &name, names)
names_to_include_or_exclude.insert(IfcUtil::wildcard_string_to_regex(name));
names_to_include_or_exclude.insert(wildcard_string_to_regex(name));
include_entities_in_processing = true;
}
@@ -317,10 +318,24 @@ namespace IfcGeom {
{
names_to_include_or_exclude.clear();
foreach(const std::string &name, names)
names_to_include_or_exclude.insert(IfcUtil::wildcard_string_to_regex(name));
names_to_include_or_exclude.insert(wildcard_string_to_regex(name));
include_entities_in_processing = false;
}
static boost::regex wildcard_string_to_regex(std::string str)
{
// Escape all non-"*?" regex special chars
std::string special_chars = "\\^.$|()[]+/";
foreach(char c, special_chars) {
std::string char_str(1, c);
boost::replace_all(str, char_str, "\\" + char_str);
}
// Convert "*?" to their regex equivalents
boost::replace_all(str, "?", ".");
boost::replace_all(str, "*", ".*");
return boost::regex(str);
}
const gp_XYZ& bounds_min() const { return bounds_min_; }
const gp_XYZ& bounds_max() const { return bounds_max_; }