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


C++ PTree类代码示例

本文整理汇总了C++中PTree的典型用法代码示例。如果您正苦于以下问题:C++ PTree类的具体用法?C++ PTree怎么用?C++ PTree使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: SaveObjectFile

  //
  // SaveObjectFile
  //
  // Save all objects, false if unable to create file
  //
  Bool SaveObjectFile(const char *name)
  {
    PTree pTree;
    FilePath path;

    // Get the global scope of the parse tree
    FScope *gScope = pTree.GetGlobalScope();

    // Save every game object
    for (NList<GameObj>::Iterator i(&GameObjCtrl::listAll); *i; i++)
    {
      SaveCreateObject(gScope, *i);
    }

    // Work out save path
    Dir::PathMake(path, Missions::GetWritePath(), name);
  
    // Write the file
    if (!CoreGame::WriteTree(pTree, path.str))
    {
      LOG_WARN(("Unable to write to file [%s]", path.str));
      return (FALSE);
    }

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

示例2: main

int
main( int argc, char *argv[] )
{
    istream *br;
    ifstream infile;
    
    if( argc == 1 )
        br = &cin;
    else if( argc == 2 ) {
        infile.open(argv[1]);
        if( infile.is_open() )
            br = &infile;
        else {
            usage(argv[0], "Cannot open " + string(argv[1]));
            return 1;
        }
    }
    else {
        usage(argv[0], "More than one file name was given");
        return 1;
    }
    
    PTree *program;
    program = Program(br);
    //evaluate the program
    program->eval();
    
    
    
}
开发者ID:RVSchool,项目名称:School-Projects,代码行数:30,代码来源:main.cpp

示例3: main

int
main( int argc, char *argv[] )
{
    istream *br;
    ifstream infile;
    
    if( argc == 1 )
        br = &cin;
    else if( argc == 2 ) {
        infile.open(argv[1]);
        if( infile.is_open() )
            br = &infile;
        else {
            usage(argv[0], "Cannot open " + string(argv[1]));
            return 1;
        }
    }
    else {
        usage(argv[0], "More than one file name was given");
        return 1;
    }

    PTree *program;

    program = Program(br);

    if( !program || errcnt )
    	return 0;
    
    cout << "Node Count Is: " << program->nodeCount() << endl;
    program->findEmptyStrings();
    program->findInvalidOps();
    
    return 0;
}
开发者ID:taylork2,项目名称:CS280,代码行数:35,代码来源:main.cpp

示例4: name

Game::HeroInfo::HeroInfo(const PTree& root) :
    name(root.get<std::string>("name")),
    user_id(root.get("userId", "")),
    elo(root.get("elo", -1)),
    crashed(root.get("crashed",false))
{
}
开发者ID:EinsamHauer,项目名称:vindinium-cpp-sdk,代码行数:7,代码来源:game.cpp

示例5: background_tiles

Game::Game(const PTree& root) :
    background_tiles(get_background_tiles(root.get_child("game.board"))),
    hashed_background_tiles(make_hashed_pair(background_tiles)),
    turn_max(root.get<int>("game.maxTurns")),
    turn(root.get<int>("game.turn")),
    state(root, hashed_background_tiles)
{
    assert( state == state );
    assert( hash_value(state) == hash_value(state) );

    int kk = 0;
    const PTree& child_heroes = root.get_child("game.heroes");
    for (PTree::const_iterator ti=child_heroes.begin(), tie=child_heroes.end(); ti!=tie; ti++)
    {
#if !defined(NDEBUG)
        const int id = ti->second.get<int>("id");
        assert( kk+1 == id );
#endif

        const_cast<HeroInfo&>(hero_infos[kk]) = HeroInfo(ti->second);

        assert( kk < 4 );
        kk++;
    }

}
开发者ID:EinsamHauer,项目名称:vindinium-cpp-sdk,代码行数:26,代码来源:game.cpp

示例6: read_xml

vector<SurfaceSample> SurfaceSample::loadFromXML(const std::string& filename) {
    vector<SurfaceSample> samples;

    try {
        PTree tree;
        read_xml(filename, tree);

        PTree root = tree.get_child("SurfaceSamples");

        for (CI p = root.begin(); p != root.end(); ++p) {
            if (p->first == "Sample") {
                Q posq = XMLHelpers::readQ(p->second.get_child("Pos"));
                Q rpyq = XMLHelpers::readQ(p->second.get_child("RPY"));
                double graspW = XMLHelpers::readDouble(p->second.get_child("GraspW"));
                //cout << "pos=" << posq << " rot=" << rpyq << " graspW=" << graspW << endl;

                Vector3D<> pos(posq[0], posq[1], posq[2]);
                RPY<> rpy(rpyq[0], rpyq[1], rpyq[2]);
                samples.push_back(SurfaceSample(Transform3D<>(pos, rpy.toRotation3D()), graspW));
            }
        }
    } catch (const ptree_error& e) {
        RW_THROW(e.what());
    }

    return samples;
}
开发者ID:dagothar,项目名称:gripperz,代码行数:27,代码来源:SurfaceSample.cpp

示例7: read

	void read(PTree & node)
	{
		std::string line, name;
		while (in.good())
		{
			std::getline(in, line, '\n');
			if (line.empty())
			{
				continue;
			}

			size_t begin = line.find_first_not_of(" \t[");
			size_t end = line.find_first_of(";#]\r", begin);
			if (begin >= end)
			{
				continue;
			}

			size_t next = line.find("=", begin);
			if (next >= end)
			{
				// New node.
				next = line.find_last_not_of(" \t\r]", end);
				name = line.substr(begin, next);
				read(root.set(name, PTree()));
				continue;
			}

			size_t next2 = line.find_first_not_of(" \t\r", next+1);
			next = line.find_last_not_of(" \t", next-1);
			if (next2 >= end)
				continue;

			name = line.substr(begin, next+1);
			if (!fopen || line.at(next2) != '&')
			{
				// New property.
				std::string value = line.substr(next2, end-next2);
				node.set(name, value);
				continue;
			}

			// Value is a reference.
			std::string value = line.substr(next2+1, end-next2-1);
			const PTree * ref_ptr;
			if (root.get(value, ref_ptr) || cache.get(value, ref_ptr))
			{
				node.set(name, *ref_ptr);
				continue;
			}

			// Load external reference.
			PTree ref;
			read_ini(value, *fopen, ref);
			cache.set(value, ref);
			node.set(name, ref);
		}
	}
开发者ID:abhishekshishodia,项目名称:vdrift,代码行数:58,代码来源:ini.cpp

示例8: read_xml

static void read_xml(std::istream & in, PTree & node, Include * include, std::string key)
{
	std::string line, escape("/"+node.value());
	while (in.good())
	{
		std::getline(in, line, '\n');
		if (line.empty())
		{
			continue;
		}

		size_t begin = line.find_first_not_of(" \t\n<");
		size_t end = line.length();
		if (begin >= end || line[begin] == '!')
		{
			continue;
		}

		line = line.substr(begin, end);

		if (line.find(escape) == 0)
		{
			break;
		}

		if (key.length() == 0)
		{
			end = line.find(" ");
			key = line.substr(0, end);
			continue;
		}

		size_t next = line.find("</"+key);
		if (next < end)
		{
			// New property.
			std::string value = line.substr(0, next);

			// Include?
			if (include && key == "include")
			{
				(*include)(node, value);
			}
			else
			{
				node.set(key, value);
			}
		}
		else
		{
			// New node.
			end = line.find(" ");
			std::string child_key = line.substr(0, end);
			read_xml(in, node.set(key, PTree()), include, child_key);
		}
		key.clear();
	}
}
开发者ID:logzero,项目名称:vdrift,代码行数:58,代码来源:xml.cpp

示例9: LoadObjectFile

  //
  // LoadObjectFile
  //
  // Load a object definition file into current state, false if not found
  //
  Bool LoadObjectFile(const char *name)
  {
    ASSERT(name);

    PTree pTree;
    Bool safe = Missions::GetSafeLoad();

    // Parse the file
    GameGod::Loader::SubSystem("#game.loader.createobjects", 1);

    if (pTree.AddFile(name))
    {
      // Get the global scope
      FScope *gScope = pTree.GetGlobalScope();
      FScope *sScope;

      // Process each function
      GameGod::Loader::SubSystem("#game.loader.createobjects", gScope->GetBodyCount());

      while ((sScope = gScope->NextFunction()) != NULL)
      {
        switch (sScope->NameCrc())
        {
          case 0xCAE286FA: // "CreateObject"
            LoadCreateObject(sScope, safe);
            GameGod::Loader::Advance();
            break;
        }
      }

      if (GameGod::CheckObjects())
      {
        FSCOPE_CHECK(gScope)
      }

      // Call each existing game object
      GameGod::Loader::SubSystem("#game.loader.configureobjects", GameObjCtrl::listAll.GetCount());

      for (NList<GameObj>::Iterator i(&GameObjCtrl::listAll); *i; i++)
      {
        // Are we in safe-mode and this is a map object
        if (safe && Promote::Object<MapObjType, MapObj>(*i))
        {
        }
        else
        {
          // Call virtual post-load function
          (*i)->PostLoad();
        }

        GameGod::Loader::Advance();
      }

      return (TRUE);
    }
开发者ID:ZhouWeikuan,项目名称:darkreign2,代码行数:60,代码来源:worldload.cpp

示例10: Export

  //
  // Export
  //
  // Export this footprint to the given file name
  //
  Bool Type::Export(const char *fileName)
  {
    PTree tree;
    FScope *root, *cellInfo;
  
    // Add the top level scope
    root = tree.GetGlobalScope()->AddFunction("ConfigureFootPrint");

    // Get the layer used for zipping
    Layer &layer = GetLayer(LAYER_LOWER);

    // Save out the grid
    for (S32 z = 0; z <= size.z; z++)
    {
      for (S32 x = 0; x <= size.x; x++)
      {
        // Write out cell info
        cellInfo = root->AddFunction("SetupCell");
        cellInfo->AddArgInteger(x);
        cellInfo->AddArgInteger(z);

        // Is this cell on the footprint
        if (x < size.x && z < size.z)
        {
          Cell &cell = GetCell(x, z);
          StdSave::TypeU32(cellInfo, "Hide", cell.GetFlag(HIDE));
          StdSave::TypeU32(cellInfo, "SetBase", cell.GetFlag(SETBASE));
          StdSave::TypeU32(cellInfo, "Second", cell.GetFlag(SECOND));
          StdSave::TypeU32(cellInfo, "Dirs", cell.dirs);
          StdSave::TypeU32(cellInfo, "ClaimLo", cell.GetFlag(CLAIMLO));
          StdSave::TypeU32(cellInfo, "ClaimHi", cell.GetFlag(CLAIMHI));
          StdSave::TypeU32(cellInfo, "BlockLOS", cell.GetFlag(BLOCKLOS));

          if (cell.GetFlag(SURFACE))
          {
            MoveTable::KeyInfo *info = MoveTable::FindSurfaceInfo(cell.surface);

            if (info)
            {
              StdSave::TypeString(cellInfo, "Surface", info->ident.str);
            }
          }
        }

        Layer::Cell &cell = layer.GetCell(x, z);
        StdSave::TypeU32(cellInfo, "Zip", cell.GetFlag(Layer::ZIP));
      }
    }
  
    // Save out to disk
    return (tree.WriteTreeText(fileName));
  }
开发者ID:ZhouWeikuan,项目名称:darkreign2,代码行数:57,代码来源:footprint_type.cpp

示例11: read_inf

static void read_inf(std::istream & in, PTree & node, Include * include, bool child)
{
	std::string line, name;
	while (in.good())
	{
		std::getline(in, line, '\n');
		if (line.empty())
		{
			continue;
		}

		size_t begin = line.find_first_not_of(" \t");
		size_t end = line.find_first_of(";#");
		if (begin >= end)
		{
			continue;
		}

		line = line.substr(begin, end);
		if (line[0] == '{' && name.length())
		{
			// New node.
			read_inf(in, node.set(name, PTree()), include, true);
			continue;
		}

		if (line[0] == '}' && child)
		{
			break;
		}

		size_t next = line.find(" ");
		end = line.length();
		name = line.substr(0, next);
		if (next < end)
		{
			// New property.
			std::string value = line.substr(next+1, end);

			// Include?
			if (include && name == "include")
			{
				(*include)(node, value);
			}
			else
			{
				node.set(name, value);
			}
			name.clear();
		}
	}
}
开发者ID:Alexander-Eck,项目名称:vdrift,代码行数:52,代码来源:ptree_inf.cpp

示例12: LoadConfig

  //
  // LoadConfig
  //
  // Load the configured difficulty settings
  //
  static void LoadConfig()
  {
    PTree pTree;
    GameIdent defaultName;

    // Clear any current settings
    ClearSettings();

    // Open the configuration file
    if (pTree.AddFile(configName))
    {
      FScope *gScope = pTree.GetGlobalScope();
      FScope *sScope;

      // Parse each function
      while ((sScope = gScope->NextFunction()) != NULL)
      {
        switch (sScope->NameCrc())
        {
          case 0x12AFF0D8: // "CreateSetting"
            ProcessCreateSetting(sScope);
            break;

          case 0x733C1EB5: // "DefaultSetting"
            defaultName = StdLoad::TypeString(sScope);
            break;
        }
      }

      // Ensure at least one setting is configured
      if (settings.GetCount())
      {
        // Setup the default setting
        if ((defaultSetting = FindSetting(defaultName)) == NULL)
        {
          defaultSetting = settings.GetHead();
        }

        // Set the current from the default
        currentSetting = defaultSetting;
      }
      else
      {
        ERR_CONFIG(("At least one difficulty setting must be supplied in [%s]", configName));
      }
    }
    else
    {
      ERR_CONFIG(("Unable to load difficulty settings configuration [%s]", configName));
    }
  }
开发者ID:ZhouWeikuan,项目名称:darkreign2,代码行数:56,代码来源:difficulty.cpp

示例13: LoadCoilover

static bool LoadCoilover(
	const PTree & cfg,
	CarSuspensionInfo & info,
	std::ostream & error_output)
{
	if (!cfg.get("spring-constant", info.spring_constant, error_output)) return false;
	if (!cfg.get("bounce", info.bounce, error_output)) return false;
	if (!cfg.get("rebound", info.rebound, error_output)) return false;
	if (!cfg.get("travel", info.travel, error_output)) return false;
	if (!cfg.get("anti-roll", info.anti_roll, error_output)) return false;
	LoadPoints(cfg, "damper-factor-", info.damper_factors);
	LoadPoints(cfg, "spring-factor-", info.spring_factors);
	return true;
}
开发者ID:HaohaoLau,项目名称:vdrift,代码行数:14,代码来源:carsuspension.cpp

示例14: operator

bool LoadDrawable::operator()(
	const PTree & cfg,
	SCENENODE & topnode,
	keyed_container<SCENENODE>::handle * nodehandle,
	keyed_container<DRAWABLE>::handle * drawhandle)
{
	std::vector<std::string> texname;
	if (!cfg.get("texture", texname)) return true;

	std::string meshname;
	if (!cfg.get("mesh", meshname, error)) return false;

	return operator()(meshname, texname, cfg, topnode, nodehandle, drawhandle);
}
开发者ID:haltakov,项目名称:synthetic-dataset,代码行数:14,代码来源:loaddrawable.cpp

示例15: LoadPhysics

bool CAR::LoadPhysics(
	const PTree & cfg,
	const std::string & carpath,
	const MATHVECTOR <float, 3> & initial_position,
	const QUATERNION <float> & initial_orientation,
	const bool defaultabs,
	const bool defaulttcs,
	const bool damage,
	ContentManager & content,
	DynamicsWorld & world,
	std::ostream & error_output)
{
	std::string carmodel;
	std::tr1::shared_ptr<MODEL> modelptr;
	if (!cfg.get("body.mesh", carmodel, error_output)) return false;
	if (!content.load(carpath, carmodel, modelptr)) return false;

	btVector3 size = ToBulletVector(modelptr->GetSize());
	btVector3 center = ToBulletVector(modelptr->GetCenter());
	btVector3 position = ToBulletVector(initial_position);
	btQuaternion rotation = ToBulletQuaternion(initial_orientation);

	if (!dynamics.Load(cfg, size, center, position, rotation, damage, world, error_output)) return false;
	dynamics.SetABS(defaultabs);
	dynamics.SetTCS(defaulttcs);

	mz_nominalmax = (GetTireMaxMz(FRONT_LEFT) + GetTireMaxMz(FRONT_RIGHT)) * 0.5;

	return true;
}
开发者ID:newleon,项目名称:vdrift,代码行数:30,代码来源:car.cpp


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