modernize C++: raw string literal

This commit is contained in:
wmayer
2023-08-07 16:02:39 +02:00
committed by Chris Hennes
parent 61daaceb8f
commit 96aabe113e
21 changed files with 48 additions and 46 deletions

View File

@@ -46,8 +46,8 @@ ReaderOBJ::ReaderOBJ(MeshKernel& kernel, Material* material)
bool ReaderOBJ::Load(std::istream &str)
{
boost::regex rx_m("^mtllib\\s+(.+)\\s*$");
boost::regex rx_u("^usemtl\\s+([\\x21-\\x7E]+)\\s*$");
boost::regex rx_g("^g\\s+([\\x21-\\x7E]+)\\s*$");
boost::regex rx_u(R"(^usemtl\s+([\x21-\x7E]+)\s*$)");
boost::regex rx_g(R"(^g\s+([\x21-\x7E]+)\s*$)");
boost::regex rx_p("^v\\s+([-+]?[0-9]*)\\.?([0-9]+([eE][-+]?[0-9]+)?)"
"\\s+([-+]?[0-9]*)\\.?([0-9]+([eE][-+]?[0-9]+)?)"
"\\s+([-+]?[0-9]*)\\.?([0-9]+([eE][-+]?[0-9]+)?)\\s*$");

View File

@@ -412,7 +412,7 @@ bool MeshInput::LoadSMF (std::istream &rstrIn)
bool MeshInput::LoadOFF (std::istream &rstrIn)
{
// http://edutechwiki.unige.ch/en/3D_file_format
boost::regex rx_n("^\\s*([0-9]+)\\s+([0-9]+)\\s+([0-9]+)\\s*$");
boost::regex rx_n(R"(^\s*([0-9]+)\s+([0-9]+)\s+([0-9]+)\s*$)");
boost::cmatch what;
bool colorPerVertex = false;
@@ -842,7 +842,7 @@ bool MeshInput::LoadPLY (std::istream &inp)
boost::regex rx_d("(([-+]?[0-9]*)\\.?([0-9]+([eE][-+]?[0-9]+)?))\\s*");
boost::regex rx_s("\\b([-+]?[0-9]+)\\s*");
boost::regex rx_u("\\b([0-9]+)\\s*");
boost::regex rx_f("^\\s*3\\s+([0-9]+)\\s+([0-9]+)\\s+([0-9]+)\\s*");
boost::regex rx_f(R"(^\s*3\s+([0-9]+)\s+([0-9]+)\s+([0-9]+)\s*)");
boost::smatch what;
for (std::size_t i = 0; i < v_count && std::getline(inp, line); i++) {
@@ -1066,7 +1066,7 @@ bool MeshInput::LoadMeshNode (std::istream &rstrIn)
boost::regex rx_p("^v\\s+([-+]?[0-9]*)\\.?([0-9]+([eE][-+]?[0-9]+)?)"
"\\s+([-+]?[0-9]*)\\.?([0-9]+([eE][-+]?[0-9]+)?)"
"\\s+([-+]?[0-9]*)\\.?([0-9]+([eE][-+]?[0-9]+)?)\\s*$");
boost::regex rx_f("^f\\s+([0-9]+)\\s+([0-9]+)\\s+([0-9]+)\\s*$");
boost::regex rx_f(R"(^f\s+([0-9]+)\s+([0-9]+)\s+([0-9]+)\s*$)");
boost::regex rx_e("\\s*]\\s*");
boost::cmatch what;
@@ -2716,7 +2716,7 @@ bool MeshOutput::SaveX3DContent (std::ostream &out, bool exportViewpoints) const
out.setf(std::ios::fixed | std::ios::showpoint);
// Header info
out << "<X3D profile=\"Immersive\" version=\"3.2\" xmlns:xsd="
out << R"(<X3D profile="Immersive" version="3.2" xmlns:xsd=)"
<< "\"http://www.w3.org/2001/XMLSchema-instance\" xsd:noNamespaceSchemaLocation="
<< "\"http://www.web3d.org/specifications/x3d-3.2.xsd\" width=\"1280px\" height=\"1024px\">\n";
out << " <head>\n"
@@ -2735,7 +2735,7 @@ bool MeshOutput::SaveX3DContent (std::ostream &out, bool exportViewpoints) const
<< "\" centerOfRotation=\"" << cnt.x << " " << cnt.y << " " << cnt.z
<< "\" position=\"" << pos.x << " " << pos.y << " " << pos.z
<< "\" orientation=\"" << axis.x << " " << axis.y << " " << axis.z << " " << angle
<< "\" description=\"camera\" fieldOfView=\"0.9\">"
<< R"(" description="camera" fieldOfView="0.9">)"
<< "</Viewpoint>\n";
};

View File

@@ -1323,7 +1323,7 @@ void CmdPartMakeFace::activated(int iMsg)
App::DocumentT doc(sketches.front()->getDocument());
std::stringstream str;
str << doc.getDocumentPython()
<< ".addObject(\"Part::Face\", \"Face\").Sources = (";
<< R"(.addObject("Part::Face", "Face").Sources = ()";
for (auto &obj : sketches) {
str << App::DocumentObjectT(obj).getObjectPython() << ", ";
}

View File

@@ -142,7 +142,7 @@ bool Mirroring::accept()
activeDoc->openTransaction("Mirroring");
QString shape, label;
QRegularExpression rx(QString::fromLatin1(" \\(Mirror #\\d+\\)$"));
QRegularExpression rx(QString::fromLatin1(R"( \(Mirror #\d+\)$)"));
QList<QTreeWidgetItem *> items = ui->shapes->selectedItems();
float normx=0, normy=0, normz=0;
int index = ui->comboBox->currentIndex();

View File

@@ -211,7 +211,7 @@ QString TaskSketchBasedParameters::getFaceReference(const QString& obj, const QS
if (o.isEmpty())
return QString();
return QString::fromLatin1("(App.getDocument(\"%1\").%2, [\"%3\"])")
return QString::fromLatin1(R"((App.getDocument("%1").%2, ["%3"]))")
.arg(QString::fromLatin1(doc->getName()), o, sub);
}

View File

@@ -144,8 +144,10 @@ void FitBSplineSurfaceWidget::onMakePlacementClicked()
.arg(q3);
QString document = QString::fromStdString(d->obj.getDocumentPython());
QString command = QString::fromLatin1("%1.addObject(\"App::Placement\", \"Placement\").Placement = %2")
.arg(document, argument);
QString command =
QString::fromLatin1(
R"(%1.addObject("App::Placement", "Placement").Placement = %2)"
).arg(document, argument);
Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Placement"));
Gui::Command::runCommand(Gui::Command::Doc, "from FreeCAD import Base");

View File

@@ -373,7 +373,7 @@ void PropertySheet::Save(Base::Writer &writer) const
}
writer.Stream() << writer.ind() << "<Cells Count=\"" << count
<< "\" xlink=\"1\">" << std::endl;
<< R"(" xlink="1">)" << std::endl;
writer.incInd();