]> git.lyx.org Git - lyx.git/blob - src/support/types.h
another safety belt
[lyx.git] / src / support / types.h
1 /**
2  * \file types.h
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * Provide a set of typedefs for commonly used things like sizes and
7  * indices wile trying to stay compatible with types used
8  * by the standard containers.
9  *
10  * \author André Pönitz
11  *
12  * Full author contact details are available in file CREDITS
13  */
14
15 #ifndef LYX_TYPES_H
16 #define LYX_TYPES_H
17
18 // this probably could be improved by using <cstddef>...
19 #include <vector>
20
21 namespace lyx
22 {
23         /// a type for positions used in paragraphs
24         // needs to be signed for a while to hold the special value -1 that is
25         // used there...
26         typedef std::vector<char>::difference_type   pos_type;
27
28
29 // set this to '0' if you want to have really safe types
30 #if 1
31
32         /// a type for sizes
33         typedef std::vector<char>::size_type         size_type;
34
35         /// a type used for numbering text classes
36         // used to be LyXTextClassList::size_type
37         typedef std::vector<char>::size_type         textclass_type;
38
39 #else
40
41         // These structs wrap simple things to make them distinguishible
42         // to the compiler.
43         // It's a shame that different typedefs are not "really" different
44
45         struct size_type {
46                 ///
47                 typedef std::vector<char>::size_type  base_type;
48                 ///
49                 size_type(base_type t) { data_ = t; }
50                 ///
51                 operator base_type() const { return data_; }
52                 ///
53                 private:
54                 base_type data_;
55         };
56
57         struct textclass_type {
58                 ///
59                 typedef std::vector<char>::size_type  base_type;
60                 ///
61                 textclass_type(base_type t) { data_ = t; }
62                 ///
63                 operator base_type() const { return data_; }
64                 ///
65                 private:
66                 base_type data_;
67         };
68
69
70 #endif
71
72 }
73
74 #endif // LYX_TYPES_H