From cc8c1ad450667c8f6f983ba4f0d640accdcb49cf Mon Sep 17 00:00:00 2001 From: neodarz Date: Tue, 10 Sep 2019 10:26:16 +0200 Subject: Little refactorisation --- api/umosapi.cpp | 8 +++----- db/uobject.cpp | 4 ++-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/api/umosapi.cpp b/api/umosapi.cpp index 57716e9..f5d7003 100644 --- a/api/umosapi.cpp +++ b/api/umosapi.cpp @@ -146,9 +146,7 @@ void UmosapiService::Api::set_path(std::string route) { void UmosapiService::Api::set_method_handler(std::string http_word, const std::function< void ( const std::shared_ptr< restbed::Session > ) >& callback) { UmosapiService::Api::_resource->set_method_handler(http_word, callback); std::locale loc; - for (auto& c : http_word) { - c = tolower(c); - } + for (auto& c : http_word) { c = tolower(c); } UmosapiService::Api::_path.words.push_back(HttpWord{http_word}); UmosapiService::Api::_swagger["paths"][UmosapiService::Api::_path.name][http_word]["description"] = ""; UmosapiService::Api::_swagger["paths"][UmosapiService::Api::_path.name][http_word]["operationId"] = ""; @@ -160,7 +158,7 @@ void UmosapiService::Api::set_error_handler(const std::function< void(int, const } void UmosapiService::Api::publish() { - for (auto& http_word: UmosapiService::Api::_path.words) { + for (const auto& http_word: UmosapiService::Api::_path.words) { auto responses = UmosapiService::Api::_swagger["paths"][UmosapiService::Api::_path.name][http_word.name]["responses"]; if (responses.find("200") == responses.end()) { UmosapiService::Api::_swagger["paths"][UmosapiService::Api::_path.name][http_word.name]["responses"]["200"]["description"] = "All is fine."; @@ -202,7 +200,7 @@ void UmosapiService::Api::parameter(std::string name, std::string description, s parameter["in"] = "path"; } else { parameter["in"] = "body"; - for (auto& def: UmosapiService::Api::_definitions.defs) { + for (const auto& def: UmosapiService::Api::_definitions.defs) { if (def.name == schema ) { std::string schema_path = "#/definitions/"; parameter["schema"]["$ref"] = schema_path.append(schema); diff --git a/db/uobject.cpp b/db/uobject.cpp index 38b472f..bb911bb 100644 --- a/db/uobject.cpp +++ b/db/uobject.cpp @@ -13,7 +13,7 @@ std::string UmosapiService::uobject::retrieveAll(std::string collection, struct auto cursor = coll.find({}); - for (auto&& doc : cursor) { + for (const auto& doc : cursor) { json_object_array_add(jsonObjects, json_tokener_parse(bsoncxx::to_json(doc).c_str())); } @@ -126,7 +126,7 @@ std::string UmosapiService::uobject::searchKeyValue(std::string collection, std: auto cursor = coll.find(bsoncxx::from_json(json_string)); - for (auto&& doc : cursor) { + for (const auto& doc : cursor) { json_object_array_add(jsonArray, json_tokener_parse(bsoncxx::to_json(doc).c_str())); } -- cgit v1.2.1