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


C++ String::Data方法代码示例

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


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

示例1: FolderRemove

	bool FileSystem::FolderRemove(const String& path, bool recursive /*= true*/) const
	{
		if (!IsFolderExist(path))
			return false;

		if (!recursive)
			return RemoveDirectoryA(path.Data()) == TRUE;

		WIN32_FIND_DATA f;
		HANDLE h = FindFirstFile((path + "/*").Data(), &f);
		if (h != INVALID_HANDLE_VALUE)
		{
			do
			{
				if (strcmp(f.cFileName, ".") == 0 || strcmp(f.cFileName, "..") == 0)
					continue;

				if (f.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY)
					FolderRemove(path + "/" + f.cFileName, true);
				else
					FileDelete(path + "/" + f.cFileName);
			} while (FindNextFile(h, &f));
		}

		FindClose(h);

		return RemoveDirectoryA(path.Data()) == TRUE;
	}
开发者ID:zenkovich,项目名称:o2,代码行数:28,代码来源:FileSystemImpl.cpp

示例2: FileMove

	bool FileSystem::FileMove(const String& source, const String& dest) const
	{
		String destFolder = GetParentPath(dest);

		if (!IsFolderExist(destFolder))
			FolderCreate(destFolder);

		return MoveFileA(source.Data(), dest.Data()) == TRUE;
	}
开发者ID:zenkovich,项目名称:o2,代码行数:9,代码来源:FileSystemImpl.cpp

