From 78c370bd6cb37c156d06e098fe4e555a9da9dcee Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Wed, 13 Nov 2024 15:52:57 +0100 Subject: fix format strings w/o printf --- src/crepe/api/Script.hpp | 2 +- src/crepe/facade/DB.cpp | 10 +++++----- src/crepe/facade/SDLContext.cpp | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/crepe/api/Script.hpp b/src/crepe/api/Script.hpp index d755fda..7ec3ebe 100644 --- a/src/crepe/api/Script.hpp +++ b/src/crepe/api/Script.hpp @@ -13,7 +13,7 @@ T & Script::get_component() const { std::vector> all_components = this->get_components(); if (all_components.size() < 1) - throw Exception("Script: no component found with type = %s", + throw Exception("Script: no component found with type = {}", typeid(T).name()); return all_components.back().get(); diff --git a/src/crepe/facade/DB.cpp b/src/crepe/facade/DB.cpp index ec6191b..80047a6 100644 --- a/src/crepe/facade/DB.cpp +++ b/src/crepe/facade/DB.cpp @@ -15,18 +15,18 @@ DB::DB(const string & path) { // init database struct libdb::DB * db; if ((ret = libdb::db_create(&db, NULL, 0)) != 0) - throw Exception("db_create: %s", libdb::db_strerror(ret)); + throw Exception("db_create: {}", libdb::db_strerror(ret)); this->db = {db, [](libdb::DB * db) { db->close(db, 0); }}; // load or create database file ret = this->db->open(this->db.get(), NULL, path.c_str(), NULL, libdb::DB_BTREE, DB_CREATE, 0); - if (ret != 0) throw Exception("db->open: %s", libdb::db_strerror(ret)); + if (ret != 0) throw Exception("db->open: {}", libdb::db_strerror(ret)); // create cursor libdb::DBC * cursor; ret = this->db->cursor(this->db.get(), NULL, &cursor, 0); - if (ret != 0) throw Exception("db->cursor: %s", libdb::db_strerror(ret)); + if (ret != 0) throw Exception("db->cursor: {}", libdb::db_strerror(ret)); this->cursor = {cursor, [](libdb::DBC * cursor) { cursor->close(cursor); }}; } @@ -44,7 +44,7 @@ string DB::get(const string & key) { memset(&db_val, 0, sizeof(libdb::DBT)); int ret = this->cursor->get(this->cursor.get(), &db_key, &db_val, DB_FIRST); - if (ret != 0) throw Exception("cursor->get: %s", libdb::db_strerror(ret)); + if (ret != 0) throw Exception("cursor->get: {}", libdb::db_strerror(ret)); return {static_cast(db_val.data), db_val.size}; } @@ -52,7 +52,7 @@ void DB::set(const string & key, const string & value) { libdb::DBT db_key = this->to_thing(key); libdb::DBT db_val = this->to_thing(value); int ret = this->db->put(this->db.get(), NULL, &db_key, &db_val, 0); - if (ret != 0) throw Exception("cursor->get: %s", libdb::db_strerror(ret)); + if (ret != 0) throw Exception("cursor->get: {}", libdb::db_strerror(ret)); } bool DB::has(const std::string & key) noexcept { diff --git a/src/crepe/facade/SDLContext.cpp b/src/crepe/facade/SDLContext.cpp index a28f7bd..1cb2936 100644 --- a/src/crepe/facade/SDLContext.cpp +++ b/src/crepe/facade/SDLContext.cpp @@ -159,7 +159,7 @@ SDLContext::texture_from_path(const std::string & path) { SDL_Surface * tmp = IMG_Load(path.c_str()); if (tmp == nullptr) { - throw Exception("surface cannot be load from %s", path.c_str()); + throw Exception("surface cannot be load from {}", path); } std::unique_ptr> @@ -171,7 +171,7 @@ SDLContext::texture_from_path(const std::string & path) { this->game_renderer.get(), img_surface.get()); if (tmp_texture == nullptr) { - throw Exception("Texture cannot be load from %s", path.c_str()); + throw Exception("Texture cannot be load from {}", path); } std::unique_ptr> -- cgit v1.2.3