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 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------------------*/
145 Bullet::Bullet(string const & t)
146 : font(MIN), character(MIN), size(MIN), user_text(1), text(t)
148 #ifdef ENABLE_ASSERTIONS
155 void Bullet::setCharacter(int c)
157 if (c < MIN || c >= CHARMAX) {
163 #ifdef ENABLE_ASSERTIONS
170 void Bullet::setFont(int f)
172 if (f < MIN || f >= FONTMAX) {
178 #ifdef ENABLE_ASSERTIONS
185 void Bullet::setSize(int s)
187 if (s < MIN || s >= SIZEMAX) {
193 #ifdef ENABLE_ASSERTIONS
200 void Bullet::setText(string const & t)
202 font = character = size = MIN;
205 #ifdef ENABLE_ASSERTIONS
212 int Bullet::getCharacter() const
219 int Bullet::getFont() const
226 int Bullet::getSize() const
233 string Bullet::getText() const
240 Bullet & Bullet::operator=(Bullet const & b)
242 #ifdef ENABLE_ASSERTIONS
246 character = b.character;
248 user_text = b.user_text;
250 #ifdef ENABLE_ASSERTIONS
251 this->testInvariant();
258 char const * Bullet::c_str() const
260 return this->getText().c_str();
264 /*-----------------End Bullet Member Functions-----------------*/
267 Bullet const ITEMIZE_DEFAULTS[];
269 #endif /* BULLET_H_ */