55 iss.read(
reinterpret_cast<char*
>(&value),
sizeof(Type));
72 auto& iss = is.stdStream();
75 value.resize(80,
'\0');
76 iss.read(&value[0], 80);
77 const std::streamsize gcount = iss.gcount();
78 value.erase(gcount <= 0 ? 0 : gcount);
83 const auto endp = value.find(
'\0');
85 if (endp != std::string::npos)
98 while (value.empty() && !is.eof())
135 const auto curr_pos = iss.tellg();
145 iss.seekg(0, std::ios_base::end);
146 const auto end_pos = iss.tellg();
164 iss.seekg(-80, std::ios_base::end);
170 int64_t footer_begin(0);
172 const auto endp = buffer.find(
"FILE_INDEX");
174 if (endp == std::string::npos)
198 iss.seekg(-88, std::ios_base::end);
208 iss.seekg(footer_begin);
215 for (int32_t step = 0; step < nSteps; ++step)
231void Foam::ensightReadFile::readString(std::string& value)
237void Foam::ensightReadFile::init(
bool detectFormat)
246 auto& iss = stdStream();
248 auto lineNum = lineNumber();
249 auto curr_pos = iss.tellg();
261 if (buffer.contains(
"Binary") || buffer.contains(
"binary"))
267 curr_pos = iss.tellg();
293 if (buffer.starts_with(
"BEGIN TIME STEP"))
298 curr_pos = iss.tellg();
300 timeStepFooterBegin_ = getTimeStepFooter(*
this, timeStepOffsets_);
302 if (timeStepOffsets_.empty())
305 timeStepOffsets_.resize(1, int64_t(curr_pos));
316 timeStepFooterBegin_ = -1;
317 timeStepOffsets_.clear();
320 DebugInfo<<
"Time-steps: " << timeStepOffsets_.size() <<
endl;
328Foam::ensightReadFile::ensightReadFile
334 timeStepFooterBegin_(-1)
340Foam::ensightReadFile::ensightReadFile
347 timeStepFooterBegin_(-1)
359 std::streamsize count
362 stdStream().
read(buf, count);
459 List<doubleVector>&
points
483 auto& iss = stdStream();
492 <<
" offset:" << label(timeStepOffsets_[
timeIndex]) <<
nl;
Input from file stream as an ISstream, normally using std::ifstream for the actual input.
virtual const fileName & name() const override
Read/write access to the name of the stream.
IFstream(const fileName &pathname, IOstreamOption streamOpt=IOstreamOption())
Construct from pathname, default or specified stream options.
virtual std::istream & stdStream() override
Access to underlying std::istream.
A simple container for options an IOstream can normally have.
streamFormat format() const noexcept
Get the current stream format.
streamFormat
Data format (ascii | binary | coherent).
@ ASCII
"ascii" (normal default)
label lineNumber() const noexcept
Const access to the current stream line number.
bool good() const noexcept
True if next operation might succeed.
bool eof() const noexcept
True if end of input seen.
ISstream & getLine(std::string &str, char delim='\n')
Raw, low-level getline (until delimiter) into a string.
void syncState()
Set stream state to match that of the std::istream.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
virtual Istream & read(token &)=0
Return next token from stream.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void resize_nocopy(const label len)
Adjust allocated size of list without necessarily.
void clear()
Clear the list, i.e. set size to zero.
A variant of IFstream with specialised handling for Ensight reading of strings, integers and floats (...
bool seekTime(const label timeIndex)
Transient single-file: seek to the file position corresponding to the given time index.
void readPoints(const label nPoints, List< floatVector > &points)
Component-wise reading of points/coordinates. Read all x components, y components and z components.
static int64_t getTimeStepFooter(IFstream &is, List< int64_t > &offsets)
Extract time step footer information (if any).
label nTimes() const noexcept
Transient single-file: the number of time steps within the file.
static int debug
Debug switch.
Istream & readKeyword(string &key)
Read element keyword. Currently the same as read(string).
virtual Istream & read(char *buf, std::streamsize count) override
Binary read.
A class for handling file names.
static bool split(const std::string &line, std::string &key, std::string &val)
Macro definitions for debug switches.
#define registerDebugSwitchWithName(Type, Tag, Name)
Define the debug information, lookup as Name.
#define defineDebugSwitchWithName(Type, Name, Value)
Define the debug information, lookup as Name.
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
#define DebugInfo
Report an information message using Foam::Info.
Namespace for handling debugging switches.
Foam::SubStrings splitSpace(const std::string &str, std::string::size_type pos=0)
Split string into sub-strings at whitespace (TAB, NL, VT, FF, CR, SPC).
void inplaceTrimRight(std::string &s)
Trim trailing whitespace inplace.
static Type getPrimitive(IFstream &is)
bool read(const char *buf, int32_t &val)
Same as readInt32.
static void readEnsightString(IFstream &is, std::string &value)
messageStream Info
Information stream (stdout output on master, null elsewhere).
Ostream & endl(Ostream &os)
Add newline and flush stream.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
errorManipArg< error, int > exit(error &err, const int errNo=1)
int64_t readInt64(Istream &is)
Read int64_t from stream.
constexpr char nl
The newline '\n' character (0x0a).