]> pilppa.org Git - lib1wire.git/blob - src/W1Util.hh
57a7daf8af344376c9c64e37338feef61398286f
[lib1wire.git] / src / W1Util.hh
1 /*
2  * W1Util.hh
3  *
4  *  Created on: Nov 14, 2010
5  *      Author: lamikr
6  */
7
8 #ifndef W1UTIL_HH_
9 #define W1UTIL_HH_
10
11 #include <fstream>
12 #include <string>
13 #include <vector>
14
15 #include <stdbool.h>
16 #include <dirent.h>
17 #include <stdbool.h>
18
19 #include "W1DataList.hh"
20
21 namespace w1 {
22         class W1Util {
23                 public:
24                         W1Util();
25                         virtual ~W1Util();
26                         static std::string concat_paths(std::string path_start, std::string path_end);
27                         static std::string concat_paths(const char *path_start, const char *path_end);
28                         static bool is_subdirectory(const char *path, dirent *direntry);
29                         static bool is_datafile(const char *path, dirent *direntry);
30                         static std::vector<std::string> get_subdirectories(const std::string& path);
31                         static std::vector<std::string> get_data_files(const std::string& path);
32                         static struct tm *parse_date_str(std::string date_str);
33                         static Data *parse_data_line(const std::string& dataline);
34                         static Data *load_first_data_row(const std::string& datafile_path);
35                         static Data *load_last_data_row(const std::string& datafile_path);
36                         static void printout_date(struct tm *date_time);
37                         static void printout_data(Data *data);
38                         static char *parse_directory_path(const char *file_path);
39                         static bool mkdirs(char *path);
40                         static std::ofstream *open_for_writing(const char *path);
41         };
42 }
43
44 #endif /* W1UTIL_HH_ */