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


C++ ChunkList类代码示例

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


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

示例1: SILOG

void FileNameHandler::onReadFinished(std::tr1::shared_ptr<DenseData> fileContents,
        std::tr1::shared_ptr<MetadataRequest> request, NameCallback callback) {

    mStats.resolved++;

    std::tr1::shared_ptr<RemoteFileMetadata> bad;
    if (!fileContents) {
        SILOG(transfer, error, "FileNameHandler couldn't find file '" << request->getURI() << "'");
        callback(bad);
        return;
    }

    FileHeaders emptyHeaders;
    Fingerprint fp = SparseData(fileContents).computeFingerprint();

    //Just treat everything as a single chunk for now
    Range::length_type file_size = fileContents->length();
    Range whole(0, file_size, LENGTH, true);
    Chunk chunk(fp, whole);
    ChunkList chunkList;
    chunkList.push_back(chunk);

    SharedChunkCache::getSingleton().getCache()->addToCache(fp, fileContents);
    std::tr1::shared_ptr<RemoteFileMetadata> met(new RemoteFileMetadata(fp, request->getURI(),
                file_size, chunkList, emptyHeaders));
    callback(met);
}
开发者ID:AsherBond,项目名称:sirikata,代码行数:27,代码来源:FileTransferHandler.cpp

示例2: Update

void ChunkManager::Update() {
	ChunkList unloadList;

	m_chunkMapMutex.lock();
	std::map<ChunkCoordKey, Chunk*>::iterator it;
	for (it = m_chunkMap.begin(); it != m_chunkMap.end(); ++it) {
		Chunk* chunk = it->second;
		if (chunk->IsUnloading()) {
			unloadList.push_back(chunk);
		}
		else if (chunk->IsRebuildComplete()) {
			chunk->CompleteMesh();
		}
	}
	m_chunkMapMutex.unlock();
	
	int numUnloadChunks = 0;
	const static int MAX_NUM_CHUNKS_UNLOAD = 1;
	for (unsigned int i = 0; i < unloadList.size() && numUnloadChunks < MAX_NUM_CHUNKS_UNLOAD; ++i) {
		Chunk* chunk = unloadList[i];
		UnloadChunk(chunk);
	}
}
开发者ID:ggtucker,项目名称:SugoiEngine,代码行数:23,代码来源:ChunkManager.cpp

示例3: convert

void convert(const std::string& pInFileName, const std::string& pOutFileName) {
	ChunkList* root = ChunkReader::loadFile(pInFileName);
	
	for(ChunksResult res = root->get("scene"); res != root->end(); ++res) {
		if( res->first != "scene" ) break;
		const ChildList& scene = res->second->getChildList();
		const std::string title = asStringChild(scene.childAt(0))->value();
		cout << "Converting " << title << ": " << endl;

		TiXmlDocument doc;
		doc.LinkEndChild( new TiXmlDeclaration( "1.0", "", "" ) );
		TiXmlElement* level = new TiXmlElement("level");

		for(unsigned long childIndex=0; childIndex < scene.count(); ++childIndex) {
			const Child* baseChild = scene.childAt(childIndex);
			if( baseChild->getType() == CCT_CHILD ) {
				const Chunk* chunk = asChunkChild( baseChild )->getChild();
				// is chunk an "entity"
				if( chunk->getName().getName() == "objectelement" ) {
					const ChildList& entity = chunk->getChildList();
					// name
					const std::string name = asStringChild(entity.childAt(0))->value();
					// type
					const std::string type = asStringChild(entity.childAt(1))->value();
					
					TiXmlElement* object = new TiXmlElement("entity");
					object->SetAttribute("name", name);
					object->SetAttribute("type", type);

					TiXmlElement* position = new TiXmlElement("position");
					TiXmlElement* rotation = new TiXmlElement("rotation");

					{
						float x=0, y=0, z=0;
						if( entity.has("loc") ) {
							const CompoundChild* location = asCompoundChild(entity.at("loc")->getChildList().childAt(0));
							x = getRealValue(location->at(0));
							y = getRealValue(location->at(1));
							z = getRealValue(location->at(2));
						}
						position->SetAttribute("x", asString(x));
						position->SetAttribute("y", asString(y));
						position->SetAttribute("z", asString(z));
					}

					{
						float x=0, y=0, z=0, w=1;
						if( entity.has("orientation") ) {
							const CompoundChild* location = asCompoundChild(entity.at("orientation")->getChildList().childAt(0));
							x = getRealValue(location->at(0));
							y = getRealValue(location->at(1));
							z = getRealValue(location->at(2));
							w = getRealValue(location->at(3));
						}
						rotation->SetAttribute("x", asString(x));
						rotation->SetAttribute("y", asString(y));
						rotation->SetAttribute("z", asString(z));
						rotation->SetAttribute("w", asString(w));
					}

					object->LinkEndChild(position);
					object->LinkEndChild(rotation);
					level->LinkEndChild(object);
				}
			}
		}
		doc.LinkEndChild( level );
		const string saveFile = pOutFileName + title + ".lvl";
		cout << "Saving to " << saveFile << endl;
		doc.SaveFile( saveFile );
	}
}
开发者ID:madeso,项目名称:lolball,代码行数:72,代码来源:main.cpp

