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


C++ String::Byte方法代码示例

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


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

示例1: Evaluate

Value StringParser::Evaluate(SymbolTable* scope, EvalContext& context)
{
	String* output = new String();
	//ByteChunk* output = context.output;
	bool docodes = false;
	next();

	while(current != '\0') {
		// Handle '$' escapes
		if(current == '{') {
			output->Append( expression(scope, context).ToCodeString() );
			continue;
		}

		if(docodes) {
			// Break out of code mode
			if(current == ']') {
				next();
				docodes = false;
				continue;
			}
			// consume whitespace
			if(current == ' ' || current == '\t' || current == '\n') {
				next();
				continue;
			}
			int b = acceptbyte();
			if(b == -1)
				Warning(string("invalid control code bytes ignored"),0,0);
			else
				output->Byte(b);

			next();
		}
		else
		{
			if(current == '/') {
				output->Byte(16);
				output->Byte(5);
			}
			else if(current == '|') {
				output->Byte(16);
				output->Byte(15);
			}
			else if(current == '[') {
				docodes = true;
			}
			else {
				// Default:
				output->Char(current);
			}
			next();
			continue;
		}
	}

	return Value(output);
}
开发者ID:jeffman,项目名称:ccscript_legacy,代码行数:58,代码来源:stringparser.cpp

示例2: Evaluate

Value BoundedExpr::Evaluate(SymbolTable* scope, EvalContext& context, bool asbool)
{
	/// Scope override; must do this for every expression that might contain an identifier
	if(this->scope != NULL)
		scope = this->scope;
	// TODO: there really has to be a better way to handle these scope overrides.
	//  Having to put this if statement at the top of certain evaluate methods is kludgy.
	//  Probably the logic for deciding the evaluation scope of a node should be at
	//  a higher level, and all nodes should have their scope of evaluation set that way.

	String* value = new String();

	Value expr_val = expr->Evaluate(scope, context);

	int pos;
	if(index < 0)
		pos = 0;
	else
		pos = size * index;

	try
	{
		// We've specified that any out-of-range access should be filled in
		// with zeroes, so we do a bit of bounds checking here
		String s = expr_val.ToCodeString();

		int over = std::max(0, pos + size - (signed)s.GetSize());
		int valid_size = std::max(0, size - over);

		if(valid_size > 0) {
			// We really ought to make a "substring constructor" --
			// we do this fairly often and it involves an unfortunate
			// amount of copying.
			*value = s.Substring(pos, valid_size);
		}
		for(int i = 0; i < size - valid_size; ++i)
			value->Byte(0);
	}
	catch(Exception& e)
	{
		Error(e.GetMessage());
	}

	return Value(value);
}
开发者ID:jeffman,项目名称:ccscript_legacy,代码行数:45,代码来源:ast.cpp


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