当前位置: 首页>>代码示例>>C++>>正文


C++ cstring::length方法代码示例

本文整理汇总了C++中cstring::length方法的典型用法代码示例。如果您正苦于以下问题:C++ cstring::length方法的具体用法?C++ cstring::length怎么用?C++ cstring::length使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cstring的用法示例。


在下文中一共展示了cstring::length方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: bml_size_white

//returns size of leading whitespace and comments
static size_t bml_size_white(const cstring& data)
{
	int i = 0;
	while (data[i]==' ' || data[i]=='\t') i++;
	if (data[i]=='#' || (data[i]=='/' && data[i+1]=='/')) return data.length();
	else return i;
}
开发者ID:Alcaro,项目名称:Arlib,代码行数:8,代码来源:bmlparse.cpp

示例2: unescape

string bmlwriter::unescape(cstring val)
{
	if (!val.startswith("-")) return val;
	
	string out;
	for (size_t i=1;i<val.length();i++)
	{
		if (val[i]=='-')
		{
			byte tmp;
			if (val[i+1]=='-')
			{
				i++;
				out += '-';
			}
			else if (fromstringhex(val.substr(i+1, i+3), tmp))
			{
				i += 2;
				out += tmp;
			}
		}
		else out += val[i];
	}
	return out;
}
开发者ID:Alcaro,项目名称:Arlib,代码行数:25,代码来源:bmlwrite.cpp

示例3: replace

static string replace(char c1, char c2, cstring s) {
	StringBuffer buf;
	for(int i = 0; i < s.length(); i++) {
		if(s[i] == c1)
			buf << c2;
		else
			buf << s[i];
	}
	return buf.toString();
}
开发者ID:alexjordan,项目名称:otawa,代码行数:10,代码来源:cfgio_Output.cpp

示例4: fromstringhex

bool fromstringhex(cstring s, arrayvieww<byte> val)
{
	if (val.size()*2 != s.length()) return false;
	bool ok = true;
	for (size_t i=0;i<val.size();i++)
	{
		ok &= fromstringhex(s.substr(i*2, i*2+2), val[i]);
	}
	return ok;
}
开发者ID:Alcaro,项目名称:Arlib,代码行数:10,代码来源:stringconv.cpp

示例5: type_core

bmlwriter::mode bmlwriter::type_core(cstring val)
{
	if (val == "") return anon;
	
	char first = val[0];
	char last = val[val.length()-1];
	
	if (val.contains("\n") || first==' ' || first=='\t' || last==' ' || last=='\t') return multiline;
	if (val.contains("\"")) return col;
	if (val.contains(" ") || val.contains("\t")) return quote;
	return eq;
}
开发者ID:Alcaro,项目名称:Arlib,代码行数:12,代码来源:bmlwrite.cpp

示例6: fromstring

bool fromstring(cstring s, double& out)
{
	out = 0;
	auto tmp_s = s.c_str();
	const char * tmp_cp = tmp_s;
	if (*tmp_cp != '-' && !isdigit(*tmp_cp)) return false;
	char * tmp_cpo;
	double ret = strtod(drop0x(tmp_cp), &tmp_cpo);
	if (tmp_cpo != tmp_cp + s.length()) return false;
	if (!isdigit(tmp_cpo[-1])) return false;
	if (ret==HUGE_VAL || ret==-HUGE_VAL) return false;
	out = ret;
	return true;
}
开发者ID:Alcaro,项目名称:Arlib,代码行数:14,代码来源:stringconv.cpp

示例7:

void	irctext::attrwrite(const int mode, const cstring &msg, 
                           const cstring &extratags)
{
	cstring	tags = extratags;
	// colors to use (possibly?)
	int	use_fg = fg, use_bg = bg;

	if(mode == 0 || msg.length() == 0)
	{
		if(msg.length() != 0)
			text::insert("end", msg, tags);
		return;
	}
	if(mode & MODE_BOLD)
		tags += " attr_b";
	if(mode & MODE_INVERSE)
		// swap colors
		if(mode & MODE_COLOR && use_fg != -1 && use_bg != -1)
		{
			int	t = use_fg;
			use_fg = use_bg;
			use_bg = t;
		}
		else
			tags += " attr_i";	// standard tag
	if(mode & MODE_UNDERLINE)
		tags += " attr_u";
	if(mode & MODE_COLOR)
	{
		if(use_fg != -1)
			tags << " fg" << use_fg;
		if(use_bg != -1)
			tags << " bg" << use_bg;
	}
	text::insert("end", msg, tags);
}
开发者ID:iivvoo-abandoned,项目名称:circus,代码行数:36,代码来源:irctext.c

示例8: linelen

static size_t linelen(const cstring& input)
{
	//pointers are generally a bad idea, but this is such a hotspot it's worth it
	const uint8_t * inputraw = input.bytes().ptr();
	size_t nlpos = 0;
	if (input.bytes_hasterm())
	{
		while (!isendl(inputraw[nlpos])) nlpos++;
	}
	else
	{
		size_t inputlen = input.length();
		while (nlpos < inputlen && !isendl(inputraw[nlpos])) nlpos++;
	}
	return nlpos;
}
开发者ID:Alcaro,项目名称:Arlib,代码行数:16,代码来源:bmlparse.cpp

示例9: parseLitt

/**
 * Parse a literal string.
 * @param litt	Literal string to parse (first character is ignored).
 */
