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


C++ StreamReader类代码示例

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


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

示例1: LoadVertexData

//=================================================================================================
// Wczytuje dane wierzcho³ków z modelu (na razie dzia³a tylko dla Vec3)
//=================================================================================================
void Mesh::LoadVertexData(VertexData* vd, StreamReader& stream)
{
	// read and check header
	Header head;
	if(!stream.Read(head))
		throw "Failed to read file header.";
	if(memcmp(head.format, "QMSH", 4) != 0)
		throw Format("Invalid file signature '%.4s'.", head.format);
	if(head.version != 20)
		throw Format("Invalid file version '%d'.", head.version);
	if(head.flags != F_PHYSICS)
		throw Format("Invalid mesh flags '%d'.", head.flags);
	vd->radius = head.radius;

	// read vertices
	uint size = sizeof(Vec3) * head.n_verts;
	if(!stream.Ensure(size))
		throw "Failed to read vertex data.";
	vd->verts.resize(head.n_verts);
	stream.Read(vd->verts.data(), size);

	// read faces
	size = sizeof(Face) * head.n_tris;
	if(!stream.Ensure(size))
		throw "Failed to read triangle data.";
	vd->faces.resize(head.n_tris);
	stream.Read(vd->faces.data(), size);
}
开发者ID:lcs2,项目名称:carpg,代码行数:31,代码来源:Mesh.cpp

示例2: ExtractEmbeds

void SISEmbeds::ExtractEmbeds(StreamReader& aReader )
	{
	iEmbeddedPkgUid = aReader.ReadInt32(); 
	iEmbeddedPkgName = aReader.ReadDescriptor();
	iEmbeddedVendorName = aReader.ReadDescriptor();
	iEmbeddedPkgIndex = aReader.ReadInt32();       
	}
开发者ID:cdaffara,项目名称:symbiandump-mw1,代码行数:7,代码来源:sisembeds.cpp

示例3: reiserfs_read

// reiserfs_read
static status_t
reiserfs_read(fs_volume *fs, fs_vnode *_node, void *cookie, off_t pos,
	void *buffer, size_t *bufferSize)
{
	TOUCH(fs);
//	FUNCTION_START();
//	Volume *volume = (Volume*)fs->private_volume;
	VNode *node = (VNode*)_node->private_node;
	FUNCTION(("((%Ld: %lu, %lu), %Ld, %p, %lu)\n", node->GetID(),
			  node->GetDirID(), node->GetObjectID(), pos, buffer,
			  *bufferSize));
	status_t error = B_OK;
	// don't read anything but files
	if (!node->IsFile()) {
		if (node->IsDir())
			error = B_IS_A_DIRECTORY;
		else
			error = B_BAD_VALUE;
	}

	// read
	StreamReader *reader = (StreamReader*)cookie;
	if (error == B_OK) {
		error = reader->Resume();
		if (error == B_OK) {
			error = reader->ReadAt(pos, buffer, *bufferSize, bufferSize);
			reader->Suspend();
		}
	}
	RETURN_ERROR(error);
}
开发者ID:luciang,项目名称:haiku,代码行数:32,代码来源:kernel_interface.cpp

示例4: fopen_s

StreamReader* FileUtil_Win32_Impl::LoadFile(const char* pszFileName)
{
	if (!pszFileName || strlen(pszFileName) <= 0) return NULL;

	std::string strFullPath = m_strRootPath + pszFileName;

	FILE* pFile = NULL;
	fopen_s(&pFile, strFullPath.c_str(), "rb");
	if (pFile == NULL)
	{
		LOGE("open file failed: %s", strFullPath.c_str());
		return NULL;
	}

	fseek(pFile, 0, SEEK_END);
	uint nFileSize = ftell(pFile);
	fseek(pFile, 0, SEEK_SET);

	char* pszBuffer = new char[nFileSize+1];
	int nReadSize = fread(pszBuffer, 1, nFileSize, pFile);
	fclose(pFile);

	pszBuffer[nFileSize] = '\0';

	StreamReader* pStreamReader = new StreamReader(pszBuffer, nFileSize, true);
	if (!pStreamReader || !pStreamReader->IsOK())
	{
		LOGE("create stream reader failed with file size: %d", nFileSize);
		SAFE_DELETE(pStreamReader);
		SAFE_DELETE_ARRAY(pszBuffer);
		return NULL;
	}

	return pStreamReader;
}
开发者ID:mshandle,项目名称:spank,代码行数:35,代码来源:FileUtil_Win32_Impl.cpp

示例5: reiserfs_open

// reiserfs_open
static status_t
reiserfs_open(fs_volume *fs, fs_vnode *_node, int openMode, void **cookie)
{
//	FUNCTION_START();
	Volume *volume = (Volume*)fs->private_volume;
	VNode *node = (VNode*)_node->private_node;
FUNCTION(("node: (%Ld: %lu, %lu)\n", node->GetID(), node->GetDirID(),
		  node->GetObjectID()));
	status_t error = B_OK;
	// check the open mode
	if ((openMode & O_RWMASK) == O_WRONLY || (openMode & O_RWMASK) == O_RDWR
		|| (openMode & (O_TRUNC | O_CREAT))) {
		error = B_READ_ONLY_DEVICE;
	}
	// create a StreamReader
	if (error == B_OK) {
		StreamReader *reader = new(nothrow) StreamReader(volume->GetTree(),
			node->GetDirID(), node->GetObjectID());
		if (reader) {
			error = reader->Suspend();
			if (error == B_OK)
				*cookie = reader;
			else
				delete reader;
		} else
			error = B_NO_MEMORY;
	}
	RETURN_ERROR(error);
}
开发者ID:luciang,项目名称:haiku,代码行数:30,代码来源:kernel_interface.cpp

