]> git.lyx.org Git - lyx.git/blob - src/support/types.h
f7dfad62feb78675b802b4a8dbb7fffcfbd16645
[lyx.git] / src / support / types.h
1 #ifndef LYX_TYPES_H
2 #define LYX_TYPES_H
3
4 // provide a set of typedefs for commonly used things like sizes and
5 // indices while trying to stay compatible with types used by the standard
6 // containers.
7
8
9 // this probably could be improved by using <cstddef>...
10 #include <vector>
11
12 namespace lyx
13 {
14         /// a type for positions used in paragraphs
15         // needs to be signed for a while to hold the special value -1 that is
16         // used there...
17         typedef std::vector<char>::difference_type   pos_type;
18
19
20 // set this to '0' if you want to have really safe types
21 #if 1
22
23         /// a type for sizes
24         typedef std::vector<char>::size_type         size_type;
25
26         /// a type used for numbering layouts   within a text class
27         // used to be LyXTextClass::size_type
28         typedef std::vector<char>::size_type         layout_type;
29
30         /// a type used for numbering text classes
31         // used to be LyXTextClassList::size_type
32         typedef std::vector<char>::size_type         textclass_type;
33
34 #else
35
36         // These structs wrap simple things to make them distinguishible
37         // to the compiler.
38         // It's a shame that different typedefs are not "really" different
39
40         struct size_type {
41                 ///
42                 typedef std::vector<char>::size_type  base_type;
43                 ///
44                 size_type(base_type t) { data_ = t; }
45                 ///
46                 operator base_type() const { return data_; }
47                 ///
48                 private:
49                 base_type data_;
50         };
51                 
52
53         struct layout_type {
54                 ///
55                 typedef std::vector<char>::size_type  base_type;
56                 ///
57                 layout_type(base_type t) { data_ = t; }
58                 ///
59                 operator base_type() const { return data_; }
60                 ///
61                 void operator++() { ++data_; }
62                 ///
63                 private:
64                 base_type data_;
65         };
66                 
67
68         struct textclass_type {
69                 ///
70                 typedef std::vector<char>::size_type  base_type;
71                 ///
72                 textclass_type(base_type t) { data_ = t; }
73                 ///
74                 operator base_type() const { return data_; }
75                 ///
76                 private:
77                 base_type data_;
78         };
79                 
80
81 #endif
82
83 }
84
85 #endif