void Parser::parseLitt(io::InStream& in, cstring litt) throw(json::Exception) {
	for(int i = 1; i < litt.length(); i++)
		if(nextChar(in) != litt[i])
			error("unknown identifier");
}
开发者ID:dllinxi,项目名称:WCET,代码行数:9,代码来源:json_Parser.cpp

示例10: bml_parse_inline_node

//takes a single line, returns the first node in it
//hasvalue is to differentiate 'foo' from 'foo='; only the former allows a multi-line value
//returns true if found a node, false for error or nothing
//if error, 'value' is the error message; if line was blank, 'value' is ""
static bool bml_parse_inline_node(cstring& data, cstring& node, bool& hasvalue, cstring& value)
{
	size_t nodestart = bml_size_white(data);
	if (nodestart == data.length())
	{
		data = "";
		value = "";
		return false;
	}
	
	size_t nodelen = nodestart;
	while (isalnum(data[nodelen]) || data[nodelen]=='-' || data[nodelen]=='.') nodelen++;
	if (nodestart == nodelen)
	{
		value = "Invalid node name";
		while (data[nodelen]!='\n' && data[nodelen]!='\0') nodelen++;
		data = data.substr(nodelen, ~0);
		return false;
	}
	node = cut(data, nodestart, nodelen, 0);
	switch (data[0])
	{
		case '\0':
		case '\t':
		case ' ':
		{
			hasvalue = false;
			return true;
		}
		case ':':
		{
			hasvalue = true;
			int valstart = 1;
			while (data[valstart]==' ' || data[valstart]=='\t') valstart++;
			value = data.substr(valstart, ~0);
			data = "";
			return true;
		}
		case '=':
		{
			if (data[1]=='"')
			{
				hasvalue = true;
				int valend = 2;
				while (data[valend]!='"' && data[valend]!='\0') valend++;
				if (data[valend]!='"' || !strchr(" \t", data[valend+1]))
				{
					while (data[valend]!='\0') valend++;
					data = data.substr(valend, ~0);
					value = "Broken quoted value";
					return false;
				}
				value = cut(data, 2, valend, 1);
				return true;
			}
			else
			{
				hasvalue = true;
				int valend = 0;
				while (data[valend]!=' ' && data[valend]!='"' && data[valend]!='\0') valend++;
				if (data[valend]=='"')
				{
					while (data[valend]!='\0') valend++;
					data = data.substr(valend, ~0);
					value = "Broken quoted value";
					return false;
				}
				value = cut(data, 1, valend, 0);
				return true;
			}
		}
		default:
			value = "Invalid node suffix";
			return false;
	}
}
开发者ID:Alcaro,项目名称:Arlib,代码行数:80,代码来源:bmlparse.cpp

示例11: if

void	irctext::tinsert(int &mode, const cstring &msg, 
                         const cstring &extratags)
{
	int	idx = 0;
	int	tag_start = 0;
	int	newmode = 0;
	int	newfg=-1, newbg=-1;
	int	notbeeped = true;

	for(idx = 0; idx < msg.length(); idx++)
	{
		int	tag_end = idx - 1;	// is a tag ends, it ends here
		if(msg[idx] == '\x02')			// bold
			newmode = MODE_BOLD;
		else if(msg[idx] == '\x03')		// color
		// filter out colors
		{
			cstring	nfg, nbg;
			newfg=-1,newbg=-1;

			newmode = MODE_COLOR;

			int	idx1=0, idx2=0;

			for(idx1=idx+1; msg[idx1] && isdigit(msg[idx1]) 
			                && idx1 <= idx+2; idx1++)
				nfg += msg[idx1];

			if(msg[idx1] == ',') // read background color??
			{
				for(idx2=idx1+1; msg[idx2] && isdigit(msg[idx2])
			                        && idx2 <= idx1+2; idx2++)
					nbg += msg[idx2];
				idx = idx2-1;
			}
			else
				idx = idx1-1;

			// no colors specified? Turn them off...

			if(!((int)nfg||(int)nbg))
			{
				newfg = -1;
				newbg = -1;
			}
			else
			{
				if((int)nfg)
					newfg = atoi(nfg)%16;	// set new fg
				else
					newfg = fg;
				if((int)nbg)
					newbg = atoi(nbg)%16;	// set new bg
				else
					newbg = bg;
			}
		}
		else if(msg[idx] == '\x07')
		{
			if(notbeeped)
			{
				tk->beep();
				notbeeped = false;
			}
			continue;
		}
		else if(msg[idx] == '\x16')		// inverse
			newmode = MODE_INVERSE;
		else if(msg[idx] == '\x1f')		// underline
			newmode = MODE_UNDERLINE;
		else if(msg[idx] == '\x0f')		// everything off
			newmode = 0;
		else if(msg[idx] == '\n')
		{
			notbeeped = true;
			newmode = 0;
			newfg=-1;
			newbg=-1;
		}
		else
			continue;

		// If we got this far, attributes must have changed, so
		// write the previous text
		if(tag_end >= tag_start)	// is there anything?
			attrwrite(mode, msg(tag_start, tag_end), extratags);

		if(newmode == MODE_COLOR)
		{
			if(newfg == -1 && newbg == -1)
				mode = 0;
			else
				mode |= newmode;
		}
		else if(mode & newmode)
			// remove, ircII behaviour is to turn off all attrs!
			mode = 0;
		else
			// tag starts
			mode |= newmode;
//.........这里部分代码省略.........
开发者ID:iivvoo-abandoned,项目名称:circus,代码行数:101,代码来源:irctext.c


注:本文中的cstring::length方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。