示例3: SetFileEditDate

	bool FileSystem::SetFileEditDate(const String& path, const TimeStamp& time) const
	{
		FILETIME lastWriteTime;
		HANDLE hFile = CreateFileA(path.Data(), GENERIC_READ | FILE_WRITE_ATTRIBUTES,
								   FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
		if (hFile == NULL)
			return false;

		SYSTEMTIME stLocal, stUTC;

		stLocal.wSecond = time.mSecond;
		stLocal.wDayOfWeek = 0;
		stLocal.wMilliseconds = 0;
		stLocal.wMinute = time.mMinute;
		stLocal.wHour = time.mHour;
		stLocal.wDay = time.mDay;
		stLocal.wMonth = time.mMonth;
		stLocal.wYear = time.mYear;

		TzSpecificLocalTimeToSystemTime(NULL, &stLocal, &stUTC);
		SystemTimeToFileTime(&stUTC, &lastWriteTime);
		if (!SetFileTime(hFile, NULL, NULL, &lastWriteTime))
		{
			auto error = GetLastError();
			printf("err %i\n", error);
			CloseHandle(hFile);
			return false;
		}

		CloseHandle(hFile);

		return true;
	}
开发者ID:zenkovich,项目名称:o2,代码行数:33,代码来源:FileSystemImpl.cpp

示例4: Load_Stream

void Sound::Load_Stream(const String& fileName) 
{
	if(fileName.Count()) return;

	name = fileName;

	FMOD_RESULT s_result = FMOD_OK;

	if(sound != nullptr)
	{
		s_result = FMOD_Sound_Release(sound);
		check_error(s_result);
	}

    s_result = FMOD_System_CreateSound(fmodSystem, fileName.Data(),
		FMOD_SOFTWARE | FMOD_UNICODE | FMOD_CREATESTREAM, nullptr, &sound);
	check_error(s_result);

	switch(type)
	{
		case MUSIC:
			FMOD_Sound_SetSoundGroup(sound, musicGroup);
			break;

		case SOUND_EFFECT:
			FMOD_Sound_SetSoundGroup(sound, noiseGroup);
			break;
	}
}
开发者ID:Vavassor,项目名称:meteor,代码行数:29,代码来源:Sound.cpp

示例5: SetWindowTitle

	void System::SetWindowTitle(const String& title)
	{
#if defined __PLATFORM_WIN32
		//m_TitleName = title;
		SetWindowText(m_RenderWindowParam.handle, title.Data());
#endif	// #if defined __PLATFORM_WIN32
	}
开发者ID:aosyang,项目名称:existence,代码行数:7,代码来源:System.cpp

示例6: FolderCreate

	bool FileSystem::FolderCreate(const String& path, bool recursive /*= true*/) const
	{
		if (IsFolderExist(path))
			return true;

		if (!recursive)
			return CreateDirectoryA(path.Data(), NULL) == TRUE;

		if (CreateDirectoryA(path.Data(), NULL) == TRUE)
			return true;

		String extrPath = ExtractPathStr(path);
		if (extrPath == path)
			return false;

		return FolderCreate(extrPath, true);
	}
开发者ID:zenkovich,项目名称:o2,代码行数:17,代码来源:FileSystemImpl.cpp

示例7: GetFileInfo

	FileInfo FileSystem::GetFileInfo(const String& path) const
	{
		FileInfo res;
		res.path = "invalid_file";

		FILETIME creationTime, lastAccessTime, lastWriteTime;
		HANDLE hFile = CreateFileA(path.Data(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL);
		if (hFile == NULL || hFile == INVALID_HANDLE_VALUE)
		{
			auto err = GetLastError();
			return res;
		}

		if (!GetFileTime(hFile, &creationTime, &lastAccessTime, &lastWriteTime))
		{
			CloseHandle(hFile);
			return res;
		}

		SYSTEMTIME stUTC, stLocal;

		FileTimeToSystemTime(&creationTime, &stUTC);
		SystemTimeToTzSpecificLocalTime(NULL, &stUTC, &stLocal);
		res.createdDate = TimeStamp(stLocal.wSecond, stLocal.wMinute, stLocal.wHour, stLocal.wDay, stLocal.wMonth, stLocal.wYear);

		FileTimeToSystemTime(&lastAccessTime, &stUTC);
		SystemTimeToTzSpecificLocalTime(NULL, &stUTC, &stLocal);
		res.accessDate = TimeStamp(stLocal.wSecond, stLocal.wMinute, stLocal.wHour, stLocal.wDay, stLocal.wMonth, stLocal.wYear);

		FileTimeToSystemTime(&lastWriteTime, &stUTC);
		SystemTimeToTzSpecificLocalTime(NULL, &stUTC, &stLocal);
		res.editDate = TimeStamp(stLocal.wSecond, stLocal.wMinute, stLocal.wHour, stLocal.wDay, stLocal.wMonth, stLocal.wYear);

		res.path = path;
		String extension = path.SubStr(path.FindLast(".") + 1);
		res.fileType = FileType::File;

		for (auto iext : mInstance->mExtensions)
		{
			if (iext.Value().Contains(extension))
			{
				res.fileType = iext.Key();
				break;
			}
		}

		DWORD dwSizeHigh = 0, dwSizeLow = 0;
		dwSizeLow = GetFileSize(hFile, &dwSizeHigh);
		res.size = (dwSizeHigh * (MAXDWORD+1)) + dwSizeLow;

		CloseHandle(hFile);

		return res;
	}
开发者ID:zenkovich,项目名称:o2,代码行数:54,代码来源:FileSystemImpl.cpp

示例8: IsFileExist

	bool FileSystem::IsFileExist(const String& path) const
	{
		DWORD tp = GetFileAttributes(path.Data());

		if (tp == INVALID_FILE_ATTRIBUTES)
			return false;

		if (tp & FILE_ATTRIBUTE_DIRECTORY)
			return false;

		return true;
	}
开发者ID:zenkovich,项目名称:o2,代码行数:12,代码来源:FileSystemImpl.cpp

示例9: CreateResourceHandles

	bool MaterialManager::CreateResourceHandles(ResourceFileNameInfo* resName)
	{
		String ext = FileSystem::Instance().GetExtension(resName->filename);
		ext.ToLowerCase();

		String relativePathName = resName->path + CORRECT_SLASH + resName->filename;

		String rname;
		BaseMaterial* material = NULL;

		if (ext==".emt")
		{
			// 打开材质脚本,获取材质名称
			TiXmlDocument matDoc(relativePathName.Data());
			matDoc.LoadFile();

			TiXmlElement* elem = matDoc.FirstChildElement();

			if (!elem) return false;

			const char* name = elem->Attribute("name");
			if (!name) return false;

			material = new Material(relativePathName);

			rname = name;
		}
		else if (ext==".cgfx")
		{
			material = new EffectMaterial(relativePathName);

			rname = resName->filename;
		}

		if (material)
		{
			AssertFatal(m_ResourceMap.find(rname)==m_ResourceMap.end(),
						"MaterialManager::CreateResourceHandles(): Specified resource name already exists.");

			m_ResourceMap[rname] = material;
			material->m_ResourceName = rname;

			return true;
		}

		return false;
	}
开发者ID:aosyang,项目名称:existence,代码行数:47,代码来源:BaseMaterial.cpp

示例10: CreateResourceHandles

	bool FontManager::CreateResourceHandles(ResourceFileNameInfo* resName)
	{
		String relativePathName = resName->path + CORRECT_SLASH + resName->filename;

		// 获取字体信息
		FT_Face ft_face;
		FT_New_Face(g_FTLibrary, relativePathName.Data(), 0, &ft_face);

		Font* font = new Font(relativePathName);

		AssertFatal(m_ResourceMap.find(ft_face->family_name)==m_ResourceMap.end(),
					"FontManager::CreateResourceHandles(): Specified resource name already exists.");
		m_ResourceMap[ft_face->family_name] = font;
		font->m_ResourceName = resName->filename;

		FT_Done_Face(ft_face);

		return true;
	}
开发者ID:aosyang,项目名称:existence,代码行数:19,代码来源:Font.cpp

示例11: SaveScene

// 将场景保存到文件
bool GameGrid::SaveScene(const String &filename)
{
	ofstream fout(filename.Data());
	if (!fout.is_open())
		return false;

	// 在x、y、z方向上依次遍历
	for (int x=0; x<WORLD_SIZE; x++)
		for (int y=0; y<WORLD_SIZE; y++)
			for (int z=0; z<WORLD_SIZE; z++)
			{
				if (m_World[x][y][z].obj)
					fout << 1 << " ";
				else
					fout << 0 << " ";
			}

	fout.close();

	return true;
}
开发者ID:aosyang,项目名称:existence,代码行数:22,代码来源:GameGrid.cpp

示例12: LoadScene

// 从文件载入场景
bool GameGrid::LoadScene(const String &filename)
{
	ifstream fin(filename.Data());
	if (!fin.is_open())
		return false;

	for (int x=0; x<WORLD_SIZE; x++)
		for (int y=0; y<WORLD_SIZE; y++)
			for (int z=0; z<WORLD_SIZE; z++)
			{
				int b;
				fin >> b;
				if (b)
					AddBox(Point3(x, y, z));
				else
					RemoveBox(Point3(x, y, z));
			}

	fin.close();

	return true;
}
开发者ID:aosyang,项目名称:existence,代码行数:23,代码来源:GameGrid.cpp

示例13: Load

bool DXShader::Load(const String& vertexFileName, const String& pixelFileName)
{
	HRESULT hr = S_OK;

	String vertexFile("data/shaders/dx/");
	vertexFile.Append(vertexFileName);

	// create vertex shader
	void* vBuffer = nullptr;
	unsigned vSize = load_binary_file(&vBuffer, vertexFile.Data());
	hr = _Device->CreateVertexShader(vBuffer, vSize, NULL, &vertexShader);
	if(FAILED(hr))
	{
		delete[] vBuffer;
		LOG_ISSUE("DIRECTX ERROR: %s - failed to load vertex shader: %s",
			hresult_text(hr).Data(), vertexFileName.Data());
		return false;
	}

	// create input layout
	const D3D11_INPUT_ELEMENT_DESC basicVertexLayoutDesc[] =
	{
		{ "POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
		{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT,    0, 16, D3D11_INPUT_PER_VERTEX_DATA, 0 }
	};
	const D3D11_INPUT_ELEMENT_DESC particleVertexLayoutDesc[] =
	{
		{ "POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 0,	D3D11_INPUT_PER_VERTEX_DATA, 0 },
		{ "COLOR",	  0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 16, D3D11_INPUT_PER_VERTEX_DATA, 0 },
		{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT,		 0, 32, D3D11_INPUT_PER_VERTEX_DATA, 0 }
	};

	const D3D11_INPUT_ELEMENT_DESC* inputLayoutDesc = (layoutType == 0) ? basicVertexLayoutDesc : particleVertexLayoutDesc;
	unsigned inputDescSize = (layoutType == 0) ? ARRAYSIZE(basicVertexLayoutDesc) : ARRAYSIZE(particleVertexLayoutDesc);

	hr = _Device->CreateInputLayout(inputLayoutDesc, inputDescSize, vBuffer, vSize, &inputLayout);
	delete[] vBuffer;
	if(FAILED(hr))
	{
		LOG_ISSUE("DIRECTX ERROR: %s - failed to create input layout "
			"for vertex shader: %s", hresult_text(hr).Data(), vertexFileName.Data());
		return false;
	}

	// create pixel shader
	String pixelFile("shaders/dx/");
	pixelFile.Append(pixelFileName);

	void* psBuffer = nullptr;
	unsigned psSize = load_binary_file(&psBuffer, pixelFile.Data());
	hr = _Device->CreatePixelShader(psBuffer, psSize, NULL, &pixelShader);
	delete[] psBuffer;
	if(FAILED(hr))
	{
		LOG_ISSUE("DIRECTX ERROR: %s - failed to load pixel shader: %s",
			hresult_text(hr).Data(), pixelFileName.Data());
		return false;
	}

	// initialize constants
	numVertexConstants = 3;
	vertexConstants[0].name = "model";
	vertexConstants[0].type = ShaderConstant::MAT4X4;
	vertexConstants[1].name = "view";
	vertexConstants[1].type = ShaderConstant::MAT4X4;
	vertexConstants[2].name = "projection";
	vertexConstants[2].type = ShaderConstant::MAT4X4;
	
	numPixelConstants = 1;
	pixelConstants[0].name = "color";
	pixelConstants[0].type = ShaderConstant::VEC4;

	int count = 0;
	for(int i = 0; i < numVertexConstants; i++)
	{
		vertexConstants[i].location = count;
		count += vertexConstants[i].GetSize();
	}
	count = 0;
	for(int i = 0; i < numPixelConstants; i++)
	{
		pixelConstants[i].location = count;
		count += pixelConstants[i].GetSize();
	}

	// create constant buffers
	int vertexConstantBufferSize = 0;
	for(int i = 0; i < numVertexConstants; i++)
		vertexConstantBufferSize += vertexConstants[i].GetSize();

	D3D11_BUFFER_DESC constantBufferDesc = {0};
	constantBufferDesc.ByteWidth = sizeof(float) * vertexConstantBufferSize;
	constantBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
	constantBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
	constantBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
	_Device->CreateBuffer(&constantBufferDesc, nullptr, &vertCB);
	if(FAILED(hr))
	{
		LOG_ISSUE("DIRECTX ERROR: %s - failed to create constant buffer "
			"for shaders: %s and %s", hresult_text(hr).Data(), vertexFileName.Data(),
//.........这里部分代码省略.........
开发者ID:Vavassor,项目名称:meteor,代码行数:101,代码来源:DXShader.cpp

示例14: FileDelete

	bool FileSystem::FileDelete(const String& file) const
	{
		return DeleteFileA(file.Data()) == TRUE;
	}
开发者ID:zenkovich,项目名称:o2,代码行数:4,代码来源:FileSystemImpl.cpp

示例15: FileCopy

	bool FileSystem::FileCopy(const String& source, const String& dest) const
	{
		FileDelete(dest);
		FolderCreate(ExtractPathStr(dest));
		return CopyFileA(source.Data(), dest.Data(), TRUE) == TRUE;
	}
开发者ID:zenkovich,项目名称:o2,代码行数:6,代码来源:FileSystemImpl.cpp


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