From 3c68c879234ed8fc7cb1b7b57653c2925c925fed Mon Sep 17 00:00:00 2001 From: scrawl Date: Wed, 1 May 2013 10:28:59 +0200 Subject: [PATCH] Fix some naming guidelines, fix topic index exception, fix exception in keyword search for some journal entries --- apps/openmw/mwgui/bookpage.cpp | 360 ++++++++++++------------- apps/openmw/mwgui/bookpage.hpp | 48 ++-- apps/openmw/mwgui/journalbooks.cpp | 188 ++++++------- apps/openmw/mwgui/journalbooks.hpp | 22 +- apps/openmw/mwgui/journalviewmodel.cpp | 168 ++++++------ apps/openmw/mwgui/journalviewmodel.hpp | 34 +-- apps/openmw/mwgui/journalwindow.cpp | 106 ++++---- components/misc/utf8stream.hpp | 38 +-- 8 files changed, 473 insertions(+), 491 deletions(-) diff --git a/apps/openmw/mwgui/bookpage.cpp b/apps/openmw/mwgui/bookpage.cpp index 309e4ea9b..1270404e9 100644 --- a/apps/openmw/mwgui/bookpage.cpp +++ b/apps/openmw/mwgui/bookpage.cpp @@ -23,18 +23,18 @@ namespace MWGui using namespace MyGUI; using namespace MWGui; -static bool ucs_space (int code_point); -static bool ucs_line_break (int code_point); -static bool ucs_breaking_space (int code_point); +static bool ucsSpace (int codePoint); +static bool ucsLineBreak (int codePoint); +static bool ucsBreakingSpace (int codePoint); struct BookTypesetter::Style { virtual ~Style () {} }; struct MWGui::TypesetBookImpl : TypesetBook { - typedef std::vector content; - typedef std::list contents; - typedef utf8_stream::point utf8_point; - typedef std::pair range; + typedef std::vector Content; + typedef std::list Contents; + typedef Utf8Stream::Point Utf8Point; + typedef std::pair Range; struct StyleImpl : BookTypesetter::Style { @@ -42,7 +42,7 @@ struct MWGui::TypesetBookImpl : TypesetBook Colour mHotColour; Colour mActiveColour; Colour mNormalColour; - interactive_id mInteractiveId; + InteractiveId mInteractiveId; bool match (IFont* tstFont, Colour tstHotColour, Colour tstActiveColour, Colour tstNormalColour, intptr_t tstInteractiveId) { @@ -66,56 +66,56 @@ struct MWGui::TypesetBookImpl : TypesetBook } }; - typedef std::list styles; + typedef std::list Styles; struct Run { StyleImpl* mStyle; - range mRange; + Range mRange; int mLeft, mRight; int mPrintableChars; }; - typedef std::vector runs; + typedef std::vector Runs; struct Line { - runs mRuns; + Runs mRuns; IntRect mRect; }; - typedef std::vector lines; + typedef std::vector Lines; struct Section { - lines mLines; + Lines mLines; IntRect mRect; }; - typedef std::vector
sections; + typedef std::vector
Sections; - typedef std::pair page; - typedef std::vector pages; + typedef std::pair Page; + typedef std::vector Pages; - pages mPages; - sections mSections; - contents mContents; - styles mStyles; + Pages mPages; + Sections mSections; + Contents mContents; + Styles mStyles; IntRect mRect; virtual ~TypesetBookImpl () {} - range addContent (BookTypesetter::utf8_span Text) + Range addContent (BookTypesetter::Utf8Span text) { - contents::iterator i = mContents.insert (mContents.end (), content (Text.first, Text.second)); + Contents::iterator i = mContents.insert (mContents.end (), Content (text.first, text.second)); if (i->size () == 0) - return range (utf8_point (NULL), utf8_point (NULL)); + return Range (Utf8Point (NULL), Utf8Point (NULL)); - utf8_point begin = &i->front (); - utf8_point end = &i->front () + i->size (); + Utf8Point begin = &i->front (); + Utf8Point end = &i->front () + i->size (); - return range (begin, end); + return Range (begin, end); } size_t pageCount () const { return mPages.size (); } @@ -125,49 +125,49 @@ struct MWGui::TypesetBookImpl : TypesetBook return std::make_pair (mRect.width (), mRect.height ()); } - template - void visitRuns (int top, int bottom, IFont* Font, visitor const & Visitor) const + template + void visitRuns (int top, int bottom, IFont* Font, Visitor const & visitor) const { - for (sections::const_iterator i = mSections.begin (); i != mSections.end (); ++i) + for (Sections::const_iterator i = mSections.begin (); i != mSections.end (); ++i) { if (top >= mRect.bottom || bottom <= i->mRect.top) continue; - for (lines::const_iterator j = i->mLines.begin (); j != i->mLines.end (); ++j) + for (Lines::const_iterator j = i->mLines.begin (); j != i->mLines.end (); ++j) { if (top >= j->mRect.bottom || bottom <= j->mRect.top) continue; - for (runs::const_iterator k = j->mRuns.begin (); k != j->mRuns.end (); ++k) + for (Runs::const_iterator k = j->mRuns.begin (); k != j->mRuns.end (); ++k) if (!Font || k->mStyle->mFont == Font) - Visitor (*i, *j, *k); + visitor (*i, *j, *k); } } } - template - void visitRuns (int top, int bottom, visitor const & Visitor) const + template + void visitRuns (int top, int bottom, Visitor const & visitor) const { - visitRuns (top, bottom, NULL, Visitor); + visitRuns (top, bottom, NULL, visitor); } StyleImpl * hitTest (int left, int top) const { - for (sections::const_iterator i = mSections.begin (); i != mSections.end (); ++i) + for (Sections::const_iterator i = mSections.begin (); i != mSections.end (); ++i) { if (top < i->mRect.top || top >= i->mRect.bottom) continue; int left1 = left - i->mRect.left; - for (lines::const_iterator j = i->mLines.begin (); j != i->mLines.end (); ++j) + for (Lines::const_iterator j = i->mLines.begin (); j != i->mLines.end (); ++j) { if (top < j->mRect.top || top >= j->mRect.bottom) continue; int left2 = left1 - j->mRect.left; - for (runs::const_iterator k = j->mRuns.begin (); k != j->mRuns.end (); ++k) + for (Runs::const_iterator k = j->mRuns.begin (); k != j->mRuns.end (); ++k) { if (left2 < k->mLeft || left2 >= k->mRight) continue; @@ -180,10 +180,10 @@ struct MWGui::TypesetBookImpl : TypesetBook return nullptr; } - IFont* affectedFont (StyleImpl* Style) + IFont* affectedFont (StyleImpl* style) { - for (styles::iterator i = mStyles.begin (); i != mStyles.end (); ++i) - if (&*i == Style) + for (Styles::iterator i = mStyles.begin (); i != mStyles.end (); ++i) + if (&*i == style) return i->mFont; return NULL; } @@ -193,92 +193,92 @@ struct MWGui::TypesetBookImpl : TypesetBook struct TypesetBookImpl::Typesetter : BookTypesetter { - typedef TypesetBookImpl book; - typedef boost::shared_ptr book_ptr; + typedef TypesetBookImpl Book; + typedef boost::shared_ptr BookPtr; int mPageWidth; int mPageHeight; - book_ptr mBook; + BookPtr mBook; Section * mSection; Line * mLine; Run * mRun; - std::vector mSectionAlignment; + std::vector mSectionAlignment; - book::content const * mCurrentContent; - alignment mCurrentAlignment; + Book::Content const * mCurrentContent; + Alignment mCurrentAlignment; - Typesetter (size_t Width, size_t Height) : - mPageWidth (Width), mPageHeight(Height), + Typesetter (size_t width, size_t height) : + mPageWidth (width), mPageHeight(height), mSection (NULL), mLine (NULL), mRun (NULL), - mCurrentAlignment (alignLeft), + mCurrentAlignment (AlignLeft), mCurrentContent (NULL) { - mBook = boost::make_shared (); + mBook = boost::make_shared (); } virtual ~Typesetter () { } - Style * createStyle (char const * FontName, Colour FontColour) + Style * createStyle (char const * fontName, Colour fontColour) { - for (styles::iterator i = mBook->mStyles.begin (); i != mBook->mStyles.end (); ++i) - if (i->match (FontName, FontColour, FontColour, FontColour, 0)) + for (Styles::iterator i = mBook->mStyles.begin (); i != mBook->mStyles.end (); ++i) + if (i->match (fontName, fontColour, fontColour, fontColour, 0)) return &*i; StyleImpl & style = *mBook->mStyles.insert (mBook->mStyles.end (), StyleImpl ()); - style.mFont = FontManager::getInstance().getByName(FontName); - style.mHotColour = FontColour; - style.mActiveColour = FontColour; - style.mNormalColour = FontColour; + style.mFont = FontManager::getInstance().getByName(fontName); + style.mHotColour = fontColour; + style.mActiveColour = fontColour; + style.mNormalColour = fontColour; style.mInteractiveId = 0; return &style; } - Style* createHotStyle (Style* _BaseStyle, coulour NormalColour, coulour HoverColour, coulour ActiveColour, interactive_id Id, bool Unique) + Style* createHotStyle (Style* baseStyle, Colour normalColour, Colour hoverColour, Colour activeColour, InteractiveId id, bool unique) { - StyleImpl* BaseStyle = dynamic_cast (_BaseStyle); + StyleImpl* BaseStyle = dynamic_cast (baseStyle); - if (!Unique) - for (styles::iterator i = mBook->mStyles.begin (); i != mBook->mStyles.end (); ++i) - if (i->match (BaseStyle->mFont, HoverColour, ActiveColour, NormalColour, Id)) + if (!unique) + for (Styles::iterator i = mBook->mStyles.begin (); i != mBook->mStyles.end (); ++i) + if (i->match (BaseStyle->mFont, hoverColour, activeColour, normalColour, id)) return &*i; StyleImpl & style = *mBook->mStyles.insert (mBook->mStyles.end (), StyleImpl ()); style.mFont = BaseStyle->mFont; - style.mHotColour = HoverColour; - style.mActiveColour = ActiveColour; - style.mNormalColour = NormalColour; - style.mInteractiveId = Id; + style.mHotColour = hoverColour; + style.mActiveColour = activeColour; + style.mNormalColour = normalColour; + style.mInteractiveId = id; return &style; } - void write (Style * _Style, utf8_span Text) + void write (Style * style, Utf8Span text) { - range text = mBook->addContent (Text); + Range range = mBook->addContent (text); - write_impl (dynamic_cast (_Style), text.first, text.second); + writeImpl (dynamic_cast (style), range.first, range.second); } - intptr_t add_content (utf8_span Text, bool Select) + intptr_t addContent (Utf8Span text, bool select) { - contents::iterator i = mBook->mContents.insert (mBook->mContents.end (), content (Text.first, Text.second)); + Contents::iterator i = mBook->mContents.insert (mBook->mContents.end (), Content (text.first, text.second)); - if (Select) + if (select) mCurrentContent = &(*i); return reinterpret_cast (&(*i)); } - void select_content (intptr_t contentHandle) + void selectContent (intptr_t contentHandle) { - mCurrentContent = reinterpret_cast (contentHandle); + mCurrentContent = reinterpret_cast (contentHandle); } void write (Style * style, size_t begin, size_t end) @@ -287,10 +287,10 @@ struct TypesetBookImpl::Typesetter : BookTypesetter assert (end <= mCurrentContent->size ()); assert (begin <= mCurrentContent->size ()); - utf8_point begin_ = &mCurrentContent->front () + begin; - utf8_point end_ = &mCurrentContent->front () + end ; + Utf8Point begin_ = &mCurrentContent->front () + begin; + Utf8Point end_ = &mCurrentContent->front () + end ; - write_impl (dynamic_cast (style), begin_, end_); + writeImpl (dynamic_cast (style), begin_, end_); } void lineBreak (float margin) @@ -314,23 +314,23 @@ struct TypesetBookImpl::Typesetter : BookTypesetter } } - void setSectionAlignment (alignment sectionAlignment) + void setSectionAlignment (Alignment sectionAlignment) { if (mSection != NULL) mSectionAlignment.back () = sectionAlignment; mCurrentAlignment = sectionAlignment; } - TypesetBook::ptr complete () + TypesetBook::Ptr complete () { int curPageStart = 0; int curPageStop = 0; - std::vector ::iterator sa = mSectionAlignment.begin (); - for (sections::iterator i = mBook->mSections.begin (); i != mBook->mSections.end (); ++i, ++sa) + std::vector ::iterator sa = mSectionAlignment.begin (); + for (Sections::iterator i = mBook->mSections.begin (); i != mBook->mSections.end (); ++i, ++sa) { // apply alignment to individual lines... - for (lines::iterator j = i->mLines.begin (); j != i->mLines.end (); ++j) + for (Lines::iterator j = i->mLines.begin (); j != i->mLines.end (); ++j) { int width = j->mRect.width (); int excess = mPageWidth - width; @@ -338,9 +338,9 @@ struct TypesetBookImpl::Typesetter : BookTypesetter switch (*sa) { default: - case alignLeft: j->mRect.left = 0; break; - case alignCenter: j->mRect.left = excess/2; break; - case alignRight: j->mRect.left = excess; break; + case AlignLeft: j->mRect.left = 0; break; + case AlignCenter: j->mRect.left = excess/2; break; + case AlignRight: j->mRect.left = excess; break; } j->mRect.right = j->mRect.left + width; @@ -361,7 +361,7 @@ struct TypesetBookImpl::Typesetter : BookTypesetter { assert (curPageStart != curPageStop); - mBook->mPages.push_back (page (curPageStart, curPageStop)); + mBook->mPages.push_back (Page (curPageStart, curPageStop)); curPageStart = i->mRect.top; curPageStop = i->mRect.bottom; @@ -376,20 +376,20 @@ struct TypesetBookImpl::Typesetter : BookTypesetter } if (curPageStart != curPageStop) - mBook->mPages.push_back (page (curPageStart, curPageStop)); + mBook->mPages.push_back (Page (curPageStart, curPageStop)); return mBook; } - void write_impl (StyleImpl * Style, utf8_stream::point _begin, utf8_stream::point _end) + void writeImpl (StyleImpl * style, Utf8Stream::Point _begin, Utf8Stream::Point _end) { - int line_height = Style->mFont->getDefaultHeight (); + int line_height = style->mFont->getDefaultHeight (); - utf8_stream stream (_begin, _end); + Utf8Stream stream (_begin, _end); while (!stream.eof ()) { - if (ucs_line_break (stream.peek ())) + if (ucsLineBreak (stream.peek ())) { stream.consume (); mLine = NULL, mRun = NULL; @@ -401,27 +401,27 @@ struct TypesetBookImpl::Typesetter : BookTypesetter int space_width = 0; int character_count = 0; - utf8_stream::point lead = stream.current (); + Utf8Stream::Point lead = stream.current (); - while (!stream.eof () && !ucs_line_break (stream.peek ()) && ucs_breaking_space (stream.peek ())) + while (!stream.eof () && !ucsLineBreak (stream.peek ()) && ucsBreakingSpace (stream.peek ())) { - GlyphInfo* gi = Style->mFont->getGlyphInfo (stream.peek ()); + GlyphInfo* gi = style->mFont->getGlyphInfo (stream.peek ()); space_width += gi->advance; stream.consume (); } - utf8_stream::point origin = stream.current (); + Utf8Stream::Point origin = stream.current (); - while (!stream.eof () && !ucs_line_break (stream.peek ()) && !ucs_breaking_space (stream.peek ())) + while (!stream.eof () && !ucsLineBreak (stream.peek ()) && !ucsBreakingSpace (stream.peek ())) { - GlyphInfo* gi = Style->mFont->getGlyphInfo (stream.peek ()); + GlyphInfo* gi = style->mFont->getGlyphInfo (stream.peek ()); word_width += gi->advance + gi->bearingX; word_height = line_height; ++character_count; stream.consume (); } - utf8_stream::point extent = stream.current (); + Utf8Stream::Point extent = stream.current (); if (lead == extent) break; @@ -432,18 +432,18 @@ struct TypesetBookImpl::Typesetter : BookTypesetter { mLine = NULL, mRun = NULL; - append_run (Style, origin, extent, extent - origin, word_width, mBook->mRect.bottom + word_height); + append_run (style, origin, extent, extent - origin, word_width, mBook->mRect.bottom + word_height); } else { int top = mLine ? mLine->mRect.top : mBook->mRect.bottom; - append_run (Style, lead, extent, extent - origin, left + space_width + word_width, top + word_height); + append_run (style, lead, extent, extent - origin, left + space_width + word_width, top + word_height); } } } - void append_run (StyleImpl * style, utf8_stream::point begin, utf8_stream::point end, int pc, int right, int bottom) + void append_run (StyleImpl * style, Utf8Stream::Point begin, Utf8Stream::Point end, int pc, int right, int bottom) { if (mSection == NULL) { @@ -501,7 +501,7 @@ struct TypesetBookImpl::Typesetter : BookTypesetter } }; -BookTypesetter::ptr BookTypesetter::create (int pageWidth, int pageHeight) +BookTypesetter::Ptr BookTypesetter::create (int pageWidth, int pageHeight) { return boost::make_shared (pageWidth, pageHeight); } @@ -663,15 +663,15 @@ namespace vertex (vr.right, vr.bottom, tr.right, tr.bottom); } - void vertex (float X, float Y, float U, float V) + void vertex (float x, float y, float u, float v) { - FloatPoint pt = mRenderXform (FloatPoint (X, Y)); + FloatPoint pt = mRenderXform (FloatPoint (x, y)); mVertices->x = pt.left; mVertices->y = pt.top ; mVertices->z = mZ; - mVertices->u = U; - mVertices->v = V; + mVertices->u = u; + mVertices->v = v; mVertices->colour = mC; ++mVertices; @@ -690,19 +690,19 @@ protected: struct TextFormat : ISubWidget { - typedef IFont* id; + typedef IFont* Id; - id mFont; + Id mFont; int mCountVertex; ITexture* mTexture; RenderItem* mRenderItem; PageDisplay * mDisplay; - TextFormat (IFont* Id, PageDisplay * Display) : - mFont (Id), + TextFormat (IFont* id, PageDisplay * display) : + mFont (id), mTexture (NULL), mRenderItem (NULL), - mDisplay (Display), + mDisplay (display), mCountVertex (0) { } @@ -739,13 +739,13 @@ protected: public: - typedef TypesetBookImpl::StyleImpl style; - typedef std::map active_text_formats; + typedef TypesetBookImpl::StyleImpl Style; + typedef std::map ActiveTextFormats; int mViewTop; int mViewBottom; - style* mFocusItem; + Style* mFocusItem; bool mItemActive; MouseButton mLastDown; boost::function mLinkClicked; @@ -755,7 +755,7 @@ public: size_t mPage; ILayerNode* mNode; - active_text_formats mActiveTextFormats; + ActiveTextFormats mActiveTextFormats; PageDisplay () { @@ -768,7 +768,7 @@ public: { IFont* Font = mBook->affectedFont (mFocusItem); - active_text_formats::iterator i = mActiveTextFormats.find (Font); + ActiveTextFormats::iterator i = mActiveTextFormats.find (Font); mNode->outOfDate (i->second->mRenderItem); } @@ -785,15 +785,15 @@ public: mItemActive = false; } - void onMouseMove (int _left, int _top) + void onMouseMove (int left, int top) { if (!mBook) return; - _left -= mCroppedParent->getAbsoluteLeft (); - _top -= mCroppedParent->getAbsoluteTop (); + left -= mCroppedParent->getAbsoluteLeft (); + top -= mCroppedParent->getAbsoluteTop (); - style * Hit = mBook->hitTest (_left, mViewTop + _top); + Style * Hit = mBook->hitTest (left, mViewTop + top); if (mLastDown == MouseButton::None) { @@ -821,36 +821,36 @@ public: } } - void onMouseButtonPressed (int _left, int _top, MouseButton _id) + void onMouseButtonPressed (int left, int top, MouseButton id) { if (!mBook) return; - _left -= mCroppedParent->getAbsoluteLeft (); - _top -= mCroppedParent->getAbsoluteTop (); + left -= mCroppedParent->getAbsoluteLeft (); + top -= mCroppedParent->getAbsoluteTop (); if (mLastDown == MouseButton::None) { - mFocusItem = mBook->hitTest (_left, mViewTop + _top); + mFocusItem = mBook->hitTest (left, mViewTop + top); mItemActive = true; dirtyFocusItem (); - mLastDown = _id; + mLastDown = id; } } - void onMouseButtonReleased(int _left, int _top, MouseButton _id) + void onMouseButtonReleased(int left, int top, MouseButton id) { if (!mBook) return; - _left -= mCroppedParent->getAbsoluteLeft (); - _top -= mCroppedParent->getAbsoluteTop (); + left -= mCroppedParent->getAbsoluteLeft (); + top -= mCroppedParent->getAbsoluteTop (); - if (mLastDown == _id) + if (mLastDown == id) { - style * mItem = mBook->hitTest (_left, mViewTop + _top); + Style * mItem = mBook->hitTest (left, mViewTop + top); bool clicked = mFocusItem == mItem; @@ -865,16 +865,16 @@ public: } } - void showPage (TypesetBook::ptr _Book, size_t newPage) + void showPage (TypesetBook::Ptr book, size_t newPage) { - boost::shared_ptr newBook = boost::dynamic_pointer_cast (_Book); + boost::shared_ptr newBook = boost::dynamic_pointer_cast (book); if (mBook != newBook) { mFocusItem = nullptr; mItemActive = 0; - for (active_text_formats::iterator i = mActiveTextFormats.begin (); i != mActiveTextFormats.end (); ++i) + for (ActiveTextFormats::iterator i = mActiveTextFormats.begin (); i != mActiveTextFormats.end (); ++i) { if (mNode != NULL) i->second->destroyDrawItem (mNode); @@ -913,7 +913,7 @@ public: if (mBook && mPage != newPage) { if (mNode != NULL) - for (active_text_formats::iterator i = mActiveTextFormats.begin (); i != mActiveTextFormats.end (); ++i) + for (ActiveTextFormats::iterator i = mActiveTextFormats.begin (); i != mActiveTextFormats.end (); ++i) mNode->outOfDate(i->second->mRenderItem); mPage = newPage; @@ -931,17 +931,17 @@ public: } } - struct createActiveFormat + struct CreateActiveFormat { PageDisplay * this_; - createActiveFormat (PageDisplay * this_) : this_ (this_) {} + CreateActiveFormat (PageDisplay * this_) : this_ (this_) {} - void operator () (Section const & Section, Line const & Line, Run const & Run) const + void operator () (Section const & section, Line const & line, Run const & run) const { - IFont* Font = Run.mStyle->mFont; + IFont* Font = run.mStyle->mFont; - active_text_formats::iterator j = this_->mActiveTextFormats.find (Font); + ActiveTextFormats::iterator j = this_->mActiveTextFormats.find (Font); if (j == this_->mActiveTextFormats.end ()) { @@ -952,16 +952,16 @@ public: j = this_->mActiveTextFormats.insert (std::make_pair (Font, textFormat)).first; } - j->second->mCountVertex += Run.mPrintableChars * 6; + j->second->mCountVertex += run.mPrintableChars * 6; } }; void createActiveFormats (boost::shared_ptr newBook) { - newBook->visitRuns (0, 0x7FFFFFFF, createActiveFormat (this)); + newBook->visitRuns (0, 0x7FFFFFFF, CreateActiveFormat (this)); if (mNode != NULL) - for (active_text_formats::iterator i = mActiveTextFormats.begin (); i != mActiveTextFormats.end (); ++i) + for (ActiveTextFormats::iterator i = mActiveTextFormats.begin (); i != mActiveTextFormats.end (); ++i) i->second->createDrawItem (mNode); } @@ -982,46 +982,46 @@ public: if (nullptr != mNode) { - for (active_text_formats::iterator i = mActiveTextFormats.begin (); i != mActiveTextFormats.end (); ++i) + for (ActiveTextFormats::iterator i = mActiveTextFormats.begin (); i != mActiveTextFormats.end (); ++i) mNode->outOfDate(i->second->mRenderItem); } } - void createDrawItem(ITexture* _texture, ILayerNode* _node) + void createDrawItem(ITexture* texture, ILayerNode* node) { //test (); - mNode = _node; + mNode = node; - for (active_text_formats::iterator i = mActiveTextFormats.begin (); i != mActiveTextFormats.end (); ++i) - i->second->createDrawItem (_node); + for (ActiveTextFormats::iterator i = mActiveTextFormats.begin (); i != mActiveTextFormats.end (); ++i) + i->second->createDrawItem (node); } - struct renderRun + struct RenderRun { PageDisplay * this_; GlyphStream &glyphStream; - renderRun (PageDisplay * this_, GlyphStream &glyphStream) : + RenderRun (PageDisplay * this_, GlyphStream &glyphStream) : this_(this_), glyphStream (glyphStream) { } - void operator () (Section const & Section, Line const & Line, Run const & Run) const + void operator () (Section const & section, Line const & line, Run const & run) const { - bool isActive = Run.mStyle->mInteractiveId && (Run.mStyle == this_->mFocusItem); + bool isActive = run.mStyle->mInteractiveId && (run.mStyle == this_->mFocusItem); - Colour colour = isActive ? (this_->mItemActive ? Run.mStyle->mActiveColour: Run.mStyle->mHotColour) : Run.mStyle->mNormalColour; + Colour colour = isActive ? (this_->mItemActive ? run.mStyle->mActiveColour: run.mStyle->mHotColour) : run.mStyle->mNormalColour; - glyphStream.reset (Section.mRect.left + Line.mRect.left + Run.mLeft, Line.mRect.top, colour); + glyphStream.reset (section.mRect.left + line.mRect.left + run.mLeft, line.mRect.top, colour); - utf8_stream stream (Run.mRange); + Utf8Stream stream (run.mRange); while (!stream.eof ()) { - utf8_stream::unicode_char code_point = stream.consume (); + Utf8Stream::UnicodeChar code_point = stream.consume (); - if (!ucs_space (code_point)) + if (!ucsSpace (code_point)) glyphStream.emitGlyph (code_point); else glyphStream.emitSpace (code_point); @@ -1047,7 +1047,7 @@ public: int visit_top = (std::max) (mViewTop, mViewTop + int (renderXform.clipTop )); int visit_bottom = (std::min) (mViewBottom, mViewTop + int (renderXform.clipBottom)); - mBook->visitRuns (visit_top, visit_bottom, textFormat.mFont, renderRun (this, glyphStream)); + mBook->visitRuns (visit_top, visit_bottom, textFormat.mFont, RenderRun (this, glyphStream)); textFormat.mRenderItem->setLastVertexCount(glyphStream.end () - vertices); } @@ -1065,14 +1065,14 @@ public: _checkMargin (); if (mNode != NULL) - for (active_text_formats::iterator i = mActiveTextFormats.begin (); i != mActiveTextFormats.end (); ++i) + for (ActiveTextFormats::iterator i = mActiveTextFormats.begin (); i != mActiveTextFormats.end (); ++i) mNode->outOfDate (i->second->mRenderItem); } void destroyDrawItem() { - for (active_text_formats::iterator i = mActiveTextFormats.begin (); i != mActiveTextFormats.end (); ++i) + for (ActiveTextFormats::iterator i = mActiveTextFormats.begin (); i != mActiveTextFormats.end (); ++i) i->second->destroyDrawItem (mNode); mNode = NULL; @@ -1086,15 +1086,15 @@ MYGUI_RTTI_DERIVED(BookPage) public: - void showPage (TypesetBook::ptr Book, size_t Page) + void showPage (TypesetBook::Ptr book, size_t page) { if (PageDisplay* pd = dynamic_cast (getSubWidgetText ())) - pd->showPage (Book, Page); + pd->showPage (book, page); else throw std::runtime_error ("The main sub-widget for a BookPage must be a PageDisplay."); } - void adviseLinkClicked (boost::function linkClicked) + void adviseLinkClicked (boost::function linkClicked) { if (PageDisplay* pd = dynamic_cast (getSubWidgetText ())) { @@ -1106,7 +1106,7 @@ public: { if (PageDisplay* pd = dynamic_cast (getSubWidgetText ())) { - pd->mLinkClicked = boost::function (); + pd->mLinkClicked = boost::function (); } } @@ -1121,34 +1121,34 @@ protected: Widget::onMouseLostFocus (_new); } - void onMouseMove(int _left, int _top) + void onMouseMove(int left, int top) { if (PageDisplay* pd = dynamic_cast (getSubWidgetText ())) { - pd->onMouseMove (_left, _top); + pd->onMouseMove (left, top); } else - Widget::onMouseMove (_left, _top); + Widget::onMouseMove (left, top); } - void onMouseButtonPressed (int _left, int _top, MouseButton _id) + void onMouseButtonPressed (int left, int top, MouseButton id) { if (PageDisplay* pd = dynamic_cast (getSubWidgetText ())) { - pd->onMouseButtonPressed (_left, _top, _id); + pd->onMouseButtonPressed (left, top, id); } else - Widget::onMouseButtonPressed (_left, _top, _id); + Widget::onMouseButtonPressed (left, top, id); } - void onMouseButtonReleased(int _left, int _top, MouseButton _id) + void onMouseButtonReleased(int left, int top, MouseButton id) { if (PageDisplay* pd = dynamic_cast (getSubWidgetText ())) { - pd->onMouseButtonReleased (_left, _top, _id); + pd->onMouseButtonReleased (left, top, id); } else - Widget::onMouseButtonReleased (_left, _top, _id); + Widget::onMouseButtonReleased (left, top, id); } }; @@ -1160,14 +1160,14 @@ void BookPage::registerMyGUIComponents () factory.registerFactory("BasisSkin"); } -static bool ucs_line_break (int code_point) +static bool ucsLineBreak (int codePoint) { - return code_point == '\n'; + return codePoint == '\n'; } -static bool ucs_space (int code_point) +static bool ucsSpace (int codePoint) { - switch (code_point) + switch (codePoint) { case 0x0020: // SPACE case 0x00A0: // NO-BREAK SPACE @@ -1195,9 +1195,9 @@ static bool ucs_space (int code_point) } } -static bool ucs_breaking_space (int code_point) +static bool ucsBreakingSpace (int codePoint) { - switch (code_point) + switch (codePoint) { case 0x0020: // SPACE //case 0x00A0: // NO-BREAK SPACE diff --git a/apps/openmw/mwgui/bookpage.hpp b/apps/openmw/mwgui/bookpage.hpp index b4c691c9f..1af3009f8 100644 --- a/apps/openmw/mwgui/bookpage.hpp +++ b/apps/openmw/mwgui/bookpage.hpp @@ -15,8 +15,8 @@ namespace MWGui /// the book page widget. struct TypesetBook { - typedef boost::shared_ptr ptr; - typedef intptr_t interactive_id; + typedef boost::shared_ptr Ptr; + typedef intptr_t InteractiveId; /// Returns the number of pages in the document. virtual size_t pageCount () const = 0; @@ -33,16 +33,16 @@ namespace MWGui /// A factory class for creating a typeset book instance. struct BookTypesetter { - typedef boost::shared_ptr ptr; - typedef TypesetBook::interactive_id interactive_id; - typedef MyGUI::Colour coulour; - typedef uint8_t const * utf8_point; - typedef std::pair utf8_span; - - enum alignment { - alignLeft = -1, - alignCenter = 0, - alignRight = +1 + typedef boost::shared_ptr Ptr; + typedef TypesetBook::InteractiveId InteractiveId; + typedef MyGUI::Colour Colour; + typedef uint8_t const * Utf8Point; + typedef std::pair Utf8Span; + + enum Alignment { + AlignLeft = -1, + AlignCenter = 0, + AlignRight = +1 }; /// Styles are used to control the character level formatting @@ -52,15 +52,15 @@ namespace MWGui struct Style; /// A factory function for creating the default implementation of a book typesetter - static ptr create (int pageWidth, int pageHeight); + static Ptr create (int pageWidth, int pageHeight); /// Create a simple text style consisting of a font and a text color. - virtual Style* createStyle (char const * Font, coulour Colour) = 0; + virtual Style* createStyle (char const * Font, Colour Colour) = 0; /// Create a hyper-link style with a user-defined identifier based on an /// existing style. The unique flag forces a new instance of this style /// to be created even if an existing instance is present. - virtual Style* createHotStyle (Style * BaseStyle, coulour NormalColour, coulour HoverColour, coulour ActiveColour, interactive_id Id, bool Unique = true) = 0; + virtual Style* createHotStyle (Style * BaseStyle, Colour NormalColour, Colour HoverColour, Colour ActiveColour, InteractiveId Id, bool Unique = true) = 0; /// Insert a line break into the document. Newline characters in the input /// text have the same affect. The margin parameter adds additional space @@ -74,25 +74,25 @@ namespace MWGui virtual void sectionBreak (float margin = 0) = 0; /// Changes the alignment for the current section of text. - virtual void setSectionAlignment (alignment sectionAlignment) = 0; + virtual void setSectionAlignment (Alignment sectionAlignment) = 0; // Layout a block of text with the specified style into the document. - virtual void write (Style * Style, utf8_span Text) = 0; + virtual void write (Style * Style, Utf8Span Text) = 0; /// Adds a content block to the document without laying it out. An /// identifier is returned that can be used to refer to it. If select /// is true, the block is activated to be references by future writes. - virtual intptr_t add_content (utf8_span Text, bool Select = true) = 0; + virtual intptr_t addContent (Utf8Span Text, bool Select = true) = 0; /// Select a previously created content block for future writes. - virtual void select_content (intptr_t contentHandle) = 0; + virtual void selectContent (intptr_t contentHandle) = 0; /// Layout a span of the selected content block into the document /// using the specified style. virtual void write (Style * Style, size_t Begin, size_t End) = 0; /// Finalize the document layout, and return a pointer to it. - virtual TypesetBook::ptr complete () = 0; + virtual TypesetBook::Ptr complete () = 0; }; /// An interface to the BookPage widget. @@ -101,14 +101,14 @@ namespace MWGui MYGUI_RTTI_DERIVED(BookPage) public: - typedef TypesetBook::interactive_id interactive_id; - typedef boost::function click_callback; + typedef TypesetBook::InteractiveId InteractiveId; + typedef boost::function ClickCallback; /// Make the widget display the specified page from the specified book. - virtual void showPage (TypesetBook::ptr Book, size_t Page) = 0; + virtual void showPage (TypesetBook::Ptr Book, size_t Page) = 0; /// Set the callback for a clicking a hyper-link in the document. - virtual void adviseLinkClicked (click_callback callback) = 0; + virtual void adviseLinkClicked (ClickCallback callback) = 0; /// Clear the hyper-link click callback. virtual void unadviseLinkClicked () = 0; diff --git a/apps/openmw/mwgui/journalbooks.cpp b/apps/openmw/mwgui/journalbooks.cpp index de6ddfffb..0a0b7683a 100644 --- a/apps/openmw/mwgui/journalbooks.cpp +++ b/apps/openmw/mwgui/journalbooks.cpp @@ -4,189 +4,189 @@ using namespace MWGui; namespace { - BookTypesetter::utf8_span to_utf8_span (char const * Text) + BookTypesetter::Utf8Span to_utf8_span (char const * text) { - typedef BookTypesetter::utf8_point point; + typedef BookTypesetter::Utf8Point point; - point begin = reinterpret_cast (Text); + point begin = reinterpret_cast (text); - return BookTypesetter::utf8_span (begin, begin + strlen (Text)); + return BookTypesetter::Utf8Span (begin, begin + strlen (text)); } const MyGUI::Colour linkHot (0.40f, 0.40f, 0.80f); const MyGUI::Colour linkNormal (0.20f, 0.20f, 0.60f); const MyGUI::Colour linkActive (0.50f, 0.50f, 1.00f); - struct addContent + struct AddContent { - BookTypesetter::ptr typesetter; - BookTypesetter::Style* body_style; + BookTypesetter::Ptr mTypesetter; + BookTypesetter::Style* mBodyStyle; - addContent (BookTypesetter::ptr typesetter, BookTypesetter::Style* body_style) : - typesetter (typesetter), body_style (body_style) + AddContent (BookTypesetter::Ptr typesetter, BookTypesetter::Style* body_style) : + mTypesetter (typesetter), mBodyStyle (body_style) { } }; - struct addSpan : addContent + struct AddSpan : AddContent { - addSpan (BookTypesetter::ptr typesetter, BookTypesetter::Style* body_style) : - addContent (typesetter, body_style) + AddSpan (BookTypesetter::Ptr typesetter, BookTypesetter::Style* body_style) : + AddContent (typesetter, body_style) { } void operator () (intptr_t topicId, size_t begin, size_t end) { - BookTypesetter::Style* style = body_style; + BookTypesetter::Style* style = mBodyStyle; if (topicId) - style = typesetter->createHotStyle (body_style, linkNormal, linkHot, linkActive, topicId); + style = mTypesetter->createHotStyle (mBodyStyle, linkNormal, linkHot, linkActive, topicId); - typesetter->write (style, begin, end); + mTypesetter->write (style, begin, end); } }; - struct addEntry + struct AddEntry { - BookTypesetter::ptr typesetter; - BookTypesetter::Style* body_style; + BookTypesetter::Ptr mTypesetter; + BookTypesetter::Style* mBodyStyle; - addEntry (BookTypesetter::ptr typesetter, BookTypesetter::Style* body_style) : - typesetter (typesetter), body_style (body_style) + AddEntry (BookTypesetter::Ptr typesetter, BookTypesetter::Style* body_style) : + mTypesetter (typesetter), mBodyStyle (body_style) { } - void operator () (JournalViewModel::Entry const & Entry) + void operator () (JournalViewModel::Entry const & entry) { - typesetter->add_content (Entry.body ()); + mTypesetter->addContent (entry.body ()); - Entry.visitSpans (addSpan (typesetter, body_style)); + entry.visitSpans (AddSpan (mTypesetter, mBodyStyle)); } }; - struct addJournalEntry : addEntry + struct AddJournalEntry : AddEntry { - bool add_header; - BookTypesetter::Style* header_style; + bool mAddHeader; + BookTypesetter::Style* mHeaderStyle; - addJournalEntry (BookTypesetter::ptr typesetter, BookTypesetter::Style* body_style, + AddJournalEntry (BookTypesetter::Ptr typesetter, BookTypesetter::Style* body_style, BookTypesetter::Style* header_style, bool add_header) : - addEntry (typesetter, body_style), - header_style (header_style), - add_header (add_header) + AddEntry (typesetter, body_style), + mHeaderStyle (header_style), + mAddHeader (add_header) { } - void operator () (JournalViewModel::JournalEntry const & Entry) + void operator () (JournalViewModel::JournalEntry const & entry) { - if (add_header) + if (mAddHeader) { - typesetter->write (header_style, Entry.timestamp ()); - typesetter->lineBreak (); + mTypesetter->write (mHeaderStyle, entry.timestamp ()); + mTypesetter->lineBreak (); } - addEntry::operator () (Entry); + AddEntry::operator () (entry); - typesetter->sectionBreak (10); + mTypesetter->sectionBreak (10); } }; - struct addTopicEntry : addEntry + struct AddTopicEntry : AddEntry { - intptr_t contentId; - BookTypesetter::Style* header_style; + intptr_t mContentId; + BookTypesetter::Style* mHeaderStyle; - addTopicEntry (BookTypesetter::ptr typesetter, BookTypesetter::Style* body_style, + AddTopicEntry (BookTypesetter::Ptr typesetter, BookTypesetter::Style* body_style, BookTypesetter::Style* header_style, intptr_t contentId) : - addEntry (typesetter, body_style), header_style (header_style), contentId (contentId) + AddEntry (typesetter, body_style), mHeaderStyle (header_style), mContentId (contentId) { } - void operator () (JournalViewModel::TopicEntry const & Entry) + void operator () (JournalViewModel::TopicEntry const & entry) { - typesetter->write (body_style, Entry.source ()); - typesetter->write (body_style, 0, 3);// begin + mTypesetter->write (mBodyStyle, entry.source ()); + mTypesetter->write (mBodyStyle, 0, 3);// begin - addEntry::operator() (Entry); + AddEntry::operator() (entry); - typesetter->select_content (contentId); - typesetter->write (body_style, 2, 3);// end quote + mTypesetter->selectContent (mContentId); + mTypesetter->write (mBodyStyle, 2, 3);// end quote - typesetter->sectionBreak (10); + mTypesetter->sectionBreak (10); } }; - struct addTopicName : addContent + struct AddTopicName : AddContent { - addTopicName (BookTypesetter::ptr typesetter, BookTypesetter::Style* style) : - addContent (typesetter, style) + AddTopicName (BookTypesetter::Ptr typesetter, BookTypesetter::Style* style) : + AddContent (typesetter, style) { } - void operator () (JournalViewModel::utf8_span topicName) + void operator () (JournalViewModel::Utf8Span topicName) { - typesetter->write (body_style, topicName); - typesetter->sectionBreak (10); + mTypesetter->write (mBodyStyle, topicName); + mTypesetter->sectionBreak (10); } }; - struct addQuestName : addContent + struct AddQuestName : AddContent { - addQuestName (BookTypesetter::ptr typesetter, BookTypesetter::Style* style) : - addContent (typesetter, style) + AddQuestName (BookTypesetter::Ptr typesetter, BookTypesetter::Style* style) : + AddContent (typesetter, style) { } - void operator () (JournalViewModel::utf8_span topicName) + void operator () (JournalViewModel::Utf8Span topicName) { - typesetter->write (body_style, topicName); - typesetter->sectionBreak (10); + mTypesetter->write (mBodyStyle, topicName); + mTypesetter->sectionBreak (10); } }; - struct addTopicLink : addContent + struct AddTopicLink : AddContent { - addTopicLink (BookTypesetter::ptr typesetter, BookTypesetter::Style* style) : - addContent (typesetter, style) + AddTopicLink (BookTypesetter::Ptr typesetter, BookTypesetter::Style* style) : + AddContent (typesetter, style) { } - void operator () (JournalViewModel::topic_id topicId, JournalViewModel::utf8_span name) + void operator () (JournalViewModel::TopicId topicId, JournalViewModel::Utf8Span name) { - BookTypesetter::Style* link = typesetter->createHotStyle (body_style, MyGUI::Colour::Black, linkHot, linkActive, topicId); + BookTypesetter::Style* link = mTypesetter->createHotStyle (mBodyStyle, MyGUI::Colour::Black, linkHot, linkActive, topicId); - typesetter->write (link, name); - typesetter->lineBreak (); + mTypesetter->write (link, name); + mTypesetter->lineBreak (); } }; - struct addQuestLink : addContent + struct AddQuestLink : AddContent { - addQuestLink (BookTypesetter::ptr typesetter, BookTypesetter::Style* style) : - addContent (typesetter, style) + AddQuestLink (BookTypesetter::Ptr typesetter, BookTypesetter::Style* style) : + AddContent (typesetter, style) { } - void operator () (JournalViewModel::quest_id id, JournalViewModel::utf8_span name) + void operator () (JournalViewModel::QuestId id, JournalViewModel::Utf8Span name) { - BookTypesetter::Style* style = typesetter->createHotStyle (body_style, MyGUI::Colour::Black, linkHot, linkActive, id); + BookTypesetter::Style* style = mTypesetter->createHotStyle (mBodyStyle, MyGUI::Colour::Black, linkHot, linkActive, id); - typesetter->write (style, name); - typesetter->lineBreak (); + mTypesetter->write (style, name); + mTypesetter->lineBreak (); } }; } -typedef TypesetBook::ptr book; +typedef TypesetBook::Ptr book; -JournalBooks::JournalBooks (JournalViewModel::ptr Model) : - Model (Model) +JournalBooks::JournalBooks (JournalViewModel::Ptr model) : + mModel (model) { } book JournalBooks::createEmptyJournalBook () { - BookTypesetter::ptr typesetter = createTypesetter (); + BookTypesetter::Ptr typesetter = createTypesetter (); BookTypesetter::Style* header = typesetter->createStyle ("EB Garamond", MyGUI::Colour (0.60f, 0.00f, 0.00f)); BookTypesetter::Style* body = typesetter->createStyle ("EB Garamond", MyGUI::Colour::Black); @@ -228,51 +228,51 @@ book JournalBooks::createEmptyJournalBook () book JournalBooks::createJournalBook () { - BookTypesetter::ptr typesetter = createTypesetter (); + BookTypesetter::Ptr typesetter = createTypesetter (); BookTypesetter::Style* header = typesetter->createStyle ("EB Garamond", MyGUI::Colour (0.60f, 0.00f, 0.00f)); BookTypesetter::Style* body = typesetter->createStyle ("EB Garamond", MyGUI::Colour::Black); - Model->visitJournalEntries (0, addJournalEntry (typesetter, body, header, true)); + mModel->visitJournalEntries (0, AddJournalEntry (typesetter, body, header, true)); return typesetter->complete (); } book JournalBooks::createTopicBook (uintptr_t topicId) { - BookTypesetter::ptr typesetter = createTypesetter (); + BookTypesetter::Ptr typesetter = createTypesetter (); BookTypesetter::Style* header = typesetter->createStyle ("EB Garamond", MyGUI::Colour (0.60f, 0.00f, 0.00f)); BookTypesetter::Style* body = typesetter->createStyle ("EB Garamond", MyGUI::Colour::Black); - Model->visitTopicName (topicId, addTopicName (typesetter, header)); + mModel->visitTopicName (topicId, AddTopicName (typesetter, header)); - intptr_t contentId = typesetter->add_content (to_utf8_span (", \"")); + intptr_t contentId = typesetter->addContent (to_utf8_span (", \"")); - Model->visitTopicEntries (topicId, addTopicEntry (typesetter, body, header, contentId)); + mModel->visitTopicEntries (topicId, AddTopicEntry (typesetter, body, header, contentId)); return typesetter->complete (); } book JournalBooks::createQuestBook (uintptr_t questId) { - BookTypesetter::ptr typesetter = createTypesetter (); + BookTypesetter::Ptr typesetter = createTypesetter (); BookTypesetter::Style* header = typesetter->createStyle ("EB Garamond", MyGUI::Colour (0.60f, 0.00f, 0.00f)); BookTypesetter::Style* body = typesetter->createStyle ("EB Garamond", MyGUI::Colour::Black); - Model->visitQuestName (questId, addQuestName (typesetter, header)); + mModel->visitQuestName (questId, AddQuestName (typesetter, header)); - Model->visitJournalEntries (questId, addJournalEntry (typesetter, body, header, false)); + mModel->visitJournalEntries (questId, AddJournalEntry (typesetter, body, header, false)); return typesetter->complete (); } book JournalBooks::createTopicIndexBook () { - BookTypesetter::ptr typesetter = BookTypesetter::create (92, 250); + BookTypesetter::Ptr typesetter = BookTypesetter::create (92, 250); - typesetter->setSectionAlignment (BookTypesetter::alignCenter); + typesetter->setSectionAlignment (BookTypesetter::AlignCenter); BookTypesetter::Style* body = typesetter->createStyle ("EB Garamond", MyGUI::Colour::Black); @@ -298,25 +298,25 @@ book JournalBooks::createTopicIndexBook () book JournalBooks::createTopicIndexBook (char character) { - BookTypesetter::ptr typesetter = BookTypesetter::create (0x7FFFFFFF, 0x7FFFFFFF); + BookTypesetter::Ptr typesetter = BookTypesetter::create (0x7FFFFFFF, 0x7FFFFFFF); BookTypesetter::Style* style = typesetter->createStyle ("EB Garamond", MyGUI::Colour::Black); - Model->visitTopicNamesStartingWith (character, addTopicLink (typesetter, style)); + mModel->visitTopicNamesStartingWith (character, AddTopicLink (typesetter, style)); return typesetter->complete (); } book JournalBooks::createQuestIndexBook (bool activeOnly) { - BookTypesetter::ptr typesetter = BookTypesetter::create (0x7FFFFFFF, 0x7FFFFFFF); + BookTypesetter::Ptr typesetter = BookTypesetter::create (0x7FFFFFFF, 0x7FFFFFFF); BookTypesetter::Style* base = typesetter->createStyle ("EB Garamond", MyGUI::Colour::Black); - Model->visitQuestNames (activeOnly, addQuestLink (typesetter, base)); + mModel->visitQuestNames (activeOnly, AddQuestLink (typesetter, base)); return typesetter->complete (); } -BookTypesetter::ptr JournalBooks::createTypesetter () +BookTypesetter::Ptr JournalBooks::createTypesetter () { //TODO: determine page size from layout... return BookTypesetter::create (240, 300); diff --git a/apps/openmw/mwgui/journalbooks.hpp b/apps/openmw/mwgui/journalbooks.hpp index e1f035259..09d3cf1a8 100644 --- a/apps/openmw/mwgui/journalbooks.hpp +++ b/apps/openmw/mwgui/journalbooks.hpp @@ -8,21 +8,21 @@ namespace MWGui { struct JournalBooks { - typedef TypesetBook::ptr book; - JournalViewModel::ptr Model; + typedef TypesetBook::Ptr Book; + JournalViewModel::Ptr mModel; - JournalBooks (JournalViewModel::ptr Model); + JournalBooks (JournalViewModel::Ptr model); - book createEmptyJournalBook (); - book createJournalBook (); - book createTopicBook (uintptr_t topicId); - book createQuestBook (uintptr_t questId); - book createTopicIndexBook (); - book createTopicIndexBook (char character); - book createQuestIndexBook (bool showAll); + Book createEmptyJournalBook (); + Book createJournalBook (); + Book createTopicBook (uintptr_t topicId); + Book createQuestBook (uintptr_t questId); + Book createTopicIndexBook (); + Book createTopicIndexBook (char character); + Book createQuestIndexBook (bool showAll); private: - BookTypesetter::ptr createTypesetter (); + BookTypesetter::Ptr createTypesetter (); }; } diff --git a/apps/openmw/mwgui/journalviewmodel.cpp b/apps/openmw/mwgui/journalviewmodel.cpp index f69a2995c..fa83f64fe 100644 --- a/apps/openmw/mwgui/journalviewmodel.cpp +++ b/apps/openmw/mwgui/journalviewmodel.cpp @@ -5,7 +5,7 @@ #include "../mwbase/environment.hpp" #include "../mwdialogue/journalentry.hpp" -//#include "MyGUI_LanguageManager.h" +#include #include @@ -24,18 +24,18 @@ class KeywordSearch { public: - typedef typename string_t::const_iterator point; + typedef typename string_t::const_iterator Point; struct Match { - point mBeg; - point mEnd; + Point mBeg; + Point mEnd; value_t mValue; }; - void seed (string_t Keyword, value_t Value) + void seed (string_t keyword, value_t value) { - seed_impl (/*std::move*/ (Keyword), /*std::move*/ (Value), 0, mRoot); + seed_impl (/*std::move*/ (keyword), /*std::move*/ (value), 0, mRoot); } void clear () @@ -44,9 +44,9 @@ public: mRoot.mKeyword.clear (); } - bool search (point Beg, point End, Match & Match) + bool search (Point beg, Point end, Match & match) { - for (point i = Beg; i != End; ++i) + for (Point i = beg; i != end; ++i) { // check first character typename Entry::childen_t::iterator candidate = mRoot.mChildren.find (std::tolower (*i, mLocale)); @@ -56,9 +56,9 @@ public: continue; // see how far the match goes - point j = i; + Point j = i; - while ((j + 1) != End) + while ((j + 1) != end) { typename Entry::childen_t::iterator next = candidate->second.mChildren.find (std::tolower (*++j, mLocale)); @@ -75,7 +75,7 @@ public: // match the rest of the keyword typename string_t::const_iterator t = candidate->second.mKeyword.begin () + (j - i); - while (j != End && t != candidate->second.mKeyword.end ()) + while (j != end && t != candidate->second.mKeyword.end ()) { if (std::tolower (*j, mLocale) != std::tolower (*t, mLocale)) break; @@ -88,9 +88,9 @@ public: continue; // we did it, report the good news - Match.mValue = candidate->second.mValue; - Match.mBeg = i; - Match.mEnd = j; + match.mValue = candidate->second.mValue; + match.mBeg = i; + match.mEnd = j; return true; } @@ -110,22 +110,22 @@ private: childen_t mChildren; }; - void seed_impl (string_t Keyword, value_t Value, size_t Depth, Entry & Entry) + void seed_impl (string_t keyword, value_t value, size_t depth, Entry & entry) { - int ch = tolower (Keyword.at (Depth), mLocale); + int ch = tolower (keyword.at (depth), mLocale); - typename Entry::childen_t::iterator j = Entry.mChildren.find (ch); + typename Entry::childen_t::iterator j = entry.mChildren.find (ch); - if (j == Entry.mChildren.end ()) + if (j == entry.mChildren.end ()) { - Entry.mChildren [ch].mValue = /*std::move*/ (Value); - Entry.mChildren [ch].mKeyword = /*std::move*/ (Keyword); + entry.mChildren [ch].mValue = /*std::move*/ (value); + entry.mChildren [ch].mKeyword = /*std::move*/ (keyword); } else { if (j->second.mKeyword.size () > 0) { - if (Keyword == j->second.mKeyword) + if (keyword == j->second.mKeyword) throw std::runtime_error ("duplicate keyword inserted"); value_t pushValue = /*std::move*/ (j->second.mValue); @@ -133,13 +133,15 @@ private: j->second.mKeyword.clear (); - if (Depth >= pushKeyword.size ()) + if (depth >= pushKeyword.size ()) throw std::runtime_error ("unexpected"); - seed_impl (/*std::move*/ (pushKeyword), /*std::move*/ (pushValue), Depth+1, j->second); + if (depth+1 < pushKeyword.size()) + seed_impl (/*std::move*/ (pushKeyword), /*std::move*/ (pushValue), depth+1, j->second); } - seed_impl (/*std::move*/ (Keyword), /*std::move*/ (Value), Depth+1, j->second); + if (depth+1 < keyword.size()) + seed_impl (/*std::move*/ (keyword), /*std::move*/ (value), depth+1, j->second); } } @@ -166,15 +168,15 @@ struct MWGui::JournalViewModelImpl : JournalViewModel { } - //TODO: replace this nasty BS - static utf8_span toUtf8Span (std::string const & str) + /// \todo replace this nasty BS + static Utf8Span toUtf8Span (std::string const & str) { if (str.size () == 0) - return utf8_span (utf8_point (NULL), utf8_point (NULL)); + return Utf8Span (Utf8Point (NULL), Utf8Point (NULL)); - utf8_point point = reinterpret_cast (str.c_str ()); + Utf8Point point = reinterpret_cast (str.c_str ()); - return utf8_span (point, point + str.size ()); + return Utf8Span (point, point + str.size ()); } void load () @@ -215,10 +217,10 @@ struct MWGui::JournalViewModelImpl : JournalViewModel typedef t_iterator iterator_t; iterator_t itr; - JournalViewModelImpl const * Model; + JournalViewModelImpl const * mModel; - BaseEntry (JournalViewModelImpl const * Model, iterator_t itr) : - Model (Model), itr (itr), loaded (false) + BaseEntry (JournalViewModelImpl const * model, iterator_t itr) : + mModel (model), itr (itr), loaded (false) {} virtual ~BaseEntry () {} @@ -237,23 +239,23 @@ struct MWGui::JournalViewModelImpl : JournalViewModel } } - utf8_span body () const + Utf8Span body () const { ensureLoaded (); return toUtf8Span (utf8text); } - void visitSpans (boost::function < void (topic_id, size_t, size_t)> visitor) const + void visitSpans (boost::function < void (TopicId, size_t, size_t)> visitor) const { ensureLoaded (); - Model->ensureKeyWordSearchLoaded (); + mModel->ensureKeyWordSearchLoaded (); std::string::const_iterator i = utf8text.begin (); keyword_search_t::Match match; - while (i != utf8text.end () && Model->mKeywordSearch.search (i, utf8text.end (), match)) + while (i != utf8text.end () && mModel->mKeywordSearch.search (i, utf8text.end (), match)) { if (i != match.mBeg) visitor (0, i - utf8text.begin (), match.mBeg - utf8text.begin ()); @@ -269,7 +271,7 @@ struct MWGui::JournalViewModelImpl : JournalViewModel }; - void visitQuestNames (bool active_only, boost::function visitor) const + void visitQuestNames (bool active_only, boost::function visitor) const { MWBase::Journal * journal = MWBase::Environment::get ().getJournal (); @@ -278,11 +280,11 @@ struct MWGui::JournalViewModelImpl : JournalViewModel if (active_only && i->second.isFinished ()) continue; - visitor (reinterpret_cast (&i->second), toUtf8Span (i->first)); + visitor (reinterpret_cast (&i->second), toUtf8Span (i->first)); } } - void visitQuestName (quest_id questId, boost::function visitor) const + void visitQuestName (QuestId questId, boost::function visitor) const { MWDialogue::Quest const * quest = reinterpret_cast (questId); @@ -307,7 +309,7 @@ struct MWGui::JournalViewModelImpl : JournalViewModel return itr->getText(MWBase::Environment::get().getWorld()->getStore()); } - utf8_span timestamp () const + Utf8Span timestamp () const { if (timestamp_buffer.empty ()) { @@ -317,7 +319,8 @@ struct MWGui::JournalViewModelImpl : JournalViewModel injectMonthName (os, itr->mMonth); - os << " (Day " << (itr->mDay + 1) << ')'; + const std::string& dayStr = MyGUI::LanguageManager::getInstance().replaceTags("#{sDay}"); + os << " (" << dayStr << " " << (itr->mDay + 1) << ')'; timestamp_buffer = os.str (); } @@ -326,7 +329,7 @@ struct MWGui::JournalViewModelImpl : JournalViewModel } }; - void visitJournalEntries (quest_id questId, boost::function visitor) const + void visitJournalEntries (QuestId questId, boost::function visitor) const { MWBase::Journal * journal = MWBase::Environment::get().getJournal(); @@ -350,19 +353,19 @@ struct MWGui::JournalViewModelImpl : JournalViewModel } } - void visitTopics (boost::function visitor) const + void visitTopics (boost::function visitor) const { throw std::runtime_error ("not implemented"); } - void visitTopicName (topic_id topicId, boost::function visitor) const + void visitTopicName (TopicId topicId, boost::function visitor) const { - MWDialogue::Topic const & Topic = * reinterpret_cast (topicId); + MWDialogue::Topic const & topic = * reinterpret_cast (topicId); - visitor (toUtf8Span (Topic.getName ())); + visitor (toUtf8Span (topic.getName ())); } - void visitTopicNamesStartingWith (int character, boost::function < void (topic_id , utf8_span) > visitor) const + void visitTopicNamesStartingWith (char character, boost::function < void (TopicId , Utf8Span) > visitor) const { MWBase::Journal * journal = MWBase::Environment::get().getJournal(); @@ -371,28 +374,29 @@ struct MWGui::JournalViewModelImpl : JournalViewModel if (i->first [0] != std::tolower (character, mLocale)) continue; - visitor (topic_id (&i->second), toUtf8Span (i->first)); + visitor (TopicId (&i->second), toUtf8Span (i->first)); } } struct TopicEntryImpl : BaseEntry { - MWDialogue::Topic const & Topic; + MWDialogue::Topic const & mTopic; mutable std::string source_buffer; - TopicEntryImpl (JournalViewModelImpl const * Model, MWDialogue::Topic const & Topic, iterator_t itr) : - BaseEntry (Model, itr), Topic (Topic) + TopicEntryImpl (JournalViewModelImpl const * model, MWDialogue::Topic const & topic, iterator_t itr) : + BaseEntry (model, itr), mTopic (topic) {} std::string getText () const { - return Topic.getEntry (*itr).getText(MWBase::Environment::get().getWorld()->getStore()); + /// \todo defines are not replaced (%PCName etc). should probably be done elsewhere though since we need the actor + return mTopic.getEntry (*itr).getText(MWBase::Environment::get().getWorld()->getStore()); } - utf8_span source () const + Utf8Span source () const { if (source_buffer.empty ()) source_buffer = "someone"; @@ -401,72 +405,50 @@ struct MWGui::JournalViewModelImpl : JournalViewModel }; - void visitTopicEntries (topic_id topicId, boost::function visitor) const + void visitTopicEntries (TopicId topicId, boost::function visitor) const { typedef MWDialogue::Topic::TEntryIter iterator_t; - MWDialogue::Topic const & Topic = * reinterpret_cast (topicId); + MWDialogue::Topic const & topic = * reinterpret_cast (topicId); - for (iterator_t i = Topic.begin (); i != Topic.end (); ++i) - visitor (TopicEntryImpl (this, Topic, i)); + for (iterator_t i = topic.begin (); i != topic.end (); ++i) + visitor (TopicEntryImpl (this, topic, i)); } }; static void injectMonthName (std::ostream & os, int month) { -#ifndef MYGUI_SIGNLETON_FIXED_FOR_MSVC - static char const * month_names [] = - { - "Morning Star", - "Sun's Dawn", - "First Seed", - "Rain's Hand", - "Second Seed", - "Midyear", - "Sun's Height", - "Last Seed", - "Hearthfire", - "Frostfall", - "Sun's Dusk", - "Evening Star", - }; - if (month >= 0 && month <= 11) - os << month_names [month ]; - else - os << month ; -#else - auto lm = MyGUI::LanguageManager::getInstance(); + MyGUI::LanguageManager& lm = MyGUI::LanguageManager::getInstance(); if (month == 0) - os << lm.getTag ("sMonthMorningstar"); + os << lm.replaceTags ("#{sMonthMorningstar}"); else if (month == 1) - os << lm.getTag ("sMonthSunsdawn"); + os << lm.replaceTags ("#{sMonthSunsdawn}"); else if (month == 2) - os << lm.getTag ("sMonthFirstseed"); + os << lm.replaceTags ("#{sMonthFirstseed}"); else if (month == 3) - os << lm.getTag ("sMonthRainshand"); + os << lm.replaceTags ("#{sMonthRainshand}"); else if (month == 4) - os << lm.getTag ("sMonthSecondseed"); + os << lm.replaceTags ("#{sMonthSecondseed}"); else if (month == 5) - os << lm.getTag ("sMonthMidyear"); + os << lm.replaceTags ("#{sMonthMidyear}"); else if (month == 6) - os << lm.getTag ("sMonthSunsheight"); + os << lm.replaceTags ("#{sMonthSunsheight}"); else if (month == 7) - os << lm.getTag ("sMonthLastseed"); + os << lm.replaceTags ("#{sMonthLastseed}"); else if (month == 8) - os << lm.getTag ("sMonthHeartfire"); + os << lm.replaceTags ("#{sMonthHeartfire}"); else if (month == 9) - os << lm.getTag ("sMonthFrostfall"); + os << lm.replaceTags ("#{sMonthFrostfall}"); else if (month == 10) - os << lm.getTag ("sMonthSunsdusk"); + os << lm.replaceTags ("#{sMonthSunsdusk}"); else if (month == 11) - os << lm.getTag ("sMonthEveningstar"); + os << lm.replaceTags ("#{sMonthEveningstar}"); else os << month; -#endif } -JournalViewModel::ptr JournalViewModel::create () +JournalViewModel::Ptr JournalViewModel::create () { return boost::make_shared (); } diff --git a/apps/openmw/mwgui/journalviewmodel.hpp b/apps/openmw/mwgui/journalviewmodel.hpp index ffc301b99..21c3a1178 100644 --- a/apps/openmw/mwgui/journalviewmodel.hpp +++ b/apps/openmw/mwgui/journalviewmodel.hpp @@ -13,17 +13,17 @@ namespace MWGui /// View-Model for the journal GUI /// /// This interface defines an abstract data model suited - // specifically to the needs of the journal GUI. It isolates + /// specifically to the needs of the journal GUI. It isolates /// the journal GUI from the implementation details of the /// game data store. struct JournalViewModel { - typedef boost::shared_ptr ptr; + typedef boost::shared_ptr Ptr; - typedef intptr_t quest_id; - typedef intptr_t topic_id; - typedef uint8_t const * utf8_point; - typedef std::pair utf8_span; + typedef intptr_t QuestId; + typedef intptr_t TopicId; + typedef uint8_t const * Utf8Point; + typedef std::pair Utf8Span; /// The base interface for both journal entries and topics. struct Entry @@ -33,12 +33,12 @@ namespace MWGui /// This function returns a borrowed reference to the body of the /// journal entry. The returned reference becomes invalid when the /// entry is destroyed. - virtual utf8_span body () const = 0; + virtual Utf8Span body () const = 0; /// Visits each subset of text in the body, delivering the beginning /// and end of the span relative to the body, and a valid topic ID if /// the span represents a keyword, or zero if not. - virtual void visitSpans (boost::function visitor) const = 0; + virtual void visitSpans (boost::function visitor) const = 0; }; /// An interface to topic data. @@ -46,7 +46,7 @@ namespace MWGui { /// Returns a pre-formatted span of UTF8 encoded text representing /// the name of the NPC this portion of dialog was heard from. - virtual utf8_span source () const = 0; + virtual Utf8Span source () const = 0; }; /// An interface to journal data. @@ -54,7 +54,7 @@ namespace MWGui { /// Returns a pre-formatted span of UTF8 encoded text representing /// the in-game date this entry was added to the journal. - virtual utf8_span timestamp () const = 0; + virtual Utf8Span timestamp () const = 0; }; @@ -68,25 +68,25 @@ namespace MWGui virtual bool isEmpty () const = 0; /// provides access to the name of the quest with the specified identifier - virtual void visitQuestName (topic_id topicId, boost::function visitor) const = 0; + virtual void visitQuestName (TopicId topicId, boost::function visitor) const = 0; /// walks the active and optionally completed, quests providing the quest id and name - virtual void visitQuestNames (bool active_only, boost::function visitor) const = 0; + virtual void visitQuestNames (bool active_only, boost::function visitor) const = 0; /// walks over the journal entries related to the specified quest identified by its id - virtual void visitJournalEntries (quest_id questId, boost::function visitor) const = 0; + virtual void visitJournalEntries (QuestId questId, boost::function visitor) const = 0; /// provides the name of the topic specified by its id - virtual void visitTopicName (topic_id topicId, boost::function visitor) const = 0; + virtual void visitTopicName (TopicId topicId, boost::function visitor) const = 0; /// walks over the topics whose names start with the specified character providing the topics id and name - virtual void visitTopicNamesStartingWith (int character, boost::function < void (topic_id , utf8_span) > visitor) const = 0; + virtual void visitTopicNamesStartingWith (char character, boost::function < void (TopicId , Utf8Span) > visitor) const = 0; /// walks over the topic entries for the topic specified by its identifier - virtual void visitTopicEntries (topic_id topicId, boost::function visitor) const = 0; + virtual void visitTopicEntries (TopicId topicId, boost::function visitor) const = 0; // create an instance of the default journal view model implementation - static ptr create (); + static Ptr create (); }; } diff --git a/apps/openmw/mwgui/journalwindow.cpp b/apps/openmw/mwgui/journalwindow.cpp index d51df5062..ab765ebe6 100644 --- a/apps/openmw/mwgui/journalwindow.cpp +++ b/apps/openmw/mwgui/journalwindow.cpp @@ -51,21 +51,21 @@ namespace { struct DisplayState { - int mPage; - book mBook; + unsigned int mPage; + Book mBook; }; - typedef std::stack display_state_stack; + typedef std::stack DisplayStateStack; - display_state_stack mStates; - book mTopicIndexBook; + DisplayStateStack mStates; + Book mTopicIndexBook; bool mQuestMode; bool mAllQuests; - template - widget_type * getWidget (char const * name) + template + T * getWidget (char const * name) { - widget_type * widget; + T * widget; WindowBase::getWidget (widget, name); return widget; } @@ -94,7 +94,7 @@ namespace return getWidget (name); } - JournalWindowImpl (JournalViewModel::ptr Model) + JournalWindowImpl (JournalViewModel::Ptr Model) : WindowBase("openmw_journal.layout"), JournalBooks (Model) { mMainWidget->setVisible(false); @@ -114,7 +114,7 @@ namespace adviseButtonClick (ShowActiveBTN, &JournalWindowImpl::notifyShowActive); { - BookPage::click_callback callback; + BookPage::ClickCallback callback; callback = boost::bind (&JournalWindowImpl::notifyTopicClicked, this, _1); @@ -124,7 +124,7 @@ namespace } { - BookPage::click_callback callback; + BookPage::ClickCallback callback; callback = boost::bind (&JournalWindowImpl::notifyIndexLinkClicked, this, _1); @@ -133,7 +133,7 @@ namespace } { - BookPage::click_callback callback; + BookPage::ClickCallback callback; callback = boost::bind (&JournalWindowImpl::notifyQuestClicked, this, _1); @@ -146,14 +146,14 @@ namespace void open() { - Model->load (); + mModel->load (); setBookMode (); MWBase::Environment::get().getSoundManager()->playSound ("book open", 1.0, 1.0); - book journalBook; - if (Model->isEmpty ()) + Book journalBook; + if (mModel->isEmpty ()) journalBook = createEmptyJournalBook (); else journalBook = createJournalBook (); @@ -163,10 +163,10 @@ namespace void close() { - Model->unload (); + mModel->unload (); - getPage (LeftBookPage)->showPage (book (), 0); - getPage (RightBookPage)->showPage (book (), 0); + getPage (LeftBookPage)->showPage (Book (), 0); + getPage (RightBookPage)->showPage (Book (), 0); while (!mStates.empty ()) mStates.pop (); @@ -209,24 +209,24 @@ namespace //TODO: figure out how to make "options" page overlay book page // correctly, so that text may show underneath - getPage (RightBookPage)->showPage (book (), 0); + getPage (RightBookPage)->showPage (Book (), 0); } - void pushBook (book Book, int Page) + void pushBook (Book book, unsigned int page) { DisplayState bs; - bs.mPage = Page; - bs.mBook = Book; + bs.mPage = page; + bs.mBook = book; mStates.push (bs); updateShowingPages (); updateCloseJournalButton (); } - void replaceBook (book Book, int Page) + void replaceBook (Book book, unsigned int page) { assert (!mStates.empty ()); - mStates.top ().mBook = Book; - mStates.top ().mPage = Page; + mStates.top ().mBook = book; + mStates.top ().mPage = page; updateShowingPages (); } @@ -245,38 +245,38 @@ namespace void updateShowingPages () { - book Book; - int Page; - int relPages; + Book book; + unsigned int page; + unsigned int relPages; if (!mStates.empty ()) { - Book = mStates.top ().mBook; - Page = mStates.top ().mPage; - relPages = Book->pageCount () - Page; + book = mStates.top ().mBook; + page = mStates.top ().mPage; + relPages = book->pageCount () - page; } else { - Page = 0; + page = 0; relPages = 0; } - setVisible (PrevPageBTN, Page > 0); + setVisible (PrevPageBTN, page > 0); setVisible (NextPageBTN, relPages > 2); setVisible (PageOneNum, relPages > 0); setVisible (PageTwoNum, relPages > 1); - getPage (LeftBookPage)->showPage ((relPages > 0) ? Book : book (), Page+0); - getPage (RightBookPage)->showPage ((relPages > 0) ? Book : book (), Page+1); + getPage (LeftBookPage)->showPage ((relPages > 0) ? book : Book (), page+0); + getPage (RightBookPage)->showPage ((relPages > 0) ? book : Book (), page+1); - setText (PageOneNum, Page + 1); - setText (PageTwoNum, Page + 2); + setText (PageOneNum, page + 1); + setText (PageTwoNum, page + 2); } void notifyTopicClicked (intptr_t linkId) { - book topicBook = createTopicBook (linkId); + Book topicBook = createTopicBook (linkId); if (mStates.size () > 1) replaceBook (topicBook, 0); @@ -290,12 +290,12 @@ namespace void notifyQuestClicked (intptr_t questId) { - book Book = createQuestBook (questId); + Book book = createQuestBook (questId); if (mStates.size () > 1) - replaceBook (Book, 0); + replaceBook (book, 0); else - pushBook (Book, 0); + pushBook (book, 0); setVisible (OptionsOverlay, false); setVisible (OptionsBTN, true); @@ -319,16 +319,16 @@ namespace popBook (); } - void showList (char const * ListId, char const * PageId, book book) + void showList (char const * listId, char const * pageId, Book book) { std::pair size = book->getSize (); - getPage (PageId)->showPage (book, 0); + getPage (pageId)->showPage (book, 0); - getWidget (ListId)->setCanvasSize (size.first, size.second); + getWidget (listId)->setCanvasSize (size.first, size.second); } - void notifyIndexLinkClicked (TypesetBook::interactive_id character) + void notifyIndexLinkClicked (TypesetBook::InteractiveId character) { setVisible (LeftTopicIndex, false); setVisible (RightTopicIndex, false); @@ -392,12 +392,12 @@ namespace { if (!mStates.empty ()) { - int & Page = mStates.top ().mPage; - book Book = mStates.top ().mBook; + unsigned int & page = mStates.top ().mPage; + Book book = mStates.top ().mBook; - if (Page < Book->pageCount () - 2) + if (page < book->pageCount () - 2) { - Page += 2; + page += 2; updateShowingPages (); } } @@ -407,11 +407,11 @@ namespace { if (!mStates.empty ()) { - int & Page = mStates.top ().mPage; + unsigned int & page = mStates.top ().mPage; - if(Page > 0) + if(page > 0) { - Page -= 2; + page -= 2; updateShowingPages (); } } @@ -420,7 +420,7 @@ namespace } // glue the implementation to the interface -JournalWindow * MWGui::JournalWindow::create (JournalViewModel::ptr Model) +JournalWindow * MWGui::JournalWindow::create (JournalViewModel::Ptr Model) { return new JournalWindowImpl (Model); } diff --git a/components/misc/utf8stream.hpp b/components/misc/utf8stream.hpp index 6c6ec65f6..19a0688b2 100644 --- a/components/misc/utf8stream.hpp +++ b/components/misc/utf8stream.hpp @@ -3,22 +3,22 @@ #include -class utf8_stream +class Utf8Stream { public: - typedef uint32_t unicode_char; - typedef unsigned char const * point; + typedef uint32_t UnicodeChar; + typedef unsigned char const * Point; //static const unicode_char sBadChar = 0xFFFFFFFF; gcc can't handle this - static unicode_char sBadChar () { return unicode_char (0xFFFFFFFF); } + static UnicodeChar sBadChar () { return UnicodeChar (0xFFFFFFFF); } - utf8_stream (point begin, point end) : + Utf8Stream (Point begin, Point end) : cur (begin), nxt (begin), end (end) { } - utf8_stream (std::pair range) : + Utf8Stream (std::pair range) : cur (range.first), nxt (range.first), end (range.second) { } @@ -28,19 +28,19 @@ public: return cur == end; } - point current () const + Point current () const { return cur; } - unicode_char peek () + UnicodeChar peek () { if (cur == nxt) next (); return val; } - unicode_char consume () + UnicodeChar consume () { if (cur == nxt) next (); @@ -48,24 +48,24 @@ public: return val; } - static std::pair decode (point cur, point end) + static std::pair decode (Point cur, Point end) { if ((*cur & 0x80) == 0) { - unicode_char chr = *cur++; + UnicodeChar chr = *cur++; return std::make_pair (chr, cur); } int octets; - unicode_char chr; + UnicodeChar chr; boost::tie (octets, chr) = octet_count (*cur++); if (octets > 5) return std::make_pair (sBadChar(), cur); - point eoc = cur + octets; + Point eoc = cur + octets; if (eoc > end) return std::make_pair (sBadChar(), cur); @@ -75,7 +75,7 @@ public: if ((*cur & 0xC0) != 0x80) // check continuation mark return std::make_pair (sBadChar(), cur);; - chr = (chr << 6) | unicode_char ((*cur++) & 0x3F); + chr = (chr << 6) | UnicodeChar ((*cur++) & 0x3F); } return std::make_pair (chr, cur); @@ -83,7 +83,7 @@ public: private: - static std::pair octet_count (unsigned char octet) + static std::pair octet_count (unsigned char octet) { int octets; @@ -107,10 +107,10 @@ private: boost::tie (val, nxt) = decode (nxt, end); } - point cur; - point nxt; - point end; - unicode_char val; + Point cur; + Point nxt; + Point end; + UnicodeChar val; }; #endif