Skip to content

Commit 08c5320

Browse files
committed
fix for csv output in cpp runtime
1 parent 03f5aaf commit 08c5320

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

SimulationRuntime/cpp/Include/Core/DataExchange/Policies/MatfileWriter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,7 @@ class MatFileWriter : public ContainerManager
753753
*/
754754
size_t nInt = get<1>(v_list).size();
755755
std::transform(get<2>(v_list).begin(), get<2>(v_list).end(), get<2>(neg_v_list).begin(),
756-
doubleHelpMatrix+nReal+nInt, WriteOutputVarBool());
756+
doubleHelpMatrix+nReal+nInt, WriteOutputVar<bool>());
757757

758758
// write matrix to file
759759
writeMatVer4Matrix("data_2", uiVarCount, _uiValueCount, _doubleMatrixData2, sizeof(double));

SimulationRuntime/cpp/Include/Core/DataExchange/Policies/TextfileWriter.h

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,18 @@ class TextFileWriter : public ContainerManager
113113
{
114114
_output_stream << get<3>(v_list) << SEPERATOR;
115115

116-
for (real_vars_t::const_iterator it = get<0>(v_list).begin(); it != get<0>(v_list).end(); ++it)
117-
_output_stream << (*it) << SEPERATOR;
118116

119-
for (int_vars_t::const_iterator it = get<1>(v_list).begin(); it != get<1>(v_list).end(); ++it)
120-
_output_stream << (*it) << SEPERATOR;
121-
for (bool_vars_t::const_iterator it = get<2>(v_list).begin(); it != get<2>(v_list).end(); ++it)
122-
_output_stream << (*it) << SEPERATOR;
117+
std::transform(get<0>(v_list).begin(), get<0>(v_list).end(), get<0>(neg_v_list).begin(),
118+
std::ostream_iterator<double>(_output_stream,","), WriteOutputVar<double>());
119+
120+
121+
std::transform(get<1>(v_list).begin(), get<1>(v_list).end(), get<1>(neg_v_list).begin(),
122+
std::ostream_iterator<int>(_output_stream,","), WriteOutputVar<int>());
123+
124+
125+
std::transform(get<2>(v_list).begin(), get<2>(v_list).end(), get<2>(neg_v_list).begin(),
126+
std::ostream_iterator<bool>(_output_stream,","), WriteOutputVar<bool>());
127+
123128
_output_stream << std::endl;
124129
}
125130

SimulationRuntime/cpp/Include/Core/DataExchange/Writer.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ struct WriteOutputVar
9999
@param val pointer to output variable
100100
@param negate if output variable is a negate alias variable
101101
*/
102-
const double operator()(const T* val, bool negate)
102+
const double operator()(const T* val, const bool negate)
103103
{
104104
//if output variable is a negate alias variable, then negate output value
105105
if(negate)
@@ -110,16 +110,17 @@ struct WriteOutputVar
110110
};
111111

112112
/**
113-
* Operator class to return value of a boolean variable
113+
* specialized bool Operator class to return value of a boolean variable
114114
*/
115-
struct WriteOutputVarBool
115+
template < >
116+
struct WriteOutputVar<bool>
116117
{
117118
/**
118119
return value of output variable
119120
@param val pointer to output variable
120121
@param negate if output variable is a negate alias variable
121122
*/
122-
const double operator()(const bool* val, bool negate)
123+
const double operator()(const bool* val, const bool negate)
123124
{
124125
//if output variable is a negate alias variable, then negate output value
125126
if (negate)

0 commit comments

Comments
 (0)