]> git.sesse.net Git - vlc/blob - modules/gui/skins2/utils/ustring.hpp
Qt4: missing parentheses
[vlc] / modules / gui / skins2 / utils / ustring.hpp
1 /*****************************************************************************
2  * ustring.hpp
3  *****************************************************************************
4  * Copyright (C) 2003 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Cyril Deguet     <asmax@via.ecp.fr>
8  *          Olivier Teulière <ipkiss@via.ecp.fr>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License along
21  * with this program; if not, write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23  *****************************************************************************/
24
25 #ifndef USTRING_HPP
26 #define USTRING_HPP
27
28 #include "../src/skin_common.hpp"
29 #include "pointer.hpp"
30
31
32 // Class for UNICODE strings handling
33 class UString: public SkinObject
34 {
35 public:
36     static const uint32_t npos;
37
38     /// Copy constructor
39     UString( const UString &rOther );
40
41     /// Create a new unicode string from an UTF8 string
42     UString( intf_thread_t *pIntf, const char *pString );
43
44     ~UString();
45
46     /// Get the unicode string
47     const uint32_t *u_str() const { return m_pString; }
48
49     /// Get the length of the string
50     uint32_t length() const { return m_length; }
51     uint32_t size() const { return m_length; }
52
53     /// Comparison
54     bool operator ==( const UString &rOther ) const;
55     bool operator !=( const UString &rOther ) const;
56     bool operator <( const UString &rOther ) const;
57     bool operator <=( const UString &rOther ) const;
58     bool operator >( const UString &rOther ) const;
59     bool operator >=( const UString &rOther ) const;
60     /// Assignment
61     UString& operator =( const UString &rOther );
62     /// Concatenation with assignment
63     UString& operator +=( const UString &rOther );
64     /// Concatenation
65     const UString operator +( const UString &rOther ) const;
66     const UString operator +( const char *pString ) const;
67
68
69     /// Search for the first occurance of the substring specified by str
70     /// in this string, starting at position. If found, it returns the
71     /// index of the first character of the matching substring. If not
72     /// found, it returns npos
73     uint32_t find( const UString &str, uint32_t position = 0 ) const;
74     uint32_t find( const char *pString, uint32_t position = 0 ) const;
75
76     /// Insert elements of str in place of n1 elements in this string,
77     /// starting at position position
78     void replace( uint32_t position, uint32_t n1, const UString &str );
79     void replace( uint32_t position, uint32_t n1, const char *pString );
80
81     /// Returns a string composed of copies of the lesser of n and size()
82     /// characters in this string starting at index position
83     UString substr( uint32_t position = 0, uint32_t n = npos) const;
84
85     /// Build a string from an integer
86     static UString fromInt(intf_thread_t *pIntf, int number);
87
88 private:
89     /// Unicode string
90     uint32_t *m_pString;
91     /// String length
92     uint32_t m_length;
93 };
94
95
96 typedef CountedPtr<UString> UStringPtr;
97
98 #endif