2 /* This is the bullet class definition file.
4 * ======================================================
6 * LyX, The Document Processor
8 * Copyright 1995 Matthias Ettrich
9 * Copyright 1995-2000 The LyX Team.
11 * This file Copyright 1997-1999
13 * ====================================================== */
24 #include "support/LAssert.h"
30 Bullet(const int f = -1, const int c = -1, const int s = -1);
33 Bullet(string const &);
36 void setCharacter(int);
42 void setText(string const &);
44 int getCharacter() const;
50 string getText() const;
54 char const * c_str() const;
56 Bullet & operator = (Bullet const &);
58 friend bool operator==(Bullet const &, Bullet const &);
60 friend bool operator!=(Bullet const & b1, Bullet const & b2) {
64 #ifdef ENABLE_ASSERTIONS
65 void testInvariant() const {
67 Assert(font < FONTMAX);
68 Assert(character >= MIN);
69 Assert(character < CHARMAX);
71 Assert(size < SIZEMAX);
72 Assert(user_text >= -1);
73 Assert(user_text <= 1);
74 // now some relational/operational tests
76 Assert(font == -1 && (character == -1 && size == -1));
77 // Assert(!text.empty()); // this isn't necessarily an error
79 // else if (user_text == -1) {
80 // Assert(!text.empty()); // this also isn't necessarily an error
84 // Assert(text.empty()); // not usually true
90 This enum makes adding additional panels or changing panel sizes
91 easier. Since you only need change these values for all tests to
92 be correct for the new values.
94 Note: MAX means the size of the array so to test you need:
95 (x < MAX) *not* (x <= MAX)
111 static string bulletSize(short int);
113 static string bulletEntry(short int, short int);
122 // size, character and font are array indices to access
123 // the predefined arrays of LaTeX equivalent strings.
125 /** flag indicates if user has control of text (1)
126 or if I can use it to generate strings (0)
131 //NOTE: Arranging these four shorts above to be together
132 // like this should ensure they are in a single cache line
134 /** text may contain a user-defined LaTeX symbol command
135 or one generated internally from the font, character
142 /*----------------Inline Bullet Member Functions------------------*/
144 inline Bullet::Bullet(string const & t)
145 : font(MIN), character(MIN), size(MIN), user_text(1), text(t)
147 #ifdef ENABLE_ASSERTIONS
153 inline void Bullet::setCharacter(int c)
155 if (c < MIN || c >= CHARMAX) {
161 #ifdef ENABLE_ASSERTIONS
167 inline void Bullet::setFont(int f)
169 if (f < MIN || f >= FONTMAX) {
175 #ifdef ENABLE_ASSERTIONS
181 inline void Bullet::setSize(int s)
183 if (s < MIN || s >= SIZEMAX) {
189 #ifdef ENABLE_ASSERTIONS
195 inline void Bullet::setText(string const & t)
197 font = character = size = MIN;
200 #ifdef ENABLE_ASSERTIONS
206 inline int Bullet::getCharacter() const
212 inline int Bullet::getFont() const
218 inline int Bullet::getSize() const
224 inline string Bullet::getText() const
230 inline Bullet & Bullet::operator=(Bullet const & b)
232 #ifdef ENABLE_ASSERTIONS
236 character = b.character;
238 user_text = b.user_text;
240 #ifdef ENABLE_ASSERTIONS
241 this->testInvariant();
247 inline char const * Bullet::c_str() const
249 return this->getText().c_str();
253 /*-----------------End Bullet Member Functions-----------------*/
256 Bullet const ITEMIZE_DEFAULTS[];
258 #endif /* BULLET_H_ */