X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FBullet.h;h=38fc29e4cbc85308cf248fe9da80ea0400066ff2;hb=068e2cfb25bfbab62f80bc0c776ca169032c2219;hp=4ad38431cd687db4afd959e60b84fa6201e65f9c;hpb=c52895023e231587208b5c9257ae7825dc493ef0;p=lyx.git diff --git a/src/Bullet.h b/src/Bullet.h index 4ad38431cd..38fc29e4cb 100644 --- a/src/Bullet.h +++ b/src/Bullet.h @@ -27,10 +27,10 @@ class Bullet { public: /// - Bullet(const int f = -1, const int c = -1, const int s = -1); + Bullet(int f = -1, int c = -1, int s = -1); /// - Bullet(string const &); + explicit Bullet(string const &); /// void setCharacter(int); @@ -47,21 +47,14 @@ public: /// int getSize() const; /// - string getText() const; + string const & getText() const; /// - string getText(); - /// - char const * c_str() const; - /// - Bullet & operator = (Bullet const &); + Bullet & operator=(Bullet const &); /// friend bool operator==(Bullet const &, Bullet const &); - /// - friend bool operator!=(Bullet const & b1, Bullet const & b2) { - return !(b1 == b2); - } protected: #ifdef ENABLE_ASSERTIONS + /// void testInvariant() const { Assert(font >= MIN); Assert(font < FONTMAX); @@ -106,18 +99,18 @@ private: }; /// - void generateText(); + void generateText() const; /// - static string bulletSize(short int); + static string const bulletSize(short int); /// - static string bulletEntry(short int, short int); + static string const bulletEntry(short int, short int); /// - short font; + int font; /// - short character; + int character; /// - short size; + int size; // size, character and font are array indices to access // the predefined arrays of LaTeX equivalent strings. @@ -126,7 +119,7 @@ private: or if I can use it to generate strings (0) or have already (-1) */ - short user_text; + mutable short user_text; //NOTE: Arranging these four shorts above to be together // like this should ensure they are in a single cache line @@ -135,13 +128,14 @@ private: or one generated internally from the font, character and size settings. */ - string text; + mutable string text; }; /*----------------Inline Bullet Member Functions------------------*/ -inline Bullet::Bullet(string const & t) +inline +Bullet::Bullet(string const & t) : font(MIN), character(MIN), size(MIN), user_text(1), text(t) { #ifdef ENABLE_ASSERTIONS @@ -150,7 +144,8 @@ inline Bullet::Bullet(string const & t) } -inline void Bullet::setCharacter(int c) +inline +void Bullet::setCharacter(int c) { if (c < MIN || c >= CHARMAX) { character = MIN; @@ -164,7 +159,8 @@ inline void Bullet::setCharacter(int c) } -inline void Bullet::setFont(int f) +inline +void Bullet::setFont(int f) { if (f < MIN || f >= FONTMAX) { font = MIN; @@ -178,7 +174,8 @@ inline void Bullet::setFont(int f) } -inline void Bullet::setSize(int s) +inline +void Bullet::setSize(int s) { if (s < MIN || s >= SIZEMAX) { size = MIN; @@ -192,7 +189,8 @@ inline void Bullet::setSize(int s) } -inline void Bullet::setText(string const & t) +inline +void Bullet::setText(string const & t) { font = character = size = MIN; user_text = 1; @@ -203,31 +201,29 @@ inline void Bullet::setText(string const & t) } -inline int Bullet::getCharacter() const +inline +int Bullet::getCharacter() const { return character; } -inline int Bullet::getFont() const +inline +int Bullet::getFont() const { return font; } -inline int Bullet::getSize() const +inline +int Bullet::getSize() const { return size; } -inline string Bullet::getText() const -{ - return text; -} - - -inline Bullet & Bullet::operator=(Bullet const & b) +inline +Bullet & Bullet::operator=(Bullet const & b) { #ifdef ENABLE_ASSERTIONS b.testInvariant(); @@ -243,15 +239,15 @@ inline Bullet & Bullet::operator=(Bullet const & b) return *this; } +/*-----------------End Bullet Member Functions-----------------*/ -inline char const * Bullet::c_str() const +inline +bool operator!=(Bullet const & b1, Bullet const & b2) { - return this->getText().c_str(); + return !(b1 == b2); } - -/*-----------------End Bullet Member Functions-----------------*/ - +/// extern Bullet const ITEMIZE_DEFAULTS[];