mirror of
https://bitbucket.org/cosmicvoids/vide_public.git
synced 2025-07-07 16:51:13 +00:00
Imported newer version of some cosmotool files
This commit is contained in:
parent
90fd74d907
commit
555e0a4d5a
6 changed files with 260 additions and 80 deletions
30
external/cosmotool/src/fortran.cpp
vendored
30
external/cosmotool/src/fortran.cpp
vendored
|
@ -1,5 +1,5 @@
|
|||
/*+
|
||||
This is CosmoTool (./src/fortran.cpp) -- Copyright (C) Guilhem Lavaux (2007-2013)
|
||||
This is CosmoTool (./src/fortran.cpp) -- Copyright (C) Guilhem Lavaux (2007-2014)
|
||||
|
||||
guilhem.lavaux@gmail.com
|
||||
|
||||
|
@ -71,6 +71,16 @@ UnformattedRead::~UnformattedRead()
|
|||
delete f;
|
||||
}
|
||||
|
||||
int64_t UnformattedRead::position() const
|
||||
{
|
||||
return f->tellg();
|
||||
}
|
||||
|
||||
void UnformattedRead::seek(int64_t pos)
|
||||
{
|
||||
f->seekg(pos, istream::beg);
|
||||
}
|
||||
|
||||
// Todo implement primitive description
|
||||
void UnformattedRead::setOrdering(Ordering o)
|
||||
{
|
||||
|
@ -112,7 +122,7 @@ void UnformattedRead::beginCheckpoint()
|
|||
checkPointRef = (cSize == Check_32bits) ? 4 : 8;
|
||||
checkPointAccum = 0;
|
||||
|
||||
checkPointRef = (cSize == Check_32bits) ? readInt32() : readInt64();
|
||||
checkPointRef = (cSize == Check_32bits) ? readUint32() : readInt64();
|
||||
checkPointAccum = 0;
|
||||
|
||||
if (f->eof())
|
||||
|
@ -144,7 +154,7 @@ void UnformattedRead::endCheckpoint(bool autodrop)
|
|||
void UnformattedRead::readOrderedBuffer(void *buffer, int size)
|
||||
throw (InvalidUnformattedAccess)
|
||||
{
|
||||
if ((checkPointAccum+size) > checkPointRef)
|
||||
if ((checkPointAccum+(uint64_t)size) > checkPointRef)
|
||||
throw InvalidUnformattedAccess();
|
||||
|
||||
f->read((char *)buffer, size);
|
||||
|
@ -186,6 +196,20 @@ float UnformattedRead::readReal32()
|
|||
return a.f;
|
||||
}
|
||||
|
||||
uint32_t UnformattedRead::readUint32()
|
||||
throw (InvalidUnformattedAccess)
|
||||
{
|
||||
union
|
||||
{
|
||||
char b[4];
|
||||
uint32_t i;
|
||||
} a;
|
||||
|
||||
readOrderedBuffer(&a, 4);
|
||||
|
||||
return a.i;
|
||||
}
|
||||
|
||||
int32_t UnformattedRead::readInt32()
|
||||
throw (InvalidUnformattedAccess)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue