made changes necessary to build a static version
[wikiq] / dtl / variables.hpp
1 /**
2    dtl-1.12 -- Diff Template Library
3    
4    In short, Diff Template Library is distributed under so called "BSD license",
5    
6    Copyright (c) 2008-2011 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      * type of edit for SES
65      */
66     typedef int edit_t;
67     const   edit_t SES_DELETE = -1;
68     const   edit_t SES_COMMON = 0;
69     const   edit_t SES_ADD    = 1;
70     
71     /**
72      * mark of SES
73      */
74 #define SES_MARK_DELETE "-"
75 #define SES_MARK_COMMON " "
76 #define SES_MARK_ADD    "+"
77
78     /**
79      * info for Unified Format
80      */
81     typedef struct eleminfo {
82         long long beforeIdx;           // index of prev sequence
83         long long afterIdx;            // index of after sequence
84         edit_t    type;                // type of edit(Add, Delete, Common)
85     } elemInfo;
86     
87     const long long DTL_SEPARATE_SIZE = 3;
88     const long long DTL_CONTEXT_SIZE  = 3;
89     
90     /**
91      * cordinate for registering route
92      */
93     typedef struct Point {
94         long long x;                         // x cordinate
95         long long y;                         // y cordinate
96         long long k;                         // vertex
97     } P;
98     
99     /**
100      * limit of cordinate size
101      */
102     const unsigned long long MAX_CORDINATES_SIZE = 2000000;
103     
104     typedef vector< long long > editPath;
105     typedef vector< P >         editPathCordinates;
106     
107     /**
108      * Structure of Unified Format Hunk
109      */
110     template <typename sesElem>
111     struct uniHunk {
112         long long a, b, c, d;        // @@ -a,b +c,d @@
113         vector< sesElem > common[2]; // anteroposterior commons on changes
114         vector< sesElem > change;    // changes
115         long long inc_dec_count;     // count of increace and decrease
116     };
117
118 #define dtl_typedefs(elem, sequence)                                    \
119     typedef pair< elem, elemInfo >            sesElem;                  \
120     typedef vector< sesElem >                 sesElemVec;               \
121     typedef vector< uniHunk< sesElem > >      uniHunkVec;               \
122     typedef list< elem >                      elemList;                 \
123     typedef vector< elem >                    elemVec;                  \
124     typedef typename uniHunkVec::iterator     uniHunkVec_iter;          \
125     typedef typename sesElemVec::iterator     sesElemVec_iter;          \
126     typedef typename elemList::iterator       elemList_iter;            \
127     typedef typename sequence::iterator       sequence_iter;            \
128     typedef typename sequence::const_iterator sequence_const_iter;      \
129     typedef typename elemVec::iterator        elemVec_iter;
130
131
132
133
134 #endif // DTL_VARIABLES_H

Benjamin Mako Hill || Want to submit a patch?