示例4: SILOG

void MeerkatNameHandler::request_finished(std::tr1::shared_ptr<HttpManager::HttpResponse> response,
        HttpManager::ERR_TYPE error, const boost::system::error_code& boost_error,
        std::tr1::shared_ptr<MetadataRequest> request, NameCallback callback) {

    std::tr1::shared_ptr<RemoteFileMetadata> bad;

    if (error == Transfer::HttpManager::REQUEST_PARSING_FAILED) {
        SILOG(transfer, error, "Request parsing failed during an HTTP name lookup (" << request->getURI() << ")");
        callback(bad);
        return;
    } else if (error == Transfer::HttpManager::RESPONSE_PARSING_FAILED) {
        SILOG(transfer, error, "Response parsing failed during an HTTP name lookup (" << request->getURI() << ")");
        callback(bad);
        return;
    } else if (error == Transfer::HttpManager::BOOST_ERROR) {
        SILOG(transfer, error, "A boost error happened during an HTTP name lookup (" << request->getURI() << "). Boost error = " << boost_error.message());
        callback(bad);
        return;
    } else if (error != HttpManager::SUCCESS) {
        SILOG(transfer, error, "An unknown error happened during an HTTP name lookup. (" << request->getURI() << ")");
        callback(bad);
        return;
    }

    if (response->getHeaders().size() == 0) {
        SILOG(transfer, error, "There were no headers returned during an HTTP name lookup (" << request->getURI() << ")");
        callback(bad);
        return;
    }

    HttpManager::Headers::const_iterator it;
    it = response->getHeaders().find("Content-Length");
    if (it != response->getHeaders().end()) {
        SILOG(transfer, error, "Content-Length header was present when it shouldn't be during an HTTP name lookup (" << request->getURI() << ")");
        callback(bad);
        return;
    }

    if (response->getStatusCode() != 200) {
        SILOG(transfer, error, "HTTP status code = " << response->getStatusCode() << " instead of 200 during an HTTP name lookup (" << request->getURI() << ")");
        callback(bad);
        return;
    }

    it = response->getHeaders().find("File-Size");
    if (it == response->getHeaders().end()) {
        SILOG(transfer, error, "Expected File-Size header not present during an HTTP name lookup (" << request->getURI() << ")");
        callback(bad);
        return;
    }
    std::string file_size_str = it->second;

    it = response->getHeaders().find("Hash");
    if (it == response->getHeaders().end()) {
        SILOG(transfer, error, "Expected Hash header not present during an HTTP name lookup (" << request->getURI() << ")");
        callback(bad);
        return;
    }
    std::string hash = it->second;

    if (response->getData()) {
        SILOG(transfer, error, "Body present during an HTTP name lookup (" << request->getURI() << ")");
        callback(bad);
        return;
    }

    Fingerprint fp;
    try {
        fp = Fingerprint::convertFromHex(hash);
    } catch(std::invalid_argument e) {
        SILOG(transfer, error, "Hash header didn't contain a valid Fingerprint string (" << request->getURI() << ")");
        callback(bad);
        return;
    }

    std::istringstream istream(file_size_str);
    uint64 file_size;
    istream >> file_size;
    std::ostringstream ostream;
    ostream << file_size;
    if(ostream.str() != file_size_str) {
        SILOG(transfer, error, "Error converting File-Size header string to integer (" << request->getURI() << ")");
        callback(bad);
        return;
    }

    //Just treat everything as a single chunk for now
    Range whole(0, file_size, LENGTH, true);
    Chunk chunk(fp, whole);
    ChunkList chunkList;
    chunkList.push_back(chunk);

    std::tr1::shared_ptr<RemoteFileMetadata> met(new RemoteFileMetadata(fp, request->getURI(),
            file_size, chunkList, response->getRawHeaders()));

    callback(met);
    SILOG(transfer, detailed, "done http name handler request_finished");
}
开发者ID:SinSiXX,项目名称:sirikata,代码行数:98,代码来源:MeerkatTransferHandler.cpp

