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

📄 string.h

📁 GNU Common C++ is a very portable and highly optimized class framework for writing C++ applications
💻 H
📖 第 1 页 / 共 2 页
字号:
	/**	 * Chop n leading characters from a string.	 *	 * @param chars count to chop.	 */	inline void chop(size_t chars)		{erase(0, chars);};	/**	 * Trim n trailing characters from a string.	 *	 * @param count number of bytes to trim.	 */	void trim(size_t count);	/**	 * Erase a portion of string.	 *	 * @param start starting index to erase from.	 * @param len number of characters to erase.	 */	void erase(size_t start, size_t len = npos);	/**	 * Insert text into a string.	 *	 * @param start starting offset to insert at.	 * @param text text to insert.	 * @param len size of text to insert.	 */	void insert(size_t start, const char *text, size_t len = 0);	/**	 * Insert other string into our string.	 *	 * @param start string offset to insert at.	 * @param str string to insert.	 */	void insert(size_t start, const String &str);	/**	 * Replace text at a specific position in the string with new	 * text.	 *	 * @param start starting offset to replace at.	 * @param len length of text to remove.	 * @param text text to replace with.	 * @param count size of replacement text.	 */	void replace(size_t start, size_t len, const char *text, size_t count = 0);        /**         * Replace text at a specific position in the string with new         * string,         *         * @param start starting offset to replace at.         * @param len length of text to remove.         * @param string reference to replace with.         */	void replace(size_t start, size_t len, const String &string);	/**	 * A more convenient version of find for nth occurences, by	 * putting the instance first.	 *	 * @param instance nth instance to look for.	 * @param text text to look for.	 * @param offset offset to start at.	 * @param len length of text.	 */	inline size_t find(unsigned instance, const char *text, size_t offset = 0, size_t len = 0) const		{return find(text, offset, len, instance);};        /**         * A more convenient version of find for nth occurences, by         * putting the instance first.         *         * @param instance nth instance to look for.         * @param string reference to look for.         * @param offset offset to start at.         */	inline size_t find(unsigned instance, const String &string, size_t offset = 0) const		{return find(string, offset, instance);};	/**	 * Return a new string that contains a specific substring of the	 * current string.	 *	 * @return new string.	 * @param start starting offset for extracted substring.		 * @param len length of substring.	 */	inline String substr(size_t start, size_t len) const		{return String(*this, start, len);};	/**	 * Return an indexed string based on the index, such as from a	 * find.  If out of range, a NULL string is returned.	 *	 * @return pointer to string data from our string,	 * @param ind index or offset to use.	 */	inline const char *(index)(size_t ind) const		{return getIndex(ind);};	/**	 * Reduce the size of the string allocation to the minimum	 * needed based on the current effective length.	 */	inline void compact(void)		{resize(getLength() + 1);};	/**	 * Old ANSI C++ compatible string pointer extraction.	 *	 * @return string data.	 */	inline char *c_str(void) const		{return getText();};	/**	 * Get our string data through dereference operator.	 *	 * @return string data.	 */	inline operator char *() const		{return getText();};	/**	 * Logical test for string empty.	 *	 * @return true if is empty.	 */	inline bool operator!(void) const		{return isEmpty();};	/**	 * Alternate get text method.	 *	 * @return string data.	 */	inline char *text(void) const		{return getText();};	/**	 * Alternate get text method.	 *	 * @return string data.	 */	inline char *data(void) const		{return getText();};	/**	 * Get length as if null terminated string.	 *	 * @return cstring length.	 */	inline size_t length(void) const		{return strlen(getText());};	/**	 * Get actual length of string data.	 *	 * @return actual size of string.	 */	inline size_t size(void) const		{return getLength();};	/**	 * Get space allocated to hold current string.	 *	 * @return space of memory buffer from heap or local.	 */	inline size_t capacity(void) const		{return getSize();};	/**	 * Return true if string is empty.	 */	bool empty(void) const		{return isEmpty();};	/**	 * Append text to the end of the current string.	 *	 * @param str text to append.	 * @param count size of text to append.	 */	void append(const char *str, size_t count = 0);#ifdef	HAVE_SNPRINTF	/**	 * Append formatted text to the end of the current string.	 *	 * @param size size of text to append.	 * @param format of data to append.	 */	void append(size_t size, const char *format, ...);#endif        /**         * Append text into the current string.         *         * @param str text to append.	 * @param offset offset to overlay.         * @param count size of text to append.         */        void append(const char *str, size_t offset, size_t count);	/**	 * Add a character to the end of a string.	 *	 * @param c char to add.	 */	void add(char c);	/**	 * Append string to the end of the current string.	 *	 * @param str string to append.	 */	void append(const String &str);	/**	 * Extract a character by array indexing.	 *	 * @return character code.	 */	inline const char operator[](unsigned ind) const		{return at(ind);};	/**	 * Assign our string for c string.	 */	inline const char *operator =(const char *str)		{return set(str);};	/**	 * Add two strings and return a temporary object.	 */	friend __EXPORT String operator+(const String &s1, const String &s2);	friend __EXPORT String operator+(const String &s1, const char *s2);	friend __EXPORT String operator+(const char *s1, const String &s2);	friend __EXPORT String operator+(const String &s1, const char c2);		friend __EXPORT String operator+(const char c1, const String &s2);	/**	 * Append operator.	 */	inline String &operator+=(const String &str)		{append(str); return *this;};	/**	 * Append operator.	 */	inline String &operator+=(char c)		{add(c); return *this;};	/**	 * Append operator.	 */	inline String &operator+=(const char *str)		{append(str); return *this;};	/**	 * Append operator.	 */	inline String &operator+=(const std::string &str)		{append(str.c_str()); return *this;};	/**	 * Fetch input from a std::istream into the current string 	 * variable until either the string variable is filled (based on	 * current length) or the deliminator is read.	 *	 * @param is stream to read.	 * @param str string to save into.	 * @param delim deliminator to use.	 * @param size optional size limitor.	 */	friend __EXPORT std::istream &getline(std::istream &is, String &str, char delim = '\n', size_t size = 0);	/**	 * Stream the content of our string variable directly to a C++	 * streaming source.	 */	friend __EXPORT std::ostream &operator<<(std::ostream &os, const String &str);	/**	 * Stream input into our variable.	 */	inline friend std::istream &operator>>(std::istream &is, String &str)		{return getline(is, str);};#ifdef	HAVE_SNPRINTF	/**	 * Print values directly into a string variable.	 *	 * @return character count.	 * @param str object reference to use.	 * @param size of string required.	 * @param format of data.	 */	friend __EXPORT int strprintf(String &str, size_t size, const char *format, ...);#endif        bool operator<(const String &str) const;        bool operator<(const char *str) const;	bool operator>(const String &str) const;	bool operator>(const char *str) const;        bool operator<=(const String &str) const;        bool operator<=(const char *str) const;        bool operator>=(const String &str) const;        bool operator>=(const char *str) const;        bool operator==(const String &str) const;        bool operator==(const char *str) const;        bool operator!=(const String &str) const;        bool operator!=(const char *str) const;#ifdef	HAVE_SNPRINTF        /**         * Append operator         */        inline String &operator+=(int i)                {append(16, "%d", i); return *this;};        inline String &operator+=(unsigned int i)                {append(16, "%u", i); return *this;};        inline String &operator+=(long l)                {append(16, "%l", l); return *this;};        inline String &operator+=(unsigned long l)                {append(16, "%ul", l); return *this;};        inline String &operator+=(float f)                {append(32, "%f", f); return *this;};        inline String &operator+=(double d)                {append(32, "%f", d); return *this;};        inline String &operator+=(short s)                {append(8, "%hd", s); return *this;};        inline String &operator+=(unsigned short s)                {append(8, "%hu", s); return *this;};        /**         * Assignment operator.         */        inline String &operator=(int i)                {set(16, "%d", i); return *this;};        inline String &operator=(unsigned int i)                {set(16, "%u", i); return *this;};        inline String &operator=(long l)                {set(16, "%l", l); return *this;};        inline String &operator=(unsigned long l)                {set(16, "%ul", l); return *this;};        inline String &operator=(float f)                {set(32, "%f", f); return *this;};        inline String &operator=(double d)                {set(32, "%f", d); return *this;};        inline String &operator=(short s)                {set(8, "%hd", s); return *this;};        inline String &operator=(unsigned short s)                {set(8, "%hu", s); return *this;};#endif	inline String &operator=(const String &original)		{copy(original); return *this;};	/**	 * Test if string is contained in our string.	 */	bool operator*=(const String &str) const;	/**	 * Test if text is contained in our string.	 */	bool operator*=(const char *str) const;};class __EXPORT SString : public String, protected std::streambuf, public std::ostream{protected:        /**         * This is the streambuf function that actually outputs the data         * to the string.  Since all output should be done with the standard         * ostream operators, this function should never be called directly.         */	int overflow(int c);public:	/**	 * Create an empty streamable string ready for input.	 */	SString();	/**	 * Copy constructor	 */	SString(const SString &from);	/**	 * Cancel out the object.	 */	~SString();};/** * The StringObject class is used to derive subclasses that use the * String managed memory pool for all space allocations by overriding * new and delete operators.  Due to size limits, StringObject should * not hold very large objects. * * @author David Sugar <dyfet@ostel.com> * @short Objects managed in reusable String memory pools */class __EXPORT StringObject{public:	/**	 * Create a new object in string managed space.	 */	void *operator new(size_t size) NEW_THROWS;	/**	 * Delete object from string managed space.	 */	void operator delete(void *obj);};#ifdef	CCXX_NAMESPACES}#endif#endif

⌨️ 快捷键说明

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