Merge pull request #27064 from ScholliYT/addObjectNameTo3mfExport
Mesh: Add object name attribute to 3MF export
This commit is contained in:
@@ -117,6 +117,44 @@ std::basic_string<XMLCh> XMLTools::toXMLString(const char* const fromTranscode)
|
||||
return str;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Escape special XML characters in a string.
|
||||
*
|
||||
* Replaces XML special characters (&, <, >, ", ') with their entity equivalents
|
||||
* (&, <, >, ", ').
|
||||
*
|
||||
* \param input The string to escape
|
||||
* \return The escaped string safe for use in XML content or attributes
|
||||
*/
|
||||
std::string XMLTools::escapeXml(const std::string& input)
|
||||
{
|
||||
std::string output;
|
||||
output.reserve(input.size());
|
||||
for (char ch : input) {
|
||||
switch (ch) {
|
||||
case '&':
|
||||
output.append("&");
|
||||
break;
|
||||
case '<':
|
||||
output.append("<");
|
||||
break;
|
||||
case '>':
|
||||
output.append(">");
|
||||
break;
|
||||
case '"':
|
||||
output.append(""");
|
||||
break;
|
||||
case '\'':
|
||||
output.append("'");
|
||||
break;
|
||||
default:
|
||||
output.push_back(ch);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
void XMLTools::terminate()
|
||||
{
|
||||
transcoder.reset();
|
||||
|
||||
@@ -47,6 +47,7 @@ class BaseExport XMLTools
|
||||
public:
|
||||
static std::string toStdString(const XMLCh* const toTranscode);
|
||||
static std::basic_string<XMLCh> toXMLString(const char* const fromTranscode);
|
||||
static std::string escapeXml(const std::string& input);
|
||||
static void initialize();
|
||||
static void terminate();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user