From d6062eefbf918b1a5b1388a4a5f7d7615bd223eb Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Thu, 4 Jan 2018 08:59:00 +0100 Subject: [PATCH] Apply clang-tidy fix 'modernize-raw-string-literal' --- lib/perfdata/elasticsearchwriter.cpp | 2 +- lib/remote/infohandler.cpp | 2 +- test/config-ops.cpp | 22 +++++++++++----------- tools/mkclass/classcompiler.cpp | 12 ++++++------ 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/lib/perfdata/elasticsearchwriter.cpp b/lib/perfdata/elasticsearchwriter.cpp index fdb0b0ce5..4711cd9ac 100644 --- a/lib/perfdata/elasticsearchwriter.cpp +++ b/lib/perfdata/elasticsearchwriter.cpp @@ -358,7 +358,7 @@ void ElasticsearchWriter::Enqueue(const String& type, const Dictionary::Ptr& fie * We do it this way to avoid problems with a near full queue. */ - String indexBody = "{ \"index\" : { \"_type\" : \"" + eventType + "\" } }\n"; + String indexBody = R"({ "index" : { "_type" : ")" + eventType + "\" } }\n"; String fieldsBody = JsonEncode(fields); Log(LogDebug, "ElasticsearchWriter") diff --git a/lib/remote/infohandler.cpp b/lib/remote/infohandler.cpp index c09483692..754948d33 100644 --- a/lib/remote/infohandler.cpp +++ b/lib/remote/infohandler.cpp @@ -98,7 +98,7 @@ bool InfoHandler::HandleRequest(const ApiUser::Ptr& user, HttpRequest& request, } else body += "Your user does not have any permissions.

"; - body += "

More information about API requests is available in the documentation.

