本文整理汇总了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);
}
示例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);
}