string.h

来自「LINUX下发送邮件的库,测试很好用,有各种发送测试的例子」· C头文件 代码 · 共 107 行

H
107
字号
/************************************************************************* *                                                                       * * This program is free software; you can redistribute it and/or modify  * * it under the terms of the GNU General Public License as published by  * * the Free Software Foundation; either version 2 of the License, or     * * (at your option) any later version.                                   * *                                                                       * *************************************************************************/#ifndef _STRING_H__#define _STRING_H__#include "global.h"#include <stdio.h>#include <string>#include <vector>#include <ctype.h>using namespace std;/** * Some convenient methods for string manipulations. * * @author Timo Benk <t_benk@web.de> */class String{	public:		/**		 * Wraps str at width width, or at the best suitable position. 		 *		 * @param str   The string that should be wrapped.		 * @param width The maximal column count of the wrapped string.		 * @returns The wrapped string.		 */		static string wrap (string str, unsigned int width);		/**		 * Returns str in lower case characters.		 *		 * @param str The string that should be lowerized.		 * @returns str in lower cases.		 */		static string to_lower (string str);		/**		 * Returns str in upper case characters.		 *		 * @param str The string that should be upperized.		 * @returns str in upper cases.		 */		static string to_upper (string str);		/**		 * Returns str as a vector of its lines.		 *		 * @param str The string that should be split up into lines.		 * @returns All lines of str grouped into a vector.		 */		static vector<string> string2lines (const string &str);				/**		 * This method parses the string str into a vector		 * of its tokens. The delimiting character is a single		 * blankspace, so if you want usefull results call String::trim()		 * before.		 *		 * @param str The string that should be tokenized.		 * @returns All tokens of str grouped into a vector.		 */		static vector<string> string2tokens (const string &str);		/**		 * This method parses the string str into a vector		 * of its tokens. 		 *		 * @param str   The string that should be tokenized.		 * @param delim A single character that should be used as 		 *              a delimiter.		 * @returns All tokens of str grouped into a vector.		 */		static vector<string> string2tokens (const string &str, char delim);		/**		 * Removes all leading and tailing blankspaces, and 		 * replaces all multiple occurences of blank spaces		 * with a single one.		 * eg:		 *       "  this   is  a   test string"		 * =>    "this is a test string"		 *		 * @param str The string that should be trimmed.		 * @returns The trimmed string.		 */		static string trim (string str);				/**		 * Converts an integer to the radix 10 into a string.		 *		 * @param i The integer that should be converted to a string.		 * @returns A string representation of i.		 */		static string itoa (int i);};#endif

⌨️ 快捷键说明

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