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(int f = -1, int c = -1, int s = -1);
33 explicit Bullet(string const &);
36 void setCharacter(int);
42 void setText(string const &);
44 int getCharacter() const;
50 string const & getText() const;
52 char const * c_str() const;
54 Bullet & operator = (Bullet const &);
56 friend bool operator==(Bullet const &, Bullet const &);
58 friend bool operator!=(Bullet const & b1, Bullet const & b2) {
62 #ifdef ENABLE_ASSERTIONS
63 void testInvariant() const {
65 Assert(font < FONTMAX);
66 Assert(character >= MIN);
67 Assert(character < CHARMAX);
69 Assert(size < SIZEMAX);
70 Assert(user_text >= -1);
71 Assert(user_text <= 1);
72 // now some relational/operational tests
74 Assert(font == -1 && (character == -1 && size == -1));
75 // Assert(!text.empty()); // this isn't necessarily an error
77 // else if (user_text == -1) {
78 // Assert(!text.empty()); // this also isn't necessarily an error
82 // Assert(text.empty()); // not usually true
88 This enum makes adding additional panels or changing panel sizes
89 easier. Since you only need change these values for all tests to
90 be correct for the new values.
92 Note: MAX means the size of the array so to test you need:
93 (x < MAX) *not* (x <= MAX)
107 void generateText() const;
109 static string bulletSize(short int);
111 static string bulletEntry(short int, short int);
120 // size, character and font are array indices to access
121 // the predefined arrays of LaTeX equivalent strings.
123 /** flag indicates if user has control of text (1)
124 or if I can use it to generate strings (0)
127 mutable short user_text;
129 //NOTE: Arranging these four shorts above to be together
130 // like this should ensure they are in a single cache line
132 /** text may contain a user-defined LaTeX symbol command
133 or one generated internally from the font, character
140 /*----------------Inline Bullet Member Functions------------------*/
143 Bullet::Bullet(string const & t)
144 : font(MIN), character(MIN), size(MIN), user_text(1), text(t)
146 #ifdef ENABLE_ASSERTIONS
153 void Bullet::setCharacter(int c)
155 if (c < MIN || c >= CHARMAX) {
161 #ifdef ENABLE_ASSERTIONS
168 void Bullet::setFont(int f)
170 if (f < MIN || f >= FONTMAX) {
176 #ifdef ENABLE_ASSERTIONS
183 void Bullet::setSize(int s)
185 if (s < MIN || s >= SIZEMAX) {
191 #ifdef ENABLE_ASSERTIONS
198 void Bullet::setText(string const & t)
200 font = character = size = MIN;
203 #ifdef ENABLE_ASSERTIONS
210 int Bullet::getCharacter() const
217 int Bullet::getFont() const
224 int Bullet::getSize() const
231 Bullet & Bullet::operator=(Bullet const & b)
233 #ifdef ENABLE_ASSERTIONS
237 character = b.character;
239 user_text = b.user_text;
241 #ifdef ENABLE_ASSERTIONS
242 this->testInvariant();
249 char const * Bullet::c_str() const
251 return getText().c_str();
255 /*-----------------End Bullet Member Functions-----------------*/
258 Bullet const ITEMIZE_DEFAULTS[];
260 #endif /* BULLET_H_ */