From: Andrei Pavel Date: Tue, 1 Nov 2022 14:13:25 +0000 (+0200) Subject: [#2601] remove std:: prefix from .cc files X-Git-Tag: Kea-2.3.3~21 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d6f69df968fee22415cd7254b7b9cb43335a8bc9;p=thirdparty%2Fkea.git [#2601] remove std:: prefix from .cc files --- diff --git a/src/bin/netconf/http_control_socket.cc b/src/bin/netconf/http_control_socket.cc index cf90ebfc32..03adb0740b 100644 --- a/src/bin/netconf/http_control_socket.cc +++ b/src/bin/netconf/http_control_socket.cc @@ -73,7 +73,7 @@ HttpControlSocket::sendCommand(ConstElementPtr command) { request->setBodyAsJson(command); try { request->finalize(); - } catch (const std::exception& ex) { + } catch (exception const& ex) { isc_throw(ControlSocketError, "failed to create request: " << ex.what()); } @@ -120,7 +120,7 @@ HttpControlSocket::sendCommand(ConstElementPtr command) { try { return (response->getBodyAsJson()); - } catch (const std::exception& ex) { + } catch (exception const& ex) { isc_throw(ControlSocketError, "unparsable response: " << ex.what()); } } diff --git a/src/bin/netconf/main.cc b/src/bin/netconf/main.cc index 24baae91fe..4abb4414db 100644 --- a/src/bin/netconf/main.cc +++ b/src/bin/netconf/main.cc @@ -15,6 +15,8 @@ using namespace isc::netconf; using namespace isc::process; +using namespace std; + int main(int argc, char* argv[]) { int ret = EXIT_SUCCESS; @@ -27,21 +29,21 @@ int main(int argc, char* argv[]) { // 'false' value disables test mode. controller->launch(argc, argv, false); } catch (const VersionMessage& ex) { - std::string msg(ex.what()); + string msg(ex.what()); if (!msg.empty()) { - std::cout << msg << std::endl; + cout << msg << endl; } } catch (const InvalidUsage& ex) { - std::string msg(ex.what()); + string msg(ex.what()); if (!msg.empty()) { - std::cerr << msg << std::endl; + cerr << msg << endl; } ret = EXIT_FAILURE; - } catch (const std::exception& ex) { - std::cerr << "Service failed: " << ex.what() << std::endl; + } catch (exception const& ex) { + cerr << "Service failed: " << ex.what() << endl; ret = EXIT_FAILURE; } catch (...) { - std::cerr << "Service failed" << std::endl; + cerr << "Service failed" << endl; ret = EXIT_FAILURE; } diff --git a/src/bin/netconf/netconf.cc b/src/bin/netconf/netconf.cc index 407828197f..50f3f9ef82 100644 --- a/src/bin/netconf/netconf.cc +++ b/src/bin/netconf/netconf.cc @@ -197,7 +197,7 @@ NetconfAgent::keaConfig(const CfgServersMapPair& service_pair) { ControlSocketBasePtr comm; try { comm = controlSocketFactory(ctrl_sock); - } catch (const std::exception& ex) { + } catch (exception const& ex) { ostringstream msg; msg << "createControlSocket failed with " << ex.what(); LOG_ERROR(netconf_logger, NETCONF_GET_CONFIG_FAILED) @@ -213,7 +213,7 @@ NetconfAgent::keaConfig(const CfgServersMapPair& service_pair) { try { answer = comm->configGet(server); config = parseAnswer(rcode, answer); - } catch (const std::exception& ex) { + } catch (exception const& ex) { ostringstream msg; msg << "config-get command failed with " << ex.what(); LOG_ERROR(netconf_logger, NETCONF_GET_CONFIG_FAILED) @@ -248,7 +248,7 @@ NetconfAgent::initSysrepo() { running_sess_->switchDatastore(Datastore::Running); startup_sess_ = Connection{}.sessionStart(); startup_sess_->switchDatastore(Datastore::Startup); - } catch (const std::exception& ex) { + } catch (exception const& ex) { isc_throw(Unexpected, "Can't establish a sysrepo session: " << ex.what()); } @@ -374,7 +374,7 @@ NetconfAgent::yangConfig(const CfgServersMapPair& service_pair) { .arg(server) .arg(prettyPrint(config)); } - } catch (const std::exception& ex) { + } catch (exception const& ex) { ostringstream msg; msg << "get YANG configuration for " << server << " failed with " << ex.what(); @@ -386,7 +386,7 @@ NetconfAgent::yangConfig(const CfgServersMapPair& service_pair) { ControlSocketBasePtr comm; try { comm = controlSocketFactory(ctrl_sock); - } catch (const std::exception& ex) { + } catch (exception const& ex) { ostringstream msg; msg << "control socket creation failed with " << ex.what(); LOG_ERROR(netconf_logger, NETCONF_SET_CONFIG_FAILED) @@ -399,7 +399,7 @@ NetconfAgent::yangConfig(const CfgServersMapPair& service_pair) { try { answer = comm->configSet(config, server); parseAnswer(rcode, answer); - } catch (const std::exception& ex) { + } catch (exception const& ex) { ostringstream msg; msg << "config-set command failed with " << ex.what(); LOG_ERROR(netconf_logger, NETCONF_SET_CONFIG_FAILED) @@ -448,9 +448,9 @@ NetconfAgent::subscribeToDataChanges(const CfgServersMapPair& service_pair) { options = options | SubscribeOptions::DoneOnly; } Subscription subscription( - running_sess_->onModuleChange(model, callback, std::nullopt, 0, options)); + running_sess_->onModuleChange(model, callback, nullopt, 0, options)); subscriptions_.emplace(server, forward(subscription)); - } catch (const std::exception& ex) { + } catch (exception const& ex) { ostringstream msg; msg << "module change subscribe failed with " << ex.what(); msg << "change subscription for model " << model << @@ -490,7 +490,7 @@ NetconfAgent::subscribeToNotifications(const CfgServersMapPair& service_pair) { try { Subscription subscription(running_sess_->onNotification(model, callback)); subscriptions_.emplace(server, forward(subscription)); - } catch (const std::exception& ex) { + } catch (exception const& ex) { ostringstream msg; msg << "event notification subscription for model " << model << " failed with: " << ex.what(); @@ -540,7 +540,7 @@ NetconfAgent::change(Session sess, const CfgServersMapPair& service_pair) { .arg(server) .arg(prettyPrint(config)); } - } catch (const std::exception& ex) { + } catch (exception const& ex) { ostringstream msg; msg << "get YANG configuration for " << server << " failed with " << ex.what(); @@ -552,7 +552,7 @@ NetconfAgent::change(Session sess, const CfgServersMapPair& service_pair) { ControlSocketBasePtr comm; try { comm = controlSocketFactory(ctrl_sock); - } catch (const std::exception& ex) { + } catch (exception const& ex) { ostringstream msg; msg << "createControlSocket failed with " << ex.what(); LOG_ERROR(netconf_logger, NETCONF_VALIDATE_CONFIG_FAILED) @@ -565,7 +565,7 @@ NetconfAgent::change(Session sess, const CfgServersMapPair& service_pair) { try { answer = comm->configTest(config, server); parseAnswer(rcode, answer); - } catch (const std::exception& ex) { + } catch (exception const& ex) { stringstream msg; msg << "configTest failed with " << ex.what(); LOG_ERROR(netconf_logger, NETCONF_VALIDATE_CONFIG_FAILED) @@ -626,7 +626,7 @@ NetconfAgent::done(Session sess, const CfgServersMapPair& service_pair) { .arg(server) .arg(prettyPrint(config)); } - } catch (const std::exception& ex) { + } catch (exception const& ex) { ostringstream msg; msg << "get YANG configuration for " << server << " failed with " << ex.what(); @@ -641,7 +641,7 @@ NetconfAgent::done(Session sess, const CfgServersMapPair& service_pair) { ControlSocketBasePtr comm; try { comm = controlSocketFactory(ctrl_sock); - } catch (const std::exception& ex) { + } catch (exception const& ex) { ostringstream msg; msg << "createControlSocket failed with " << ex.what(); LOG_ERROR(netconf_logger, NETCONF_UPDATE_CONFIG_FAILED) @@ -656,7 +656,7 @@ NetconfAgent::done(Session sess, const CfgServersMapPair& service_pair) { try { answer = comm->configSet(config, server); parseAnswer(rcode, answer); - } catch (const std::exception& ex) { + } catch (exception const& ex) { stringstream msg; msg << "configSet failed with " << ex.what(); LOG_ERROR(netconf_logger, NETCONF_UPDATE_CONFIG_FAILED) @@ -683,7 +683,7 @@ void NetconfAgent::logChanges(Session sess, string_view const& model) { ostringstream stream; stream << "/" << model << ":*//."; - std::string const xpath(stream.str()); + string const xpath(stream.str()); ChangeCollection const changes(sess.getChanges(xpath)); for (Change const& change : changes) { ostringstream msg; diff --git a/src/bin/netconf/netconf_cfg_mgr.cc b/src/bin/netconf/netconf_cfg_mgr.cc index f9f9512f5b..888fa3dcac 100644 --- a/src/bin/netconf/netconf_cfg_mgr.cc +++ b/src/bin/netconf/netconf_cfg_mgr.cc @@ -21,6 +21,8 @@ using namespace isc::dhcp; using namespace isc::process; using namespace isc::data; +using namespace std; + namespace isc { namespace netconf { @@ -41,7 +43,7 @@ NetconfConfig::extractConfiguredGlobals(ConstElementPtr config) { "extractConfiguredGlobals must be given a map element"); } - const std::map& values = config->mapValue(); + const map& values = config->mapValue(); for (auto value = values.begin(); value != values.end(); ++value) { if (value->second->getType() != Element::list && value->second->getType() != Element::map) { @@ -54,13 +56,13 @@ NetconfCfgMgr::NetconfCfgMgr() : DCfgMgrBase(ConfigPtr(new NetconfConfig())) { } -std::string +string NetconfCfgMgr::getConfigSummary(const uint32_t /*selection*/) { NetconfConfigPtr ctx = getNetconfConfig(); // No globals to print. - std::ostringstream s; + ostringstream s; // Then print managed servers. for (auto serv : *ctx->getCfgServersMap()) { @@ -109,7 +111,7 @@ NetconfCfgMgr::parse(isc::data::ConstElementPtr config_set, // And parse the configuration. ConstElementPtr answer; - std::string excuse; + string excuse; try { // Do the actual parsing NetconfSimpleParser parser; @@ -165,9 +167,9 @@ NetconfConfig::toElement() const { return (result); } -std::list> +list> NetconfCfgMgr::jsonPathsToRedact() const { - static std::list> const list({ + static list> const list({ {"hooks-libraries", "[]", "parameters", "*"}, }); return list; diff --git a/src/bin/netconf/netconf_config.cc b/src/bin/netconf/netconf_config.cc index b3ed215051..eac9ce5cb0 100644 --- a/src/bin/netconf/netconf_config.cc +++ b/src/bin/netconf/netconf_config.cc @@ -141,7 +141,7 @@ ControlSocketConfigParser::parse(ConstElementPtr ctrl_sock_config) { CfgControlSocket::Type type; try { type = CfgControlSocket::stringToType(type_str); - } catch (const std::exception& ex) { + } catch (exception const& ex) { isc_throw(ConfigError, ex.what() << " '" << type_str << "' (" << getPosition("socket-type", ctrl_sock_config) << ")"); } @@ -157,7 +157,7 @@ ControlSocketConfigParser::parse(ConstElementPtr ctrl_sock_config) { // Create the control socket. try { result.reset(new CfgControlSocket(type, name, url)); - } catch (const std::exception& ex) { + } catch (exception const& ex) { isc_throw(ConfigError, ex.what() << " (" << ctrl_sock_config->getPosition() << ")"); } @@ -185,7 +185,7 @@ ServerConfigParser::parse(ConstElementPtr server_config) { } try { result.reset(new CfgServer(model, ctrl_sock)); - } catch (const std::exception& ex) { + } catch (exception const& ex) { isc_throw(ConfigError, ex.what() << " (" << server_config->getPosition() << ")"); } diff --git a/src/bin/netconf/netconf_controller.cc b/src/bin/netconf/netconf_controller.cc index 4fcc771509..3149543bd4 100644 --- a/src/bin/netconf/netconf_controller.cc +++ b/src/bin/netconf/netconf_controller.cc @@ -54,7 +54,7 @@ NetconfController::createProcess() { } isc::data::ConstElementPtr -NetconfController::parseFile(const std::string& name) { +NetconfController::parseFile(string const& name) { ParserContext parser; return (parser.parseFile(name, ParserContext::PARSER_NETCONF)); } diff --git a/src/bin/netconf/netconf_parser.cc b/src/bin/netconf/netconf_parser.cc index 3587cbcdf8..c113378b02 100644 --- a/src/bin/netconf/netconf_parser.cc +++ b/src/bin/netconf/netconf_parser.cc @@ -228,7 +228,7 @@ namespace isc { namespace netconf { break; case symbol_kind::S_STRING: // "constant string" - value.YY_MOVE_OR_COPY< std::string > (YY_MOVE (that.value)); + value.YY_MOVE_OR_COPY< string > (YY_MOVE (that.value)); break; default: @@ -265,7 +265,7 @@ namespace isc { namespace netconf { break; case symbol_kind::S_STRING: // "constant string" - value.move< std::string > (YY_MOVE (that.value)); + value.move< string > (YY_MOVE (that.value)); break; default: @@ -302,7 +302,7 @@ namespace isc { namespace netconf { break; case symbol_kind::S_STRING: // "constant string" - value.copy< std::string > (that.value); + value.copy< string > (that.value); break; default: @@ -338,7 +338,7 @@ namespace isc { namespace netconf { break; case symbol_kind::S_STRING: // "constant string" - value.move< std::string > (that.value); + value.move< string > (that.value); break; default: @@ -379,7 +379,7 @@ namespace isc { namespace netconf { { case symbol_kind::S_STRING: // "constant string" #line 110 "netconf_parser.yy" - { yyoutput << yysym.value.template as < std::string > (); } + { yyoutput << yysym.value.template as < string > (); } #line 384 "netconf_parser.cc" break; @@ -665,7 +665,7 @@ namespace isc { namespace netconf { break; case symbol_kind::S_STRING: // "constant string" - yylhs.value.emplace< std::string > (); + yylhs.value.emplace< string > (); break; default: @@ -753,7 +753,7 @@ namespace isc { namespace netconf { case 14: // value: "constant string" #line 151 "netconf_parser.yy" - { yylhs.value.as < ElementPtr > () = ElementPtr(new StringElement(yystack_[0].value.as < std::string > (), ctx.loc2pos(yystack_[0].location))); } + { yylhs.value.as < ElementPtr > () = ElementPtr(new StringElement(yystack_[0].value.as < string > (), ctx.loc2pos(yystack_[0].location))); } #line 758 "netconf_parser.cc" break; @@ -806,8 +806,8 @@ namespace isc { namespace netconf { #line 183 "netconf_parser.yy" { // map containing a single entry - ctx.unique(yystack_[2].value.as < std::string > (), ctx.loc2pos(yystack_[2].location)); - ctx.stack_.back()->set(yystack_[2].value.as < std::string > (), yystack_[0].value.as < ElementPtr > ()); + ctx.unique(yystack_[2].value.as < string > (), ctx.loc2pos(yystack_[2].location)); + ctx.stack_.back()->set(yystack_[2].value.as < string > (), yystack_[0].value.as < ElementPtr > ()); } #line 813 "netconf_parser.cc" break; @@ -817,8 +817,8 @@ namespace isc { namespace netconf { { // map consisting of a shorter map followed by // comma and string:value - ctx.unique(yystack_[2].value.as < std::string > (), ctx.loc2pos(yystack_[2].location)); - ctx.stack_.back()->set(yystack_[2].value.as < std::string > (), yystack_[0].value.as < ElementPtr > ()); + ctx.unique(yystack_[2].value.as < string > (), ctx.loc2pos(yystack_[2].location)); + ctx.stack_.back()->set(yystack_[2].value.as < string > (), yystack_[0].value.as < ElementPtr > ()); } #line 824 "netconf_parser.cc" break; @@ -876,8 +876,8 @@ namespace isc { namespace netconf { case 33: // unknown_map_entry: "constant string" ":" #line 229 "netconf_parser.yy" { - const std::string& where = ctx.contextName(); - const std::string& keyword = yystack_[1].value.as < std::string > (); + const string& where = ctx.contextName(); + const string& keyword = yystack_[1].value.as < string > (); error(yystack_[1].location, "got unexpected keyword \"" + keyword + "\" in " + where + " map."); } @@ -999,7 +999,7 @@ namespace isc { namespace netconf { if (old) { // Check if it was a comment or a duplicate if ((old->size() != 1) || !old->contains("comment")) { - std::stringstream msg; + stringstream msg; msg << "duplicate user-context entries (previous at " << old->getPosition().str() << ")"; error(yystack_[3].location, msg.str()); @@ -1028,7 +1028,7 @@ namespace isc { namespace netconf { { ElementPtr parent = ctx.stack_.back(); ElementPtr user_context(new MapElement(ctx.loc2pos(yystack_[3].location))); - ElementPtr comment(new StringElement(yystack_[0].value.as < std::string > (), ctx.loc2pos(yystack_[0].location))); + ElementPtr comment(new StringElement(yystack_[0].value.as < string > (), ctx.loc2pos(yystack_[0].location))); user_context->set("comment", comment); // Handle already existing user context @@ -1036,7 +1036,7 @@ namespace isc { namespace netconf { if (old) { // Check for duplicate comment if (old->contains("comment")) { - std::stringstream msg; + stringstream msg; msg << "duplicate user-context/comment entries (previous at " << old->getPosition().str() << ")"; error(yystack_[3].location, msg.str()); @@ -1119,7 +1119,7 @@ namespace isc { namespace netconf { case 77: // library: "library" $@13 ":" "constant string" #line 415 "netconf_parser.yy" { - ElementPtr lib(new StringElement(yystack_[0].value.as < std::string > (), ctx.loc2pos(yystack_[0].location))); + ElementPtr lib(new StringElement(yystack_[0].value.as < string > (), ctx.loc2pos(yystack_[0].location))); ctx.stack_.back()->set("library", lib); ctx.leave(); } @@ -1277,7 +1277,7 @@ namespace isc { namespace netconf { case 112: // model: "model" $@20 ":" "constant string" #line 535 "netconf_parser.yy" { - ElementPtr model(new StringElement(yystack_[0].value.as < std::string > (), ctx.loc2pos(yystack_[0].location))); + ElementPtr model(new StringElement(yystack_[0].value.as < string > (), ctx.loc2pos(yystack_[0].location))); ctx.stack_.back()->set("model", model); ctx.leave(); } @@ -1361,7 +1361,7 @@ namespace isc { namespace netconf { case 130: // socket_name: "socket-name" $@23 ":" "constant string" #line 586 "netconf_parser.yy" { - ElementPtr name(new StringElement(yystack_[0].value.as < std::string > (), ctx.loc2pos(yystack_[0].location))); + ElementPtr name(new StringElement(yystack_[0].value.as < string > (), ctx.loc2pos(yystack_[0].location))); ctx.stack_.back()->set("socket-name", name); ctx.leave(); } @@ -1380,7 +1380,7 @@ namespace isc { namespace netconf { case 132: // socket_url: "socket-url" $@24 ":" "constant string" #line 596 "netconf_parser.yy" { - ElementPtr url(new StringElement(yystack_[0].value.as < std::string > (), ctx.loc2pos(yystack_[0].location))); + ElementPtr url(new StringElement(yystack_[0].value.as < string > (), ctx.loc2pos(yystack_[0].location))); ctx.stack_.back()->set("socket-url", url); ctx.leave(); } @@ -1454,7 +1454,7 @@ namespace isc { namespace netconf { case 151: // name: "name" $@27 ":" "constant string" #line 654 "netconf_parser.yy" { - ElementPtr name(new StringElement(yystack_[0].value.as < std::string > (), ctx.loc2pos(yystack_[0].location))); + ElementPtr name(new StringElement(yystack_[0].value.as < string > (), ctx.loc2pos(yystack_[0].location))); ctx.stack_.back()->set("name", name); ctx.leave(); } @@ -1483,7 +1483,7 @@ namespace isc { namespace netconf { case 154: // severity: "severity" $@28 ":" "constant string" #line 669 "netconf_parser.yy" { - ElementPtr sev(new StringElement(yystack_[0].value.as < std::string > (), ctx.loc2pos(yystack_[0].location))); + ElementPtr sev(new StringElement(yystack_[0].value.as < string > (), ctx.loc2pos(yystack_[0].location))); ctx.stack_.back()->set("severity", sev); ctx.leave(); } @@ -1557,7 +1557,7 @@ namespace isc { namespace netconf { case 171: // output: "output" $@31 ":" "constant string" #line 718 "netconf_parser.yy" { - ElementPtr sev(new StringElement(yystack_[0].value.as < std::string > (), ctx.loc2pos(yystack_[0].location))); + ElementPtr sev(new StringElement(yystack_[0].value.as < string > (), ctx.loc2pos(yystack_[0].location))); ctx.stack_.back()->set("output", sev); ctx.leave(); } @@ -1606,7 +1606,7 @@ namespace isc { namespace netconf { case 176: // pattern: "pattern" $@32 ":" "constant string" #line 745 "netconf_parser.yy" { - ElementPtr sev(new StringElement(yystack_[0].value.as < std::string > (), ctx.loc2pos(yystack_[0].location))); + ElementPtr sev(new StringElement(yystack_[0].value.as < string > (), ctx.loc2pos(yystack_[0].location))); ctx.stack_.back()->set("pattern", sev); ctx.leave(); } @@ -2306,7 +2306,6 @@ namespace isc { namespace netconf { void isc::netconf::NetconfParser::error(const location_type& loc, - const std::string& what) -{ + const string& what) { ctx.error(loc, what); } diff --git a/src/bin/netconf/netconf_parser.h b/src/bin/netconf/netconf_parser.h index c465ecbaf0..54266fac8e 100644 --- a/src/bin/netconf/netconf_parser.h +++ b/src/bin/netconf/netconf_parser.h @@ -442,7 +442,7 @@ namespace isc { namespace netconf { char dummy4[sizeof (int64_t)]; // "constant string" - char dummy5[sizeof (std::string)]; + char dummy5[sizeof (string)]; }; /// The size of the largest semantic type. @@ -763,7 +763,7 @@ namespace isc { namespace netconf { break; case symbol_kind::S_STRING: // "constant string" - value.move< std::string > (std::move (that.value)); + value.move< string > (std::move (that.value)); break; default: @@ -846,13 +846,13 @@ namespace isc { namespace netconf { #endif #if 201103L <= YY_CPLUSPLUS - basic_symbol (typename Base::kind_type t, std::string&& v, location_type&& l) + basic_symbol (typename Base::kind_type t, string&& v, location_type&& l) : Base (t) , value (std::move (v)) , location (std::move (l)) {} #else - basic_symbol (typename Base::kind_type t, const std::string& v, const location_type& l) + basic_symbol (typename Base::kind_type t, const string& v, const location_type& l) : Base (t) , value (v) , location (l) @@ -902,7 +902,7 @@ switch (yykind) break; case symbol_kind::S_STRING: // "constant string" - value.template destroy< std::string > (); + value.template destroy< string > (); break; default: @@ -1043,10 +1043,10 @@ switch (yykind) #endif } #if 201103L <= YY_CPLUSPLUS - symbol_type (int tok, std::string v, location_type l) + symbol_type (int tok, string v, location_type l) : super_type (token_kind_type (tok), std::move (v), std::move (l)) #else - symbol_type (int tok, const std::string& v, const location_type& l) + symbol_type (int tok, const string& v, const location_type& l) : super_type (token_kind_type (tok), v, l) #endif { @@ -1780,14 +1780,14 @@ switch (yykind) #if 201103L <= YY_CPLUSPLUS static symbol_type - make_STRING (std::string v, location_type l) + make_STRING (string v, location_type l) { return symbol_type (token::TOKEN_STRING, std::move (v), std::move (l)); } #else static symbol_type - make_STRING (const std::string& v, const location_type& l) + make_STRING (const string& v, const location_type& l) { return symbol_type (token::TOKEN_STRING, v, l); } @@ -2259,7 +2259,7 @@ switch (yykind) break; case symbol_kind::S_STRING: // "constant string" - value.copy< std::string > (YY_MOVE (that.value)); + value.copy< string > (YY_MOVE (that.value)); break; default: @@ -2312,7 +2312,7 @@ switch (yykind) break; case symbol_kind::S_STRING: // "constant string" - value.move< std::string > (YY_MOVE (s.value)); + value.move< string > (YY_MOVE (s.value)); break; default: diff --git a/src/bin/netconf/netconf_parser.yy b/src/bin/netconf/netconf_parser.yy index cc2d9684b8..1bfe87e52d 100644 --- a/src/bin/netconf/netconf_parser.yy +++ b/src/bin/netconf/netconf_parser.yy @@ -98,7 +98,7 @@ using namespace std; START_SUB_NETCONF ; -%token STRING "constant string" +%token STRING "constant string" %token INTEGER "integer" %token FLOAT "floating point" %token BOOLEAN "boolean" @@ -227,8 +227,8 @@ not_empty_list: value { // if you want to have a nice expression printed when unknown (mistyped?) // parameter is found. unknown_map_entry: STRING COLON { - const std::string& where = ctx.contextName(); - const std::string& keyword = $1; + const string& where = ctx.contextName(); + const string& keyword = $1; error(@1, "got unexpected keyword \"" + keyword + "\" in " + where + " map."); }; @@ -325,7 +325,7 @@ user_context: USER_CONTEXT { if (old) { // Check if it was a comment or a duplicate if ((old->size() != 1) || !old->contains("comment")) { - std::stringstream msg; + stringstream msg; msg << "duplicate user-context entries (previous at " << old->getPosition().str() << ")"; error(@1, msg.str()); @@ -352,7 +352,7 @@ comment: COMMENT { if (old) { // Check for duplicate comment if (old->contains("comment")) { - std::stringstream msg; + stringstream msg; msg << "duplicate user-context/comment entries (previous at " << old->getPosition().str() << ")"; error(@1, msg.str()); @@ -752,7 +752,6 @@ pattern: PATTERN { void isc::netconf::NetconfParser::error(const location_type& loc, - const std::string& what) -{ + const string& what) { ctx.error(loc, what); } diff --git a/src/bin/netconf/parser_context.cc b/src/bin/netconf/parser_context.cc index 0fad211472..f52675f8e5 100644 --- a/src/bin/netconf/parser_context.cc +++ b/src/bin/netconf/parser_context.cc @@ -29,14 +29,14 @@ ParserContext::~ParserContext() } isc::data::ElementPtr -ParserContext::parseString(const std::string& str, ParserType parser_type) +ParserContext::parseString(string const& str, ParserType parser_type) { scanStringBegin(str, parser_type); return (parseCommon()); } isc::data::ElementPtr -ParserContext::parseFile(const std::string& filename, ParserType parser_type) { +ParserContext::parseFile(string const& filename, ParserType parser_type) { FILE* f = fopen(filename.c_str(), "r"); if (!f) { isc_throw(ParseError, "Unable to open file " << filename); @@ -72,7 +72,7 @@ ParserContext::parseCommon() { void ParserContext::error(const isc::netconf::location& loc, - const std::string& what, + string const& what, size_t pos) { if (pos == 0) { @@ -83,13 +83,13 @@ ParserContext::error(const isc::netconf::location& loc, } void -ParserContext::error(const std::string& what) +ParserContext::error(string const& what) { isc_throw(ParseError, what); } void -ParserContext::fatal(const std::string& what) +ParserContext::fatal(string const& what) { isc_throw(ParseError, what); } @@ -97,14 +97,14 @@ ParserContext::fatal(const std::string& what) isc::data::Element::Position ParserContext::loc2pos(isc::netconf::location& loc) { - const std::string& file = *loc.begin.filename; + string const& file = *loc.begin.filename; const uint32_t line = loc.begin.line; const uint32_t pos = loc.begin.column; return (isc::data::Element::Position(file, line, pos)); } void -ParserContext::require(const std::string& name, +ParserContext::require(string const& name, isc::data::Element::Position open_loc, isc::data::Element::Position close_loc) { @@ -119,7 +119,7 @@ ParserContext::require(const std::string& name, } void -ParserContext::unique(const std::string& name, +ParserContext::unique(string const& name, isc::data::Element::Position loc) { ConstElementPtr value = stack_.back()->get(name); @@ -153,7 +153,7 @@ ParserContext::leave() cstack_.pop_back(); } -const std::string +string const ParserContext::contextName() { switch (ctx_) { @@ -184,8 +184,8 @@ ParserContext::contextName() void ParserContext::warning(const isc::netconf::location& loc, - const std::string& what) { - std::ostringstream msg; + string const& what) { + ostringstream msg; msg << loc << ": " << what; LOG_WARN(netconf_logger, NETCONF_CONFIG_SYNTAX_WARNING) .arg(msg.str()); diff --git a/src/bin/netconf/tests/control_socket_unittests.cc b/src/bin/netconf/tests/control_socket_unittests.cc index d9ba2f24e8..763c853097 100644 --- a/src/bin/netconf/tests/control_socket_unittests.cc +++ b/src/bin/netconf/tests/control_socket_unittests.cc @@ -846,7 +846,7 @@ TEST_F(HttpControlSocketTest, partial) { ConstElementPtr json = Element::fromJSON("{ \"want-partial\": true }"); // Warn this makes time. - cout << "this test waits for 2 seconds" << endl; + cout << "Waiting 2s..." << endl; // Try configSet: it should get a communication error, try { diff --git a/src/bin/netconf/tests/parser_unittests.cc b/src/bin/netconf/tests/parser_unittests.cc index be0a0a848e..2c1e0bef6a 100644 --- a/src/bin/netconf/tests/parser_unittests.cc +++ b/src/bin/netconf/tests/parser_unittests.cc @@ -908,7 +908,7 @@ TEST(ParserTest, duplicateMapEntries) { }; size_t cnt = 0; test(sample_json, sample_json, cnt); - cout << "checked " << cnt << " duplicated map entries\n"; + cout << "Checked " << cnt << " duplicated map entries.\n"; } /// @brief Test fixture for trailing commas. diff --git a/src/bin/netconf/unix_control_socket.cc b/src/bin/netconf/unix_control_socket.cc index 480b74ad96..e5495dda99 100644 --- a/src/bin/netconf/unix_control_socket.cc +++ b/src/bin/netconf/unix_control_socket.cc @@ -88,7 +88,7 @@ UnixControlSocket::sendCommand(ConstElementPtr command) { try { return (received_feed->toElement()); - } catch (const std::exception& ex) { + } catch (exception const& ex) { isc_throw(ControlSocketError, "unparsable response: " << ex.what()); } } diff --git a/src/lib/yang/adaptor_option.cc b/src/lib/yang/adaptor_option.cc index 4839d844e8..e0405c15b7 100644 --- a/src/lib/yang/adaptor_option.cc +++ b/src/lib/yang/adaptor_option.cc @@ -48,7 +48,7 @@ AdaptorOption::collect(ConstElementPtr option, OptionCodes& codes) { ConstElementPtr code = option->get("code"); string index = space->stringValue() + "@" + name->stringValue(); uint16_t val = static_cast(code->intValue()); - codes.insert(std::pair(index, val)); + codes.insert(pair(index, val)); } } @@ -115,7 +115,7 @@ AdaptorOption::initCodesInternal(OptionCodes& codes, const string& space, size_t params_size) { for (size_t i = 0; i < params_size; ++i) { string index = space + "@" + params[i].name; - codes.insert(std::pair(index, params[i].code)); + codes.insert(pair(index, params[i].code)); } } diff --git a/src/lib/yang/tests/config_unittests.cc b/src/lib/yang/tests/config_unittests.cc index f04b8f6e23..a5c1d17c12 100644 --- a/src/lib/yang/tests/config_unittests.cc +++ b/src/lib/yang/tests/config_unittests.cc @@ -326,7 +326,7 @@ TEST_F(ConfigTestKeaV4, examples4) { for (string file : examples) { resetSession(); string path = string(CFG_EXAMPLES) + "/kea4/" + file; - cout << "Testing file " << path << endl; + SCOPED_TRACE("\n* Tested file: " + path); ConstElementPtr json; ASSERT_NO_THROW_LOG(json = loadFile(path)); json = isc::test::moveComments(json); @@ -368,7 +368,7 @@ TEST_F(ConfigTestKeaV6, examples6) { for (string file : examples) { resetSession(); string path = string(CFG_EXAMPLES) + "/kea6/" + file; - cout << "Testing file " << path << endl; + SCOPED_TRACE("\n* Tested file: " + path); ConstElementPtr json; ASSERT_NO_THROW_LOG(json = loadFile(path)); json = isc::test::moveComments(json); diff --git a/src/lib/yang/translator.cc b/src/lib/yang/translator.cc index c2642c88b3..77e6e13fc5 100644 --- a/src/lib/yang/translator.cc +++ b/src/lib/yang/translator.cc @@ -123,7 +123,7 @@ TranslatorBasic::decode64(string const& input) { } void -TranslatorBasic::deleteItem(const std::string& xpath) { +TranslatorBasic::deleteItem(string const& xpath) { /// @todo: Remove this if convenient. It is not strictly required and only done to detect /// missing schema nodes and throw an exception to keep old behavior. try { @@ -328,7 +328,7 @@ TranslatorBasic::translateToYang(ConstElementPtr const& element, // A null ElementPtr is how we signal that this item requires no value. // Useful when setting YANG lists which is the only way to set their // keys in sysrepo since setting the key itself results in an error. - return std::nullopt; + return nullopt; } else if (element->getType() == Element::map) { /// @todo: implement isc_throw(NotImplemented, "TranslatorBasic::value(): map element"); diff --git a/src/lib/yang/translator_database.cc b/src/lib/yang/translator_database.cc index 1039568af3..74f4b8c771 100644 --- a/src/lib/yang/translator_database.cc +++ b/src/lib/yang/translator_database.cc @@ -161,7 +161,7 @@ TranslatorDatabases::getDatabasesFromAbsoluteXpath(string const& xpath) { } ElementPtr -TranslatorDatabases::getDatabasesKea(DataNode const& data_node, std::string const& xpath) { +TranslatorDatabases::getDatabasesKea(DataNode const& data_node, string const& xpath) { return getList(data_node, xpath, *this, &TranslatorDatabase::getDatabase); } diff --git a/src/lib/yang/translator_host.cc b/src/lib/yang/translator_host.cc index b82670db45..522e3ea480 100644 --- a/src/lib/yang/translator_host.cc +++ b/src/lib/yang/translator_host.cc @@ -42,7 +42,7 @@ TranslatorHost::getHost(DataNode const& data_node) { } ElementPtr -TranslatorHost::getHostFromAbsoluteXpath(std::string const& xpath) { +TranslatorHost::getHostFromAbsoluteXpath(string const& xpath) { try { return getHost(findXPath(xpath)); } catch(NetconfError const&) { @@ -141,7 +141,7 @@ TranslatorHosts::getHosts(DataNode const& data_node) { } ElementPtr -TranslatorHosts::getHostsFromAbsoluteXpath(std::string const& xpath) { +TranslatorHosts::getHostsFromAbsoluteXpath(string const& xpath) { try { return getHosts(findXPath(xpath)); } catch(NetconfError const&) { diff --git a/src/lib/yang/translator_shared_network.cc b/src/lib/yang/translator_shared_network.cc index aff8d460f9..dccc41b9cc 100644 --- a/src/lib/yang/translator_shared_network.cc +++ b/src/lib/yang/translator_shared_network.cc @@ -62,7 +62,7 @@ TranslatorSharedNetwork::getSharedNetworkFromAbsoluteXpath(string const& xpath) ElementPtr TranslatorSharedNetwork::getSharedNetworkKea(DataNode const& data_node, - const std::string& subsel) { + string const& subsel) { ElementPtr result = Element::createMap(); getMandatoryLeaf(result, data_node, "name"); @@ -157,7 +157,7 @@ TranslatorSharedNetwork::setSharedNetwork(string const& xpath, void TranslatorSharedNetwork::setSharedNetworkKea(string const& xpath, ConstElementPtr elem, - const std::string& subsel) { + string const& subsel) { // Skip key "name". checkAndSetLeaf(elem, xpath, "cache-max-age", LeafBaseType::Uint32); diff --git a/src/lib/yang/translator_subnet.cc b/src/lib/yang/translator_subnet.cc index 68cc2b4dee..ed2421338b 100644 --- a/src/lib/yang/translator_subnet.cc +++ b/src/lib/yang/translator_subnet.cc @@ -375,7 +375,7 @@ TranslatorSubnets::getSubnetsFromAbsoluteXpath(string const& xpath) { ElementPtr TranslatorSubnets::getSubnetsCommon(DataNode const& data_node, - const std::string& subsel) { + string const& subsel) { return getList(data_node, subsel, *this, &TranslatorSubnet::getSubnet); } @@ -417,7 +417,7 @@ TranslatorSubnets::setSubnetsIetf6(string const& xpath, ConstElementPtr elem) { void TranslatorSubnets::setSubnetsKea(string const& xpath, ConstElementPtr elem, - const std::string& subsel) { + string const& subsel) { for (size_t i = 0; i < elem->size(); ++i) { ConstElementPtr subnet = elem->get(i); if (!subnet->contains("id")) {