]> git.lyx.org Git - lyx.git/blob - src/support/types.h
Create a grfx::Loader class and so move large chunks of code out of
[lyx.git] / src / support / types.h
1 /**
2  * \file types.h
3  * Copyright 2002 the LyX Team
4  * Read 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
13 #ifndef LYX_TYPES_H
14 #define LYX_TYPES_H
15
16 // this probably could be improved by using <cstddef>...
17 #include <vector>
18
19 namespace lyx
20 {
21         /// a type for positions used in paragraphs
22         // needs to be signed for a while to hold the special value -1 that is
23         // used there...
24         typedef std::vector<char>::difference_type   pos_type;
25
26
27 // set this to '0' if you want to have really safe types
28 #if 1
29
30         /// a type for sizes
31         typedef std::vector<char>::size_type         size_type;
32
33         /// a type used for numbering text classes
34         // used to be LyXTextClassList::size_type
35         typedef std::vector<char>::size_type         textclass_type;
36
37 #else
38
39         // These structs wrap simple things to make them distinguishible
40         // to the compiler.
41         // It's a shame that different typedefs are not "really" different
42
43         struct size_type {
44                 ///
45                 typedef std::vector<char>::size_type  base_type;
46                 ///
47                 size_type(base_type t) { data_ = t; }
48                 ///
49                 operator base_type() const { return data_; }
50                 ///
51                 private:
52                 base_type data_;
53         };
54
55         struct textclass_type {
56                 ///
57                 typedef std::vector<char>::size_type  base_type;
58                 ///
59                 textclass_type(base_type t) { data_ = t; }
60                 ///
61                 operator base_type() const { return data_; }
62                 ///
63                 private:
64                 base_type data_;
65         };
66
67
68 #endif
69
70 }
71
72 #endif // LYX_TYPES_H