From f733af6aa501b9cbb6d27ada1bd87a649c78f0f9 Mon Sep 17 00:00:00 2001 From: Phil Miller Date: Fri, 4 Aug 2023 14:41:01 -0700 Subject: [PATCH] Bmi_Fortran_Adapter: drop 'using namespace std' --- include/realizations/catchment/Bmi_Fortran_Adapter.hpp | 8 ++++---- src/realizations/catchment/Bmi_Fortran_Adapter.cpp | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/realizations/catchment/Bmi_Fortran_Adapter.hpp b/include/realizations/catchment/Bmi_Fortran_Adapter.hpp index 51d7f267bd..6c162cd7b4 100644 --- a/include/realizations/catchment/Bmi_Fortran_Adapter.hpp +++ b/include/realizations/catchment/Bmi_Fortran_Adapter.hpp @@ -25,7 +25,7 @@ namespace models { public: - explicit Bmi_Fortran_Adapter(const string &type_name, std::string library_file_path, + explicit Bmi_Fortran_Adapter(const std::string &type_name, std::string library_file_path, std::string forcing_file_path, bool allow_exceed_end, bool has_fixed_time_step, const std::string ®istration_func, utils::StreamHandler output) @@ -33,7 +33,7 @@ namespace models { has_fixed_time_step, registration_func, output) {} - Bmi_Fortran_Adapter(const string &type_name, std::string library_file_path, std::string bmi_init_config, + Bmi_Fortran_Adapter(const std::string &type_name, std::string library_file_path, std::string bmi_init_config, std::string forcing_file_path, bool allow_exceed_end, bool has_fixed_time_step, std::string registration_func, utils::StreamHandler output) : AbstractCLibBmiAdapter(type_name, @@ -67,7 +67,7 @@ namespace models { model_initialized = true; throw e; } - catch (exception &e) { + catch (std::exception &e) { //This will catch any other exception, but the it will be cast to this base type. //This means it looses it any specific type/message information. So if construct_and_init_backing_model_for_fortran //throws an exception besides runtime_error, catch that type explicitly. @@ -76,7 +76,7 @@ namespace models { } } - string GetComponentName() override; + std::string GetComponentName() override; /** * Get the backing model's current time. diff --git a/src/realizations/catchment/Bmi_Fortran_Adapter.cpp b/src/realizations/catchment/Bmi_Fortran_Adapter.cpp index a2804df671..8c7a8c4e57 100644 --- a/src/realizations/catchment/Bmi_Fortran_Adapter.cpp +++ b/src/realizations/catchment/Bmi_Fortran_Adapter.cpp @@ -3,7 +3,7 @@ using namespace models::bmi; -string Bmi_Fortran_Adapter::GetComponentName() { +std::string Bmi_Fortran_Adapter::GetComponentName() { char component_name[BMI_MAX_COMPONENT_NAME]; if (get_component_name(&bmi_model->handle, component_name) != BMI_SUCCESS) { throw std::runtime_error(model_name + " failed to get model component name."); @@ -126,7 +126,7 @@ int Bmi_Fortran_Adapter::GetVarGrid(std::string name) { std::string Bmi_Fortran_Adapter::GetGridType(int grid_id) { char gridtype_c_str[BMI_MAX_TYPE_NAME]; if (get_grid_type(&bmi_model->handle, &grid_id, gridtype_c_str) != BMI_SUCCESS) { - throw std::runtime_error(model_name + " failed to get grid type for grid ID " + to_string(grid_id) + "."); + throw std::runtime_error(model_name + " failed to get grid type for grid ID " + std::to_string(grid_id) + "."); } return std::string(gridtype_c_str); } @@ -134,7 +134,7 @@ std::string Bmi_Fortran_Adapter::GetGridType(int grid_id) { int Bmi_Fortran_Adapter::GetGridRank(int grid_id) { int gridrank; if (get_grid_rank(&bmi_model->handle, &grid_id, &gridrank) != BMI_SUCCESS) { - throw std::runtime_error(model_name + " failed to get grid rank for grid ID " + to_string(grid_id) + "."); + throw std::runtime_error(model_name + " failed to get grid rank for grid ID " + std::to_string(grid_id) + "."); } return gridrank; } @@ -142,7 +142,7 @@ int Bmi_Fortran_Adapter::GetGridRank(int grid_id) { int Bmi_Fortran_Adapter::GetGridSize(int grid_id) { int gridsize; if (get_grid_size(&bmi_model->handle, &grid_id, &gridsize) != BMI_SUCCESS) { - throw std::runtime_error(model_name + " failed to get grid size for grid ID " + to_string(grid_id) + "."); + throw std::runtime_error(model_name + " failed to get grid size for grid ID " + std::to_string(grid_id) + "."); } return gridsize; }