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


C++ UString::c_str方法代码示例

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


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

示例1: extractFiles

void extractFiles(Aurora::RIMFile &rim, Aurora::GameID game) {
	const Aurora::Archive::ResourceList &resources = rim.getResources();
	const size_t fileCount = resources.size();

	std::printf("Number of files: %u\n\n", (uint)fileCount);

	size_t i = 1;
	for (Aurora::Archive::ResourceList::const_iterator r = resources.begin(); r != resources.end(); ++r, ++i) {
		const Aurora::FileType type     = TypeMan.aliasFileType(r->type, game);
		const Common::UString  fileName = TypeMan.setFileType(r->name, type);

		std::printf("Extracting %u/%u: %s ... ", (uint)i, (uint)fileCount, fileName.c_str());

		Common::SeekableReadStream *stream = 0;
		try {
			stream = rim.getResource(r->index);

			dumpStream(*stream, fileName);

			std::printf("Done\n");
		} catch (Common::Exception &e) {
			Common::printException(e, "");
		}

		delete stream;
	}

}
开发者ID:TC01,项目名称:xoreos-tools,代码行数:28,代码来源:unrim.cpp

示例2: Video

void QuickTimeDecoder::VideoSampleDesc::initCodec(Graphics::Surface &surface) {
	if (_codecTag == MKID_BE('mp4v')) {
		Common::UString videoType;

		// Parse the object type
		switch (_parentTrack->objectTypeMP4) {
		case 0x20:
			videoType = "h.263";

			_videoCodec = new H263Codec(_parentTrack->width, _parentTrack->height);
			if (_parentTrack->extraData)
				_videoCodec->decodeFrame(surface, *_parentTrack->extraData);
			break;

		default:
			videoType = "Unknown";
			break;
		}

		if (!_videoCodec)
			warning("MPEG-4 Video (%s) not yet supported", videoType.c_str());

	} else if (_codecTag == MKID_BE('SVQ3')) {
		// TODO: Sorenson Video 3
		warning("Sorenson Video 3 not yet supported");
	} else {
		warning("Unsupported codec \'%s\'", tag2str(_codecTag));
	}
}
开发者ID:Hellzed,项目名称:xoreos,代码行数:29,代码来源:quicktime.cpp

示例3: runScript

bool ScriptContainer::runScript(const Common::UString &script,
                                const Aurora::NWScript::ScriptState &state,
                                Aurora::NWScript::Object *owner,
                                Aurora::NWScript::Object *triggerer) {
	if (script.empty())
		return true;

	try {
		Aurora::NWScript::NCSFile ncs(script);

		const Aurora::NWScript::Variable &retVal = ncs.run(state, owner, triggerer);
		if (retVal.getType() == Aurora::NWScript::kTypeInt)
			return retVal.getInt() != 0;
		if (retVal.getType() == Aurora::NWScript::kTypeFloat)
			return retVal.getFloat() != 0.0f;

		return true;

	} catch (Common::Exception &e) {
		e.add("Failed running script \"%s\"", script.c_str());
		Common::printException(e, "WARNING: ");
		return false;
	}

	return true;
}
开发者ID:jbowtie,项目名称:xoreos,代码行数:26,代码来源:container.cpp

示例4: extractFiles

void extractFiles(Aurora::HERFFile &herf) {
	const Aurora::Archive::ResourceList &resources = herf.getResources();
	const size_t fileCount = resources.size();

	std::printf("Number of files: %u\n\n", (uint)fileCount);

	size_t i = 1;
	for (Aurora::Archive::ResourceList::const_iterator r = resources.begin(); r != resources.end(); ++r, ++i) {
		Common::UString fileName = r->name, fileExt = TypeMan.setFileType("", r->type);
		if (fileName.empty())
			findHashedName(r->hash, fileName, fileExt);

		fileName = fileName + fileExt;

		std::printf("Extracting %u/%u: %s ... ", (uint)i, (uint)fileCount, fileName.c_str());

		Common::SeekableReadStream *stream = 0;
		try {
			stream = herf.getResource(r->index);

			dumpStream(*stream, fileName);

			std::printf("Done\n");
		} catch (Common::Exception &e) {
			Common::printException(e, "");
		}

		delete stream;
	}

}
开发者ID:cc9cii,项目名称:xoreos-tools,代码行数:31,代码来源:unherf.cpp

示例5: dumpResourcesList

