]> git.lyx.org Git - lyx.git/blob - src/Spacing.h
simplify build process of tex2lyx
[lyx.git] / src / Spacing.h
1 // -*- C++ -*-
2 /**
3  * \file src/Spacing.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Lars Gullik Bjønnes
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef SPACING_H
13 #define SPACING_H
14
15 #ifdef TEX2LYX
16 #include "tex2lyx/Spacing.h"
17 #else
18
19 #include <iosfwd>
20 #include <string>
21
22
23 namespace lyx {
24
25
26 ///
27 class Spacing {
28 public:
29         ///
30         enum Space {
31                 ///
32                 Single,
33                 ///
34                 Onehalf,
35                 ///
36                 Double,
37                 ///
38                 Other,
39                 ///
40                 Default
41         };
42         ///
43         Spacing() : space(Default), value("1.0") {}
44         ///
45         Spacing(Spacing::Space sp, double val = 1.0) {
46                 set(sp, val);
47         }
48         Spacing(Spacing::Space sp, std::string const & val) {
49                 set(sp, val);
50         }
51         ///
52         bool isDefault() const {
53                 return space == Default;
54         }
55         ///
56         std::string const getValueAsString() const;
57         ///
58         double getValue() const;
59         ///
60         Spacing::Space getSpace() const { return space; }
61         ///
62         void set(Spacing::Space sp, double val = 1.0);
63         ///
64         void set(Spacing::Space sp, std::string const & val);
65         ///
66         void writeFile(std::ostream &, bool para = false) const;
67         ///
68         std::string const writeEnvirBegin() const;
69         ///
70         std::string const writeEnvirEnd() const;
71
72 private:
73         ///
74         Space space;
75         ///
76         std::string value;
77         /// names of line spacing
78         static std::string const spacing_string[];
79 };
80
81
82 ///
83 inline
84 bool operator==(Spacing const & a, Spacing const & b)
85 {
86         return a.getSpace() == b.getSpace()
87                 && a.getValueAsString() == b.getValueAsString();
88 }
89
90 ///
91 inline
92 bool operator!=(Spacing const & a, Spacing const & b)
93 {
94         return !(a == b);
95 }
96
97 } // namespace lyx
98
99 #endif // TEX2LYX
100 #endif // SPACING_H