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


C++ NzString类代码示例

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


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

示例1: NazaraLock

bool NzDirectory::NextResult(bool skipDots)
{
	NazaraLock(m_mutex);

	#if NAZARA_CORE_SAFE
	if (!m_impl)
	{
		NazaraError("Directory not opened");
		return false;
	}
	#endif

	NzString name;
	do
	{
		if (!m_impl->NextResult())
			return false;

		name = m_impl->GetResultName();

		if (skipDots && (name == '.' || name == ".."))
			continue;

		if (name.Match(m_pattern))
			break;
	}
	while (true);

	return true;
}
开发者ID:Moumou38,项目名称:NazaraEngine,代码行数:30,代码来源:Directory.cpp

示例2: ToString

NzString NzStringStream::ToString() const
{
	NzString string;
	string.Reserve(m_bufferSize);

	for (const NzString& str : m_strings)
		string += str;

	return string;
}
开发者ID:BigFax,项目名称:NazaraEngine,代码行数:10,代码来源:StringStream.cpp

示例3: ReadLine

NzString NzInputStream::ReadLine(unsigned int lineSize)
{
	NzString line;
	if (lineSize == 0) // Taille maximale indéterminée
	{
		const unsigned int bufferSize = 64;

		char buffer[bufferSize+1];
		buffer[bufferSize] = '\0';

		unsigned int readSize;
		do
		{
			readSize = Read(buffer, bufferSize);

			const char* ptr = std::strchr(buffer, '\n');
			if (ptr)
			{
				unsigned int pos = ptr-buffer;

				if (m_streamOptions & nzStreamOption_Text && pos > 0 && buffer[pos-1] == '\r')
					line.Append(buffer, pos-1);
				else
					line.Append(buffer, pos);

				if (!SetCursorPos(GetCursorPos() - readSize + pos + 1))
					NazaraWarning("Failed to reset cursos pos");

				break;
			}
			else
				line.Append(buffer, readSize);
		}
		while (readSize == bufferSize);
	}
	else
	{
		line.Set(lineSize, '\0');
		unsigned int readSize = Read(&line[0], lineSize);
		unsigned int pos = line.Find('\n');
		if (pos <= readSize) // Faux uniquement si le caractère n'est pas présent (npos étant le plus grand entier)
		{
			if (m_streamOptions & nzStreamOption_Text && pos > 0 && line[pos-1] == '\r')
				line.Resize(pos);
			else
				line.Resize(pos+1);

			if (!SetCursorPos(GetCursorPos() - readSize + pos + 1))
				NazaraWarning("Failed to reset cursos pos");
		}
		else
			line.Resize(readSize);
	}

	return line;
}
开发者ID:GuillaumeBelz,项目名称:NazaraEngine,代码行数:56,代码来源:InputStream.cpp

示例4: SetSource

void NzShaderStage::SetSource(const NzString& source)
{
	#if NAZARA_RENDERER_SAFE
	if (!m_id)
	{
		NazaraError("Shader stage is not initialized");
		return;
	}
	#endif

	const char* tmp = source.GetConstBuffer();
	GLint length = source.GetSize();
	glShaderSource(m_id, 1, &tmp, &length);
}
开发者ID:BigFax,项目名称:NazaraEngine,代码行数:14,代码来源:ShaderStage.cpp

示例5: Execute

bool NzLuaInstance::Execute(const NzString& code)
{
	if (code.IsEmpty())
		return true;

	if (luaL_loadstring(m_state, code.GetConstBuffer()) != 0)
	{
		m_lastError = lua_tostring(m_state, -1);
		lua_pop(m_state, 1);

		return false;
	}

	return Run(0, 0);
}
开发者ID:MrFraggy,项目名称:NazaraEngine,代码行数:15,代码来源:LuaInstance.cpp

示例6: glCreateProgram

