]> git.lyx.org Git - lyx.git/blob - src/Spacing.h
cosmetics
[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 class Spacing {
27 public:
28         ///
29         enum Space {
30                 ///
31                 Single,
32                 ///
33                 Onehalf,
34                 ///
35                 Double,
36                 ///
37                 Other,
38                 ///
39                 Default
40         };
41         ///
42         Spacing() : space(Default), value("1.0") {}
43         ///
44         Spacing(Spacing::Space sp, double val = 1.0) { set(sp, val); }
45         ///
46         Spacing(Spacing::Space sp, std::string const & val) { set(sp, val); }
47         ///
48         bool isDefault() const { return space == Default; }
49         ///
50         std::string const getValueAsString() const;
51         ///
52         double getValue() const;
53         ///
54         Spacing::Space getSpace() const { return space; }
55         ///
56         void set(Spacing::Space sp, double val = 1.0);
57         ///
58         void set(Spacing::Space sp, std::string const & val);
59         ///
60         void writeFile(std::ostream &, bool para = false) const;
61         ///
62         std::string const writeEnvirBegin() const;
63         ///
64         std::string const writeEnvirEnd() const;
65
66 private:
67         ///
68         Space space;
69         ///
70         std::string value;
71         /// names of line spacing
72         static std::string const spacing_string[];
73 };
74
75
76 ///
77 inline
78 bool operator==(Spacing const & a, Spacing const & b)
79 {
80         return a.getSpace() == b.getSpace()
81                 && a.getValueAsString() == b.getValueAsString();
82 }
83
84 ///
85 inline
86 bool operator!=(Spacing const & a, Spacing const & b)
87 {
88         return !(a == b);
89 }
90
91 } // namespace lyx
92
93 #endif // TEX2LYX
94 #endif // SPACING_H