コード例 #1
0
void DataRecorder::BeginFile(CSVRow headerRow, std::string identifier)
{
	time_t now = time(0);
	tm* dt = localtime(&now);

	std::ostringstream oss;

	oss << 1900 + dt->tm_year;
	oss << 1 + dt->tm_mon;
	oss << dt->tm_mday;
	oss << "_";
	oss << dt->tm_hour;
	oss << dt->tm_min;
	oss << dt->tm_sec;

	StreamDataPtr s = std::make_unique<StreamData>();
	s->m_stream;
	s->m_filePath = "logs/log-" + identifier + "-" + oss.str() + ".csv";
	s->m_columns = headerRow.m_cellData.size();

	m_streams.emplace(identifier, std::move(s));

	//open each stream and write header row
	
	m_streams[identifier]->m_stream.open(m_directoryPath + m_streams[identifier]->m_filePath);
	m_streams[identifier]->m_stream << headerRow.GetRow();

}
コード例 #2
0
void DataRecorder::Record(CSVRow row, std::string identifier)
{
	assert(row.m_cellData.size() == m_streams[identifier]->m_columns);

	m_streams[identifier]->m_stream << row.GetRow();
}