00001 /***************************************************************************** 00002 * ustring.hpp 00003 ***************************************************************************** 00004 * Copyright (C) 2003 the VideoLAN team 00005 * $Id$ 00006 * 00007 * Authors: Cyril Deguet <asmax@via.ecp.fr> 00008 * Olivier Teulière <ipkiss@via.ecp.fr> 00009 * 00010 * This program is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. 00014 * 00015 * This program is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 * GNU General Public License for more details. 00019 * 00020 * You should have received a copy of the GNU General Public License 00021 * along with this program; if not, write to the Free Software 00022 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. 00023 *****************************************************************************/ 00024 00025 #ifndef USTRING_HPP 00026 #define USTRING_HPP 00027 00028 #include "../src/skin_common.hpp" 00029 #include "pointer.hpp" 00030 00031 00032 // Class for UNICODE strings handling 00033 class UString: public SkinObject 00034 { 00035 public: 00036 static const uint32_t npos; 00037 00038 /// Copy constructor 00039 UString( const UString &rOther ); 00040 00041 /// Create a new unicode string from an UTF8 string 00042 UString( intf_thread_t *pIntf, const char *pString ); 00043 00044 ~UString(); 00045 00046 /// Get the unicode string 00047 const uint32_t *u_str() const { return m_pString; } 00048 00049 /// Get the length of the string 00050 uint32_t length() const { return m_length; } 00051 uint32_t size() const { return m_length; } 00052 00053 /// Comparison 00054 bool operator ==( const UString &rOther ) const; 00055 bool operator !=( const UString &rOther ) const; 00056 bool operator <( const UString &rOther ) const; 00057 bool operator <=( const UString &rOther ) const; 00058 bool operator >( const UString &rOther ) const; 00059 bool operator >=( const UString &rOther ) const; 00060 /// Assignment 00061 void operator =( const UString &rOther ); 00062 /// Concatenation with assignment 00063 void operator +=( const UString &rOther ); 00064 /// Concatenation 00065 const UString operator +( const UString &rOther ) const; 00066 const UString operator +( const char *pString ) const; 00067 00068 00069 /// Search for the first occurance of the substring specified by str 00070 /// in this string, starting at position. If found, it returns the 00071 /// index of the first character of the matching substring. If not 00072 /// found, it returns npos 00073 uint32_t find( const UString &str, uint32_t position = 0 ) const; 00074 uint32_t find( const char *pString, uint32_t position = 0 ) const; 00075 00076 /// Insert elements of str in place of n1 elements in this string, 00077 /// starting at position position 00078 void replace( uint32_t position, uint32_t n1, const UString &str ); 00079 void replace( uint32_t position, uint32_t n1, const char *pString ); 00080 00081 /// Returns a string composed of copies of the lesser of n and size() 00082 /// characters in this string starting at index position 00083 UString substr( uint32_t position = 0, uint32_t n = npos) const; 00084 00085 /// Build a string from an integer 00086 static UString fromInt(intf_thread_t *pIntf, int number); 00087 00088 /// XXX: temporary 00089 void debug() const; 00090 00091 private: 00092 /// Unicode string 00093 uint32_t *m_pString; 00094 /// String length 00095 uint32_t m_length; 00096 }; 00097 00098 00099 typedef CountedPtr<UString> UStringPtr; 00100 00101 #endif
1.5.1