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
64 void testInvariant() const {
66 Assert(font < FONTMAX);
67 Assert(character >= MIN);
68 Assert(character < CHARMAX);
70 Assert(size < SIZEMAX);
71 Assert(user_text >= -1);
72 Assert(user_text <= 1);
73 // now some relational/operational tests
75 Assert(font == -1 && (character == -1 && size == -1));
76 // Assert(!text.empty()); // this isn't necessarily an error
78 // else if (user_text == -1) {
79 // Assert(!text.empty()); // this also isn't necessarily an error
83 // Assert(text.empty()); // not usually true
89 This enum makes adding additional panels or changing panel sizes
90 easier. Since you only need change these values for all tests to
91 be correct for the new values.
93 Note: MAX means the size of the array so to test you need:
94 (x < MAX) *not* (x <= MAX)
108 void generateText() const;
110 static string bulletSize(short int);
112 static string bulletEntry(short int, short int);
121 // size, character and font are array indices to access
122 // the predefined arrays of LaTeX equivalent strings.
124 /** flag indicates if user has control of text (1)
125 or if I can use it to generate strings (0)
128 mutable short user_text;
130 //NOTE: Arranging these four shorts above to be together
131 // like this should ensure they are in a single cache line
133 /** text may contain a user-defined LaTeX symbol command
134 or one generated internally from the font, character
141 /*----------------Inline Bullet Member Functions------------------*/
144 Bullet::Bullet(string const & t)
145 : font(MIN), character(MIN), size(MIN), user_text(1), text(t)
147 #ifdef ENABLE_ASSERTIONS
154 void Bullet::setCharacter(int c)
156 if (c < MIN || c >= CHARMAX) {
162 #ifdef ENABLE_ASSERTIONS
169 void Bullet::setFont(int f)
171 if (f < MIN || f >= FONTMAX) {
177 #ifdef ENABLE_ASSERTIONS
184 void Bullet::setSize(int s)
186 if (s < MIN || s >= SIZEMAX) {
192 #ifdef ENABLE_ASSERTIONS
199 void Bullet::setText(string const & t)
201 font = character = size = MIN;
204 #ifdef ENABLE_ASSERTIONS
211 int Bullet::getCharacter() const
218 int Bullet::getFont() const
225 int Bullet::getSize() const
232 Bullet & Bullet::operator=(Bullet const & b)
234 #ifdef ENABLE_ASSERTIONS
238 character = b.character;
240 user_text = b.user_text;
242 #ifdef ENABLE_ASSERTIONS
243 this->testInvariant();
250 char const * Bullet::c_str() const
252 return getText().c_str();
256 /*-----------------End Bullet Member Functions-----------------*/
260 Bullet const ITEMIZE_DEFAULTS[];
262 #endif /* BULLET_H_ */