]> git.lyx.org Git - lyx.git/blob - src/support/types.h
Transfer tempName() implementation to FileName.
[lyx.git] / src / support / types.h
1 // -*- C++ -*-
2 /**
3  * \file types.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * Provide a set of typedefs for commonly used things like sizes and
8  * indices wile trying to stay compatible with types used
9  * by the standard containers.
10  *
11  * \author André Pönitz
12  *
13  * Full author contact details are available in file CREDITS.
14  */
15
16 #ifndef LYX_TYPES_H
17 #define LYX_TYPES_H
18
19 #include <cstddef>
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 ptrdiff_t  pos_type;
27
28         /// a type for paragraph offsets
29         // FIXME: should be unsigned as well.
30         // however, simply changing it breaks a downward loop somewhere...
31         typedef ptrdiff_t  pit_type;
32
33         /// a type for the nesting depth of a paragraph
34         typedef size_t     depth_type;
35
36 // set this to '0' if you want to have really safe types
37 #if 1
38
39         /// a type for sizes
40         typedef size_t     size_type;
41
42         /// a type used for numbering text classes
43         typedef size_t     textclass_type;
44
45 #else
46
47         // These structs wrap simple things to make them distinguishible
48         // to the compiler.
49         // It's a shame that different typedefs are not "really" different
50
51         struct size_type {
52                 ///
53                 typedef size_t  base_type;
54                 ///
55                 size_type(base_type t) { data_ = t; }
56                 ///
57                 operator base_type() const { return data_; }
58                 ///
59                 private:
60                 base_type data_;
61         };
62
63         struct textclass_type {
64                 ///
65                 typedef size_t   base_type;
66                 ///
67                 textclass_type(base_type t) { data_ = t; }
68                 ///
69                 operator base_type() const { return data_; }
70                 ///
71                 private:
72                 base_type data_;
73         };
74
75
76 #endif
77
78         ///
79         enum word_location {
80                 // the word around the cursor, only if the cursor is
81                 //not at a boundary
82                 WHOLE_WORD_STRICT,
83                 // the word around the cursor
84                 WHOLE_WORD,
85                 /// the word begining from the cursor position
86                 PARTIAL_WORD,
87                 /// the word around the cursor or before the cursor
88                 PREVIOUS_WORD,
89                 /// the next word (not yet used)
90                 NEXT_WORD
91         };
92
93         ///
94         enum PageSides {
95                 ///
96                 OneSide,
97                 ///
98                 TwoSides
99         };
100
101 } // namespace lyx
102
103 #endif // LYX_TYPES_H