示例5: switch

// Importing into the world chunks
void ChunkManager::ImportQubicleBinaryMatrix(QubicleMatrix* pMatrix, vec3 position, QubicleImportDirection direction)
{
	bool mirrorX = false;
	bool mirrorY = false;
	bool mirrorZ = false;
	bool flipXZ = false;
	bool flipXY = false;
	bool flipYZ = false;

	switch (direction)
	{
	case QubicleImportDirection_Normal: {  } break;
	case QubicleImportDirection_MirrorX: { mirrorX = true; } break;
	case QubicleImportDirection_MirrorY: { mirrorY = true; } break;
	case QubicleImportDirection_MirrorZ: { mirrorZ = true; } break;
	case QubicleImportDirection_RotateY90: { mirrorX = true; flipXZ = true; } break;
	case QubicleImportDirection_RotateY180: { mirrorX = true; mirrorZ = true; } break;
	case QubicleImportDirection_RotateY270: { mirrorZ = true; flipXZ = true; } break;
	case QubicleImportDirection_RotateX90: { mirrorZ = true; flipYZ = true; } break;
	case QubicleImportDirection_RotateX180: { mirrorZ = true; mirrorY = true; } break;
	case QubicleImportDirection_RotateX270: { mirrorY = true; flipYZ = true; } break;
	case QubicleImportDirection_RotateZ90: { mirrorY = true; flipXY = true; } break;
	case QubicleImportDirection_RotateZ180: { mirrorX = true; mirrorY = true; } break;
	case QubicleImportDirection_RotateZ270: { mirrorX = true; flipXY = true; } break;
	}

	ChunkList vChunkBatchUpdateList;

	float r = 1.0f;
	float g = 1.0f;
	float b = 1.0f;
	float a = 1.0f;

	unsigned int xValueToUse = pMatrix->m_matrixSizeX;
	unsigned int yValueToUse = pMatrix->m_matrixSizeY;
	unsigned int zValueToUse = pMatrix->m_matrixSizeZ;
	if (flipXZ)
	{
		xValueToUse = pMatrix->m_matrixSizeZ;
		zValueToUse = pMatrix->m_matrixSizeX;
	}
	if (flipXY)
	{
		xValueToUse = pMatrix->m_matrixSizeY;
		yValueToUse = pMatrix->m_matrixSizeX;
	}
	if (flipYZ)
	{
		yValueToUse = pMatrix->m_matrixSizeZ;
		zValueToUse = pMatrix->m_matrixSizeY;
	}

	int xPosition = 0;
	if (mirrorX)
		xPosition = xValueToUse - 1;

	for (unsigned int x = 0; x < xValueToUse; x++)
	{
		int yPosition = 0;
		if (mirrorY)
			yPosition = yValueToUse - 1;

		for (unsigned int y = 0; y < yValueToUse; y++)
		{
			int zPosition = 0;
			if (mirrorZ)
				zPosition = zValueToUse - 1;

			for (unsigned int z = 0; z < zValueToUse; z++)
			{
				int xPosition_modified = xPosition;
				int yPosition_modified = yPosition;
				int zPosition_modified = zPosition;
				if (flipXZ)
				{
					xPosition_modified = zPosition;
					zPosition_modified = xPosition;
				}
				if (flipXY)
				{
					xPosition_modified = yPosition;
					yPosition_modified = xPosition;
				}
				if (flipYZ)
				{
					yPosition_modified = zPosition;
					zPosition_modified = yPosition;
				}

				if (pMatrix->GetActive(xPosition_modified, yPosition_modified, zPosition_modified) == false)
				{
					// Do nothing
				}
				else
				{
					unsigned int colour = pMatrix->GetColourCompact(xPosition_modified, yPosition_modified, zPosition_modified);

					vec3 blockPos = position - vec3((xValueToUse + 0.05f)*0.5f, 0.0f, (zValueToUse + 0.05f)*0.5f) + vec3(x*Chunk::BLOCK_RENDER_SIZE*2.0f, y*Chunk::BLOCK_RENDER_SIZE*2.0f, z*Chunk::BLOCK_RENDER_SIZE*2.0f);

//.........这里部分代码省略.........
开发者ID:CodeMason,项目名称:Vox,代码行数:101,代码来源:ChunkManager.cpp

示例6: while

void ChunkManager::UpdatingChunksThread()
{
	while (m_updateThreadActive)
	{
		while (m_pPlayer == NULL)
		{
#ifdef _WIN32
			Sleep(100);
#else
			usleep(100000);
#endif
		}

		while (m_stepLockEnabled == true && m_updateStepLock == true)
		{
#ifdef _WIN32
			Sleep(100);
#else
			usleep(100000);
#endif
		}

		ChunkList updateChunkList;
		ChunkCoordKeysList addChunkList;
		ChunkList rebuildChunkList;
		ChunkList unloadChunkList;

		m_ChunkMapMutexLock.lock();
		typedef map<ChunkCoordKeys, Chunk*>::iterator it_type;
		for (it_type iterator = m_chunksMap.begin(); iterator != m_chunksMap.end(); iterator++)
		{
			Chunk* pChunk = iterator->second;

			updateChunkList.push_back(pChunk);
		}
		m_ChunkMapMutexLock.unlock();

		// Updating chunks
		int numAddedChunks = 0;
		int MAX_NUM_CHUNKS_ADD = 10;
		sort(updateChunkList.begin(), updateChunkList.end(), Chunk::ClosestToCamera);
		for (unsigned int i = 0; i < (int)updateChunkList.size(); i++)
		{
			Chunk* pChunk = updateChunkList[i];

			if (pChunk != NULL)
			{
				pChunk->Update(0.01f);

				int gridX = pChunk->GetGridX();
				int gridY = pChunk->GetGridY();
				int gridZ = pChunk->GetGridZ();

				float xPos = gridX * Chunk::CHUNK_SIZE * Chunk::BLOCK_RENDER_SIZE*2.0f;
				float yPos = gridY * Chunk::CHUNK_SIZE * Chunk::BLOCK_RENDER_SIZE*2.0f;
				float zPos = gridZ * Chunk::CHUNK_SIZE * Chunk::BLOCK_RENDER_SIZE*2.0f;

				vec3 chunkCenter = vec3(xPos, yPos, zPos) + vec3(Chunk::CHUNK_SIZE*Chunk::BLOCK_RENDER_SIZE, Chunk::CHUNK_SIZE*Chunk::BLOCK_RENDER_SIZE, Chunk::CHUNK_SIZE*Chunk::BLOCK_RENDER_SIZE);
				vec3 distanceVec = chunkCenter - m_pPlayer->GetCenter();
				float lengthValue = length(distanceVec);

				if (lengthValue > m_loaderRadius)
				{
					unloadChunkList.push_back(pChunk);
				}
				else
				{
					if (numAddedChunks < MAX_NUM_CHUNKS_ADD)
					{
						// Check neighbours
						if (pChunk->GetNumNeighbours() < 6 && (pChunk->IsEmpty() == false) || (gridY == 0))
						{
							if (pChunk->GetxMinus() == NULL)
							{
								ChunkCoordKeys coordKey;
								coordKey.x = gridX - 1;
								coordKey.y = gridY;
								coordKey.z = gridZ;
								float xPos = coordKey.x * Chunk::CHUNK_SIZE * Chunk::BLOCK_RENDER_SIZE*2.0f;
								float yPos = coordKey.y * Chunk::CHUNK_SIZE * Chunk::BLOCK_RENDER_SIZE*2.0f;
								float zPos = coordKey.z * Chunk::CHUNK_SIZE * Chunk::BLOCK_RENDER_SIZE*2.0f;

								vec3 chunkCenter = vec3(xPos, yPos, zPos) + vec3(Chunk::CHUNK_SIZE*Chunk::BLOCK_RENDER_SIZE, Chunk::CHUNK_SIZE*Chunk::BLOCK_RENDER_SIZE, Chunk::CHUNK_SIZE*Chunk::BLOCK_RENDER_SIZE);
								vec3 distanceVec = chunkCenter - m_pPlayer->GetCenter();
								float lengthValue = length(distanceVec);

								if (lengthValue <= m_loaderRadius)
								{
									addChunkList.push_back(coordKey);
									numAddedChunks++;
								}
							}
							if (pChunk->GetxPlus() == NULL)
							{
								ChunkCoordKeys coordKey;
								coordKey.x = gridX + 1;
								coordKey.y = gridY;
								coordKey.z = gridZ;
								float xPos = coordKey.x * Chunk::CHUNK_SIZE * Chunk::BLOCK_RENDER_SIZE*2.0f;
								float yPos = coordKey.y * Chunk::CHUNK_SIZE * Chunk::BLOCK_RENDER_SIZE*2.0f;
//.........这里部分代码省略.........
开发者ID:CodeMason,项目名称:Vox,代码行数:101,代码来源:ChunkManager.cpp

示例7: while

void ChunkManager::UpdateChunksThread() {
	while (m_updateThreadActive) {

		while (m_stepLockEnabled && m_updateStepLock) {
			std::this_thread::sleep_for(std::chrono::milliseconds(100));
		}

		ChunkList updateList;
		ChunkList rebuildList;
		ChunkCoordKeyList addKeyList;

		// STEP 1: PUT ALL CREATED CHUNKS IN `UPDATE LIST`

		m_chunkMapMutex.lock();
		std::map<ChunkCoordKey, Chunk*>::iterator it;
		for (it = m_chunkMap.begin(); it != m_chunkMap.end(); ++it) {
			Chunk* chunk = it->second;
			if (!chunk->IsUnloading()) {
				updateList.push_back(chunk);
			}
		}
		m_chunkMapMutex.unlock();

		// STEP 2: FIND CHUNKS TO ADD (OR UNLOAD IF THEY'RE TOO FAR)

		int numAddedChunks = 0;
		const int MAX_NUM_CHUNKS_ADD = 10;
		std::sort(updateList.begin(), updateList.end(), Chunk::ClosestToCamera);
		for (unsigned int i = 0; i < updateList.size(); ++i) {

			Chunk* chunk = updateList[i];

			if (chunk) {
				glm::vec3 chunkCenter = chunk->GetCenter();
				glm::vec3 cameraPos = m_renderer->GetCamera().GetPosition();
				float cameraDistance = glm::length(chunkCenter - cameraPos);

				if (cameraDistance > m_loadRadius) {
					chunk->SetUnloading();
				}
				else if (numAddedChunks < MAX_NUM_CHUNKS_ADD) {

					ChunkCoordKeyList missing = chunk->GetMissingNeighbors();

					if (!chunk->IsEmpty()) {

						for (ChunkCoordKey key : missing) {

							if (std::find(addKeyList.begin(), addKeyList.end(), key) == addKeyList.end()) {

								// Here we are calculating the distance of each
								// neighbor chunk to decide if we should add it
								glm::vec3 chunkCenter = Chunk::GetWorldCenter(key.x, key.y, key.z);
								float cameraDistance = glm::length(chunkCenter - cameraPos);

								if (cameraDistance <= m_loadRadius && key.y == 0) {
									addKeyList.push_back(key);
									++numAddedChunks;
								}
							}
						}
					}
				}
			}
		}
		updateList.clear();

		// STEP 3: ADD CHUNKS

		for (unsigned int i = 0; i < addKeyList.size(); ++i) {
			ChunkCoordKey key = addKeyList[i];
			CreateNewChunk(key.x, key.y, key.z);
		}
		addKeyList.clear();

		// STEP 4: CHECK FOR REBUILD CHUNKS

		m_chunkMapMutex.lock();
		for (it = m_chunkMap.begin(); it != m_chunkMap.end(); ++it) {
			Chunk* chunk = it->second;
			if (!chunk->IsUnloading() && chunk->NeedsRebuild()) {
				rebuildList.push_back(chunk);
			}
		}
		m_chunkMapMutex.unlock();

		// STEP 5: REBUILD CHUNKS

		int numRebuildChunks = 0;
		const int MAX_NUM_CHUNKS_REBUILD = 30;
		for (unsigned int i = 0; i < rebuildList.size() && numRebuildChunks < MAX_NUM_CHUNKS_REBUILD; ++i) {
			Chunk* chunk = rebuildList[i];
			chunk->RebuildMesh();
			++numRebuildChunks;
		}
		rebuildList.clear();

		if (m_stepLockEnabled && !m_updateStepLock) {
			m_updateStepLock = true;
		}
//.........这里部分代码省略.........
开发者ID:ggtucker,项目名称:SugoiEngine,代码行数:101,代码来源:ChunkManager.cpp

示例8: return

chunk_t *chunk_get_prev(chunk_t *cur, chunk_nav_t nav)
{
   if (cur == NULL)
   {
      return(NULL);
   }
   chunk_t *pc = g_cl.GetPrev(cur);
   if ((pc == NULL) || (nav == CNAV_ALL))
   {
      return(pc);
   }
   if (cur->flags & PCF_IN_PREPROC)
   {
      /* If in a preproc, return NULL if trying to leave */
      if ((pc->flags & PCF_IN_PREPROC) == 0)
      {
         return(NULL);
      }
      return(pc);
   }
   /* Not in a preproc, skip any proproc */
   while ((pc != NULL) && (pc->flags & PCF_IN_PREPROC))
   {
      pc = g_cl.GetPrev(pc);
   }
   return(pc);
}
开发者ID:bengardner,项目名称:uncrustify,代码行数:27,代码来源:chunk_list.cpp

示例9: GetData

void SavePackets::GetData(Demuxer& dmx, int len)
{
    io::pos chk_pos = dmx.ObjStrm().tellg();
    if( !chunks.empty() && (chk_pos <= chunks.back().extPos) )
        chunks.clear();
    chunks.push_back( Chunk(chk_pos, len) );

    MyParent::GetData(dmx, len);
}
开发者ID:cargabsj175,项目名称:bombono-dvd,代码行数:9,代码来源:cutmpeg.cpp

示例10: chunk_move_after

void chunk_move_after(chunk_t *pc_in, chunk_t *ref)
{
   g_cl.Pop(pc_in);
   g_cl.AddAfter(pc_in, ref);

   /* HACK: Adjust the original column */
   pc_in->column       = ref->column + space_col_align(ref, pc_in);
   pc_in->orig_col     = pc_in->column;
   pc_in->orig_col_end = pc_in->orig_col + pc_in->len();
}
开发者ID:CastIrony,项目名称:uncrustify,代码行数:10,代码来源:chunk_list.cpp

示例11: return

/**
 * Add a copy before the given chunk.
 * If ref is NULL, add at the head.
 */
chunk_t *chunk_add_before(const chunk_t *pc_in, chunk_t *ref)
{
   chunk_t *pc;

   if ((pc = chunk_dup(pc_in)) != NULL)
   {
      if (ref != NULL)
      {
         g_cl.AddBefore(pc, ref);
      }
      else
      {
         g_cl.AddTail(pc);
      }
   }
   return(pc);
}
开发者ID:CastIrony,项目名称:uncrustify,代码行数:21,代码来源:chunk_list.cpp

示例12: chunk_del

void chunk_del(chunk_t *pc)
{
   g_cl.Pop(pc);
   //if ((pc->flags & PCF_OWN_STR) && (pc->str != NULL))
   //{
   //   delete[] (char *)pc->str;
   //   pc->str = NULL;
   //}
   delete pc;
}
开发者ID:CastIrony,项目名称:uncrustify,代码行数:10,代码来源:chunk_list.cpp

示例13: exit

chunk_t *chunk_dup(const chunk_t *pc_in)
{
   chunk_t *pc;

   /* Allocate the entry */
   pc = new chunk_t;
   if (pc == NULL)
   {
      exit(1);
   }

   /* Copy all fields and then init the entry */
   *pc = *pc_in;
   g_cl.InitEntry(pc);

   return(pc);
}
开发者ID:bengardner,项目名称:uncrustify,代码行数:17,代码来源:chunk_list.cpp

示例14: chunk_swap

/**
 * Swaps the two chunks.
 *
 * @param pc1  The first chunk
 * @param pc2  The second chunk
 */
void chunk_swap(chunk_t *pc1, chunk_t *pc2)
{
   g_cl.Swap(pc1, pc2);
}
开发者ID:bengardner,项目名称:uncrustify,代码行数:10,代码来源:chunk_list.cpp

示例15: chunk_swap_lines

/**
 * Swaps two lines that are started with the specified chunks.
 *
 * @param pc1  The first chunk of line 1
 * @param pc2  The first chunk of line 2
 */
void chunk_swap_lines(chunk_t *pc1, chunk_t *pc2)
{
   chunk_t *ref2;
   chunk_t *tmp;

   pc1 = chunk_first_on_line(pc1);
   pc2 = chunk_first_on_line(pc2);

   if ((pc1 == NULL) || (pc2 == NULL) || (pc1 == pc2))
   {
      return;
   }

   /**
    * Example start:
    * ? - start1 - a1 - b1 - nl1 - ? - ref2 - start2 - a2 - b2 - nl2 - ?
    *      ^- pc1                              ^- pc2
    */
   ref2 = chunk_get_prev(pc2);

   /* Move the line started at pc2 before pc1 */
   while ((pc2 != NULL) && !chunk_is_newline(pc2))
   {
      tmp = chunk_get_next(pc2);
      g_cl.Pop(pc2);
      g_cl.AddBefore(pc2, pc1);
      pc2 = tmp;
   }

   /**
    * Should now be:
    * ? - start2 - a2 - b2 - start1 - a1 - b1 - nl1 - ? - ref2 - nl2 - ?
    *                         ^- pc1                              ^- pc2
    */

   /* Now move the line started at pc1 after ref2 */
   while ((pc1 != NULL) && !chunk_is_newline(pc1))
   {
      tmp = chunk_get_next(pc1);
      g_cl.Pop(pc1);
      if (ref2 != NULL)
      {
         g_cl.AddAfter(pc1, ref2);
      }
      else
      {
         g_cl.AddHead(pc1);
      }
      ref2 = pc1;
      pc1  = tmp;
   }

   /**
    * Should now be:
    * ? - start2 - a2 - b2 - nl1 - ? - ref2 - start1 - a1 - b1 - nl2 - ?
    *                         ^- pc1                              ^- pc2
    */

   /* pc1 and pc2 should be the newlines for their lines.
    * swap the chunks and the nl_count so that the spacing remains the same.
    */
   if ((pc1 != NULL) && (pc2 != NULL))
   {
      int nl_count = pc1->nl_count;

      pc1->nl_count = pc2->nl_count;
      pc2->nl_count = nl_count;

      chunk_swap(pc1, pc2);
   }
} // chunk_swap_lines
开发者ID:bengardner,项目名称:uncrustify,代码行数:77,代码来源:chunk_list.cpp


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