$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
line.hh
1 // Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
2 // (LRDE)
3 //
4 // This file is part of Olena.
5 //
6 // Olena is free software: you can redistribute it and/or modify it under
7 // the terms of the GNU General Public License as published by the Free
8 // Software Foundation, version 2 of the License.
9 //
10 // Olena is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with Olena. If not, see <http://www.gnu.org/licenses/>.
17 //
18 // As a special exception, you may use this file as part of a free
19 // software project without restriction. Specifically, if other files
20 // instantiate templates or use macros or inline functions from this
21 // file, or you compile this file and link it with other files to produce
22 // an executable, this file does not by itself cause the resulting
23 // executable to be covered by the GNU General Public License. This
24 // exception does not however invalidate any other reasons why the
25 // executable file might be covered by the GNU General Public License.
26 
27 #ifndef SCRIBO_CORE_TAG_LINE_HH
28 # define SCRIBO_CORE_TAG_LINE_HH
29 
30 # include <iostream>
31 
35 
36 namespace scribo
37 {
38 
39  // Line id tag.
40  struct LineId;
41 
42 
43  namespace line
44  {
45 
46  enum Tag
47  {
48  None = 0,
49  Ignored,
50  Needs_Precise_Stats_Update,
51  Merged,
52  Pathological
53  };
54 
55 
56 
57  // The following next enumerations are based on the page content
58  // XML format.
59  //
60  // XSD:
61  // http://schema.primaresearch.org/PAGE/gts/pagecontent/2009-03-16/pagecontent.xsd
62 
63  enum ReadingDirection
64  {
65  BottomToTop,
66  LeftToRight,
67  RightToLeft,
68  TopToBottom
69  };
70 
71 
72  enum Type
73  {
74  Caption,
75  Credit,
77  Floating,
78  Footer,
79  Header,
80  Heading,
81  PageNumber,
82  Paragraph,
83 
84  // These types are not supported by the XSD.
86  Text,
87  Undefined
88  };
89 
90 
91  std::ostream&
92  operator<<(std::ostream& ostr, const Tag& tag);
93 
94  std::ostream&
95  operator<<(std::ostream& ostr, const ReadingDirection& direction);
96 
97  std::ostream&
98  operator<<(std::ostream& ostr, const Type& type);
99  Type str2type(const std::string& str);
100 
101 
102 # ifndef MLN_INCLUDE_ONLY
103 
104  inline
105  std::ostream&
106  operator<<(std::ostream& ostr, const Tag& tag)
107  {
108  std::string str;
109  switch(tag)
110  {
111  default:
112  case None:
113  str = "None";
114  break;
115  case Ignored:
116  str = "Ignored";
117  break;
118  case Needs_Precise_Stats_Update:
119  str = "Needs_Precise_Stats_Update";
120  break;
121  case Merged:
122  str = "Merged";
123  break;
124  case Pathological:
125  str = "Pathological";
126  break;
127  }
128 
129  return ostr << str;
130  }
131 
132 
133 
134  inline
135  std::ostream&
136  operator<<(std::ostream& ostr, const ReadingDirection& direction)
137  {
138  std::string str;
139  switch(direction)
140  {
141  case BottomToTop:
142  str = "bottom-to-top";
143  break;
144  default:
145  case LeftToRight:
146  str = "left-to-right";
147  break;
148  case RightToLeft:
149  str = "right-to-left";
150  break;
151  case TopToBottom:
152  str = "top-to-bottom";
153  break;
154  }
155 
156  return ostr << str;
157  }
158 
159 
160  inline
161  std::string type2str(const Type& type)
162  {
163  std::string str;
164  switch(type)
165  {
166  case Caption:
167  str = "caption";
168  break;
169  case Credit:
170  str = "credit";
171  break;
172  case DropCapital:
173  str = "drop-capital";
174  break;
175  case Floating:
176  str = "floating";
177  break;
178  case Footer:
179  str = "footer";
180  break;
181  case Header:
182  str = "header";
183  break;
184  case Heading:
185  str = "heading";
186  break;
187  case PageNumber:
188  str = "page-number";
189  break;
190  case Paragraph:
191  str = "paragraph";
192  break;
193 
194  // Values unsupported by the XSD
195  case Punctuation:
196  str = "punctuation";
197  break;
198  case Text:
199  str = "text";
200  break;
201  default:
202  case Undefined:
203  str = "undefined";
204  break;
205  }
206 
207  return str;
208  }
209 
210  inline
211  std::ostream&
212  operator<<(std::ostream& ostr, const Type& type)
213  {
214  return ostr << type2str(type);
215  }
216 
217 
218  inline
219  Type str2type(const std::string& str)
220  {
221  if (str == "caption")
222  return Caption;
223  else if (str == "credit")
224  return Credit;
225  else if (str == "drop-capital")
226  return DropCapital;
227  else if (str == "floating")
228  return Floating;
229  else if (str == "footer")
230  return Footer;
231  else if (str == "header")
232  return Header;
233  else if (str == "heading")
234  return Heading;
235  else if (str == "page-number")
236  return PageNumber;
237  else if (str == "paragraph")
238  return Paragraph;
239 
240  // Values unsupported by the XSD
241  else if(str == "punctuation")
242  return Punctuation;
243  else if (str == "text")
244  return Text;
245 
246  return Undefined;
247  }
248 
249 
250 # endif // ! MLN_INCLUDE_ONLY
251 
252 
253  } // end of namespace scribo::line
254 
255 } // end of namespace scribo
256 
257 
258 #endif // ! SCRIBO_CORE_TAG_LINE_HH