Skip to content

Instantly share code, notes, and snippets.

@SolemnJoker
SolemnJoker / csv.cpp
Last active November 7, 2020 06:51
[read csv by cpp] c++读取csv文件 #c++ #csv
#include "csv.h"
inline
std::vector<std::string> split_csv_line(const std::string& str) {
char seperator = ',';
std::vector<std::string> results;
std::string::size_type start = str.find_first_not_of(' ');
std::string::size_type sep = str.find(seperator);
while (sep != std::string::npos) {
@SolemnJoker
SolemnJoker / utils.h
Last active November 7, 2020 06:51
[get files list ] 获取文件列表 #c++ #file
inline
std::vector<std::string> getFilesList(std::string dirpath){
DIR *dir = opendir(dirpath.c_str());
if (dir == NULL)
{
std::cout << "opendir error" << std::endl;
}
std::vector<std::string> all_path;
struct dirent *entry;
@SolemnJoker
SolemnJoker / defer.h
Last active November 7, 2020 06:42
[c++ unit] #c++
class ExecuteOnExit{
public:
ExecuteOnExit() = default;
// movable
ExecuteOnExit(ExecuteOnExit&& ) = default;
ExecuteOnExit& operator=(ExecuteOnExit&& ) = default;
// non copyable
ExecuteOnExit(const ExecuteOnExit& e) = delete;