⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 string.h

📁 这个是symbian下的一个蛮庞大的3D游戏源代码!对于学习3D开发的人有很大的帮助!
💻 H
字号:
#ifndef _LANG_STRING_H
#define _LANG_STRING_H


#include <assert.h>


namespace lang
{

	
class Converter;
	

/** 
 * Immutable Unicode character string. Used encoding is UTF-8.
 * 
 * @ingroup lang
 */
class String
{
public:
	/** Creates an zero length string. */
	String();

	/** 
	 * Creates a string from the 0-terminated UTF-8 code unit sequence.
	 * @exception OutOfMemoryException
	 */
	String( const char* str );

	/** 
	 * Creates a string from the encoded character sequence.
	 * Ignores invalid character sequences.
	 * @exception OutOfMemoryException
	 */
	String( const void* data, int size, const Converter& decoder );

	/** 
	 * Copy by reference. 
	 */
	String( const String& other );

	///
	~String();

	/** 
	 * Copy by reference. 
 	 */
	String&		operator=( const String& other );

	/** 
	 * Returns number of UTF-8 code units in the string. 
	 */
	int			length() const;

	/**
	 * Returns UTF-8 code unit at specified index. 
	 */
	char		charAt( int index ) const;
	
	/**
	 * Copies characters from this string into the destination character array.
	 * NOTE: Does not terminate output with zero, see get() for getting full 
	 * string in zero-terminated form.
	 *
	 * @param begin Index to the beginning (inclusive) of the substring.
	 * @param end Index to the end (exclusive) of the substring.
	 */
	void		getChars( int begin, int end, char* dest ) const;

	/**
	 * Copies characters from this string into the destination character array
	 * and terminates the output with zero.
	 * Asserts if buffer not large enough, but terminates it still with zero.
	 * @param buf [out] Receives the string.
	 * @param bufsize Size of the buffer.
	 */
	void		get( char* buf, int bufsize ) const;

	/**
	 * Returns 0-terminated UTF-8 data.
	 *
	 * WARNING: This is convenience method, which uses static buffer
	 * to store string characters which it returns. So calling the function
	 * too many times in the same statement might result in loss of 
	 * information in the function return value.
	 * Always use get or cpy in 'mission critical' situations and this function
	 * only for example in debug output or other less critical situations.
	 */
	const char*	c_str() const;

	/**
	 * Returns the first index within this string of the specified character.
	 * Starts the search from the specified position.
	 *
	 * @param ch Character to find.
	 * @param index The first position to search.
	 * @return Index of the found position or -1 if the character was not found from the string.
	 */
	int			indexOf( char ch, int index ) const;

	/**
	 * Bitwise lecigographical compare between this string and other string. 
	 * @return If this string is lexicographically before other then the return value is <0 and if this string is after other string then >0. If the strings are equal then the return value is 0.
	 */
	int			compareTo( const String& other ) const;

	/**
	 * Bitwise lecigographical compare between this string and other string. 
	 * @return If this string is lexicographically before other then the return value is <0 and if this string is after other string then >0. If the strings are equal then the return value is 0.
	 */
	int			compareTo( const char* other ) const;

	/** Concatenate two Strings. */
	lang::String 
		operator+( const String& other ) const;

	/** Concatenate 0-terminated UTF-8 char sequence and String. */
	lang::String 
		operator+( const char* other ) const;

	/** 
	 * Safe zero-terminated character string copy to limited buffer. 
	 * @return true if string fit to the buffer.
	 */
	static bool cpy( char* buf, int bufsize, const char* sz );

	/** 
	 * Safe string copy to limited buffer. 
	 * @return true if string fit to the buffer.
	 */
	static bool cpy( char* buf, int bufsize, const String& str );

private:
	int m_h;
};


} // lang


/** 
 * Concatenate 0-terminated UTF-8 char sequence and String. 
 * @exception OutOfMemoryException
 */
inline lang::String 
	operator+( const char* first, const lang::String& second )		{return lang::String(first)+second;}


#endif // _LANG_STRING_H


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -