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


C++ csRef::GetNode方法代码示例

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


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

示例1: CopyXMLNode

void CopyXMLNode(csRef<iDocumentNode> source, csRef<iDocumentNode> target, int mode)
{
    if (mode == 0)
    {
        target->RemoveNodes();
        target->RemoveAttributes();
    }
    
    // copy nodes
    csRef<iDocumentNodeIterator> nodeIter = source->GetNodes();
    while (nodeIter->HasNext())
    {
        csRef<iDocumentNode> child = nodeIter->Next();
        csRef<iDocumentNode> targetChild = target->GetNode(child->GetValue());
        if (targetChild==NULL || mode==3)  // Mode 3 means don't merge tags but just insert multiples, so we create a new one here every time
        {
            targetChild = target->CreateNodeBefore(child->GetType());
            if (targetChild == NULL)
                assert(!"failed to create XML node, you are probably using wrong XML parser (xmlread instead of xmltiny)");
            targetChild->SetValue(child->GetValue());
        }
        CopyXMLNode(child, targetChild, mode);
    }
    
    // copy attributes
    csRef <iDocumentAttributeIterator> attrIter = source->GetAttributes();
    while (attrIter->HasNext())
    {
        csRef<iDocumentAttribute> attr = attrIter->Next();
        const char* attrName = attr->GetName();
        if (mode==1  ||  !target->GetAttribute(attrName))
            target->SetAttribute(attrName, attr->GetValue());
    }
}
开发者ID:Chettie,项目名称:Eulora-client,代码行数:34,代码来源:psxmlparser.cpp

示例2: ParseMeshObj

void OptimiseData::ParseMeshObj(csArray<csString>& libsNeeded, csArray<csString>& materialsNeeded,
                                csString& mapInPath, csRef<iDocumentNode> meshobj)
{
  csRef<iDocumentNodeIterator> meshobjs = meshobj->GetNodes("meshobj");
  while(meshobjs->HasNext())
  {
    ParseMeshObj(libsNeeded, materialsNeeded, mapInPath, meshobjs->Next());
  }

  if(meshobj->GetNode("params"))
  {
    meshobj = meshobj->GetNode("params");
    if(meshobj->GetNode("factory"))
    {
      bool found = false;
      for(size_t i=0; i<meshFactsOut.GetSize(); i++)
      {
        if(csString(meshFactsOut[i]->GetRoot()->GetNode("library")->GetNode("meshfact")->GetAttributeValue("name")).Compare(meshobj->GetNode("factory")->GetContentsValue()))
        {
          libsNeeded.PushSmart(meshobj->GetNode("factory")->GetContentsValue());
          found = true;
        }
      }

      if(!found)
      {
        // Print error and mark data as incorrect.
        csFPrintf(stderr, "ERROR: Mesh object %s uses mesh factory %s but there is no factory data!\n",
          meshobj->GetAttributeValue("name"), meshobj->GetNode("factory")->GetContentsValue());
      }
    }
    if(meshobj->GetNode("material"))
    {
      bool found = false;
      for(size_t i=0; i<materials.GetSize(); i++)
      {
        if(csString(materials[i]->GetAttributeValue("name")).Compare(meshobj->GetNode("material")->GetContentsValue()))
        {
          materialsNeeded.PushSmart(meshobj->GetNode("material")->GetContentsValue());
          found = true;
        }
      }

      if(!found)
      {
        // Print error and mark data as incorrect.
        csFPrintf(stderr, "ERROR: Mesh object %s uses material %s but there is no such material declaration!\n",
          meshobj->GetAttributeValue("name"), meshobj->GetNode("material")->GetContentsValue());
      }
    }
  }
  else if(meshobj->GetNode("paramsfile"))
  {
    csString paramsPath = mapInPath + "/" + meshobj->GetNode("paramsfile")->GetContentsValue();
    csRef<iFile> file = vfs->Open(paramsPath, VFS_FILE_READ);
    csRef<iDocument> paramsDoc = docSys->CreateDocument();
    paramsDoc->Parse(file);
    meshobj = paramsDoc->GetRoot()->GetNode("params");
    if(meshobj->GetNode("factory"))
    {
      bool found = false;
      for(size_t i=0; i<meshFactsOut.GetSize(); i++)
      {
        if(csString(meshFactsOut[i]->GetRoot()->GetNode("library")->GetNode("meshfact")->GetAttributeValue("name")).Compare(meshobj->GetNode("factory")->GetContentsValue()))
        {
          libsNeeded.PushSmart(meshobj->GetNode("factory")->GetContentsValue());
          found = true;
        }
      }

      if(!found)
      {
        // Print error and mark data as incorrect.
        csFPrintf(stderr, "ERROR: Mesh object %s uses mesh factory %s but there is no factory data!\n",
          meshobj->GetParent()->GetAttributeValue("name"), meshobj->GetNode("factory")->GetContentsValue());
      }
    }
    if(meshobj->GetNode("material"))
    {
      bool found = false;
      for(size_t i=0; i<materials.GetSize(); i++)
      {
        if(csString(materials[i]->GetAttributeValue("name")).Compare(meshobj->GetNode("material")->GetContentsValue()))
        {
          materialsNeeded.PushSmart(meshobj->GetNode("material")->GetContentsValue());
          found = true;
        }
      }

      if(!found)
      {
        // Print error and mark data as incorrect.
        csFPrintf(stderr, "ERROR: Mesh object %s uses material %s but there is no such material declaration!\n",
          meshobj->GetParent()->GetAttributeValue("name"), meshobj->GetNode("material")->GetContentsValue());
      }
    }
  }
}
开发者ID:GameLemur,项目名称:Crystal-Space,代码行数:98,代码来源:optimisedata.cpp