bool NzShader::Create()
{
	NzContext::EnsureContext();

	m_program = glCreateProgram();
	if (!m_program)
	{
		NazaraError("Failed to create program");
		return false;
	}

	m_linked = false;

	glBindAttribLocation(m_program, NzOpenGL::VertexComponentIndex[nzVertexComponent_InstanceData0], "InstanceData0");
	glBindAttribLocation(m_program, NzOpenGL::VertexComponentIndex[nzVertexComponent_InstanceData1], "InstanceData1");
	glBindAttribLocation(m_program, NzOpenGL::VertexComponentIndex[nzVertexComponent_InstanceData2], "InstanceData2");
	glBindAttribLocation(m_program, NzOpenGL::VertexComponentIndex[nzVertexComponent_InstanceData3], "InstanceData3");
	glBindAttribLocation(m_program, NzOpenGL::VertexComponentIndex[nzVertexComponent_InstanceData4], "InstanceData4");
	glBindAttribLocation(m_program, NzOpenGL::VertexComponentIndex[nzVertexComponent_InstanceData5], "InstanceData5");
	glBindAttribLocation(m_program, NzOpenGL::VertexComponentIndex[nzVertexComponent_Color],         "VertexColor");
	glBindAttribLocation(m_program, NzOpenGL::VertexComponentIndex[nzVertexComponent_Normal],        "VertexNormal");
	glBindAttribLocation(m_program, NzOpenGL::VertexComponentIndex[nzVertexComponent_Position],      "VertexPosition");
	glBindAttribLocation(m_program, NzOpenGL::VertexComponentIndex[nzVertexComponent_Tangent],       "VertexTangent");
	glBindAttribLocation(m_program, NzOpenGL::VertexComponentIndex[nzVertexComponent_TexCoord],      "VertexTexCoord");
	glBindAttribLocation(m_program, NzOpenGL::VertexComponentIndex[nzVertexComponent_Userdata0],     "VertexUserdata0");
	glBindAttribLocation(m_program, NzOpenGL::VertexComponentIndex[nzVertexComponent_Userdata1],     "VertexUserdata1");
	glBindAttribLocation(m_program, NzOpenGL::VertexComponentIndex[nzVertexComponent_Userdata2],     "VertexUserdata2");
	glBindAttribLocation(m_program, NzOpenGL::VertexComponentIndex[nzVertexComponent_Userdata3],     "VertexUserdata3");
	glBindAttribLocation(m_program, NzOpenGL::VertexComponentIndex[nzVertexComponent_Userdata4],     "VertexUserdata4");

	if (NzRenderer::HasCapability(nzRendererCap_MultipleRenderTargets))
	{
		NzString uniform;
		uniform = "RenderTarget";

		unsigned int maxRenderTargets = NzRenderer::GetMaxRenderTargets();
		for (unsigned int i = 0; i < maxRenderTargets; ++i)
		{
			NzString uniformName = uniform + NzString::Number(i);
			glBindFragDataLocation(m_program, i, uniformName.GetConstBuffer());
		}
	}

	if (NzOpenGL::IsSupported(nzOpenGLExtension_GetProgramBinary))
		glProgramParameteri(m_program, GL_PROGRAM_BINARY_RETRIEVABLE_HINT, GL_TRUE);

	return true;
}
开发者ID:MrFraggy,项目名称:NazaraEngine,代码行数:48,代码来源:Shader.cpp

示例7: Exists

bool NzDirectory::Exists(const NzString& dirPath)
{
	if (dirPath.IsEmpty())
		return false;

	return NzDirectoryImpl::Exists(NzFile::NormalizePath(dirPath));
}
开发者ID:Moumou38,项目名称:NazaraEngine,代码行数:7,代码来源:Directory.cpp

示例8: Remove

bool NzDirectory::Remove(const NzString& dirPath, bool emptyDirectory)
{
	if (dirPath.IsEmpty())
		return false;

	if (emptyDirectory)
	{
		NzDirectory dir(dirPath);
		if (!dir.Open())
			return NzDirectoryImpl::Remove(dirPath); // Si on n'arrive pas à ouvrir le dossier, on tente de le supprimer

		while (dir.NextResult(true))
		{
			if (dir.IsResultDirectory())
			{
				if (!Remove(dir.GetResultPath(), true))
					return false;
			}
			else if (!NzFile::Delete(dir.GetResultPath()))
			{
				NazaraError(dir.GetResultPath());
				return false;
			}
		}

		dir.Close();
	}

	return NzDirectoryImpl::Remove(NzFile::NormalizePath(dirPath));
}
开发者ID:Moumou38,项目名称:NazaraEngine,代码行数:30,代码来源:Directory.cpp

示例9: SetShader

void NzUberShaderPreprocessor::SetShader(nzShaderStage stage, const NzString& source, const NzString& shaderFlags, const NzString& requiredFlags)
{
    Shader& shader = m_shaders[stage];
    shader.present = true;
    shader.source = source;

    // On extrait les flags de la chaîne
    std::vector<NzString> flags;
    shaderFlags.Split(flags, ' ');

    for (NzString& flag : flags)
	{
		auto it = m_flags.find(flag);
		if (it == m_flags.end())
			m_flags[flag] = 1U << m_flags.size();

		auto it2 = shader.flags.find(flag);
		if (it2 == shader.flags.end())
			shader.flags[flag] = 1U << shader.flags.size();
	}

	// On construit les flags requis pour l'activation du shader
	shader.requiredFlags = 0;

	flags.clear();
	requiredFlags.Split(flags, ' ');

    for (NzString& flag : flags)
	{
		nzUInt32 flagVal;

		auto it = m_flags.find(flag);
		if (it == m_flags.end())
		{
			flagVal = 1U << m_flags.size();
			m_flags[flag] = flagVal;
		}
		else
			flagVal = it->second;

		shader.requiredFlags |= flagVal;
	}
}
开发者ID:MrFraggy,项目名称:NazaraEngine,代码行数:43,代码来源:UberShaderPreprocessor.cpp

