1
2
3
4
5
6 #include <cpp2cm/cpp2cm/Patch.hpp>
7 #include <soulng/util/Unicode.hpp>
8 #include <boost/lexical_cast.hpp>
9
10 namespace cpp2cm {
11
12 using namespace soulng::unicode;
13
14 Patch::Patch(Kind kind_) : kind(kind_)
15 {
16 }
17
18 Patch::~Patch()
19 {
20 }
21
22 void Patch::SetFileName(const std::u32string& fileName_)
23 {
24 fileName = fileName_;
25 }
26
27 void Patch::SetLineNumber(const std::u32string& lineNumber_)
28 {
29 lineNumber = lineNumber_;
30 }
31
32 int Patch::LineNumber() const
33 {
34 return boost::lexical_cast<int>(ToUtf8(lineNumber));
35 }
36
37 InsertPatch::InsertPatch(const std::u32string& text_) : Patch(Patch::Kind::insert_), text(text_)
38 {
39 }
40
41 DeletePatch::DeletePatch() : Patch(Patch::Kind::delete_)
42 {
43 }
44
45 ModifyPatch::ModifyPatch(const std::u32string& oldText_, const std::u32string& newText_) : Patch(Patch::Kind::modify_), oldText(oldText_), newText(newText_)
46 {
47 }
48
49 PatchFile::PatchFile(const std::string& path_) : path(path_)
50 {
51 }
52
53 void PatchFile::AddPatch(Patch* patch)
54 {
55 patches.push_back(std::unique_ptr<Patch>(patch));
56 }
57
58 }