# PhasicFlow: src/phasicFlow/streams/Stream/Istream.hpp Source File

Istream.hpp
Go to the documentation of this file.
/*------------------------------- phasicFlow ---------------------------------
O C enter of
O O E ngineering and
O O M ultiscale modeling of
OOOOOOO F luid flow
------------------------------------------------------------------------------
Copyright (C): www.cemf.ir
email: hamid.r.norouzi AT gmail.com
------------------------------------------------------------------------------
Licence:
This file is part of phasicFlow code. It is a free software for simulating
granular and multiphase flows. You can redistribute it and/or modify it under
the terms of GNU General Public License v3 or any other later versions.
phasicFlow is distributed to help others in their research in the field of
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-----------------------------------------------------------------------------*/
// based on OpenFOAM stream, with some modifications/simplifications
// to be tailored to our needs
#ifndef __Istream_hpp__
#define __Istream_hpp__
#include <limits>
#include <iostream>
#include "iIstream.hpp"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace pFlow
{
class Istream
:
public iIstream
{
// Private Data
word name_;
std::istream& is_;
//- Get the next valid character
char nextValid();
//- Read a word token
void readWordToken(token& t);
//- Read a variable name starting with '$'.
// Handles "$var" and "${var}" forms, permits '/' scoping character.
Istream& readVariable(word& str);
//- No copy assignment
void operator=(const Istream&) = delete;
public:
//- Construct wrapper around std::istream, set stream status
Istream( std::istream& is, const word& streamName);
//- Destructor
virtual ~Istream() = default;
//- Return the name of the stream
virtual const word& name() const
{
return name_;
}
//- Return non-const access to the name of the stream
virtual word& name()
{
return name_;
}
//- Return flags of output stream
virtual ios_base::fmtflags flags() const;
//- Raw, low-level get character function.
Istream& get(char& c);
//- Raw, low-level peek function.
// Does not remove the character from the stream.
// Returns the next character in the stream or EOF if the
// end of file is read.
int peek();
//- Raw, low-level getline (until delimiter) into a string.
Istream& getLine(word& str, char delim = '\n');
//- Low-level discard until delimiter
// return the number of characters extracted
std::streamsize getLine(std::nullptr_t, char delim = '\n');
//- Raw, low-level putback character function.
Istream& putback(const char c);
//- Return next token from stream
virtual iIstream& read(token& t) override;
//- Read a character
virtual iIstream& read(char& c) override;
//- Read a word
virtual iIstream& read(word& str) override;
//- Read a string
virtual iIstream& readString(word& str) override;
//- Read a int64
virtual iIstream& read(int64&) override;
//- Read a int32
virtual iIstream& read(int32&) override;
//- Read a int16
virtual iIstream& read(int16&) override;
//- Read a int8
virtual iIstream& read(int8&) override;
//- Read a label
virtual iIstream& read(label&) override;
//- Read a uint32
virtual iIstream& read(uint32&) override;
//- Read a uint16
virtual iIstream& read(uint16&) override;
//- Read a float
virtual iIstream& read(float& val) override;
//- Read a double
virtual iIstream& read(double& val) override;
//- Rewind the stream so that it may be read again
virtual void rewind();
//- Set stream flags
virtual ios_base::fmtflags flags(const ios_base::fmtflags flags);
//- Access to underlying std::istream
virtual std::istream& stdStream()
{
return is_;
}
//- Const access to underlying std::istream
virtual const std::istream& stdStream() const
{
return is_;
}
};
}
#endif
pFlow::Istream::operator=
void operator=(const Istream &)=delete
pFlow::Istream::stdStream
virtual std::istream & stdStream()
Definition: Istream.hpp:164
pFlow::token
Definition: token.hpp:42
pFlow::Istream::nextValid
char nextValid()
Definition: Istream.cpp:53
iIstream.hpp
pFlow::Istream::readWordToken
void readWordToken(token &t)
Definition: Istream.cpp:131
pFlow::uint32
unsigned int uint32
Definition: builtinTypes.hpp:59
pFlow::word
std::string word
Definition: builtinTypes.hpp:63
pFlow::Istream::name
virtual word & name()
Definition: Istream.hpp:84
pFlow::int64
long long int int64
Definition: builtinTypes.hpp:55
pFlow::Istream::name
virtual const word & name() const
Definition: Istream.hpp:78
pFlow
Definition: demComponent.hpp:28
pFlow::Istream::rewind
virtual void rewind()
Definition: Istream.cpp:850
pFlow::Istream::readString
virtual iIstream & readString(word &str) override
Definition: Istream.cpp:683
pFlow::Istream
Definition: Istream.hpp:38
pFlow::int16
short int int16
Definition: builtinTypes.hpp:51
pFlow::uint16
unsigned short int uint16
Definition: builtinTypes.hpp:57
pFlow::iIstream
Definition: iIstream.hpp:33
pFlow::Istream::readVariable
Istream & readVariable(word &str)
Definition: Istream.cpp:145
pFlow::int32
int int32
Definition: builtinTypes.hpp:53
pFlow::Istream::read
virtual iIstream & read(token &t) override
Definition: Istream.cpp:395
pFlow::Istream::~Istream
virtual ~Istream()=default
pFlow::Istream::get
Istream & get(char &c)
Definition: Istream.cpp:328
pFlow::Istream::Istream
Istream(std::istream &is, const word &streamName)
Definition: Istream.cpp:308
pFlow::Istream::name_
word name_
Definition: Istream.hpp:44
pFlow::label
std::size_t label
Definition: builtinTypes.hpp:61
pFlow::int8
signed char int8
Definition: builtinTypes.hpp:49
pFlow::Istream::peek
int peek()
Definition: Istream.cpp:342
pFlow::Istream::flags
virtual ios_base::fmtflags flags() const
Definition: Istream.cpp:864
pFlow::Istream::stdStream
virtual const std::istream & stdStream() const
Definition: Istream.hpp:170
pFlow::Istream::putback
Istream & putback(const char c)
Definition: Istream.cpp:378
pFlow::Istream::getLine
Istream & getLine(word &str, char delim='\n')
Definition: Istream.cpp:348
pFlow::Istream::is_
std::istream & is_
Definition: Istream.hpp:46