mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 18:16:40 +00:00
Merge branch 'master' into performance_improvements
# Conflicts: # src/ifcconvert/ColladaSerializer.cpp # src/ifcconvert/ColladaSerializer.h # src/ifcgeom/IfcGeomIterator.h # src/ifcgeom/IfcGeomRenderStyles.h
This commit is contained in:
@@ -69,7 +69,10 @@ void init_locale() {
|
||||
//
|
||||
// Opens the file, gets the filesize and reads a chunk in memory
|
||||
//
|
||||
IfcSpfStream::IfcSpfStream(const std::string& fn) {
|
||||
IfcSpfStream::IfcSpfStream(const std::string& fn)
|
||||
: stream(0)
|
||||
, buffer(0)
|
||||
{
|
||||
eof = false;
|
||||
#ifdef _MSC_VER
|
||||
int fn_buffer_size = MultiByteToWideChar(CP_UTF8, 0, fn.c_str(), -1, 0, 0);
|
||||
@@ -86,7 +89,7 @@ IfcSpfStream::IfcSpfStream(const std::string& fn) {
|
||||
}
|
||||
valid = true;
|
||||
fseek(stream, 0, SEEK_END);
|
||||
size = (unsigned int) ftell(stream);;
|
||||
size = (unsigned int) ftell(stream);
|
||||
rewind(stream);
|
||||
#ifdef BUF_SIZE
|
||||
offset = 0;
|
||||
@@ -96,11 +99,14 @@ IfcSpfStream::IfcSpfStream(const std::string& fn) {
|
||||
buffer = new char[size];
|
||||
#endif
|
||||
ptr = 0;
|
||||
len = 0;
|
||||
len = 0;
|
||||
ReadBuffer(false);
|
||||
}
|
||||
|
||||
IfcSpfStream::IfcSpfStream(std::istream& f, int l) {
|
||||
IfcSpfStream::IfcSpfStream(std::istream& f, int l)
|
||||
: stream(0)
|
||||
, buffer(0)
|
||||
{
|
||||
eof = false;
|
||||
size = l;
|
||||
#ifdef BUF_SIZE
|
||||
@@ -114,7 +120,10 @@ IfcSpfStream::IfcSpfStream(std::istream& f, int l) {
|
||||
len = l;
|
||||
}
|
||||
|
||||
IfcSpfStream::IfcSpfStream(void* data, int l) {
|
||||
IfcSpfStream::IfcSpfStream(void* data, int l)
|
||||
: stream(0)
|
||||
, buffer(0)
|
||||
{
|
||||
eof = false;
|
||||
size = l;
|
||||
#ifdef BUF_SIZE
|
||||
@@ -124,7 +133,7 @@ IfcSpfStream::IfcSpfStream(void* data, int l) {
|
||||
buffer = (char*) data;
|
||||
valid = true;
|
||||
ptr = 0;
|
||||
len = l;
|
||||
len = l;
|
||||
}
|
||||
|
||||
IfcSpfStream::~IfcSpfStream()
|
||||
|
||||
@@ -17,12 +17,14 @@
|
||||
* *
|
||||
********************************************************************************/
|
||||
|
||||
#include "IfcUtil.h"
|
||||
#include "../ifcparse/IfcException.h"
|
||||
|
||||
#include <boost/algorithm/string/replace.hpp>
|
||||
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
|
||||
#include "../ifcparse/IfcException.h"
|
||||
|
||||
#include "IfcUtil.h"
|
||||
|
||||
void IfcEntityList::push(IfcUtil::IfcBaseClass* l) {
|
||||
if (l) {
|
||||
@@ -143,4 +145,43 @@ bool IfcUtil::valid_binary_string(const std::string& s) {
|
||||
if (*it != '0' && *it != '1') return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
void IfcUtil::sanitate_material_name(std::string &str)
|
||||
{
|
||||
// Spaces in material names have been observed to cause problems with obj and dae importers.
|
||||
// Handle other potential problematic characters here too if observing problems.
|
||||
boost::replace_all(str, " ", "_");
|
||||
}
|
||||
|
||||
void IfcUtil::escape_xml(std::string &str)
|
||||
{
|
||||
boost::replace_all(str, "\"", """);
|
||||
boost::replace_all(str, "'", "'");
|
||||
boost::replace_all(str, "<", "<");
|
||||
boost::replace_all(str, ">", ">");
|
||||
boost::replace_all(str, "&", "&");
|
||||
}
|
||||
|
||||
void IfcUtil::unescape_xml(std::string &str)
|
||||
{
|
||||
boost::replace_all(str, """, "\"");
|
||||
boost::replace_all(str, "'", "'");
|
||||
boost::replace_all(str, "<", "<");
|
||||
boost::replace_all(str, ">", ">");
|
||||
boost::replace_all(str, "&", "&");
|
||||
}
|
||||
|
||||
+15
-3
@@ -26,15 +26,20 @@
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/dynamic_bitset.hpp>
|
||||
|
||||
#ifdef USE_IFC4
|
||||
#include "../ifcparse/Ifc4enum.h"
|
||||
#else
|
||||
#include "../ifcparse/Ifc2x3enum.h"
|
||||
#endif
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/dynamic_bitset.hpp>
|
||||
#include <boost/regex.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
#define foreach BOOST_FOREACH
|
||||
#define rforeach BOOST_REVERSE_FOREACH
|
||||
|
||||
class Argument;
|
||||
class IfcEntityList;
|
||||
class IfcEntityListList;
|
||||
@@ -110,6 +115,13 @@ namespace IfcUtil {
|
||||
};
|
||||
|
||||
bool valid_binary_string(const std::string& s);
|
||||
|
||||
boost::regex wildcard_string_to_regex(std::string str);
|
||||
|
||||
/// Replaces spaces and potentially other problem causing characters with underscores.
|
||||
void sanitate_material_name(std::string &str);
|
||||
void escape_xml(std::string &str);
|
||||
void unescape_xml(std::string &str);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
|
||||
Reference in New Issue
Block a user