本文整理汇总了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);
}
示例2: ExtractEmbeds
void SISEmbeds::ExtractEmbeds(StreamReader& aReader )
{
iEmbeddedPkgUid = aReader.ReadInt32();
iEmbeddedPkgName = aReader.ReadDescriptor();
iEmbeddedVendorName = aReader.ReadDescriptor();
iEmbeddedPkgIndex = aReader.ReadInt32();
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
示例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");
}
}
示例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() );
}
示例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;
}
示例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);
}
示例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);
}
示例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();
}
示例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();
}
示例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;
}
示例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;
}