示例10: dirPath

bool NzDirectory::Copy(const NzString& sourcePath, const NzString& destPath)
{
	if (sourcePath.IsEmpty() || destPath.IsEmpty())
		return false;

	NzString dirPath(sourcePath);
	NzString dest(NzFile::NormalizePath(destPath));

	if (!Create(destPath, true))
	{
		NazaraError("Unable to create \"" + destPath + '"');
		return false;
	}

	NzDirectory dir(dirPath);
	if (!dir.Open())
	{
		NazaraError("Unable to open \"" + destPath + '"');
		return false;
	}

	while (dir.NextResult(true))
	{
		if (dir.IsResultDirectory())
		{
			if (!Copy(dir.GetResultPath(), dest + NAZARA_DIRECTORY_SEPARATOR + dir.GetResultName()))
				return false;
		}
		else if (!NzFile::Copy(dir.GetResultPath(), dest + NAZARA_DIRECTORY_SEPARATOR + dir.GetResultName()))
		{
			NazaraError("Failed to copy \"" + dir.GetResultPath() + "\" to \"" + dest + NAZARA_DIRECTORY_SEPARATOR + dir.GetResultName() + '"');
			return false;
		}
	}

	dir.Close();

	return true;
}
开发者ID:Moumou38,项目名称:NazaraEngine,代码行数:39,代码来源:Directory.cpp

示例11: NazaraError

NzString NzShaderStage::GetSource() const
{
	#if NAZARA_RENDERER_SAFE
	if (!m_id)
	{
		NazaraError("Shader stage is not initialized");
		return NzString();
	}
	#endif

	NzString source;

	GLint length = 0;
	glGetShaderiv(m_id, GL_SHADER_SOURCE_LENGTH, &length);
	if (length > 1) // Le caractère de fin compte
	{
		source.Set(length - 1, '\0'); // La taille retournée est celle du buffer (Avec caractère de fin)
		glGetShaderSource(m_id, length, nullptr, &source[0]);
	}

	return source;
}
开发者ID:BigFax,项目名称:NazaraEngine,代码行数:22,代码来源:ShaderStage.cpp

示例12: AddSubMesh

void NzMesh::AddSubMesh(const NzString& identifier, NzSubMesh* subMesh)
{
	#if NAZARA_UTILITY_SAFE
	if (!m_impl)
	{
		NazaraError("Mesh not created");
		return;
	}

	if (identifier.IsEmpty())
	{
		NazaraError("Identifier is empty");
		return;
	}

	auto it = m_impl->subMeshMap.find(identifier);
	if (it != m_impl->subMeshMap.end())
	{
		NazaraError("SubMesh identifier \"" + identifier + "\" is already used");
		return;
	}

	if (!subMesh)
	{
		NazaraError("Invalid submesh");
		return;
	}

	if (m_impl->animationType != subMesh->GetAnimationType())
	{
		NazaraError("Submesh animation type must match mesh animation type");
		return;
	}
	#endif

	int index = m_impl->subMeshes.size();

	subMesh->AddResourceListener(this, index);
	subMesh->AddResourceReference();

	m_impl->aabbUpdated = false; // On invalide l'AABB
	m_impl->subMeshes.push_back(subMesh);
	m_impl->subMeshMap[identifier] = index;
}
开发者ID:BigFax,项目名称:NazaraEngine,代码行数:44,代码来源:Mesh.cpp

示例13: Create

