No empty .Rs/.Re
[netbsd-mini2440.git] / gnu / dist / groff / src / roff / troff / hvunits.h
blob8f82e6204fba8ff503942585264b0597800a3727
1 /* $NetBSD$ */
3 // -*- C++ -*-
4 /* Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
5 Written by James Clark (jjc@jclark.com)
7 This file is part of groff.
9 groff is free software; you can redistribute it and/or modify it under
10 the terms of the GNU General Public License as published by the Free
11 Software Foundation; either version 2, or (at your option) any later
12 version.
14 groff is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 for more details.
19 You should have received a copy of the GNU General Public License along
20 with groff; see the file COPYING. If not, write to the Free Software
21 Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
24 class vunits {
25 int n;
26 public:
27 vunits();
28 vunits(units);
29 units to_units();
30 int is_zero();
31 vunits& operator+=(const vunits&);
32 vunits& operator-=(const vunits&);
33 friend inline vunits scale(vunits n, units x, units y); // scale n by x/y
34 friend inline vunits scale(vunits n, vunits x, vunits y);
35 friend inline vunits operator +(const vunits&, const vunits&);
36 friend inline vunits operator -(const vunits&, const vunits&);
37 friend inline vunits operator -(const vunits&);
38 friend inline int operator /(const vunits&, const vunits&);
39 friend inline vunits operator /(const vunits&, int);
40 friend inline vunits operator *(const vunits&, int);
41 friend inline vunits operator *(int, const vunits&);
42 friend inline int operator <(const vunits&, const vunits&);
43 friend inline int operator >(const vunits&, const vunits&);
44 friend inline int operator <=(const vunits&, const vunits&);
45 friend inline int operator >=(const vunits&, const vunits&);
46 friend inline int operator ==(const vunits&, const vunits&);
47 friend inline int operator !=(const vunits&, const vunits&);
50 extern vunits V0;
53 class hunits {
54 int n;
55 public:
56 hunits();
57 hunits(units);
58 units to_units();
59 int is_zero();
60 hunits& operator+=(const hunits&);
61 hunits& operator-=(const hunits&);
62 friend inline hunits scale(hunits n, units x, units y); // scale n by x/y
63 friend inline hunits scale(hunits n, double x);
64 friend inline hunits operator +(const hunits&, const hunits&);
65 friend inline hunits operator -(const hunits&, const hunits&);
66 friend inline hunits operator -(const hunits&);
67 friend inline int operator /(const hunits&, const hunits&);
68 friend inline hunits operator /(const hunits&, int);
69 friend inline hunits operator *(const hunits&, int);
70 friend inline hunits operator *(int, const hunits&);
71 friend inline int operator <(const hunits&, const hunits&);
72 friend inline int operator >(const hunits&, const hunits&);
73 friend inline int operator <=(const hunits&, const hunits&);
74 friend inline int operator >=(const hunits&, const hunits&);
75 friend inline int operator ==(const hunits&, const hunits&);
76 friend inline int operator !=(const hunits&, const hunits&);
79 extern hunits H0;
81 extern int get_vunits(vunits *, unsigned char si);
82 extern int get_hunits(hunits *, unsigned char si);
83 extern int get_vunits(vunits *, unsigned char si, vunits prev_value);
84 extern int get_hunits(hunits *, unsigned char si, hunits prev_value);
86 inline vunits:: vunits() : n(0)
90 inline units vunits::to_units()
92 return n*vresolution;
95 inline int vunits::is_zero()
97 return n == 0;
100 inline vunits operator +(const vunits & x, const vunits & y)
102 vunits r;
103 r = x;
104 r.n += y.n;
105 return r;
108 inline vunits operator -(const vunits & x, const vunits & y)
110 vunits r;
111 r = x;
112 r.n -= y.n;
113 return r;
116 inline vunits operator -(const vunits & x)
118 vunits r;
119 r.n = -x.n;
120 return r;
123 inline int operator /(const vunits & x, const vunits & y)
125 return x.n/y.n;
128 inline vunits operator /(const vunits & x, int n)
130 vunits r;
131 r = x;
132 r.n /= n;
133 return r;
136 inline vunits operator *(const vunits & x, int n)
138 vunits r;
139 r = x;
140 r.n *= n;
141 return r;
144 inline vunits operator *(int n, const vunits & x)
146 vunits r;
147 r = x;
148 r.n *= n;
149 return r;
152 inline int operator <(const vunits & x, const vunits & y)
154 return x.n < y.n;
157 inline int operator >(const vunits & x, const vunits & y)
159 return x.n > y.n;
162 inline int operator <=(const vunits & x, const vunits & y)
164 return x.n <= y.n;
167 inline int operator >=(const vunits & x, const vunits & y)
169 return x.n >= y.n;
172 inline int operator ==(const vunits & x, const vunits & y)
174 return x.n == y.n;
177 inline int operator !=(const vunits & x, const vunits & y)
179 return x.n != y.n;
183 inline vunits& vunits::operator+=(const vunits & x)
185 n += x.n;
186 return *this;
189 inline vunits& vunits::operator-=(const vunits & x)
191 n -= x.n;
192 return *this;
195 inline hunits:: hunits() : n(0)
199 inline units hunits::to_units()
201 return n*hresolution;
204 inline int hunits::is_zero()
206 return n == 0;
209 inline hunits operator +(const hunits & x, const hunits & y)
211 hunits r;
212 r = x;
213 r.n += y.n;
214 return r;
217 inline hunits operator -(const hunits & x, const hunits & y)
219 hunits r;
220 r = x;
221 r.n -= y.n;
222 return r;
225 inline hunits operator -(const hunits & x)
227 hunits r;
228 r = x;
229 r.n = -x.n;
230 return r;
233 inline int operator /(const hunits & x, const hunits & y)
235 return x.n/y.n;
238 inline hunits operator /(const hunits & x, int n)
240 hunits r;
241 r = x;
242 r.n /= n;
243 return r;
246 inline hunits operator *(const hunits & x, int n)
248 hunits r;
249 r = x;
250 r.n *= n;
251 return r;
254 inline hunits operator *(int n, const hunits & x)
256 hunits r;
257 r = x;
258 r.n *= n;
259 return r;
262 inline int operator <(const hunits & x, const hunits & y)
264 return x.n < y.n;
267 inline int operator >(const hunits & x, const hunits & y)
269 return x.n > y.n;
272 inline int operator <=(const hunits & x, const hunits & y)
274 return x.n <= y.n;
277 inline int operator >=(const hunits & x, const hunits & y)
279 return x.n >= y.n;
282 inline int operator ==(const hunits & x, const hunits & y)
284 return x.n == y.n;
287 inline int operator !=(const hunits & x, const hunits & y)
289 return x.n != y.n;
293 inline hunits& hunits::operator+=(const hunits & x)
295 n += x.n;
296 return *this;
299 inline hunits& hunits::operator-=(const hunits & x)
301 n -= x.n;
302 return *this;
305 inline hunits scale(hunits n, units x, units y)
307 hunits r;
308 r.n = scale(n.n, x, y);
309 return r;
312 inline vunits scale(vunits n, units x, units y)
314 vunits r;
315 r.n = scale(n.n, x, y);
316 return r;
319 inline vunits scale(vunits n, vunits x, vunits y)
321 vunits r;
322 r.n = scale(n.n, x.n, y.n);
323 return r;
326 inline hunits scale(hunits n, double x)
328 hunits r;
329 r.n = int(n.n*x);
330 return r;
333 inline units scale(units n, double x)
335 return int(n*x);
338 inline units points_to_units(units n)
340 return scale(n, units_per_inch, 72);