]> git.lyx.org Git - lyx.git/blob - src/support/types.h
c4dedcdece3510546ead4290b69cad78c42031b7
[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 // this probably could be improved by using <cstddef>...
20 #include <vector>
21
22 namespace lyx
23 {
24         /// a type for positions used in paragraphs
25         // needs to be signed for a while to hold the special value -1 that is
26         // used there...
27         typedef std::vector<char>::difference_type   pos_type;
28
29         /// a type for the nesting depth of a paragraph
30         typedef unsigned int depth_type;
31
32 // set this to '0' if you want to have really safe types
33 #if 1
34
35         /// a type for sizes
36         typedef std::vector<char>::size_type         size_type;
37
38         /// a type used for numbering text classes
39         // used to be LyXTextClassList::size_type
40         typedef std::vector<char>::size_type         textclass_type;
41
42 #else
43
44         // These structs wrap simple things to make them distinguishible
45         // to the compiler.
46         // It's a shame that different typedefs are not "really" different
47
48         struct size_type {
49                 ///
50                 typedef std::vector<char>::size_type  base_type;
51                 ///
52                 size_type(base_type t) { data_ = t; }
53                 ///
54                 operator base_type() const { return data_; }
55                 ///
56                 private:
57                 base_type data_;
58         };
59
60         struct textclass_type {
61                 ///
62                 typedef std::vector<char>::size_type  base_type;
63                 ///
64                 textclass_type(base_type t) { data_ = t; }
65                 ///
66                 operator base_type() const { return data_; }
67                 ///
68                 private:
69                 base_type data_;
70         };
71
72
73 #endif
74
75         ///
76         enum word_location {
77                 // the word around the cursor, only if the cursor is
78                 //not at a boundary
79                 WHOLE_WORD_STRICT,
80                 // the word around the cursor
81                 WHOLE_WORD,
82                 /// the word begining from the cursor position
83                 PARTIAL_WORD,
84                 /// the word around the cursor or before the cursor
85                 PREVIOUS_WORD,
86                 /// the next word (not yet used)
87                 NEXT_WORD
88         };
89
90 }
91
92 #endif // LYX_TYPES_H