"; + body += R"(

More information about API requests is available in the documentation.

)"; response.WriteBody(body.CStr(), body.GetLength()); } diff --git a/test/config-ops.cpp b/test/config-ops.cpp index ac7817d37..c47ab0305 100644 --- a/test/config-ops.cpp +++ b/test/config-ops.cpp @@ -109,34 +109,34 @@ BOOST_AUTO_TEST_CASE(simple) expr = ConfigCompiler::CompileText("", "256 >> 4 >> 3"); BOOST_CHECK(expr->Evaluate(frame).GetValue() == 2); - expr = ConfigCompiler::CompileText("", "\"hello\" == \"hello\""); + expr = ConfigCompiler::CompileText("", R"("hello" == "hello")"); BOOST_CHECK(expr->Evaluate(frame).GetValue()); - expr = ConfigCompiler::CompileText("", "\"hello\" != \"hello\""); + expr = ConfigCompiler::CompileText("", R"("hello" != "hello")"); BOOST_CHECK(!expr->Evaluate(frame).GetValue()); - expr = ConfigCompiler::CompileText("", "\"foo\" in [ \"foo\", \"bar\" ]"); + expr = ConfigCompiler::CompileText("", R"("foo" in [ "foo", "bar" ])"); BOOST_CHECK(expr->Evaluate(frame).GetValue()); - expr = ConfigCompiler::CompileText("", "\"foo\" in [ \"bar\", \"baz\" ]"); + expr = ConfigCompiler::CompileText("", R"("foo" in [ "bar", "baz" ])"); BOOST_CHECK(!expr->Evaluate(frame).GetValue()); expr = ConfigCompiler::CompileText("", "\"foo\" in null"); BOOST_CHECK(!expr->Evaluate(frame).GetValue()); - expr = ConfigCompiler::CompileText("", "\"foo\" in \"bar\""); + expr = ConfigCompiler::CompileText("", R"("foo" in "bar")"); BOOST_CHECK_THROW(expr->Evaluate(frame).GetValue(), ScriptError); - expr = ConfigCompiler::CompileText("", "\"foo\" !in [ \"bar\", \"baz\" ]"); + expr = ConfigCompiler::CompileText("", R"("foo" !in [ "bar", "baz" ])"); BOOST_CHECK(expr->Evaluate(frame).GetValue()); - expr = ConfigCompiler::CompileText("", "\"foo\" !in [ \"foo\", \"bar\" ]"); + expr = ConfigCompiler::CompileText("", R"("foo" !in [ "foo", "bar" ])"); BOOST_CHECK(!expr->Evaluate(frame).GetValue()); expr = ConfigCompiler::CompileText("", "\"foo\" !in null"); BOOST_CHECK(expr->Evaluate(frame).GetValue()); - expr = ConfigCompiler::CompileText("", "\"foo\" !in \"bar\""); + expr = ConfigCompiler::CompileText("", R"("foo" !in "bar")"); BOOST_CHECK_THROW(expr->Evaluate(frame).GetValue(), ScriptError); expr = ConfigCompiler::CompileText("", "{ a += 3 }"); @@ -156,10 +156,10 @@ BOOST_AUTO_TEST_CASE(simple) expr = ConfigCompiler::CompileText("", "\"test\" + 3"); BOOST_CHECK(expr->Evaluate(frame).GetValue() == "test3"); - expr = ConfigCompiler::CompileText("", "\"\\\"te\\\\st\""); + expr = ConfigCompiler::CompileText("", R"("\"te\\st")"); BOOST_CHECK(expr->Evaluate(frame).GetValue() == "\"te\\st"); - expr = ConfigCompiler::CompileText("", "\"\\'test\""); + expr = ConfigCompiler::CompileText("", R"("\'test")"); BOOST_CHECK_THROW(expr->Evaluate(frame).GetValue(), ScriptError); expr = ConfigCompiler::CompileText("", "({ a = 3\nb = 3 })"); @@ -172,7 +172,7 @@ BOOST_AUTO_TEST_CASE(advanced) std::unique_ptr expr; Function::Ptr func; - expr = ConfigCompiler::CompileText("", "regex(\"^Hello\", \"Hello World\")"); + expr = ConfigCompiler::CompileText("", R"(regex("^Hello", "Hello World"))"); BOOST_CHECK(expr->Evaluate(frame).GetValue()); expr = ConfigCompiler::CompileText("", "__boost_test()"); diff --git a/tools/mkclass/classcompiler.cpp b/tools/mkclass/classcompiler.cpp index 3d48c25f5..dca909ae0 100644 --- a/tools/mkclass/classcompiler.cpp +++ b/tools/mkclass/classcompiler.cpp @@ -494,7 +494,7 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo&) else m_Impl << "\t" << "if (" << argName << ".IsEmpty())" << std::endl; - m_Impl << "\t\t" << "BOOST_THROW_EXCEPTION(ValidationError(dynamic_cast(this), { \"" << field.Name << "\" }, \"Attribute must not be empty.\"));" << std::endl << std::endl; + m_Impl << "\t\t" << "BOOST_THROW_EXCEPTION(ValidationError(dynamic_cast(this), { \"" << field.Name << R"(" }, "Attribute must not be empty."));)" << std::endl << std::endl; } if (field.Attributes & FADeprecated) { @@ -503,7 +503,7 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo&) else m_Impl << "\t" << "if (" << argName << " != GetDefault" << field.GetFriendlyName() << "())" << std::endl; - m_Impl << "\t\t" << "Log(LogWarning, \"" << klass.Name << "\") << \"Attribute '" << field.Name << "' for object '\" << dynamic_cast(this)->GetName() << \"' of type '\" << dynamic_cast(this)->GetReflectionType()->GetName() << \"' is deprecated and should not be used.\";" << std::endl; + m_Impl << "\t\t" << "Log(LogWarning, \"" << klass.Name << "\") << \"Attribute '" << field.Name << R"(' for object '" << dynamic_cast(this)->GetName() << "' of type '" << dynamic_cast(this)->GetReflectionType()->GetName() << "' is deprecated and should not be used.";)" << std::endl; } if (field.Type.ArrayRank > 0) { @@ -518,7 +518,7 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo&) m_Impl << "\t" << "if (value.IsObjectType()) {" << std::endl << "\t\t" << "Function::Ptr func = value;" << std::endl << "\t\t" << "if (func->IsDeprecated())" << std::endl - << "\t\t\t" << "Log(LogWarning, \"" << klass.Name << "\") << \"Attribute '" << field.Name << "' for object '\" << dynamic_cast(this)->GetName() << \"' of type '\" << dynamic_cast(this)->GetReflectionType()->GetName() << \"' is set to a deprecated function: \" << func->GetName();" << std::endl + << "\t\t\t" << "Log(LogWarning, \"" << klass.Name << "\") << \"Attribute '" << field.Name << R"(' for object '" << dynamic_cast(this)->GetName() << "' of type '" << dynamic_cast(this)->GetReflectionType()->GetName() << "' is set to a deprecated function: " << func->GetName();)" << std::endl << "\t" << "}" << std::endl << std::endl; } @@ -531,13 +531,13 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo&) m_Impl << "!value.IsEmpty() && "; m_Impl << "!utils.ValidateName(\"" << field.Type.TypeName << "\", value))" << std::endl - << "\t\t" << "BOOST_THROW_EXCEPTION(ValidationError(dynamic_cast(this), { \"" << field.Name << "\" }, \"Object '\" + value + \"' of type '" << field.Type.TypeName + << "\t\t" << "BOOST_THROW_EXCEPTION(ValidationError(dynamic_cast(this), { \"" << field.Name << R"(" }, "Object '" + value + "' of type ')" << field.Type.TypeName << "' does not exist.\"));" << std::endl; } else if (field.Type.ArrayRank > 0 && (ftype == "Number" || ftype == "Boolean")) { m_Impl << "\t" << "try {" << std::endl << "\t\t" << "Convert::ToDouble(value);" << std::endl << "\t" << "} catch (const std::invalid_argument&) {" << std::endl - << "\t\t" << "BOOST_THROW_EXCEPTION(ValidationError(dynamic_cast(this), { \"" << field.Name << "\", \"Array element '\" + value + \"' of type '\" + value.GetReflectionType()->GetName() + \"' is not valid here; expected type '" << ftype << "'.\"));" << std::endl + << "\t\t" << "BOOST_THROW_EXCEPTION(ValidationError(dynamic_cast(this), { \"" << field.Name << R"(", "Array element '" + value + "' of type '" + value.GetReflectionType()->GetName() + "' is not valid here; expected type ')" << ftype << "'.\"));" << std::endl << "\t" << "}" << std::endl; } @@ -1144,7 +1144,7 @@ void ClassCompiler::CodeGenValidator(const std::string& name, const std::string& << "\t\t\t" << "if (utils.ValidateName(\"" << rule.Type << "\", value))" << std::endl << "\t\t\t\t" << "return;" << std::endl << "\t\t\t" << "else" << std::endl - << "\t\t\t\t" << "BOOST_THROW_EXCEPTION(ValidationError(dynamic_pointer_cast(object), location, \"Object '\" + value + \"' of type '" << rule.Type << "' does not exist.\"));" << std::endl + << "\t\t\t\t" << R"(BOOST_THROW_EXCEPTION(ValidationError(dynamic_pointer_cast(object), location, "Object '" + value + "' of type ')" << rule.Type << "' does not exist.\"));" << std::endl << "\t\t" << "}" << std::endl; } -- 2.49.0