示例6: FileRead

	static int FileRead(sqlite3_file* pFile, void* pBuf, int amt, sqlite3_int64 offset64)
	{
		DBFile* file = (DBFile*)pFile;
		StreamReader* reader = file->reader;

		if (reader == NULL)
			return SQLITE_IOERR_READ;

		assert(offset64 >= 0);

		size_t offset = (size_t)offset64; // TODO: support 64bit
		reader->seek(offset);

		int read = reader->readRaw(pBuf, amt);
		if (read < amt)
		{
			uint8* fillStart = (uint8*)pBuf;
			fillStart += read;

			// sqlite needs us to fill zeroes when IOERR_SHORT_READ
			memset(fillStart, 0, amt - read);
			return SQLITE_IOERR_SHORT_READ;
		}

		return SQLITE_OK;
	}
开发者ID:noriter,项目名称:nit,代码行数:26,代码来源:PackageService.cpp

示例7: PngReaderCallback

static void PngReaderCallback(png_structp pPngStruct, png_bytep pData, png_size_t nSize)
{
	StreamReader* pStream = (StreamReader*)png_get_io_ptr(pPngStruct);

	if (!pStream->Read(pData, nSize))
	{
		png_error(pPngStruct,"pngReaderCallback failed");
	}
}
开发者ID:mshandle,项目名称:spank,代码行数:9,代码来源:Image.cpp

示例8:

		void Array2D::init(StreamReader& s)
		{
			for(unsigned i = 0, length = s.ber(); i < length; i++) {
				unsigned index = s.ber();
				insert( index, std::auto_ptr<Array1D>( new Array1D(*this, index, s) ) );
			}

			if( toElement().hasOwner() ) rpg2k_analyze_assert( s.eof() );
		}
开发者ID:take-cheeze,项目名称:rpgtukuru-iphone,代码行数:9,代码来源:Array2D.cpp

示例9: ExtractControllerInfo

void SISControllerInfo::ExtractControllerInfo(StreamReader& aReader )
	{	
	iMajor = aReader.ReadInt32();
	iMinor = aReader.ReadInt32();
	iBuild = aReader.ReadInt32();
	iOffset = aReader.ReadInt32();
	iAlgorithmType = aReader.ReadInt32();
	char* controllerHash = aReader.ReadDescriptor();
	delete [] controllerHash;
	}
开发者ID:cdaffara,项目名称:symbiandump-mw1,代码行数:10,代码来源:siscontrollerinfo.cpp

示例10: StreamWriter

	void Program::Run()
	{
		StreamWriter* sw = new StreamWriter(new String("test.txt"));
		sw->WriteLine(new String("Hi! I'm a stream writer"));
		sw->Flush();
		sw->Close();
		StreamReader* sr = new StreamReader(new String("test.txt"));
		String* text = sr->ReadToEnd();
		sr->Close();
		Console::WriteLine(text);
	}
开发者ID:AlexAlbala,项目名称:AlterNative-Tests,代码行数:11,代码来源:Program.cpp

示例11: read

SyntaxTree::Node SyntaxTree:: read(StreamReader& reader)
{
   int type = reader.getDWord(-1);
   ref_t arg = reader.getDWord();
   int str = reader.getDWord();

   if (type == -1) {
      return Node();
   }
   else return Node(this, reader.Position(), (LexicalType)type, arg, str);
}
开发者ID:ELENA-LANG,项目名称:elena-lang,代码行数:11,代码来源:syntaxtree.cpp

示例12: HttpGet

static string HttpGet(string url) {
  HttpWebRequest req = WebRequest.Create(url)
                       as HttpWebRequest;
  string result = null;
  using (HttpWebResponse resp = req.GetResponse()
                                as HttpWebResponse)
  {
    StreamReader reader =
        new StreamReader(resp.GetResponseStream());
    result = reader.ReadToEnd();
  }
开发者ID:sebasmannem,项目名称:koios,代码行数:11,代码来源:REST_client.c

示例13: loadSectionContribs

static Error loadSectionContribs(FixedStreamArray<ContribType> &Output,
                                 StreamReader &Reader) {
  if (Reader.bytesRemaining() % sizeof(ContribType) != 0)
    return make_error<RawError>(
        raw_error_code::corrupt_file,
        "Invalid number of bytes of section contributions");

  uint32_t Count = Reader.bytesRemaining() / sizeof(ContribType);
  if (auto EC = Reader.readArray(Output, Count))
    return EC;
  return Error::success();
}
开发者ID:EdHurtig,项目名称:llvm,代码行数:12,代码来源:DbiStream.cpp

示例14: seekCallback

int StreamReader::seekCallback(void *data, const uint64_t pos)
{
    StreamReader *that = static_cast<StreamReader *>(data);
    if (static_cast<int64_t>(pos) > that->streamSize()) { // krazy:exclude=typedefs
        // attempt to seek past the end of our data.
        return -1;
    }

    that->setCurrentPos(pos);
    // this should return a true/false, but it doesn't, so assume success.

    return 0;
}
开发者ID:KDE,项目名称:phonon-vlc,代码行数:13,代码来源:streamreader.cpp

示例15: initialize

std::error_code ByteStream::initialize(StreamReader &Reader, uint32_t Length) {
  initialize(Length);
  std::error_code EC = Reader.readBytes(Data);
  if (EC)
    reset();
  return EC;
}
开发者ID:CAFxX,项目名称:llvm-1,代码行数:7,代码来源:ByteStream.cpp


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