void ResourceManager::dumpResourcesList(const Common::UString &fileName) const {
	Common::DumpFile file;

	if (!file.open(fileName))
		throw Common::Exception(Common::kOpenError);

	file.writeString("                Name                 |        Hash        |     Size    \n");
	file.writeString("-------------------------------------|--------------------|-------------\n");

	for (ResourceMap::const_iterator r = _resources.begin(); r != _resources.end(); ++r) {
		if (r->second.empty())
			continue;

		const Resource &res = r->second.back();

		const Common::UString &name = res.name;
		const Common::UString   ext = TypeMan.setFileType("", res.type);
		const uint64           hash = r->first;
		const uint32           size = getResourceSize(res);

		const Common::UString line =
			Common::UString::sprintf("%32s%4s | 0x%016llX | %12d\n", name.c_str(), ext.c_str(),
                               (unsigned long long) hash, size);

		file.writeString(line);
	}

	file.flush();

	if (file.err())
		throw Common::Exception("Write error");

	file.close();
}
开发者ID:EffWun,项目名称:xoreos,代码行数:34,代码来源:resman.cpp

示例6: addResourceDir

ResourceManager::ChangeID ResourceManager::addResourceDir(const Common::UString &dir,
		const char *glob, int depth, uint32 priority) {

	// Find the directory
	Common::UString directory = Common::FilePath::findSubDirectory(_baseDir, dir, true);
	if (directory.empty())
		throw Common::Exception("No such directory \"%s\"", dir.c_str());

	// Find files
	Common::FileList files;
	files.addDirectory(directory, depth);

	ChangeID change = newChangeSet();

	if (!glob) {
		// Add the files
		addResources(files, change, priority);
		return change;
	}

	// Find files matching the glob pattern
	Common::FileList globFiles;
	files.getSubList(glob, globFiles, true);

	// Add the files
	addResources(globFiles, change, priority);
	return change;
}
开发者ID:EffWun,项目名称:xoreos,代码行数:28,代码来源:resman.cpp

示例7: printUsage

void printUsage(FILE *stream, const Common::UString &name) {
	std::fprintf(stream, "BioWare TLK to XML converter\n\n");
	std::fprintf(stream, "Usage: %s [<options>] <input file> [<output file>]\n", name.c_str());
	std::fprintf(stream, "  -h      --help              This help text\n");
	std::fprintf(stream, "          --version           Display version information\n\n");
	std::fprintf(stream, "          --cp1250            Read TLK strings as Windows CP-1250\n");
	std::fprintf(stream, "          --cp1251            Read TLK strings as Windows CP-1251\n");
	std::fprintf(stream, "          --cp1252            Read TLK strings as Windows CP-1252\n");
	std::fprintf(stream, "          --cp932             Read TLK strings as Windows CP-932\n");
	std::fprintf(stream, "          --cp936             Read TLK strings as Windows CP-936\n");
	std::fprintf(stream, "          --cp949             Read TLK strings as Windows CP-949\n");
	std::fprintf(stream, "          --cp950             Read TLK strings as Windows CP-950\n");
	std::fprintf(stream, "          --utf8              Read TLK strings as UTF-8\n");
	std::fprintf(stream, "          --utf16le           Read TLK strings as little-endian UTF-16\n");
	std::fprintf(stream, "          --utf16be           Read TLK strings as big-endian UTF-16\n\n");
	std::fprintf(stream, "          --nwn               Use Neverwinter Nights encodings\n");
	std::fprintf(stream, "          --nwn2              Use Neverwinter Nights 2 encodings\n");
	std::fprintf(stream, "          --kotor             Use Knights of the Old Republic encodings\n");
	std::fprintf(stream, "          --kotor2            Use Knights of the Old Republic II encodings\n");
	std::fprintf(stream, "          --jade              Use Jade Empire encodings\n");
	std::fprintf(stream, "          --witcher           Use The Witcher encodings\n");
	std::fprintf(stream, "          --dragonage         Use Dragon Age encodings\n");
	std::fprintf(stream, "          --dragonage2        Use Dragon Age II encodings\n\n");
	std::fprintf(stream, "If no output file is given, the output is written to stdout.\n\n");
	std::fprintf(stream, "There is no way to autodetect the encoding of strings in TLK files,\n");
	std::fprintf(stream, "so an encoding must be specified. Alternatively, the game this TLK\n");
	std::fprintf(stream, "is from can be given, and an appropriate encoding according to that\n");
	std::fprintf(stream, "game and the language ID found in the TLK is used.\n");
}
开发者ID:TC01,项目名称:xoreos-tools,代码行数:29,代码来源:tlk2xml.cpp

示例8: loadLayout