示例3: ParseMeshFact

void OptimiseData::ParseMeshFact(csRef<iDocumentNode>& meshFact, csRef<iDocumentNode>& tempDocRoot,
                                 csRefArray<iDocumentNode>& tempMats)
{
  csRef<iDocumentNode> params = meshFact->GetNode("params");
  if(params.IsValid())
  {
    bool first = true;
    csRef<iDocumentNodeIterator> submeshes = params->GetNodes("submesh");
    if(!submeshes->HasNext())
    {
      submeshes = params->GetNodes("curve");
    }

    while((first && params->GetNode("material")) || submeshes->HasNext())
    {
      csString materialName;
      if(first && params->GetNode("material"))
      {
        materialName = params->GetNode("material")->GetContentsValue();
        first = false;
      }
      else if(submeshes->HasNext())
      {
        csRef<iDocumentNode> submesh = submeshes->Next();
        if(submesh->GetNode("material"))
        {
          materialName = submesh->GetNode("material")->GetContentsValue();
        }
        else
        {
          continue;
        }
      }

      bool hasMaterialDecl = false;

      csRef<iDocumentNode> material;
      for(size_t j=0; j<materials.GetSize(); j++)
      {
        material = materials[j];
        if(materialName.Compare(material->GetAttributeValue("name")))
        {
          hasMaterialDecl = true;
          break;
        }
      }

      if(!hasMaterialDecl)
      {
        // Print error and mark data as incorrect.
        csFPrintf(stderr, "ERROR: Meshfact %s uses material %s but there is no material declaration!\n",
          meshFact->GetAttributeValue("name"), materialName.GetData());
      }

      tempMats.PushSmart(material);
    }
  }

  csRef<iDocumentNodeIterator> undermeshes = meshFact->GetNodes("meshfact");
  while(undermeshes->HasNext())
  {
    csRef<iDocumentNode> next = undermeshes->Next();
    ParseMeshFact(next, tempDocRoot, tempMats);
  }
}
开发者ID:GameLemur,项目名称:Crystal-Space,代码行数:65,代码来源:optimisedata.cpp


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