bool NzWindowImpl::Create(const NzVideoMode& mode, const NzString& title, nzUInt32 style)
{
	bool fullscreen = (style & nzWindowStyle_Fullscreen) != 0;
	DWORD win32Style, win32StyleEx;
	unsigned int x, y;
	unsigned int width = mode.width;
	unsigned int height = mode.height;
	if (fullscreen)
	{
		DEVMODE win32Mode;
		std::memset(&win32Mode, 0, sizeof(DEVMODE));
		win32Mode.dmBitsPerPel = mode.bitsPerPixel;
		win32Mode.dmPelsHeight = mode.height;
		win32Mode.dmPelsWidth  = mode.width;
		win32Mode.dmFields	   = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
		win32Mode.dmSize	   = sizeof(DEVMODE);

		if (ChangeDisplaySettings(&win32Mode, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL)
		{
			// Situation extrêmement rare grâce à NzVideoMode::IsValid appelé par NzWindow
			NazaraError("Failed to change display settings for fullscreen, this video mode is not supported by your computer");
			fullscreen = false;
		}
	}

	// Testé une seconde fois car sa valeur peut changer
	if (fullscreen)
	{
		x = 0;
		y = 0;
		win32Style = WS_CLIPCHILDREN | WS_POPUP;

		// Pour cacher la barre des tâches
		// http://msdn.microsoft.com/en-us/library/windows/desktop/ff700543(v=vs.85).aspx
		win32StyleEx = WS_EX_APPWINDOW;

		fullscreenWindow = this;
	}
	else
	{
		win32Style = WS_VISIBLE;
		if (style & nzWindowStyle_Titlebar)
		{
			win32Style |= WS_CAPTION | WS_MINIMIZEBOX;
			if (style & nzWindowStyle_Closable)
				win32Style |= WS_SYSMENU;

			if (style & nzWindowStyle_Resizable)
				win32Style |= WS_MAXIMIZEBOX | WS_SIZEBOX;
		}
		else
			win32Style |= WS_POPUP;

		win32StyleEx = 0;

		RECT rect = {0, 0, static_cast<LONG>(width), static_cast<LONG>(height)};
		AdjustWindowRect(&rect, win32Style, false);
		width = rect.right-rect.left;
		height = rect.bottom-rect.top;

		x = (GetSystemMetrics(SM_CXSCREEN) - width)/2;
		y = (GetSystemMetrics(SM_CYSCREEN) - height)/2;
	}

	m_callback = 0;

	#if NAZARA_UTILITY_THREADED_WINDOW
	NzMutex mutex;
	NzConditionVariable condition;
	m_threadActive = true;

	// On attend que la fenêtre soit créée
	mutex.Lock();
	m_thread = NzThread(WindowThread, &m_handle, win32StyleEx, title.GetWideString().data(), win32Style, x, y, width, height, this, &mutex, &condition);
	condition.Wait(&mutex);
	mutex.Unlock();
	#else
	m_handle = CreateWindowExW(win32StyleEx, className, title.GetWideString().data(), win32Style, x, y, width, height, nullptr, nullptr, GetModuleHandle(nullptr), this);
	#endif

	if (!m_handle)
	{
		NazaraError("Failed to create window: " + NzError::GetLastSystemError());
		return false;
	}

	if (fullscreen)
	{
		SetForegroundWindow(m_handle);
		ShowWindow(m_handle, SW_SHOW);
	}

	m_eventListener = true;
	m_ownsWindow = true;
	#if !NAZARA_UTILITY_THREADED_WINDOW
	m_sizemove = false;
	#endif
	m_style = style;

	// Récupération de la position/taille de la fenêtre (Après sa création)
//.........这里部分代码省略.........
开发者ID:GuillaumeBelz,项目名称:NazaraEngine,代码行数:101,代码来源:WindowImpl.cpp

示例14: GetGlobal

nzLuaType NzLuaInstance::GetGlobal(const NzString& name) const
{
	return FromLuaType(lua_getglobal(m_state, name.GetConstBuffer()));
}
开发者ID:MrFraggy,项目名称:NazaraEngine,代码行数:4,代码来源:LuaInstance.cpp

示例15: NazaraError

bool NzPluginManager::Mount(const NzString& pluginPath, bool appendExtension)
{
	if (!Initialize())
	{
		NazaraError("Failed to initialize PluginManager");
		return false;
	}

	NzString path = pluginPath;
	if (appendExtension && !path.EndsWith(NAZARA_DYNLIB_EXTENSION))
		path += NAZARA_DYNLIB_EXTENSION;

	bool exists = false;
	if (!NzFile::IsAbsolute(path))
	{
		for (const NzString& dir : s_directories)
		{
			NzString testPath;
			testPath.Reserve(dir.GetSize() + path.GetSize() + 10);

			testPath = dir;
			testPath += NAZARA_DIRECTORY_SEPARATOR;
			testPath += path;

			if (NzFile::Exists(testPath))
			{
				path = testPath;
				exists = true;
				break;
			}
		}
	}
	else if (NzFile::Exists(path))
		exists = true;

	if (!exists)
	{
		NazaraError("Failed to find plugin file");
		return false;
	}

	std::unique_ptr<NzDynLib> library(new NzDynLib);
	if (!library->Load(path))
	{
		NazaraError("Failed to load plugin");
		return false;
	}

	PluginLoad func = reinterpret_cast<PluginLoad>(library->GetSymbol("NzPluginLoad"));
	if (!func)
	{
		NazaraError("Failed to get symbol NzPluginLoad");
		return false;
	}

	if (!func())
	{
		NazaraError("Plugin failed to load");
		return false;
	}

	s_plugins[pluginPath] = library.release();

	return true;
}
开发者ID:GuillaumeBelz,项目名称:NazaraEngine,代码行数:65,代码来源:PluginManager.cpp


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