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