]> git.lyx.org Git - lyx.git/blob - src/support/types.h
remove lyxrc dependence from support/*
[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 <boost/cstdint.hpp>
20
21 #include <cstddef>
22
23 namespace lyx {
24
25         /// The type used to hold characters in paragraphs
26 #ifdef USE_WCHAR_T
27         // Prefer this if possible because GNU libstdc++ has usable
28         // std::ctype<wchar_t> locale facets but not
29         // std::ctype<boost::uint32_t>. gcc older than 3.4 is also missing
30         // usable std::char_traits<boost::uint32_t>.
31         typedef wchar_t char_type;
32 #else
33         typedef boost::uint32_t char_type;
34 #endif
35
36         /// a type for positions used in paragraphs
37         // needs to be signed for a while to hold the special value -1 that is
38         // used there
39         typedef ptrdiff_t  pos_type;
40
41         /// a type for paragraph offsets
42         // FIXME: should be unsigned as well.
43         // however, simply changing it breaks a downward loop somewhere...
44         typedef ptrdiff_t  pit_type;
45
46         /// a type for the nesting depth of a paragraph
47         typedef size_t     depth_type;
48
49 // set this to '0' if you want to have really safe types
50 #if 1
51
52         /// a type for sizes
53         typedef size_t     size_type;
54
55         /// a type used for numbering text classes
56         typedef size_t     textclass_type;
57
58 #else
59
60         // These structs wrap simple things to make them distinguishible
61         // to the compiler.
62         // It's a shame that different typedefs are not "really" different
63
64         struct size_type {
65                 ///
66                 typedef size_t  base_type;
67                 ///
68                 size_type(base_type t) { data_ = t; }
69                 ///
70                 operator base_type() const { return data_; }
71                 ///
72                 private:
73                 base_type data_;
74         };
75
76         struct textclass_type {
77                 ///
78                 typedef size_t   base_type;
79                 ///
80                 textclass_type(base_type t) { data_ = t; }
81                 ///
82                 operator base_type() const { return data_; }
83                 ///
84                 private:
85                 base_type data_;
86         };
87
88
89 #endif
90
91         ///
92         enum word_location {
93                 // the word around the cursor, only if the cursor is
94                 //not at a boundary
95                 WHOLE_WORD_STRICT,
96                 // the word around the cursor
97                 WHOLE_WORD,
98                 /// the word begining from the cursor position
99                 PARTIAL_WORD,
100                 /// the word around the cursor or before the cursor
101                 PREVIOUS_WORD,
102                 /// the next word (not yet used)
103                 NEXT_WORD
104         };
105
106 } // namespace lyx
107
108 #endif // LYX_TYPES_H