1
2
3
4
5
6 #ifndef CPP2CM_CPP2CM_SOURCE_FILE_INCLUDED
7 #define CPP2CM_CPP2CM_SOURCE_FILE_INCLUDED
8 #include <cpp2cm/cpp2cm/Patch.hpp>
9 #include <list>
10 #include <unordered_map>
11
12 namespace cpp2cm {
13
14 class SourceFile
15 {
16 public:
17 SourceFile(const std::u32string& name_, const std::string& path_);
18 bool InMemory() const { return inMemory; }
19 void Read();
20 void Write();
21 void Apply(Patch* patch);
22 const std::u32string& Name() const { return name; }
23 const std::string& Path() const { return path; }
24 private:
25 std::u32string name;
26 std::string path;
27 bool inMemory;
28 std::list<std::u32string> lines;
29 std::unordered_map<int, std::std::list<std::u32string>::iterator>lineIteratorMap;
30 };
31
32 class SourceFiles
33 {
34 public:
35 SourceFiles();
36 void Sort();
37 void Add(SourceFile* sourceFile);
38 void Apply(PatchFile* patches);
39 void Write();
40 const std::std::vector<std::std::unique_ptr<SourceFile>>&Get() const{returnsourceFiles;}
41 private:
42 std::vector<std::std::unique_ptr<SourceFile>>sourceFiles;
43 std::unordered_map<std::u32string, SourceFile*> sourceFileMap;
44 };
45
46 }
47
48 #endif // CPP2CM_CPP2CM_SOURCE_FILE_INCLUDED