本文整理汇总了C++中VNode::SetupString方法的典型用法代码示例。如果您正苦于以下问题:C++ VNode::SetupString方法的具体用法?C++ VNode::SetupString怎么用?C++ VNode::SetupString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VNode
的用法示例。
在下文中一共展示了VNode::SetupString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ParseStringVNode
//
// StdParse::ParseStringVNode
//
// Parses a string VNode, NULL if error
//
VNode* StdParse::ParseStringVNode(TBuf *tBuf)
{
// Allow empty strings
Bool empty = FALSE;
// Store string delimiter
char delim[2];
// Accept the start of the string literal
tBuf->NextToken();
// Insert string delimiter
delim[0] = *tBuf->lastToken;
// Insert null terminator
delim[1] = '\0';
// Start reading the string constant
tBuf->ReadConstant(*delim);
// Read in string
switch (tBuf->NextToken())
{
// Copy string, then accept closing symbol
case TR_OK:
tBuf->Accept(delim);
break;
// Must have been an empty string
case TR_PUN:
tBuf->Expect(delim);
empty = TRUE;
break;
// This should be caught in tBuf
case TR_EOF:
ERR_FATAL(("Unexpected return code"));
default:
ERR_FATAL(("Missing case"));
}
// Create the new VNode
VNode *newNode = new VNode;
newNode->SetupString(empty ? "" : tBuf->prevToken);
return (newNode);
}
示例2: ParseAssignment
//
// ParseAssignment
//
// Parse an item value assignment
//
Bool CmdParse::ParseAssignment(void *context, VarSys::VarItem *item)
{
ASSERT(item);
// Peek at the next token
switch (tBuf.PeekToken())
{
case TR_OK:
break;
case TR_PUN:
{
switch (*tBuf.peekToken)
{
case '=':
tBuf.AcceptPunct();
break;
case ';':
return (FALSE);
break;
}
break;
}
case TR_EOF:
return (FALSE);
break;
default:
ERR_FATAL(("Missing case"));
}
// Allow editing in a development build
#ifdef DEVELOPMENT
// But give a warning
if (item->flags & VarSys::NOEDIT)
{
CON_ERR(("Warning! Can not be modified in a release build"))
}
#else
// Check that this item can be edited from the console
if (item->flags & VarSys::NOEDIT)
{
tBuf.TokenError("This item can not be modified");
}
#endif
VNode *node;
// See if we are assigning one var to another
if (ParseVarAssignment(context, item))
{
return (TRUE);
}
// Parse the VNode data
if ((node = StdParse::ParseAtomicVNode(&tBuf)) == NULL)
{
// Convert a single identifier to a string value
if (tBuf.PeekToken() == TR_OK)
{
tBuf.AcceptIdent();
node = new VNode;
node->SetupString(tBuf.lastToken);
}
else
{
tBuf.TokenError("Invalid value");
}
}
// Assign the new value
switch (item->type)
{
// Changing an integer item
case VarSys::VI_INTEGER:
switch (node->aType)
{
case VNode::AT_INTEGER:
item->SetInteger(node->GetInteger());
break;
case VNode::AT_FPOINT:
item->SetInteger((S32)node->GetFPoint());
break;
default:
delete node;
tBuf.TokenError("Expected %s value", VarSys::GetTypeString(item->type));
}
break;
//.........这里部分代码省略.........