From 7ab1887c5b6fac2a7790725a99a50a8b8a4a9e84 Mon Sep 17 00:00:00 2001 From: Timo Koch <timo.koch@iws.uni-stuttgart.de> Date: Tue, 21 Mar 2017 14:13:38 +0100 Subject: [PATCH] [mpnc] Correctly implement typesafe interfaces using std::string --- .../mpnc/implicit/vtkwritermodule.hh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/dumux/porousmediumflow/mpnc/implicit/vtkwritermodule.hh b/dumux/porousmediumflow/mpnc/implicit/vtkwritermodule.hh index a886b47476..7fb260fd8b 100644 --- a/dumux/porousmediumflow/mpnc/implicit/vtkwritermodule.hh +++ b/dumux/porousmediumflow/mpnc/implicit/vtkwritermodule.hh @@ -181,7 +181,7 @@ protected: */ template <class MultiWriter> void commitScalarBuffer_(MultiWriter &writer, - std::string name, + const std::string& name, ScalarVector &buffer, bool vertexCentered = true) { @@ -196,13 +196,13 @@ protected: */ template <class MultiWriter> void commitPhaseBuffer_(MultiWriter &writer, - std::string pattern, + const std::string& pattern, PhaseVector &buffer, bool vertexCentered = true) { char name[512]; for (int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) { - snprintf(name, 512, pattern, FluidSystem::phaseName(phaseIdx)); + snprintf(name, 512, pattern.c_str(), FluidSystem::phaseName(phaseIdx).c_str()); if (vertexCentered) writer.attachVertexData(buffer[phaseIdx], name, 1); @@ -216,13 +216,13 @@ protected: */ template <class MultiWriter> void commitComponentBuffer_(MultiWriter &writer, - std::string pattern, + const std::string& pattern, ComponentVector &buffer, bool vertexCentered = true) { char name[512]; for (int compIdx = 0; compIdx < numComponents; ++compIdx) { - snprintf(name, 512, pattern, FluidSystem::componentName(compIdx)); + snprintf(name, 512, pattern.c_str(), FluidSystem::componentName(compIdx).c_str()); if (vertexCentered) writer.attachVertexData(buffer[compIdx], name, 1); @@ -236,16 +236,16 @@ protected: */ template <class MultiWriter> void commitPhaseComponentBuffer_(MultiWriter &writer, - std::string pattern, + const std::string& pattern, PhaseComponentMatrix &buffer, bool vertexCentered = true) { char name[512]; for (int phaseIdx= 0; phaseIdx < numPhases; ++phaseIdx) { for (int compIdx = 0; compIdx < numComponents; ++compIdx) { - snprintf(name, 512, pattern, - FluidSystem::phaseName(phaseIdx), - FluidSystem::componentName(compIdx)); + snprintf(name, 512, pattern.c_str(), + FluidSystem::phaseName(phaseIdx).c_str(), + FluidSystem::componentName(compIdx).c_str()); if (vertexCentered) writer.attachVertexData(buffer[phaseIdx][compIdx], name, 1); -- GitLab