Commit f04ddb76 authored by Zhiping Jiang (蒋志平)'s avatar Zhiping Jiang (蒋志平) 💬

better styling.

parent 566f2dfa
......@@ -7,3 +7,14 @@
//
#include "jzplib_utilities.h"
namespace cve {
std::string chronoTime2StringUsingTimeFormat(const std::string & timeFormat, const std::chrono::time_point<std::chrono::system_clock> & chronoTime) {
auto in_time_t = std::chrono::system_clock::to_time_t(chronoTime);
std::stringstream ss;
char strChar[512];
std::strftime(strChar, sizeof(strChar), timeFormat.c_str(), localtime(&in_time_t));
return std::string(strChar);
}
}
......@@ -18,38 +18,31 @@
#include <sstream>
namespace cve {
std::string chronoTime2StringUsingTimeFormat(const std::string & timeFormat = "%Y%m%d_%H%M", const std::chrono::time_point<std::chrono::system_clock> & chronoTime = std::chrono::system_clock::now()) {
auto in_time_t = std::chrono::system_clock::to_time_t(chronoTime);
std::stringstream ss;
char strChar[512];
std::strftime(strChar, sizeof(strChar), timeFormat.c_str(), localtime(&in_time_t));
return std::string(strChar);
}
}
template<typename _Tp> class CSVFileWriter {
public:
std::string delimeter = " ";
void addCSVLine(std::vector<_Tp> slot) {
slots.push_back(slot);
}
void writeToFile(const std::string & filePath) {
std::ofstream textFile(filePath);
int i = 0, j =0 ;
for (i= 0; i< slots.size(); i++) {
for (j = 0; j < slots[i].size()-1; j++) {
textFile<<std::setprecision(10) <<slots[i][j]<<delimeter;
}
textFile<<std::setprecision(10) <<slots[i][j]<<std::endl;
std::string chronoTime2StringUsingTimeFormat(const std::string & timeFormat = "%Y%m%d_%H%M", const std::chrono::time_point<std::chrono::system_clock> & chronoTime = std::chrono::system_clock::now());
template<typename _Tp> class CSVFileWriter {
public:
std::string delimeter = " ";
void addCSVLine(std::vector<_Tp> slot) {
slots.push_back(slot);
}
textFile.flush();
textFile.close();
void writeToFile(const std::string & filePath) {
std::ofstream textFile(filePath);
int i = 0, j =0 ;
for (i= 0; i< slots.size(); i++) {
for (j = 0; j < slots[i].size()-1; j++) {
textFile<<std::setprecision(10) <<slots[i][j]<<delimeter;
}
textFile<<std::setprecision(10) <<slots[i][j]<<std::endl;
}
textFile.flush();
textFile.close();
};
private:
std::vector<std::vector<_Tp>> slots;
};
private:
std::vector<std::vector<_Tp>> slots;
};
}
#endif /* jzplib_utilities_h */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment