diff --git a/src/App/Document.cpp b/src/App/Document.cpp index 787d59e725..7ffd9efab3 100644 --- a/src/App/Document.cpp +++ b/src/App/Document.cpp @@ -921,7 +921,7 @@ std::string Document::getTransientDirectoryName(const std::string& uuid, const s void Document::Save (Base::Writer &writer) const { - writer.Stream() << "& obj, std:: Base::ZipWriter writer(out); writer.putNextEntry("Document.xml"); writer.Stream() << "" << endl; - writer.Stream() << "" << endl; + writer.Stream() << R"()" << endl; // Add this block to have the same layout as for normal documents writer.Stream() << "" << endl; writer.Stream() << "" << endl; diff --git a/src/App/PropertyExpressionEngine.cpp b/src/App/PropertyExpressionEngine.cpp index df9163262b..ab00701b76 100644 --- a/src/App/PropertyExpressionEngine.cpp +++ b/src/App/PropertyExpressionEngine.cpp @@ -265,7 +265,7 @@ void PropertyExpressionEngine::Save(Base::Writer &writer) const writer.Stream() << "\">" << std::endl; writer.incInd(); } else { - writer.Stream() << "\" xlink=\"1\">" << std::endl; + writer.Stream() << R"(" xlink="1">)" << std::endl; writer.incInd(); PropertyExpressionContainer::Save(writer); } diff --git a/src/App/PropertyPythonObject.cpp b/src/App/PropertyPythonObject.cpp index e55d3e9825..4fa12a9ba9 100644 --- a/src/App/PropertyPythonObject.cpp +++ b/src/App/PropertyPythonObject.cpp @@ -156,7 +156,7 @@ void PropertyPythonObject::loadPickle(const std::string& str) Base::PyGILStateLocker lock; try { std::string buffer = str; - boost::regex pickle("S'(\\w+)'.+S'(\\w+)'\\n"); + boost::regex pickle(R"(S'(\w+)'.+S'(\w+)'\n)"); boost::match_results what; std::string::const_iterator start, end; start = buffer.begin(); @@ -271,7 +271,7 @@ void PropertyPythonObject::Save (Base::Writer &writer) const repr = Base::base64_encode((const unsigned char*)repr.c_str(), repr.size()); std::string val = /*encodeValue*/(repr); writer.Stream() << writer.ind() << " what; std::string::const_iterator start, end; start = buffer.begin(); diff --git a/src/Gui/CallTips.cpp b/src/Gui/CallTips.cpp index 45fe10a281..517fbef1a5 100644 --- a/src/Gui/CallTips.cpp +++ b/src/Gui/CallTips.cpp @@ -707,7 +707,7 @@ void CallTipsList::callTipItemActivated(QListWidgetItem *item) * Try to find out if call needs arguments. * For this we search the description for appropriate hints ... */ - QRegularExpression argumentMatcher( QRegularExpression::escape( callTip.name ) + QLatin1String("\\s*\\(\\s*\\w+.*\\)") ); + QRegularExpression argumentMatcher( QRegularExpression::escape( callTip.name ) + QLatin1String(R"(\s*\(\s*\w+.*\))") ); argumentMatcher.setPatternOptions( QRegularExpression::InvertedGreedinessOption ); //< set regex non-greedy! if (argumentMatcher.match( callTip.description ).hasMatch()) { diff --git a/src/Gui/CommandStd.cpp b/src/Gui/CommandStd.cpp index d408fc1267..2ff072f3ec 100644 --- a/src/Gui/CommandStd.cpp +++ b/src/Gui/CommandStd.cpp @@ -94,7 +94,7 @@ void StdCmdWorkbench::activated(int i) QString msg(QLatin1String(e.what())); // ignore '' prefixes QRegularExpression rx; - rx.setPattern(QLatin1String("^\\s*:\\s*")); + rx.setPattern(QLatin1String(R"(^\s*:\s*)")); auto match = rx.match(msg); if (match.hasMatch()) msg = msg.mid(match.capturedLength()); diff --git a/src/Gui/DlgCreateNewPreferencePackImp.cpp b/src/Gui/DlgCreateNewPreferencePackImp.cpp index c53e6bee0f..f02535c21a 100644 --- a/src/Gui/DlgCreateNewPreferencePackImp.cpp +++ b/src/Gui/DlgCreateNewPreferencePackImp.cpp @@ -48,7 +48,7 @@ DlgCreateNewPreferencePackImp::DlgCreateNewPreferencePackImp(QWidget* parent) { ui->setupUi(this); - QRegularExpression validNames(QString::fromUtf8("[^/\\\\?%*:|\"<>]+")); + QRegularExpression validNames(QString::fromUtf8(R"([^/\\?%*:|"<>]+)")); _nameValidator.setRegularExpression(validNames); ui->lineEdit->setValidator(&_nameValidator); ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); diff --git a/src/Gui/DlgSettingsImageImp.cpp b/src/Gui/DlgSettingsImageImp.cpp index b67c719881..2eac9773a5 100644 --- a/src/Gui/DlgSettingsImageImp.cpp +++ b/src/Gui/DlgSettingsImageImp.cpp @@ -237,7 +237,7 @@ void DlgSettingsImageImp::onStandardSizeBoxActivated(int index) else { // try to extract from the string QString text = ui->standardSizeBox->itemText(index); - QRegularExpression rx(QLatin1String("\\b\\d{2,5}\\b")); + QRegularExpression rx(QLatin1String(R"(\b\d{2,5}\b)")); int pos = 0; auto match = rx.match(text, pos); if (match.hasMatch()) { diff --git a/src/Gui/FileDialog.cpp b/src/Gui/FileDialog.cpp index 6762485a11..4485d50ff4 100644 --- a/src/Gui/FileDialog.cpp +++ b/src/Gui/FileDialog.cpp @@ -86,7 +86,7 @@ FileDialog::~FileDialog() void FileDialog::onSelectedFilter(const QString& /*filter*/) { - QRegularExpression rx(QLatin1String("\\(\\*.(\\w+)")); + QRegularExpression rx(QLatin1String(R"(\(\*.(\w+))")); QString suf = selectedNameFilter(); auto match = rx.match(suf); if (match.hasMatch()) { @@ -186,7 +186,7 @@ QString FileDialog::getSaveFileName (QWidget * parent, const QString & caption, } QRegularExpression rx; - rx.setPattern(QLatin1String("\\s(\\(\\*\\.\\w{1,})\\W")); + rx.setPattern(QLatin1String(R"(\s(\(\*\.\w{1,})\W)")); auto match = rx.match(*filterToSearch); if (match.hasMatch()) { int index = match.capturedStart(); @@ -498,7 +498,7 @@ void FileOptionsDialog::accept() else if (!fn.isEmpty()) { QFileInfo fi(fn); QString ext = fi.completeSuffix(); - QRegularExpression rx(QLatin1String("\\(\\*.(\\w+)")); + QRegularExpression rx(QLatin1String(R"(\(\*.(\w+))")); QString suf = selectedNameFilter(); auto match = rx.match(suf); if (match.hasMatch()) @@ -869,7 +869,7 @@ SelectModule::SelectModule (const QString& type, const SelectModule::Dict& types QString module = it.value(); // ignore file types in (...) - rx.setPattern(QLatin1String("\\s+\\([\\w\\*\\s\\.]+\\)$")); + rx.setPattern(QLatin1String(R"(\s+\([\w\*\s\.]+\)$)")); auto match = rx.match(filter); if (match.hasMatch()) { filter = filter.left(match.capturedStart()); diff --git a/src/Gui/MDIView.cpp b/src/Gui/MDIView.cpp index 3227c82282..d13bada7e7 100644 --- a/src/Gui/MDIView.cpp +++ b/src/Gui/MDIView.cpp @@ -149,13 +149,13 @@ void MDIView::onRelabel(Gui::Document *pDoc) // Try to separate document name and view number if there is one QString cap = windowTitle(); // Either with dirty flag ... - QRegularExpression rx(QLatin1String("(\\s\\:\\s\\d+\\[\\*\\])$")); + QRegularExpression rx(QLatin1String(R"((\s\:\s\d+\[\*\])$)")); QRegularExpressionMatch match; //int pos = boost::ignore_unused(cap.lastIndexOf(rx, -1, &match)); if (!match.hasMatch()) { // ... or not - rx.setPattern(QLatin1String("(\\s\\:\\s\\d+)$")); + rx.setPattern(QLatin1String(R"((\s\:\s\d+)$)")); //pos = boost::ignore_unused(cap.lastIndexOf(rx, -1, &match)); } diff --git a/src/Gui/Placement.cpp b/src/Gui/Placement.cpp index b7259bcc9d..b938027796 100644 --- a/src/Gui/Placement.cpp +++ b/src/Gui/Placement.cpp @@ -274,7 +274,7 @@ void PlacementHandler::applyPlacement(App::DocumentObject* obj, const QString& d QString PlacementHandler::getIncrementalPlacement(App::DocumentObject* obj, const QString& data) const { return QString::fromLatin1( - "App.getDocument(\"%1\").%2.%3=%4.multiply(App.getDocument(\"%1\").%2.%3)") + R"(App.getDocument("%1").%2.%3=%4.multiply(App.getDocument("%1").%2.%3))") .arg(QString::fromLatin1(obj->getDocument()->getName()), QString::fromLatin1(obj->getNameInDocument()), QString::fromLatin1(this->propertyName.c_str()), diff --git a/src/Gui/SelectionView.cpp b/src/Gui/SelectionView.cpp index 35eaddbd01..ce592d3658 100644 --- a/src/Gui/SelectionView.cpp +++ b/src/Gui/SelectionView.cpp @@ -333,7 +333,7 @@ void SelectionView::select(QListWidgetItem* item) //Gui::Selection().clearSelection(); Gui::Command::runCommand(Gui::Command::Gui,"Gui.Selection.clearSelection()"); //Gui::Selection().addSelection(elements[0].toLatin1(),elements[1].toLatin1(),0); - QString cmd = QString::fromLatin1("Gui.Selection.addSelection(App.getDocument(\"%1\").getObject(\"%2\"))").arg(elements[0],elements[1]); + QString cmd = QString::fromLatin1(R"(Gui.Selection.addSelection(App.getDocument("%1").getObject("%2")))").arg(elements[0],elements[1]); Gui::Command::runCommand(Gui::Command::Gui,cmd.toLatin1()); }catch(Base::Exception &e) { e.ReportException(); @@ -350,7 +350,7 @@ void SelectionView::deselect() return; //Gui::Selection().rmvSelection(elements[0].toLatin1(),elements[1].toLatin1(),0); - QString cmd = QString::fromLatin1("Gui.Selection.removeSelection(App.getDocument(\"%1\").getObject(\"%2\"))").arg(elements[0],elements[1]); + QString cmd = QString::fromLatin1(R"(Gui.Selection.removeSelection(App.getDocument("%1").getObject("%2")))").arg(elements[0],elements[1]); try { Gui::Command::runCommand(Gui::Command::Gui,cmd.toLatin1()); }catch(Base::Exception &e) { @@ -457,7 +457,7 @@ void SelectionView::touch() QStringList elements = item->data(Qt::UserRole).toStringList(); if (elements.size() < 2) return; - QString cmd = QString::fromLatin1("App.getDocument(\"%1\").getObject(\"%2\").touch()").arg(elements[0],elements[1]); + QString cmd = QString::fromLatin1(R"(App.getDocument("%1").getObject("%2").touch())").arg(elements[0],elements[1]); try { Gui::Command::runCommand(Gui::Command::Doc,cmd.toLatin1()); }catch(Base::Exception &e) { @@ -475,19 +475,19 @@ void SelectionView::toPython() return; try { - QString cmd = QString::fromLatin1("obj = App.getDocument(\"%1\").getObject(\"%2\")").arg(elements[0], elements[1]); + QString cmd = QString::fromLatin1(R"(obj = App.getDocument("%1").getObject("%2"))").arg(elements[0], elements[1]); Gui::Command::runCommand(Gui::Command::Gui,cmd.toLatin1()); if (elements.length() > 2) { App::Document* doc = App::GetApplication().getDocument(elements[0].toLatin1()); App::DocumentObject* obj = doc->getObject(elements[1].toLatin1()); QString property = getProperty(obj); - cmd = QString::fromLatin1("shp = App.getDocument(\"%1\").getObject(\"%2\").%3") + cmd = QString::fromLatin1(R"(shp = App.getDocument("%1").getObject("%2").%3)") .arg(elements[0], elements[1], property); Gui::Command::runCommand(Gui::Command::Gui,cmd.toLatin1()); if (supportPart(obj, elements[2])) { - cmd = QString::fromLatin1("elt = App.getDocument(\"%1\").getObject(\"%2\").%3.%4") + cmd = QString::fromLatin1(R"(elt = App.getDocument("%1").getObject("%2").%3.%4)") .arg(elements[0], elements[1], property, elements[2]); Gui::Command::runCommand(Gui::Command::Gui,cmd.toLatin1()); } @@ -512,7 +512,7 @@ void SelectionView::showPart() if (!module.isEmpty() && !property.isEmpty() && supportPart(obj, elements[2])) { try { Gui::Command::addModule(Gui::Command::Gui, module.toLatin1()); - QString cmd = QString::fromLatin1("%1.show(App.getDocument(\"%2\").getObject(\"%3\").%4.%5)") + QString cmd = QString::fromLatin1(R"(%1.show(App.getDocument("%2").getObject("%3").%4.%5))") .arg(module, elements[0], elements[1], property, elements[2]); Gui::Command::runCommand(Gui::Command::Gui,cmd.toLatin1()); } diff --git a/src/Gui/SoFCDB.cpp b/src/Gui/SoFCDB.cpp index 24fccc844b..deac328c32 100644 --- a/src/Gui/SoFCDB.cpp +++ b/src/Gui/SoFCDB.cpp @@ -592,7 +592,7 @@ void Gui::SoFCDB::writeX3D(SoVRMLGroup* node, bool exportViewpoints, std::ostrea << "\" centerOfRotation=\"" << cnt[0] << " " << cnt[1] << " " << cnt[2] << "\" position=\"" << pos[0] << " " << pos[1] << " " << pos[2] << "\" orientation=\"" << axis[0] << " " << axis[1] << " " << axis[2] << " " << angle - << "\" description=\"camera\" fieldOfView=\"0.9\">" + << R"(" description="camera" fieldOfView="0.9">)" << "\n"; }; diff --git a/src/Gui/SoFCVectorizeSVGAction.cpp b/src/Gui/SoFCVectorizeSVGAction.cpp index 3f70660331..f3ca2a172b 100644 --- a/src/Gui/SoFCVectorizeSVGAction.cpp +++ b/src/Gui/SoFCVectorizeSVGAction.cpp @@ -402,11 +402,11 @@ SoFCVectorizeSVGAction::getSVGOutput() const void SoFCVectorizeSVGAction::printHeader() const { std::ostream& str = this->getSVGOutput()->getFileStream(); - str << "" << std::endl; + str << R"()" << std::endl; str << "" << std::endl; str << "getOrientation() == LANDSCAPE) { diff --git a/src/Gui/Splashscreen.cpp b/src/Gui/Splashscreen.cpp index 1f2a6e355a..8d4b48017e 100644 --- a/src/Gui/Splashscreen.cpp +++ b/src/Gui/Splashscreen.cpp @@ -204,7 +204,7 @@ public: } else { // ignore activation of commands - rx.setPattern(QLatin1String("^\\s*(\\+App::|Create|CmdC:|CmdG:|Act:)\\s*")); + rx.setPattern(QLatin1String(R"(^\s*(\+App::|Create|CmdC:|CmdG:|Act:)\s*)")); match = rx.match(msg); if (match.hasMatch() && match.capturedStart() == 0) return; diff --git a/src/Mod/Mesh/App/Core/IO/ReaderOBJ.cpp b/src/Mod/Mesh/App/Core/IO/ReaderOBJ.cpp index ed60f41e22..4c01424e80 100644 --- a/src/Mod/Mesh/App/Core/IO/ReaderOBJ.cpp +++ b/src/Mod/Mesh/App/Core/IO/ReaderOBJ.cpp @@ -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*$"); diff --git a/src/Mod/Mesh/App/Core/MeshIO.cpp b/src/Mod/Mesh/App/Core/MeshIO.cpp index ddea25b813..d85c5c743e 100644 --- a/src/Mod/Mesh/App/Core/MeshIO.cpp +++ b/src/Mod/Mesh/App/Core/MeshIO.cpp @@ -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 << "\n"; out << " \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">)" << "\n"; }; diff --git a/src/Mod/Part/Gui/Command.cpp b/src/Mod/Part/Gui/Command.cpp index b057ef4a81..b6497236fe 100644 --- a/src/Mod/Part/Gui/Command.cpp +++ b/src/Mod/Part/Gui/Command.cpp @@ -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() << ", "; } diff --git a/src/Mod/Part/Gui/Mirroring.cpp b/src/Mod/Part/Gui/Mirroring.cpp index 1841f678df..335df72fc5 100644 --- a/src/Mod/Part/Gui/Mirroring.cpp +++ b/src/Mod/Part/Gui/Mirroring.cpp @@ -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 items = ui->shapes->selectedItems(); float normx=0, normy=0, normz=0; int index = ui->comboBox->currentIndex(); diff --git a/src/Mod/PartDesign/Gui/TaskSketchBasedParameters.cpp b/src/Mod/PartDesign/Gui/TaskSketchBasedParameters.cpp index 668fc3663f..b866fb728e 100644 --- a/src/Mod/PartDesign/Gui/TaskSketchBasedParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskSketchBasedParameters.cpp @@ -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); } diff --git a/src/Mod/ReverseEngineering/Gui/FitBSplineSurface.cpp b/src/Mod/ReverseEngineering/Gui/FitBSplineSurface.cpp index d2d38fc790..f1f87e6a0f 100644 --- a/src/Mod/ReverseEngineering/Gui/FitBSplineSurface.cpp +++ b/src/Mod/ReverseEngineering/Gui/FitBSplineSurface.cpp @@ -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"); diff --git a/src/Mod/Spreadsheet/App/PropertySheet.cpp b/src/Mod/Spreadsheet/App/PropertySheet.cpp index 0a13b5f783..0bdb77ce99 100644 --- a/src/Mod/Spreadsheet/App/PropertySheet.cpp +++ b/src/Mod/Spreadsheet/App/PropertySheet.cpp @@ -373,7 +373,7 @@ void PropertySheet::Save(Base::Writer &writer) const } writer.Stream() << writer.ind() << "" << std::endl; + << R"(" xlink="1">)" << std::endl; writer.incInd();