OpenSceneGraph/include/osgText/EncodedText

93 lines
3.4 KiB
C++

/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
//C++ header - Open Scene Graph - Copyright (C) 1998-2002 Robert Osfield
//Distributed under the terms of the GNU Library General Public License (LGPL)
//as published by the Free Software Foundation.
/* --------------------------------------------------------------------------
*
* openscenegraph textLib / FTGL wrapper (http://homepages.paradise.net.nz/henryj/code/)
*
* --------------------------------------------------------------------------
*
* prog: max rheiner;mrn@paus.ch
* date: 4/25/2001 (m/d/y)
*
* --------------------------------------------------------------------------
*
* --------------------------------------------------------------------------
*/
#ifndef OSGTEXT_ENCODEDTEXT
#define OSGTEXT_ENCODEDTEXT 1
#include <osg/Referenced>
#include <osgText/Export>
#include <vector>
#include <string>
namespace osgText {
class OSGTEXT_EXPORT EncodedText : public osg::Referenced
{
public:
/**
* Types of string encodings supported
*/
enum Encoding
{
ENCODING_UNDEFINED, /// not using Unicode
ENCODING_ASCII = ENCODING_UNDEFINED,/// unsigned char ASCII
ENCODING_UTF8, /// 8-bit unicode transformation format
ENCODING_UTF16, /// 16-bit signature
ENCODING_UTF16_BE, /// 16-bit big-endian
ENCODING_UTF16_LE, /// 16-bit little-endian
ENCODING_UTF32, /// 32-bit signature
ENCODING_UTF32_BE, /// 32-bit big-endian
ENCODING_UTF32_LE, /// 32-bit little-endian
ENCODING_SIGNATURE, /// detect encoding from signature
};
EncodedText();
void setOverrideEncoding(Encoding encoding);
Encoding getOverrideEncoding() const { return _overrideEncoding; }
Encoding getEncoding() const { return _encoding; }
std::vector<int>::const_iterator begin() const { return _unicodeText.begin(); }
std::vector<int>::const_iterator end() const { return _unicodeText.end(); }
protected:
friend class Text;
std::string convertWideString(const char* text);
std::string convertWideString(const wchar_t* text);
void setText(const unsigned char* text, int length = -1);
int getNextCharacter(const unsigned char*& charString) const;
/// This method will extract any ZWNBSP signature at the start of the string
Encoding findEncoding(const unsigned char*& charString) const;
Encoding _encoding;
Encoding _overrideEncoding;
std::vector<int> _unicodeText;
};
}
#endif // OSGTEXT_TEXT