lintel 0.2.0
Loading...
Searching...
No Matches
FileService.h
Go to the documentation of this file.
1#ifndef LOGGING_FILE_H
2#define LOGGING_FILE_H
3
4#include <filesystem>
5#include <fstream>
6#include <ostream>
7#include <regex>
8#include <sstream>
9#include <utility>
10#include <vector>
11
12namespace lintel {
17{
18private:
19 std::filesystem::path m_path;
20
21public:
26 class Stream
27 {
28 private:
29 std::ifstream m_file;// stream for operations
30 bool m_endOfFile = false;// marks if end of file is reached
31 std::string m_nextLine = "";
32
33 public:
38 explicit Stream(const std::filesystem::path &path);
39
44 bool isEndOfFile() const;
45
50 std::string getLine();
51 };
52
57 explicit FileService(std::filesystem::path path);
58
63 bool isFile();
64
69 bool exists();
70
75 std::size_t getSize();
76
80 void deleteFile();
81
86 std::string readFile();
87
92 std::string getName();
93
98 std::filesystem::path getPath();
99
104 void writeToFile(const std::string &content, bool overwrite = false);
105
110 void createFile(std::size_t sizeOfFile);
111
116 void createSymlinkTo(const std::filesystem::path &to);
117
123 std::vector<std::string> matches(const std::regex &regex);
124
130
134 friend std::ostream &operator<<(std::ostream &os, const FileService &file)
135 {
136 os << "path: " << file.m_path;
137 return os;
138 }
139};
140
141}// namespace lintel
142#endif// LOGGING_FILE_H
Definition FileService.h:27
Stream(const std::filesystem::path &path)
Definition FileService.h:17
void createFile(std::size_t sizeOfFile)
std::filesystem::path getPath()
FileService(std::filesystem::path path)
friend std::ostream & operator<<(std::ostream &os, const FileService &file)
Definition FileService.h:134
std::string getName()
FileService::Stream createStream()
std::vector< std::string > matches(const std::regex &regex)
std::size_t getSize()
void createSymlinkTo(const std::filesystem::path &to)
std::string readFile()
void writeToFile(const std::string &content, bool overwrite=false)
Definition BaseFeature.h:6
constexpr std::string_view type_name()
Definition TypeName.h:9