From b1bbc998960fff2169dc5a992c47d08723472f9b Mon Sep 17 00:00:00 2001 From: chai Date: Sun, 14 Oct 2018 22:52:40 +0800 Subject: =?UTF-8?q?*=E7=9B=B4=E6=8E=A5=E6=B8=B2=E6=9F=93=E5=AD=97=E7=AC=A6?= =?UTF-8?q?=E4=B8=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/libjin/Graphics/Font/Text.h | 74 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 src/libjin/Graphics/Font/Text.h (limited to 'src/libjin/Graphics/Font/Text.h') diff --git a/src/libjin/Graphics/Font/Text.h b/src/libjin/Graphics/Font/Text.h new file mode 100644 index 0000000..3faabc0 --- /dev/null +++ b/src/libjin/Graphics/Font/Text.h @@ -0,0 +1,74 @@ +#ifndef __LIBJIN_TEXT_H +#define __LIBJIN_TEXT_H + +#include + +namespace jin +{ +namespace graphics +{ + + typedef unsigned int Codepoint; + + typedef std::vector Content; + + class Text; + class Decoder; + + enum Encode + { + UTF8, // utf-8 + //UTF16, // utf-16 + ASCII, // ASCII + }; + + /* raw encoded text */ + class Text + { + public: + Text(Encode encode, const void* data); + Text(Encode encode, const void* data, unsigned int length); + ~Text(); + + const Content& getContent() const; + const Content& operator*() const; + + private: + class Iterator + { + public: + Iterator(const Iterator& itor); + Iterator(const Encode& encode, const void* data, unsigned int length); + ~Iterator(); + + Codepoint get(); + Iterator begin(); + Iterator end(); + void toBegin(); + void toEnd(); + Codepoint operator *(); + /* prefix ++ */ + Iterator& operator ++(); + /* postfix ++ */ + Iterator operator ++(int); + bool operator !=(const Iterator& itor); + bool operator ==(const Iterator& itor); + + private: + void operator = (const Iterator&); + + const Encode encode; + const Decoder* decoder; + const void* p; + const void* const data; + unsigned int length; + }; + + Content content; + + }; + +} // graphics +} // jin + +#endif \ No newline at end of file -- cgit v1.1-26-g67d0