1
2
3
4
5
6 #ifndef CPP2CM_CPP2CM_PATCH_INCLUDED
7 #define CPP2CM_CPP2CM_PATCH_INCLUDED
8 #include <string>
9 #include <vector>
10 #include <memory>
11
12 namespace cpp2cm {
13
14 class Patch
15 {
16 public:
17 enum class Kind { insert_, delete_, modify_ };
18 Patch(Kind kind_);
19 virtual ~Patch();
20 Kind GetKind() const { return kind; }
21 void SetFileName(const std::u32string& fileName_);
22 const std::u32string& FileName() const { return fileName; }
23 void SetLineNumber(const std::u32string& lineNumber_);
24 int LineNumber() const;
25 private:
26 Kind kind;
27 std::u32string fileName;
28 std::u32string lineNumber;
29 };
30
31 class InsertPatch : public Patch
32 {
33 public:
34 InsertPatch(const std::u32string& text_);
35 const std::u32string& Text() const { return text; }
36 private:
37 std::u32string text;
38 };
39
40 class DeletePatch : public Patch
41 {
42 public:
43 DeletePatch();
44 };
45
46 class ModifyPatch : public Patch
47 {
48 public:
49 ModifyPatch(const std::u32string& oldText_, const std::u32string& newText_);
50 const std::u32string& OldText() const { return oldText; }
51 const std::u32string& NewText() const { return newText; }
52 private:
53 std::u32string oldText;
54 std::u32string newText;
55 };
56
57 class PatchFile
58 {
59 public:
60 PatchFile(const std::string& path_);
61 const std::string& Path() const { return path; }
62 void AddPatch(Patch* patch);
63 const std::std::vector<std::std::unique_ptr<Patch>>&Patches() const{returnpatches;}
64 private:
65 std::string path;
66 std::vector<std::std::unique_ptr<Patch>>patches;
67 };
68
69 }
70
71 #endif // CPP2CM_CPP2CM_PATCH_INCLUDED