void Room::loadLayout(const Common::UString &roomFile) {
	if (!ResMan.hasResource(roomFile, Aurora::kFileTypeRML) || EventMan.quitRequested())
		return;

	GFF4File rml(roomFile, Aurora::kFileTypeRML, kRMLID);
	if (rml.getTypeVersion() != kVersion40)
		throw Common::Exception("Unsupported RML version %s", Common::debugTag(rml.getTypeVersion()).c_str());

	const GFF4Struct &rmlTop = rml.getTopLevel();

	float roomPos[3] = { 0.0f, 0.0f, 0.0f };
	rmlTop.getVector3(kGFF4Position, roomPos[0], roomPos[1], roomPos[2]);

	float roomOrient[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
	rmlTop.getVector4(kGFF4Orientation, roomOrient[0], roomOrient[1], roomOrient[2], roomOrient[3]);
	roomOrient[3] = Common::rad2deg(acos(roomOrient[3]) * 2.0);

	Common::Matrix4x4 roomTransform;
	roomTransform.translate(roomPos[0], roomPos[1], roomPos[2]);
	roomTransform.rotate(roomOrient[3], roomOrient[0], roomOrient[1], roomOrient[2]);

	status("Loading room \"%s\" (%d)", roomFile.c_str(), _id);

	const GFF4List &models = rmlTop.getList(kGFF4EnvRoomModelList);
	_models.reserve(models.size());

	for (GFF4List::const_iterator m = models.begin(); m != models.end(); ++m) {
		if (!*m || ((*m)->getLabel() != kMDLID))
			continue;

		float scale = (*m)->getFloat(kGFF4EnvModelScale);

		float pos[3] = { 0.0f, 0.0f, 0.0f };
		(*m)->getVector3(kGFF4Position, pos[0], pos[1], pos[2]);

		float orient[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
		(*m)->getVector4(kGFF4Orientation, orient[0], orient[1], orient[2], orient[3]);
		orient[3] = Common::rad2deg(acos(orient[3]) * 2.0);

		// TODO: Instances

		Graphics::Aurora::Model *model = loadModelObject((*m)->getString(kGFF4EnvModelFile));
		if (!model)
			continue;

		_models.push_back(model);

		Common::Matrix4x4 modelTransform(roomTransform);

		modelTransform.translate(pos[0], pos[1], pos[2]);
		modelTransform.rotate(orient[3], orient[0], orient[1], orient[2]);

		modelTransform.getPosition(pos[0], pos[1], pos[2]);
		modelTransform.getAxisAngle(orient[3], orient[0], orient[1], orient[2]);

		model->setPosition(pos[0], pos[1], pos[2]);
		model->setOrientation(orient[0], orient[1], orient[2], orient[3]);
		model->setScale(scale, scale, scale);
	}
}
开发者ID:kevL,项目名称:xoreos,代码行数:60,代码来源:room.cpp

示例9: readVarTable

void ScriptObject::readVarTable(const GFF4List &varTable) {
	for (GFF4List::const_iterator v = varTable.begin(); v != varTable.end(); ++v) {
		if (!*v || ((*v)->getLabel() != kVARSID))
			continue;

		const Common::UString name  = (*v)->getString (kGFF4ScriptVarTableName);
		const uint8           type  = (*v)->getUint   (kGFF4ScriptVarTableType);
		const GFF4Struct     *value = (*v)->getGeneric(kGFF4ScriptVarTableValue);

		if (name.empty() || (type == 0) || !value || !value->hasField(0))
			continue;

		switch (type) {
			case  4:
				setVariable(name, Aurora::NWScript::Variable());
				break;

			case  1:
				setVariable(name, (int32) value->getSint(0));
				break;

			case  2:
				setVariable(name, (float) value->getDouble(0));
				break;

			case  3:
			case 12:
				setVariable(name, value->getString(0));
				break;

			default:
				throw Common::Exception("Unknown variable type %u (\"%s\")", type, name.c_str());
		}
	}
}
开发者ID:Glyth,项目名称:xoreos,代码行数:35,代码来源:scriptobject.cpp

示例10: speakOneLiner

void Object::speakOneLiner(Common::UString conv, Object *UNUSED(tokenTarget)) {
	if (conv.empty())
		conv = _conversation;
	if (conv.empty())
		return;

	Common::UString text;
	Common::UString sound;


	try {
		Aurora::DLGFile dlg(conv, this);

		const Aurora::DLGFile::Line *line = dlg.getOneLiner();
		if (line) {
			text  = line->text.getString();
			sound = line->sound;
		}

	} catch (Common::Exception &e) {
		e.add("Failed evaluating one-liner from conversation \"%s\"", conv.c_str());
		Common::printException(e, "WARNING: ");
	}

	if (!text.empty())
		speakString(text, 0);
	if (!sound.empty())
		playSound(sound);
}
开发者ID:cc9cii,项目名称:xoreos,代码行数:29,代码来源:object.cpp

示例11: loadTexture

void AreaBackground::loadTexture(const Common::UString &name) {
	Common::SeekableReadStream *cbgt = 0, *pal = 0, *twoda = 0;
	Graphics::CBGT *image = 0;

	try {
		if (!(cbgt  = ResMan.getResource(name, Aurora::kFileTypeCBGT)))
			throw Common::Exception("No such CBGT");
		if (!(pal   = ResMan.getResource(name, Aurora::kFileTypePAL)))
			throw Common::Exception("No such PAL");
		if (!(twoda = ResMan.getResource(name, Aurora::kFileType2DA)))
			throw Common::Exception("No such 2DA");

		image    = new Graphics::CBGT(*cbgt, *pal, *twoda);
		_texture = TextureMan.add(Graphics::Aurora::Texture::create(image, Aurora::kFileTypeCBGT), name);

	} catch (Common::Exception &e) {
		delete image;
		delete cbgt;
		delete pal;
		delete twoda;

		e.add("Failed loading area background \"%s\"", name.c_str());
		throw;
	}

	delete cbgt;
	delete pal;
	delete twoda;
}
开发者ID:clone2727,项目名称:xoreos,代码行数:29,代码来源:areabackground.cpp

示例12: load

void VideoPlayer::load(const Common::UString &name) {
	delete _video;
	_video = 0;

	::Aurora::FileType type;
	Common::SeekableReadStream *video = ResMan.getResource(::Aurora::kResourceVideo, name, &type);
	if (!video)
		throw Common::Exception("No such video resource \"%s\"", name.c_str());

	// Loading the different image formats
	switch (type) {
	case ::Aurora::kFileTypeBIK:
		_video = new Bink(video);
		break;
	case ::Aurora::kFileTypeMOV:
		_video = new QuickTimeDecoder(video);
		break;
	case ::Aurora::kFileTypeXMV:
		_video = new XboxMediaVideo(video);
		break;
	case ::Aurora::kFileTypeVX:
		_video = new ActimagineDecoder(video);
		break;
	default:
		delete video;
		throw Common::Exception("Unsupported video resource type %d", (int) type);
	}

	_video->setScale(VideoDecoder::kScaleUpDown);
}
开发者ID:cc9cii,项目名称:xoreos,代码行数:30,代码来源:videoplayer.cpp

示例13: loadModule

void Module::loadModule(const Common::UString &module, const Common::UString &entryLocation,
                        ObjectType entryLocationType) {

	unload(false);

	_module = module;

	_entryLocation     = entryLocation;
	_entryLocationType = entryLocationType;

	try {

		load();

	} catch (Common::Exception &e) {
		_module.clear();

		e.add("Failed loading module \"%s\"", module.c_str());
		throw e;
	}

	_newModule.clear();

	_hasModule = true;
}
开发者ID:clone2727,项目名称:xoreos,代码行数:25,代码来源:module.cpp

示例14: add

TextureHandle TextureManager::add(Texture *texture, Common::UString name) {
	Common::StackLock lock(_mutex);

	bool reloadable = true;
	if (name.empty()) {
		reloadable = false;

		name = Common::generateIDRandomString();
	}

	TextureMap::iterator text = _textures.find(name);
	if (text != _textures.end())
		throw Common::Exception("Texture \"%s\" already exists", name.c_str());

	std::pair<TextureMap::iterator, bool> result;

	ManagedTexture *t = new ManagedTexture(name, texture);

	result = _textures.insert(std::make_pair(name, t));

	text = result.first;

	text->second->reloadable = reloadable;

	return TextureHandle(text);
}
开发者ID:jjardon,项目名称:eos,代码行数:26,代码来源:textureman.cpp

示例15: executeScript

void Functions::executeScript(Aurora::NWScript::FunctionContext &ctx) {
	Common::UString script = ctx.getParams()[0].getString();

	// Max resource name length is 16, and ExecuteScript should truncate accordingly
	script.truncate(16);

	if (!ResMan.hasResource(script, Aurora::kFileTypeNCS))
		return;

	Aurora::NWScript::Object *object = getParamObject(ctx, 1);
	try {
		Aurora::NWScript::NCSFile ncs(script);

		// Let the child script inherit the environment of this parent script
		Aurora::NWScript::VariableContainer *env = ctx.getCurrentEnvironment();
		if (env)
			ncs.setEnvironment(*env);

		ncs.run(object);
	} catch (Common::Exception &e) {
		e.add("Failed ExecuteScript(\"%s\", %s)", script.c_str(), Aurora::NWScript::formatTag(object).c_str());

		Common::printException(e, "WARNING: ");
	}
}
开发者ID:vincele,项目名称:xoreos,代码行数:25,代码来源:functions_action.cpp


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