1 /**
2    dtl -- Diff Template Library
3 
4    In short, Diff Template Library is distributed under so called "BSD license",
5 
6    Copyright (c) 2015 Tatsuhiko Kubo <cubicdaiya@gmail.com>
7    All rights reserved.
8 
9    Redistribution and use in source and binary forms, with or without modification,
10    are permitted provided that the following conditions are met:
11 
12    * Redistributions of source code must retain the above copyright notice,
13    this list of conditions and the following disclaimer.
14 
15    * Redistributions in binary form must reproduce the above copyright notice,
16    this list of conditions and the following disclaimer in the documentation
17    and/or other materials provided with the distribution.
18 
19    * Neither the name of the authors nor the names of its contributors
20    may be used to endorse or promote products derived from this software
21    without specific prior written permission.
22 
23    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24    "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26    A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27    OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28    SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
29    TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30    PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31    LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32    NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 */
35 
36 /* If you use this library, you must include dtl.hpp only. */
37 
38 #ifndef DTL_VARIABLES_H
39 #define DTL_VARIABLES_H
40 
41 #include <vector>
42 #include <list>
43 #include <string>
44 #include <algorithm>
45 #include <iostream>
46 
47 namespace dtl {
48 
49     using std::vector;
50     using std::string;
51     using std::pair;
52     using std::ostream;
53     using std::list;
54     using std::for_each;
55     using std::distance;
56     using std::fill;
57     using std::cout;
58     using std::endl;
59     using std::rotate;
60     using std::swap;
61     using std::max;
62 
63     /**
64      * version string
65      */
66     const string version = "1.19";
67 
68     /**
69      * type of edit for SES
70      */
71     typedef int edit_t;
72     const   edit_t SES_DELETE = -1;
73     const   edit_t SES_COMMON = 0;
74     const   edit_t SES_ADD    = 1;
75 
76     /**
77      * mark of SES
78      */
79 #define SES_MARK_DELETE "-"
80 #define SES_MARK_COMMON " "
81 #define SES_MARK_ADD    "+"
82 
83     /**
84      * info for Unified Format
85      */
86     typedef struct eleminfo {
87         long long beforeIdx;           // index of prev sequence
88         long long afterIdx;            // index of after sequence
89         edit_t    type;                // type of edit(Add, Delete, Common)
operator ==dtl::eleminfo90         bool operator==(const eleminfo& other) const{
91             return (this->beforeIdx == other.beforeIdx && this->afterIdx == other.afterIdx && this->type == other.type);
92         }
93     } elemInfo;
94 
95     const long long DTL_SEPARATE_SIZE = 3;
96     const long long DTL_CONTEXT_SIZE  = 3;
97 
98     /**
99      * cordinate for registering route
100      */
101     typedef struct Point {
102         long long x;                         // x cordinate
103         long long y;                         // y cordinate
104         long long k;                         // vertex
105     } P;
106 
107     /**
108      * limit of cordinate size
109      */
110     const unsigned long long MAX_CORDINATES_SIZE = 2000000;
111 
112     typedef vector< long long > editPath;
113     typedef vector< P >         editPathCordinates;
114 
115     /**
116      * Structure of Unified Format Hunk
117      */
118     template <typename sesElem>
119     struct uniHunk {
120         long long a, b, c, d;        // @@ -a,b +c,d @@
121         vector< sesElem > common[2]; // anteroposterior commons on changes
122         vector< sesElem > change;    // changes
123         long long inc_dec_count;     // count of increace and decrease
124     };
125 
126 #define dtl_typedefs(elem, sequence)                                    \
127     typedef pair< elem, elemInfo >            sesElem;                  \
128     typedef vector< sesElem >                 sesElemVec;               \
129     typedef vector< uniHunk< sesElem > >      uniHunkVec;               \
130     typedef list< elem >                      elemList;                 \
131     typedef vector< elem >                    elemVec;                  \
132     typedef typename uniHunkVec::iterator     uniHunkVec_iter;          \
133     typedef typename sesElemVec::iterator     sesElemVec_iter;          \
134     typedef typename elemList::iterator       elemList_iter;            \
135     typedef typename sequence::iterator       sequence_iter;            \
136     typedef typename sequence::const_iterator sequence_const_iter;      \
137     typedef typename elemVec::iterator        elemVec_iter;
138 
139 
140 }
141 
142 #endif // DTL_VARIABLES_H
143