Skip to content

Commit 7f38446

Browse files
authored
Merge pull request #589 from sebproell/cstr
Remove unnecessary c_str() in exceptions
2 parents 1c4bc87 + 7eae1ac commit 7f38446

File tree

209 files changed

+635
-804
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

209 files changed

+635
-804
lines changed

apps/create_rtdfiles/4C_create_rtdfiles_wrapper.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ namespace RTD
3737
// open ascii file for writing the cell type information
3838
std::ofstream elementinformationfile(elementinformationfilename.c_str());
3939
if (!elementinformationfile)
40-
FOUR_C_THROW("failed to open file: {}", elementinformationfilename.c_str());
40+
FOUR_C_THROW("failed to open file: {}", elementinformationfilename);
4141
elementinformationfile << "# yaml file created using 4C version (git SHA1):\n";
4242
elementinformationfile << "# " << VersionControl::git_hash << "\n#\n";
4343

@@ -52,7 +52,7 @@ namespace RTD
5252
// open ascii file for writing all header parameters
5353
std::ofstream headerdocumentationfile(headerdocumentationfilename.c_str());
5454
if (!headerdocumentationfile)
55-
FOUR_C_THROW("failed to open file: {}", headerdocumentationfilename.c_str());
55+
FOUR_C_THROW("failed to open file: {}", headerdocumentationfilename);
5656
headerdocumentationfile << "..\n Created using 4C version (git SHA1):\n";
5757
headerdocumentationfile << " " << VersionControl::git_hash << "\n\n";
5858
headerdocumentationfile << ".. _headerparameters:\n\n";
@@ -87,7 +87,7 @@ namespace RTD
8787
// open ascii file for writing all header parameters
8888
std::ofstream celltypeocumentationfile(celltypedocumentationfilename.c_str());
8989
if (!celltypeocumentationfile)
90-
FOUR_C_THROW("failed to open file: {}", celltypedocumentationfilename.c_str());
90+
FOUR_C_THROW("failed to open file: {}", celltypedocumentationfilename);
9191
celltypeocumentationfile << "..\n Created using 4C version (git SHA1):\n";
9292
celltypeocumentationfile << " " << VersionControl::git_hash << "\n\n";
9393

@@ -102,7 +102,7 @@ namespace RTD
102102
// open ascii file for writing all material parameters
103103
std::ofstream materialdocumentationfile(materialdocumentationfilename.c_str());
104104
if (!materialdocumentationfile)
105-
FOUR_C_THROW("failed to open file: {}", materialdocumentationfilename.c_str());
105+
FOUR_C_THROW("failed to open file: {}", materialdocumentationfilename);
106106
materialdocumentationfile << "..\n Created using 4C version (git SHA1):\n";
107107
materialdocumentationfile << " " << VersionControl::git_hash << "\n\n";
108108
write_material_reference(materialdocumentationfile, Global::valid_materials());
@@ -116,7 +116,7 @@ namespace RTD
116116
// open ascii file for writing all constrains / conditions parameters
117117
std::ofstream conditiondocumentationfile(conditiondocumentationfilename.c_str());
118118
if (!conditiondocumentationfile)
119-
FOUR_C_THROW("failed to open file: {}", conditiondocumentationfilename.c_str());
119+
FOUR_C_THROW("failed to open file: {}", conditiondocumentationfilename);
120120
conditiondocumentationfile << "..\n Created using 4C version (git SHA1):\n";
121121
conditiondocumentationfile << " " << VersionControl::git_hash << "\n\n";
122122
write_conditions_reference(conditiondocumentationfile, Input::valid_conditions());
@@ -133,7 +133,7 @@ namespace RTD
133133
// open ascii file for writing other (non header) parameters
134134
std::ofstream variousdocumentationfile(variousdocumentationfilename.c_str());
135135
if (!variousdocumentationfile)
136-
FOUR_C_THROW("failed to open file: {}", variousdocumentationfilename.c_str());
136+
FOUR_C_THROW("failed to open file: {}", variousdocumentationfilename);
137137
variousdocumentationfile << "..\n Created using 4C version (git SHA1):\n";
138138
variousdocumentationfile << " " << VersionControl::git_hash << "\n\n";
139139
write_various_reference(variousdocumentationfile);

