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

📄 string_util.hh

📁 MySql C++ library
💻 HH
字号:
#ifndef __STRING_UTIL1__
#define __STRING_UTIL1__
#include <ctype.h>
#include <string>
using namespace std;

extern void strip (string& s); // Strips blanks at left and right ends

extern void escape_string (string& s); // C++ equivalent of mysql_escape_string

inline void str_to_upr (string& s) { // Changes case of string to upper
	for (unsigned int cnt=0; cnt < s.length(); cnt++) {
		char c = s[cnt]; s[cnt]=toupper(c);
	}
}

inline void str_to_lwr (string& s) { // Changes case of string to lower
	for (unsigned int cnt=0; cnt < s.length(); cnt++) {
		char c = s[cnt]; s[cnt]=tolower(c);
	}
}

inline void strip_all_blanks (string& s) { // Removes all blanks
	for (unsigned int counter=0;counter < s.size();counter++)
		if (s[counter] == ' ') { s.erase(counter,1); counter--;}
}

inline void strip_all_non_num (string& s) { // Removes all non-numerics
	for (unsigned int counter=0;counter < s.size();counter++)
		if (!isdigit(s[counter])) { s.erase(counter,1); counter--;}
}


#endif

⌨️ 快捷键说明

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