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


C++ VNode::GetString方法代码示例

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


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

示例1: ParseAssignment


//.........这里部分代码省略.........
      // 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;

      // Changing a floating point item
      case VarSys::VI_FPOINT:
        switch (node->aType)
        {
          case VNode::AT_INTEGER:
            item->SetFloat((F32)node->GetInteger());
            break;
          case VNode::AT_FPOINT:
            item->SetFloat(node->GetFPoint());
            break;
          default:
            delete node;
            tBuf.TokenError("Expected %s value", VarSys::GetTypeString(item->type));
        }
        break;

      // Changing a string item
      case VarSys::VI_STRING:
        switch (node->aType)
        {
          case VNode::AT_STRING:
            item->SetStr(node->GetString());
            break;
          default:
            delete node;
            tBuf.TokenError("Expected %s value", VarSys::GetTypeString(item->type));
        }
        break;

      // Unable to change this type of item
      default :
        delete node;
        tBuf.TokenError("Unable to modify items of this type");  
    }

    // Delete the temporary VNode
    delete node;

    // Success
    return (TRUE);
  }
开发者ID:grasmanek94,项目名称:darkreign2,代码行数:101,代码来源:console.cpp

示例2: ParseArguments

  //
  // ParseArguments
  //
  // Creates var items from command line arguments
  //
  void CmdParse::ParseArguments(void *context, Bool rawVar, Bool rawData)
  {
    U32 argCount = 0;
    VarPathIdent argPath;
    VarPathIdent argOffsetPath;
    VNode *node;

    // Reset argument count
    argCount = 0;

    // Delete the current scope if it exists (may exit this function via exception)
    DeleteArguments();

    // Store command name in first argument
    MakeArgName(CmdParse::StackLevel(), argPath, argCount);
    VarSys::CreateString(argPath.str, tBuf.lastToken, VarSys::DEFAULT);

    MakeArgOffset(CmdParse::StackLevel(), argOffsetPath, argCount++);
    VarSys::CreateInteger(argOffsetPath.str, 0);

    if (rawData)
    {
      // Store rest of command line in second argument
      MakeArgName(CmdParse::StackLevel(), argPath, argCount);
      VarSys::CreateString(argPath.str, tBuf.CurrentStr());

      MakeArgOffset(CmdParse::StackLevel(), argOffsetPath, argCount++);
      VarSys::CreateInteger(argOffsetPath.str, argCount);

      // Finished parsing
      while (tBuf.NextToken() != TR_EOF) {}
    }
    else
    {
      Bool done = FALSE;

      // Parse all arguments
      while (!done)
      { 
        // Save the position of this argument
        U32 argPos = tBuf.CurrentPos();

        // Generate argument name
        MakeArgName(CmdParse::StackLevel(), argPath, argCount);

        // Generate argument index name
        MakeArgOffset(CmdParse::StackLevel(), argOffsetPath, argCount);

        // Parse the VNode data
        if ((node = StdParse::ParseAtomicVNode(&tBuf)) != NULL)
        {
          // Create the offset var
          VarSys::CreateInteger(argOffsetPath.str, argPos);

          switch (node->aType)
          {
            case VNode::AT_INTEGER:
              VarSys::CreateInteger(argPath.str, node->GetInteger());
              break;

            case VNode::AT_FPOINT:
              VarSys::CreateFloat(argPath.str, node->GetFPoint());
              break;

            case VNode::AT_STRING:
              VarSys::CreateString(argPath.str, node->GetString());
              break;

            default:
              ERR_FATAL(("Invalid node type!"));
          }

          // Successfully made an arg
          argCount++;

          // Delete the temporary VNode
          delete node;   
        }
        else
        {
          // Examine what we've got
          switch (tBuf.PeekToken())
          { 
            case TR_OK :
            {
              VarSys::VarItem *varItem;

              // Create the offset var
              VarSys::CreateInteger(argOffsetPath.str, argPos);

              // Accept the identifier
              tBuf.AcceptIdent();

              // Are we in raw var mode or is this argument a var item
              if (!rawVar && (varItem = VarSys::FindVarItem(tBuf.lastToken, context)) != NULL)
//.........这里部分代码省略.........
开发者ID:grasmanek94,项目名称:darkreign2,代码行数:101,代码来源:console.cpp

示例3: Setup

//
// ICTicker::Setup
//
// setup this control using a 'DefineControl' function
//
void ICTicker::Setup(FScope *fScope)
{
  switch (fScope->NameCrc())
  {
    case 0x2B96BEE1: // "Speed"
      speed = StdLoad::TypeU32(fScope);
      break;

    case 0xC9FCFE2A: // "Clear"
      Clear();
      break;

    case 0x6FEF8A3E: // "AddText"
    {
      const CH *text = TRANSLATE((StdLoad::TypeString(fScope)));

      // Get the optional argument 
      // (why is this MUCH more complicated than its needs to be?)
      VNode *vNode = fScope->NextArgument(VNode::AT_STRING, FALSE);
      const char *dir = "Up";
      if (vNode)
      {
        dir = vNode->GetString();
      }
      
      switch (Crc::CalcStr(dir))
      {
        case 0xBA190163: // "Left"
          AddText(text, DIR_LEFT);
          break;

        case 0xE2DDD72B: // "Right"
          AddText(text, DIR_RIGHT);
          break;

        case 0xF975A769: // "Up"
          AddText(text, DIR_UP);
          break;

        case 0xEF54F336: // "Down"
          AddText(text, DIR_DOWN);
          break;

        case 0x59D598FC: // "Alpha"
          AddText(text, DIR_ALPHA);
          break;

        default:
          fScope->ScopeError("Unkown Direction '%s'", dir);
          break;
      }
      break;
    }

    default:
    {
      IControl::Setup(fScope);
      break;
    }
  }
}
开发者ID:ZhouWeikuan,项目名称:darkreign2,代码行数:66,代码来源:icticker.cpp


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