root/OpenSceneGraph/trunk/include/osgText/String @ 13041

Revision 13041, 3.2 kB (checked in by robert, 2 years ago)

Ran script to remove trailing spaces and tabs

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2 *
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.
7 *
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.
12*/
13
14#ifndef OSGTEXT_STRING
15#define OSGTEXT_STRING 1
16
17#include <vector>
18#include <set>
19#include <string>
20
21#include <osgText/Export>
22
23namespace osgText {
24
25// ********************************  HACK  **********************************
26// Following class is needed to work around a DLL export problem. See file
27// include/osg/PrimitiveSet for details.
28
29class VectorUInt: public std::vector<unsigned int>
30{
31    typedef std::vector<value_type> vector_type;
32public:
33    VectorUInt(): vector_type() {}
34    VectorUInt(const VectorUInt &copy): vector_type(copy) {}
35    VectorUInt(unsigned int* beg, unsigned int* end): vector_type(beg, end) {}
36    explicit VectorUInt(unsigned int n): vector_type(n) {}
37};
38
39// **************************************************************************
40
41class Text;
42
43class OSGTEXT_EXPORT String : public VectorUInt
44{
45    public:
46
47        typedef VectorUInt vector_type;
48
49        /**
50         * Types of string encodings supported
51         */
52        enum Encoding
53        {
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        };
65
66
67        String() {}
68        String(const String& str);
69        String(const std::string& str) { set(str); }
70        String(const wchar_t* text) { set(text); }
71        String(const std::string& text,Encoding encoding) { set(text,encoding); }
72
73        String& operator = (const String& str);
74
75        void set(const std::string& str);
76
77        /** Set the text using a wchar_t string,
78          * which is converted to an internal TextString.*/
79        void set(const wchar_t* text);
80
81        /** Set the text using a Unicode encoded std::string, which is converted to an internal TextString.
82          * The encoding parameter specifies which Unicode encoding is used in the std::string. */
83        void set(const std::string& text,Encoding encoding);
84
85        /** returns a UTF8 encoded version of this osgText::String.*/
86        std::string createUTF8EncodedString() const;
87
88    protected:
89
90};
91
92}
93
94
95#endif
Note: See TracBrowser for help on using the browser.