]> git.lyx.org Git - lyx.git/blob - src/support/types.h
48fc219e8fa59d9e65aec4632a687eaacef8f896
[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         // The type used to hold characters in paragraphs
24         //typedef uint32_t char_type; // Possibly the ucs-4 type we will use
25         //typedef wchar_t char_type;  // The wide char type CJK-LyX uses
26         typedef char char_type;       // Current narrow char type in use
27
28
29         /// a type for positions used in paragraphs
30         // needs to be signed for a while to hold the special value -1 that is
31         // used there
32         typedef ptrdiff_t  pos_type;
33
34         /// a type for paragraph offsets
35         // FIXME: should be unsigned as well.
36         // however, simply changing it breaks a downward loop somewhere...
37         typedef ptrdiff_t  pit_type;
38
39         /// a type for the nesting depth of a paragraph
40         typedef size_t     depth_type;
41
42 // set this to '0' if you want to have really safe types
43 #if 1
44
45         /// a type for sizes
46         typedef size_t     size_type;
47
48         /// a type used for numbering text classes
49         typedef size_t     textclass_type;
50
51 #else
52
53         // These structs wrap simple things to make them distinguishible
54         // to the compiler.
55         // It's a shame that different typedefs are not "really" different
56
57         struct size_type {
58                 ///
59                 typedef size_t  base_type;
60                 ///
61                 size_type(base_type t) { data_ = t; }
62                 ///
63                 operator base_type() const { return data_; }
64                 ///
65                 private:
66                 base_type data_;
67         };
68
69         struct textclass_type {
70                 ///
71                 typedef size_t   base_type;
72                 ///
73                 textclass_type(base_type t) { data_ = t; }
74                 ///
75                 operator base_type() const { return data_; }
76                 ///
77                 private:
78                 base_type data_;
79         };
80
81
82 #endif
83
84         ///
85         enum word_location {
86                 // the word around the cursor, only if the cursor is
87                 //not at a boundary
88                 WHOLE_WORD_STRICT,
89                 // the word around the cursor
90                 WHOLE_WORD,
91                 /// the word begining from the cursor position
92                 PARTIAL_WORD,
93                 /// the word around the cursor or before the cursor
94                 PREVIOUS_WORD,
95                 /// the next word (not yet used)
96                 NEXT_WORD
97         };
98
99 } // namespace lyx
100
101 #endif // LYX_TYPES_H