]> git.lyx.org Git - lyx.git/blob - src/support/types.h
layout as string
[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 text classes
27         // used to be LyXTextClassList::size_type
28         typedef std::vector<char>::size_type         textclass_type;
29
30 #else
31
32         // These structs wrap simple things to make them distinguishible
33         // to the compiler.
34         // It's a shame that different typedefs are not "really" different
35
36         struct size_type {
37                 ///
38                 typedef std::vector<char>::size_type  base_type;
39                 ///
40                 size_type(base_type t) { data_ = t; }
41                 ///
42                 operator base_type() const { return data_; }
43                 ///
44                 private:
45                 base_type data_;
46         };
47
48         struct textclass_type {
49                 ///
50                 typedef std::vector<char>::size_type  base_type;
51                 ///
52                 textclass_type(base_type t) { data_ = t; }
53                 ///
54                 operator base_type() const { return data_; }
55                 ///
56                 private:
57                 base_type data_;
58         };
59                 
60
61 #endif
62
63 }
64
65 #endif