~ubuntu-branches/ubuntu/wily/opencollada/wily

« back to all changes in this revision

Viewing changes to COLLADABaseUtils/include/COLLADABUNativeString.h

  • Committer: Package Import Robot
  • Author(s): Matteo F. Vescovi
  • Date: 2015-05-14 17:23:27 UTC
  • Revision ID: package-import@ubuntu.com-20150514172327-f862u8envms01fra
Tags: upstream-0.1.0~20140703.ddf8f47+dfsg1
ImportĀ upstreamĀ versionĀ 0.1.0~20140703.ddf8f47+dfsg1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    Copyright (c) 2008-2009 NetAllied Systems GmbH
 
3
 
 
4
    This file is part of COLLADABaseUtils.
 
5
 
 
6
    Licensed under the MIT Open Source License, 
 
7
    for details please see LICENSE file or the website
 
8
    http://www.opensource.org/licenses/mit-license.php
 
9
*/
 
10
 
 
11
#ifndef __COLLADABU_NATIVESTRING_H__
 
12
#define __COLLADABU_NATIVESTRING_H__
 
13
 
 
14
#include "COLLADABUPrerequisites.h"
 
15
 
 
16
 
 
17
namespace COLLADABU
 
18
{
 
19
 
 
20
        /** A string class to store strings encoded in the systems native encoding.*/
 
21
 
 
22
        class NativeString : public String
 
23
        {
 
24
        public:
 
25
                enum Encoding
 
26
                {
 
27
                        ENCODING_NATIVE,
 
28
                        ENCODING_UTF8
 
29
                };
 
30
        public:
 
31
                /**Content is initialized to a copy of the string object str.
 
32
                If @a encoding is ENCODING_NATIVE, @a str is assumed to be encoded in the platform native encoding.
 
33
                If @a encoding is ENCODING_UTF8, @a str is assumed to be encoded in UTF8.*/
 
34
                explicit NativeString(const String& str, Encoding encoding = ENCODING_NATIVE);
 
35
 
 
36
                NativeString(const WideString& wstr) : String()
 
37
                {
 
38
                        fromWideString(wstr);
 
39
                }
 
40
 
 
41
 
 
42
                /** Content is initialized to an empty NativeString. */
 
43
                explicit NativeString ( );
 
44
 
 
45
                /** Content is initialized to a copy of a substring of str. The substring is the portion of 
 
46
                str that begins at the character position pos and takes up to n characters (it takes less than 
 
47
                n if the end of str is reached before).*/
 
48
//              NativeString ( const String& str, size_t pos, size_t n = npos ) : String(str, pos, n){}
 
49
 
 
50
                /* Content is initialized to a copy of the string formed by the first n characters in the array 
 
51
                of characters pointed by s.*/
 
52
//              NativeString ( const char * s, size_t n ) : String(s, n){}
 
53
 
 
54
                /** Content is initialized to a copy of the string formed by the null-terminated character sequence 
 
55
                (C string) pointed by s. The length of the character sequence is determined by the first occurrence 
 
56
                of a null character (as determined by traits.length(s)). This version can be used to initialize a
 
57
                string object using a string literal constant.*/
 
58
                explicit NativeString ( const char * s, Encoding encoding = ENCODING_NATIVE);
 
59
 
 
60
                /** Content is initialized as a string formed by a repetition of character c, n times.*/
 
61
//              NativeString ( size_t n, char c ) : String(n, c){}
 
62
 
 
63
                /**If InputIterator is an integral type, behaves as the sixth constructor version (the one right above 
 
64
                this) by typecasting begin and end to call it:
 
65
                string(static_cast<size_t>(begin),static_cast<char>(end));
 
66
                In any other case, the parameters are taken as iterators, and the content is initialized with the values 
 
67
                of the elements that go from the element referred by iterator begin to the element right before the one 
 
68
                referred by iterator end.
 
69
                */
 
70
                template<class InputIterator> 
 
71
                NativeString (InputIterator begin, InputIterator end) : String(begin, end) {}
 
72
 
 
73
                /** Returns the string as unicode encoded wide string.*/
 
74
                WideString toWideString()const;
 
75
 
 
76
                /** Returns the string as utf encoded string.*/
 
77
                String toUtf8String() const;
 
78
 
 
79
 
 
80
        private:
 
81
                void fromWideString(const WideString& wstr);
 
82
        };
 
83
 
 
84
}
 
85
 
 
86
 
 
87
#endif //__COLLADABU_NATIVESTRING_H__