return;
}
+ /* default separators */
+ m_Separators.push_back("\n");
+ m_Separators.push_back(";");
+ m_Separators.push_back(",");
+ m_Separators.push_back("|");
+
String line = lines[0];
size_t sp_index = line.FindFirstOf(" ");
size_t col_index = line.FindFirstOf(":");
String header = line.SubStr(0, col_index);
String params;
+ std::vector<String> separators;
if (line.GetLength() > col_index + 2)
params = line.SubStr(col_index + 2);
m_OutputFormat = params;
else if (header == "Columns")
boost::algorithm::split(m_Columns, params, boost::is_any_of(" "));
+ else if (header == "Separators")
+ boost::algorithm::split(separators, params, boost::is_any_of(" "));
+ /* ugly ascii long to char conversion, but works */
+ if (separators.size() > 0)
+ m_Separators[0] = String(1, static_cast<char>(Convert::ToLong(separators[0])));
+ if (separators.size() > 1)
+ m_Separators[1] = String(1, static_cast<char>(Convert::ToLong(separators[1])));
+ if (separators.size() > 2)
+ m_Separators[2] = String(1, static_cast<char>(Convert::ToLong(separators[2])));
+ if (separators.size() > 3)
+ m_Separators[3] = String(1, static_cast<char>(Convert::ToLong(separators[3])));
else if (header == "ColumnHeaders")
m_ColumnHeaders = (params == "on");
else if (header == "Filter") {
if (first)
first = false;
else
- fp << ";";
+ fp << m_Separators[1];
fp << column;
}
- fp << "\n";
+ fp << m_Separators[0];
}
if (m_OutputFormat == "csv") {
if (first)
first = false;
else
- fp << ";";
+ fp << m_Separators[1];
if (value.IsObjectType<Array>())
PrintCsvArray(fp, value, 0);
fp << value;
}
- fp << "\n";
+ fp << m_Separators[0];
}
} else if (m_OutputFormat == "json") {
fp << Value(rs).Serialize();
if (first)
first = false;
else
- fp << ((level == 0) ? "," : "|");
+ fp << ((level == 0) ? m_Separators[2] : m_Separators[3]);
if (value.IsObjectType<Array>())
PrintCsvArray(fp, value, level + 1);
String sCode = Convert::ToString(code);
String sLength = Convert::ToString(data.GetLength());
- String header = sCode + String(16 - 3 - sLength.GetLength() - 1, ' ') + sLength + "\n";
+ String header = sCode + String(16 - 3 - sLength.GetLength() - 1, ' ') + sLength + m_Separators[0];
stream->Write(header.CStr(), header.GetLength());
}