apps/global_full/4C_global_full_main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ namespace
263263
FOUR_C_THROW("4C produced an unknown floating point exception.");
264264
break;
265265
}
266-
FOUR_C_THROW("4C produced a {} floating point exception.", exception_string.c_str());
266+
FOUR_C_THROW("4C produced a {} floating point exception.", exception_string);
267267
}
268268
#endif
269269

apps/post_monitor/4C_post_monitor.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ void MonWriter::write_mon_stress_file(
163163
{
164164
// stop it now
165165
if ((stresstype != "none") and (stresstype != "ndxyz"))
166-
FOUR_C_THROW("Cannot deal with requested stress output type: {}", stresstype.c_str());
166+
FOUR_C_THROW("Cannot deal with requested stress output type: {}", stresstype);
167167

168168
// write stress
169169
if (stresstype != "none")
@@ -187,7 +187,7 @@ void MonWriter::write_mon_strain_file(
187187
{
188188
// stop it now
189189
if ((straintype != "none") and (straintype != "ndxyz"))
190-
FOUR_C_THROW("Cannot deal with requested strain output type: {}", straintype.c_str());
190+
FOUR_C_THROW("Cannot deal with requested strain output type: {}", straintype);
191191

192192
if (straintype != "none")
193193
{
@@ -213,7 +213,7 @@ void MonWriter::write_mon_pl_strain_file(
213213
{
214214
// stop it now
215215
if ((straintype != "none") and (straintype != "ndxyz"))
216-
FOUR_C_THROW("Cannot deal with requested plastic strain output type: {}", straintype.c_str());
216+
FOUR_C_THROW("Cannot deal with requested plastic strain output type: {}", straintype);
217217

218218
if (straintype != "none")
219219
{
@@ -329,7 +329,7 @@ void MonWriter::write_mon_heatflux_file(
329329
{
330330
// stop it now
331331
if ((heatfluxtype != "none") and (heatfluxtype != "ndxyz"))
332-
FOUR_C_THROW("Cannot deal with requested heatflux output type: {}", heatfluxtype.c_str());
332+
FOUR_C_THROW("Cannot deal with requested heatflux output type: {}", heatfluxtype);
333333

334334
// write heatflux
335335
if (heatfluxtype != "none")
@@ -357,8 +357,7 @@ void MonWriter::write_mon_tempgrad_file(
357357
{
358358
// stop it now
359359
if ((tempgradtype != "none") and (tempgradtype != "ndxyz"))
360-
FOUR_C_THROW(
361-
"Cannot deal with requested temperature gradient output type: {}", tempgradtype.c_str());
360+
FOUR_C_THROW("Cannot deal with requested temperature gradient output type: {}", tempgradtype);
362361

363362
if (tempgradtype != "none")
364363
{
@@ -1851,8 +1850,8 @@ int main(int argc, char** argv)
18511850
mymonwriter.write_mon_file(problem, infieldtype, node);
18521851
}
18531852
else
1854-
FOUR_C_THROW("Unsupported field type {} for problem-type Multiphase_Poroelasticity",
1855-
infieldtype.c_str());
1853+
FOUR_C_THROW(
1854+
"Unsupported field type {} for problem-type Multiphase_Poroelasticity", infieldtype);
18561855
break;
18571856
}
18581857
case Core::ProblemType::poromultiphasescatra:
@@ -1879,7 +1878,7 @@ int main(int argc, char** argv)
18791878
}
18801879
else
18811880
FOUR_C_THROW("Unsupported field type {} for problem-type Multiphase_Poroelasticity_ScaTra",
1882-
infieldtype.c_str());
1881+
infieldtype);
18831882
break;
18841883
}
18851884
default:

apps/post_processor/4C_post_processor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ int main(int argc, char** argv)
627627
if (filter == "ensight" || filter == "vtu" || filter == "vtu_node_based" || filter == "vti")
628628
run_ensight_vtu_filter(problem);
629629
else
630-
FOUR_C_THROW("Unknown filter {} given, supported filters: [ensight|vtu|vti]", filter.c_str());
630+
FOUR_C_THROW("Unknown filter {} given, supported filters: [ensight|vtu|vti]", filter);
631631

632632
} // try
633633
catch (Core::Exception& err)

apps/pre_exodus/4C_pre_exodus.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ namespace
4848

4949
// open default bc specification file
5050
std::ofstream defaultbc(defaultbcfilename.c_str());
51-
if (!defaultbc) FOUR_C_THROW("failed to open file: {}", defaultbcfilename.c_str());
51+
if (!defaultbc) FOUR_C_THROW("failed to open file: {}", defaultbcfilename);
5252

5353
// write mesh verbosely
5454
defaultbc << "----------- Mesh contents -----------" << std::endl << std::endl;
@@ -303,7 +303,7 @@ int main(int argc, char** argv)
303303

304304
// open default header file
305305
std::ofstream defaulthead(defaultheadfilename.c_str());
306-
if (!defaulthead) FOUR_C_THROW("failed to open file: {}", defaultheadfilename.c_str());
306+
if (!defaulthead) FOUR_C_THROW("failed to open file: {}", defaultheadfilename);
307307

308308
// get valid input parameters
309309
auto parameters = Input::valid_parameters();

apps/pre_exodus/4C_pre_exodus_writedat.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ int EXODUS::write_dat_file(const std::string& datfile, const EXODUS::Mesh& mymes
2525
{
2626
// open datfile
2727
std::ofstream dat(datfile.c_str());
28-
if (!dat) FOUR_C_THROW("failed to open file: {}", datfile.c_str());
28+
if (!dat) FOUR_C_THROW("failed to open file: {}", datfile);
2929

3030
// write dat-file intro
3131
EXODUS::write_dat_intro(headfile, mymesh, dat);
@@ -259,8 +259,7 @@ std::vector<double> EXODUS::calc_normal_surf_locsys(const int ns_id, const EXODU
259259
}
260260
if (normaltangent.size() == 1)
261261
{
262-
FOUR_C_THROW(
263-
"Warning! No normal defined for SurfLocsys within nodeset '{}'!", (ns.get_name()).c_str());
262+
FOUR_C_THROW("Warning! No normal defined for SurfLocsys within nodeset '{}'!", (ns.get_name()));
264263
}
265264

266265
// find tangent by Gram-Schmidt

src/adapter/4C_adapter_ale.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ void Adapter::AleBaseAlgorithm::setup_ale(
142142
default:
143143
{
144144
FOUR_C_THROW("Decide, whether ALE_TYPE = '{}' is linear or nonlinear.",
145-
adyn->get<std::string>("ALE_TYPE").c_str());
145+
adyn->get<std::string>("ALE_TYPE"));
146146
break;
147147
}
148148
}

src/adapter/4C_adapter_scatra_base_algorithm.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ Adapter::ScaTraBaseAlgorithm::ScaTraBaseAlgorithm(const Teuchos::ParameterList&
6363
// -------------------------------------------------------------------
6464
auto output = discret->writer();
6565
if (discret->num_global_elements() == 0)
66-
FOUR_C_THROW("No elements in discretization {}", discret->name().c_str());
66+
FOUR_C_THROW("No elements in discretization {}", discret->name());
6767
output->write_mesh(0, 0.0);
6868

6969
// -------------------------------------------------------------------

src/ale/4C_ale_ale2_evaluate.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ int Discret::Elements::Ale2::evaluate(Teuchos::ParameterList& params,
4949
else if (action == "calc_jacobian_determinant")
5050
act = Ale2::calc_det_jac;
5151
else
52-
FOUR_C_THROW("{} is an unknown type of action for Ale2", action.c_str());
52+
FOUR_C_THROW("{} is an unknown type of action for Ale2", action);
5353

5454
bool spatialconfiguration = true;
5555
if (params.isParameter("use spatial configuration"))

src/ale/4C_ale_ale3_input.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ bool Discret::Elements::Ale3::read_element(const std::string& eletype, const std
5454
break;
5555
}
5656
default:
57-
FOUR_C_THROW("Unknown distype {} for ALE3 element", distype.c_str());
57+
FOUR_C_THROW("Unknown distype {} for ALE3 element", distype);
5858
// just set to something to shutup compiler
5959
gaussrule = Core::FE::GaussRule3D::undefined;
6060
break;

0 commit comments

Comments
 (0)