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


C++ MemoryReadStream::size方法代码示例

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


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

示例1: Cmd_Extract

bool Console::Cmd_Extract(int argc, const char **argv) {
	if (argc != 5) {
		DebugPrintf("Extract a file from the game's archives\n");
		DebugPrintf("Usage :\n");
		DebugPrintf("extract [room] [node id] [face number] [object type]\n");
		return true;
	}

	// Room names are uppercase
	Common::String room = Common::String(argv[1]);
	room.toUppercase();

	uint16 id = atoi(argv[2]);
	uint16 face = atoi(argv[3]);
	DirectorySubEntry::ResourceType type = (DirectorySubEntry::ResourceType) atoi(argv[4]);

	const DirectorySubEntry *desc = _vm->getFileDescription(room.c_str(), id, face, type);

	if (!desc) {
		DebugPrintf("File with room %s, id %d, face %d and type %d does not exist\n", room.c_str(), id, face, type);
		return true;
	}

	Common::MemoryReadStream *s = desc->getData();
	Common::String filename = Common::String::format("node%s_%d_face%d.%d", room.c_str(), id, face, type);
	Common::DumpFile f;
	f.open(filename);

	uint8 *buf = new uint8[s->size()];

	s->read(buf, s->size());
	f.write(buf, s->size());

	delete[] buf;

	f.close();

	delete s;

	DebugPrintf("File '%s' successfully written\n", filename.c_str());

	return true;
}
开发者ID:moshverhavikk,项目名称:grim_mouse,代码行数:43,代码来源:console.cpp

示例2: stream

GTEST_TEST_F(LanguageManager, preParseColorCodes) {
	static const byte kColorString    [] = "<c""\xAB""\xCD""\xEF"">Foobar</c>";
	static const byte kPreparsedString[] = "<cABCDEFFF>Foobar</c>";

	Common::MemoryReadStream stream(kColorString);

	Common::MemoryReadStream *preparsed = LangMan.preParseColorCodes(stream);
	ASSERT_NE(preparsed, static_cast<Common::MemoryReadStream *>(0));
	ASSERT_EQ(preparsed->size(), sizeof(kPreparsedString));

	for (size_t i = 0; i < sizeof(kPreparsedString); i++)
		EXPECT_EQ(preparsed->readChar(), kPreparsedString[i]) << "At index " << i;

	delete preparsed;
}
开发者ID:xoreos,项目名称:phaethon,代码行数:15,代码来源:language.cpp

示例3: stream

GTEST_TEST(MemoryReadStream, readStream) {
	static const byte data[3] = { 0x12, 0x34, 0x56 };
	Common::MemoryReadStream stream(data);

	Common::MemoryReadStream *streamRead = stream.readStream(ARRAYSIZE(data));

	EXPECT_EQ(streamRead->size(), ARRAYSIZE(data));
	for (size_t i = 0; i < ARRAYSIZE(data); i++)
		EXPECT_EQ(streamRead->readByte(), data[i]) << "At index " << i;

	delete streamRead;

	stream.seek(0);

	EXPECT_THROW(stream.readStream(ARRAYSIZE(data) + 1), Common::Exception);
}
开发者ID:Supermanu,项目名称:xoreos,代码行数:16,代码来源:memreadstream.cpp

示例4: srcStream

			warning("Failed to find audio entry %i", number);
			return NULL;
		}
	} else {
		audioRes = _resMan->findResource(ResourceId(kResourceTypeAudio36, volume, number), false);
		if (!audioRes) {
			warning("Failed to find audio entry (%i, %i, %i, %i, %i)", volume, (number >> 24) & 0xff,
					(number >> 16) & 0xff, (number >> 8) & 0xff, number & 0xff);
			return NULL;
		}
	}

	// Load the data into a MemoryReadStream. The AudioStream here cannot rely on
	// memory from the resource manager.
	Common::MemoryReadStream srcStream(audioRes->data, audioRes->size, DisposeAfterUse::NO);
	Common::ScopedPtr<Common::SeekableReadStream> stream(srcStream.readStream(srcStream.size()));

	byte audioFlags;
	uint32 audioCompressionType = audioRes->getAudioCompressionType();
	Audio::SeekableAudioStream *audioSeekStream = 0;

	if (audioCompressionType) {
#if (defined(USE_MAD) || defined(USE_VORBIS) || defined(USE_FLAC))
		switch (audioCompressionType) {
		case MKTAG('M','P','3',' '):
#ifdef USE_MAD
			audioSeekStream = Audio::makeMP3Stream(stream.release(), DisposeAfterUse::YES);
#endif
			break;
		case MKTAG('O','G','G',' '):
#ifdef USE_VORBIS
开发者ID:project-cabal,项目名称:cabal,代码行数:31,代码来源:audio.cpp


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