From 7d5f055547e70fa93ee9ac944e62f8d657b9dc55 Mon Sep 17 00:00:00 2001 From: chai Date: Fri, 19 Oct 2018 08:36:44 +0800 Subject: =?UTF-8?q?*=E4=BF=AE=E6=94=B9=E6=96=87=E4=BB=B6=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/libjin/Graphics/Font/je_text.h | 79 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 src/libjin/Graphics/Font/je_text.h (limited to 'src/libjin/Graphics/Font/je_text.h') diff --git a/src/libjin/Graphics/Font/je_text.h b/src/libjin/Graphics/Font/je_text.h new file mode 100644 index 0000000..38e60ca --- /dev/null +++ b/src/libjin/Graphics/Font/je_text.h @@ -0,0 +1,79 @@ +#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; + + /// + /// Supported text encoding. + /// + enum Encode + { + UTF8, ///< utf-8 + ASCII, ///< ASCII + }; + + /// + /// Decoded text. Saved as unicode codepoints. + /// + 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; + + }; + + } // namespace graphics +} // namespace jin + +#endif \ No newline at end of file -- cgit v1.1-26-g67d0