Design Patterns in Modern C++ by Dmitri Nesteruk

Design Patterns in Modern C++ by Dmitri Nesteruk

Author:Dmitri Nesteruk
Language: eng
Format: epub
Publisher: Apress, Berkeley, CA


As you can see, TextRange just stores the start and end points to which it applies, as well as the actual formatting information—whether we want to capitalize text as well as any other formatting option (bold, italic, etc.). It has just a single member function covers(), which helps us determine whether this piece of formatting needs to be applied to the character at the given position.

BetterFormattedText stores a vector of TextRange flyweights and is able to construct new ones on demand:

1 TextRange& get_range(int start, int end)

2 {

3 formatting.emplace_back(TextRange{ start, end });

4 return *formatting.rbegin();

5 }



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.