1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
3 * This library is open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version. The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * OpenSceneGraph Public License for more details.
15#define OSGTEXT_STRING 1
21#include <osgText/Export>
25// ******************************** HACK **********************************
26// Following class is needed to work around a DLL export problem. See file
27// include/osg/PrimitiveSet for details.
29class VectorUInt: public std::vector<unsigned int>
31 typedef std::vector<value_type> vector_type;
33 VectorUInt(): vector_type() {}
34 VectorUInt(const VectorUInt ©): vector_type(copy) {}
35 VectorUInt(unsigned int* beg, unsigned int* end): vector_type(beg, end) {}
36 explicit VectorUInt(unsigned int n): vector_type(n) {}
39// **************************************************************************
43class OSGTEXT_EXPORT String : public VectorUInt
47 typedef VectorUInt vector_type;
50 * Types of string encodings supported
54 ENCODING_UNDEFINED, /// not using Unicode
55 ENCODING_ASCII = ENCODING_UNDEFINED,/// unsigned char ASCII
56 ENCODING_UTF8, /// 8-bit unicode transformation format
57 ENCODING_UTF16, /// 16-bit signature
58 ENCODING_UTF16_BE, /// 16-bit big-endian
59 ENCODING_UTF16_LE, /// 16-bit little-endian
60 ENCODING_UTF32, /// 32-bit signature
61 ENCODING_UTF32_BE, /// 32-bit big-endian
62 ENCODING_UTF32_LE, /// 32-bit little-endian
63 ENCODING_SIGNATURE, /// detect encoding from signature
64 ENCODING_CURRENT_CODE_PAGE /// Use Windows Current Code Page ecoding
69 String(const String& str);
70 String(const std::string& str) { set(str); }
71 String(const wchar_t* text) { set(text); }
72 String(const std::string& text,Encoding encoding) { set(text,encoding); }
74 String& operator = (const String& str);
76 void set(const std::string& str);
78 /** Set the text using a wchar_t string,
79 * which is converted to an internal TextString.*/
80 void set(const wchar_t* text);
82 /** Set the text using a Unicode encoded std::string, which is converted to an internal TextString.
83 * The encoding parameter specifies which Unicode encoding is used in the std::string. */
84 void set(const std::string& text,Encoding encoding);
86 /** returns a UTF8 encoded version of this osgText::String.*/
87 std::string createUTF8EncodedString() const;