From c644ffbe5e04d63b372048d63c56f4a1a5a394dd Mon Sep 17 00:00:00 2001 From: Stinkfist0 Date: Tue, 31 May 2016 14:04:44 +0300 Subject: [PATCH] Move wildcard_string_to_regex() from IfcParse to IfcGeom as it's not really related to parsing IFC at all. --- src/ifcgeom/IfcGeomIterator.h | 19 +++++++++++++++++-- src/ifcparse/IfcUtil.cpp | 16 ---------------- src/ifcparse/IfcUtil.h | 8 -------- 3 files changed, 17 insertions(+), 26 deletions(-) diff --git a/src/ifcgeom/IfcGeomIterator.h b/src/ifcgeom/IfcGeomIterator.h index ceed8fec4c..9f4528098e 100644 --- a/src/ifcgeom/IfcGeomIterator.h +++ b/src/ifcgeom/IfcGeomIterator.h @@ -65,6 +65,7 @@ #include #include +#include #include #include @@ -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_; } diff --git a/src/ifcparse/IfcUtil.cpp b/src/ifcparse/IfcUtil.cpp index 8ba5e5f413..054aae7fd2 100644 --- a/src/ifcparse/IfcUtil.cpp +++ b/src/ifcparse/IfcUtil.cpp @@ -111,22 +111,6 @@ bool IfcUtil::valid_binary_string(const std::string& s) { return true; } -#ifndef IFCPARSE_NO_REGEX -boost::regex IfcUtil::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); -} -#endif - void IfcUtil::sanitate_material_name(std::string &str) { // Spaces in material names have been observed to cause problems with obj and dae importers. diff --git a/src/ifcparse/IfcUtil.h b/src/ifcparse/IfcUtil.h index 42f341b953..3c3ecbfc5d 100644 --- a/src/ifcparse/IfcUtil.h +++ b/src/ifcparse/IfcUtil.h @@ -36,9 +36,6 @@ #include #include -#ifndef IFCPARSE_NO_REGEX //allow builds without boost.regex - #include -#endif #include #define foreach BOOST_FOREACH @@ -119,11 +116,6 @@ namespace IfcUtil { }; IfcParse_EXPORT bool valid_binary_string(const std::string& s); - -#ifndef IFCPARSE_NO_REGEX - IfcParse_EXPORT boost::regex wildcard_string_to_regex(std::string str); -#endif - /// Replaces spaces and potentially other problem causing characters with underscores. IfcParse_EXPORT void sanitate_material_name(std::string &str); IfcParse_EXPORT void escape_xml(std::string &str);