streams updated, processorsStream, masterStream
This commit is contained in:
parent
bb7dc17c67
commit
100a211645
|
@ -58,7 +58,6 @@ endif()
|
|||
|
||||
if(pFlow_Build_MPI)
|
||||
find_package(MPI REQUIRED)
|
||||
link_libraries(MPI::MPI_CXX)
|
||||
endif()
|
||||
|
||||
|
||||
|
@ -78,7 +77,7 @@ add_subdirectory(src)
|
|||
#add_subdirectory(utilities)
|
||||
|
||||
#add_subdirectory(DEMSystems)
|
||||
#add_subdirectory(testIO)
|
||||
add_subdirectory(testIO)
|
||||
|
||||
install(FILES "${PROJECT_BINARY_DIR}/phasicFlowConfig.H"
|
||||
DESTINATION include)
|
||||
|
|
|
@ -4,13 +4,37 @@ types/basicTypes/bTypesFunctions.cpp
|
|||
types/basicTypes/Logical.cpp
|
||||
types/types.cpp
|
||||
|
||||
|
||||
|
||||
globals/error.cpp
|
||||
|
||||
streams/token/tokenIO.cpp
|
||||
streams/token/token.cpp
|
||||
streams/iStream/IOstream.cpp
|
||||
streams/iStream/iOstream.cpp
|
||||
streams/iStream/iIstream.cpp
|
||||
streams/Stream/Ostream.cpp
|
||||
streams/Stream/Istream.cpp
|
||||
streams/processorOstream/processorOstream.cpp
|
||||
streams/masterOstream/masterOstream.cpp
|
||||
streams/TStream/iTstream.cpp
|
||||
streams/TStream/oTstream.cpp
|
||||
streams/Fstream/iFstream.cpp
|
||||
streams/Fstream/oFstream.cpp
|
||||
streams/Fstream/fileStream.cpp
|
||||
streams/streams.cpp
|
||||
|
||||
fileSystem/fileSystem.cpp
|
||||
|
||||
processors/processors.cpp
|
||||
)
|
||||
|
||||
globals/error.cpp)
|
||||
|
||||
set(link_libs)
|
||||
if(MPI_FOUND)
|
||||
set(link_libs Kokkos::kokkos tbb PRIVATE MPI::MPI_CXX)
|
||||
else()
|
||||
set(link_libs Kokkos::kokkos tbb)
|
||||
endif()
|
||||
|
||||
pFlow_add_library_install(phasicFlow SourceFiles link_libs)
|
||||
|
||||
target_include_directories(phasicFlow PUBLIC ./globals)
|
||||
|
||||
|
|
|
@ -284,13 +284,13 @@ pFlow::fileSystem pFlow::operator +
|
|||
return path;
|
||||
}
|
||||
|
||||
pFlow::iOstream& pFlow::operator << (iOstream& os, fileSystem fs)
|
||||
pFlow::iOstream& pFlow::operator << (iOstream& os, const fileSystem& fs)
|
||||
{
|
||||
os << fs.path_.c_str();
|
||||
return os;
|
||||
}
|
||||
|
||||
std::ostream& pFlow::operator << (std::ostream& os, fileSystem fs)
|
||||
std::ostream& pFlow::operator << (std::ostream& os, const fileSystem& fs)
|
||||
{
|
||||
os << fs.path_.c_str();
|
||||
return os;
|
||||
|
|
|
@ -29,21 +29,20 @@ Licence:
|
|||
namespace pFlow
|
||||
{
|
||||
|
||||
|
||||
// - Forward
|
||||
class iOstream;
|
||||
class ostream;
|
||||
class fileSystem;
|
||||
|
||||
iOstream& operator <<
|
||||
(
|
||||
iOstream& os,
|
||||
fileSystem fs
|
||||
const fileSystem& fs
|
||||
);
|
||||
|
||||
std::ostream& operator <<
|
||||
(
|
||||
std::ostream& os,
|
||||
fileSystem fs
|
||||
const fileSystem& fs
|
||||
);
|
||||
|
||||
|
||||
|
@ -59,29 +58,40 @@ fileSystem operator +
|
|||
const word fName
|
||||
);
|
||||
|
||||
// a class to manage file/directory names
|
||||
/**
|
||||
* Manages file pathes, manupulate and combines them.
|
||||
*
|
||||
*/
|
||||
class fileSystem
|
||||
{
|
||||
public:
|
||||
|
||||
using pathType = std::filesystem::path;
|
||||
|
||||
protected:
|
||||
|
||||
/// File path
|
||||
std::filesystem::path path_;
|
||||
|
||||
/// Is this a directory path?
|
||||
bool isDir_;
|
||||
|
||||
|
||||
// protected static variables
|
||||
/// Not premitted chars in file name
|
||||
inline static word notPermittedCharsFile = word(" ") + word("\t\n\0;:?*/<>\"?\'");
|
||||
|
||||
// protected methods
|
||||
|
||||
/// Is name is valid for a file?
|
||||
bool static validFileName(const word& name)
|
||||
{
|
||||
return name.find_first_of(notPermittedCharsFile);
|
||||
}
|
||||
|
||||
/// Is a valid file name?
|
||||
bool static checkFileName(const word& name);
|
||||
|
||||
public:
|
||||
|
||||
/// return current working directory
|
||||
inline static fileSystem CWD()
|
||||
{
|
||||
return fileSystem(std::filesystem::current_path().c_str());
|
||||
|
@ -89,92 +99,103 @@ public:
|
|||
|
||||
public:
|
||||
|
||||
//// - Constructors
|
||||
|
||||
typedef std::filesystem::path pathType;
|
||||
|
||||
|
||||
/// Default
|
||||
fileSystem():
|
||||
path_(),
|
||||
isDir_(true)
|
||||
{}
|
||||
// Constructors
|
||||
|
||||
/// From dir and file name
|
||||
fileSystem( const word& dir, const word& file = "");
|
||||
|
||||
/// From dir and file name
|
||||
fileSystem( const char* dir, const char* file = "");
|
||||
|
||||
/// Copy
|
||||
fileSystem( const pathType& path );
|
||||
|
||||
/// Copy
|
||||
fileSystem(const fileSystem&) = default;
|
||||
|
||||
/// Move
|
||||
fileSystem(fileSystem&&) = default;
|
||||
|
||||
/// Copy assignment
|
||||
fileSystem& operator = (const fileSystem&) = default;
|
||||
|
||||
/// Move assignment
|
||||
fileSystem& operator = (fileSystem&&) = default;
|
||||
|
||||
/// Destructor
|
||||
~fileSystem() = default;
|
||||
|
||||
// Methods
|
||||
//// - Methods
|
||||
|
||||
/// Is directory?
|
||||
bool isDir() const
|
||||
{
|
||||
return isDir_;
|
||||
}
|
||||
|
||||
/// Const access to path
|
||||
const pathType& path()const
|
||||
{
|
||||
return path_;
|
||||
}
|
||||
|
||||
/// Path in word type
|
||||
word wordPath()const
|
||||
{
|
||||
return word(path_.c_str());
|
||||
}
|
||||
|
||||
// dir path of this
|
||||
/// Dir part of the path
|
||||
fileSystem dirPath() const;
|
||||
|
||||
// file name of this (if any)
|
||||
/// File name part of the path (if any)
|
||||
word fileName() const;
|
||||
|
||||
// absolute path of this
|
||||
/// Absolute path of this
|
||||
fileSystem absolute()const;
|
||||
|
||||
|
||||
//fileSystem relative()const;
|
||||
|
||||
// canonical path of this (it should exist)
|
||||
/// Canonical path of this (it should exist)
|
||||
fileSystem canonical()const;
|
||||
|
||||
// only operate on dir path
|
||||
// check if the dir path exists
|
||||
/// Only operate on dir path
|
||||
/// Check if the dir path exists
|
||||
bool dirExist()const;
|
||||
|
||||
// check if the path exists
|
||||
/// Check if the path exists
|
||||
bool exist()const;
|
||||
|
||||
// operate on dir path only
|
||||
// create dir based on the path and returns the canonical path
|
||||
/// Operate on dir path only
|
||||
/// Create dir based on the path and returns the canonical path
|
||||
fileSystem createDirs()const;
|
||||
|
||||
|
||||
// if this is dir path, add the filename to dir path
|
||||
// if it is file path, replace the file name
|
||||
/// If this is dir path, add the filename to dir path
|
||||
/// if it is file path, replace the file name
|
||||
void operator += (const word& fileName);
|
||||
|
||||
// it operates on dir path only
|
||||
// it adds the dir path of fs to this
|
||||
/// It operates on dir path only
|
||||
/// Add the dir path of fs to this
|
||||
void operator /=(const fileSystem& fs );
|
||||
|
||||
// Create a dir path from dir path of fs1 and fas2 in the
|
||||
// form of fs1/fs2
|
||||
/// Create a dir path from dir path of fs1 and fas2 in the
|
||||
/// form of fs1/fs2
|
||||
friend fileSystem operator /(const fileSystem& fs1, const fileSystem& fs2 );
|
||||
|
||||
|
||||
// return the dir path of this
|
||||
/// Return the dir path of this
|
||||
fileSystem operator()(bool retDir = true) const;
|
||||
|
||||
//// - IO
|
||||
friend iOstream& operator << (iOstream& os, const fileSystem& fs);
|
||||
|
||||
friend iOstream& operator << (iOstream& os, fileSystem fs);
|
||||
|
||||
friend std::ostream& operator << (std::ostream& os, fileSystem fs);
|
||||
friend std::ostream& operator << (std::ostream& os, const fileSystem& fs);
|
||||
|
||||
};
|
||||
|
||||
|
@ -182,18 +203,22 @@ public:
|
|||
using fileSystemList = List<fileSystem>;
|
||||
|
||||
|
||||
|
||||
/// Free function to reture current working directory
|
||||
inline fileSystem CWD()
|
||||
{
|
||||
return fileSystem::CWD();
|
||||
}
|
||||
|
||||
/// Free function to check if the path is dir path
|
||||
bool isDirectory(const fileSystem& path);
|
||||
|
||||
/// free function to check if the path is regular file
|
||||
bool isRegularFile(const fileSystem& path);
|
||||
|
||||
/// A list of sub-directories that exist in path.
|
||||
fileSystemList subDirectories(const fileSystem& path);
|
||||
|
||||
/// A list of file paths that exist in the path.
|
||||
fileSystemList containingFiles(const fileSystem& path);
|
||||
|
||||
} // pFlow
|
||||
|
|
|
@ -37,8 +37,8 @@ pFlow::iOstream& fatalErrorMessage(const char* fileName, int linNumber )
|
|||
{
|
||||
|
||||
errorStream<<"\n>>> Fatal error in phasicFlow\n" <<
|
||||
"Error occured in source file "<< redText(fileName) <<
|
||||
" at line "<<redText(linNumber)<<'\n';
|
||||
"Error occured in source file "<< Red_Text(fileName) <<
|
||||
" at line "<<Red_Text(linNumber)<<'\n';
|
||||
return errorStream;
|
||||
|
||||
}
|
||||
|
@ -47,9 +47,9 @@ pFlow::iOstream& fatalErrorInMessage(const char* fnName, const char* fileName, i
|
|||
{
|
||||
|
||||
errorStream<<"\n>>> Fatal error in phasicFlow\n" <<
|
||||
" Error is issued in function " << redText(fnName)<<
|
||||
", located in file "<< redText(fileName) <<
|
||||
" at line "<< redText(linNumber) << '\n';
|
||||
" Error is issued in function " << Red_Text(fnName)<<
|
||||
", located in file "<< Red_Text(fileName) <<
|
||||
" at line "<< Red_Text(linNumber) << '\n';
|
||||
return errorStream;
|
||||
}
|
||||
|
||||
|
@ -57,9 +57,9 @@ pFlow::iOstream& notImplementedErrorMessage(const char*fnName, const char* fileN
|
|||
{
|
||||
|
||||
errorStream<<"\n>>> Fatal error in phasicFlow\n";
|
||||
errorStream<<" Function "<< redText(fnName) << " has not implmented yet!\n" <<
|
||||
" Function definition is in source file "<< redText(fileName) <<
|
||||
" at line "<< redText(lineNumber) <<'\n';
|
||||
errorStream<<" Function "<< Red_Text(fnName) << " has not implmented yet!\n" <<
|
||||
" Function definition is in source file "<< Red_Text(fileName) <<
|
||||
" at line "<< Red_Text(lineNumber) <<'\n';
|
||||
return errorStream;
|
||||
}
|
||||
|
||||
|
@ -68,10 +68,10 @@ pFlow::iOstream& ioErrorMessage(const char* fileName, int fileLineNumber, const
|
|||
{
|
||||
|
||||
errorStream<<"\n>>> Fatal IO file error\n"<<
|
||||
" IO error at number "<<redText(fileLineNumber)<<
|
||||
" of file " << redText(fileName)<<'\n';
|
||||
errorStream<<" IO operation is peformed from function "<<redText(fnName) <<
|
||||
" in file "<< redText(fName)<< " at line "<< redText(lNumber) <<'\n';
|
||||
" IO error at number "<<Red_Text(fileLineNumber)<<
|
||||
" of file " << Red_Text(fileName)<<'\n';
|
||||
errorStream<<" IO operation is peformed from function "<<Red_Text(fnName) <<
|
||||
" in file "<< Red_Text(fName)<< " at line "<< Red_Text(lNumber) <<'\n';
|
||||
return errorStream;
|
||||
}
|
||||
|
||||
|
@ -85,9 +85,9 @@ pFlow::iOstream& warningMessage(const char* fnName, const char* fileName, int li
|
|||
{
|
||||
|
||||
errorStream<<"\n>>> Warning in phasicFlow\n"<<
|
||||
" Warning is issued in function " << yellowText(fnName)<<
|
||||
" in source file "<< yellowText(fileName) <<
|
||||
" at line "<< yellowText(linNumber) <<'\n';
|
||||
" Warning is issued in function " << Yellow_Text(fnName)<<
|
||||
" in source file "<< Yellow_Text(fileName) <<
|
||||
" at line "<< Yellow_Text(linNumber) <<'\n';
|
||||
return errorStream;
|
||||
}
|
||||
|
||||
|
|
|
@ -42,8 +42,12 @@ void pFlow::processors::initProcessors(int argc, char *argv[])
|
|||
|
||||
processors::globalSize_ = MPI::COMM_WORLD.Get_size();
|
||||
processors::globalRank_ = MPI::COMM_WORLD.Get_rank();
|
||||
//CheckMPI(MPI_comm_size( MPI_COMM_WORLD, &processors::globalSize_), true );
|
||||
//CheckMPI(MPI_comm_rank( MPI_COMM_WORLD, &processors::globalRank_), true );
|
||||
|
||||
pFlow::pOutput.activatePrefix();
|
||||
pFlow::pOutput.setPrefixNum(processors::globalRank_);
|
||||
|
||||
pFlow::mOutput.setMasterSlave(processors::isMaster());
|
||||
pFlow::errReport.setMasterSlave(processors::isMaster());
|
||||
}
|
||||
#else
|
||||
|
||||
|
|
|
@ -17,9 +17,6 @@ Licence:
|
|||
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
-----------------------------------------------------------------------------*/
|
||||
// based on OpenFOAM stream, with some modifications/simplifications
|
||||
// to be tailored to our needs
|
||||
|
||||
|
||||
#include "fileStream.hpp"
|
||||
#include "error.hpp"
|
||||
|
@ -133,6 +130,3 @@ std::ofstream& pFlow::fileStream::outStream()
|
|||
{
|
||||
return outStream_();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -33,49 +33,61 @@ Licence:
|
|||
namespace pFlow
|
||||
{
|
||||
|
||||
/**
|
||||
* Creates and manages an input/output file stream
|
||||
* with specified format.
|
||||
*
|
||||
* It is based on OpenFOAM stream, with some modifications/simplifications
|
||||
* to be tailored to our needs.
|
||||
*/
|
||||
class fileStream
|
||||
{
|
||||
protected:
|
||||
|
||||
// - in file stream
|
||||
/// in file stream
|
||||
uniquePtr<std::ifstream> inStream_;
|
||||
|
||||
// - out file stream
|
||||
/// out file stream
|
||||
uniquePtr<std::ofstream> outStream_;
|
||||
|
||||
bool binary_ = false;
|
||||
|
||||
// - open input file
|
||||
/// open input file
|
||||
void openInFile(const fileSystem& path);
|
||||
|
||||
// - open output file
|
||||
/// open output file
|
||||
void openOutFile(const fileSystem& path);
|
||||
|
||||
// - close streams
|
||||
/// close streams
|
||||
void close();
|
||||
|
||||
public:
|
||||
|
||||
// - Constructors
|
||||
//// - Constructors
|
||||
|
||||
/// From file path and input type and format.
|
||||
fileStream( const fileSystem& path, bool outStream = false, bool binary = false);
|
||||
|
||||
/// No copy
|
||||
fileStream(const fileStream&)= delete;
|
||||
|
||||
/// No assignment
|
||||
fileStream& operator=(const fileStream&)=delete;
|
||||
|
||||
/// Destructor
|
||||
virtual ~fileStream()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
|
||||
// - access
|
||||
//// - Access
|
||||
|
||||
/// Access input file stream
|
||||
std::ifstream& inStream();
|
||||
|
||||
/// Access output file stream
|
||||
std::ofstream& outStream();
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -17,9 +17,6 @@ Licence:
|
|||
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
-----------------------------------------------------------------------------*/
|
||||
// based on OpenFOAM stream, with some modifications/simplifications
|
||||
// to be tailored to our needs
|
||||
|
||||
|
||||
#include "iFstream.hpp"
|
||||
|
||||
|
|
|
@ -17,9 +17,6 @@ Licence:
|
|||
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 __iFstream_hpp__
|
||||
#define __iFstream_hpp__
|
||||
|
||||
|
@ -31,7 +28,12 @@ Licence:
|
|||
namespace pFlow
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* Input file stream for reading binary or ascii data from a file.
|
||||
*
|
||||
* It is based on OpenFOAM stream, with some modifications/simplifications
|
||||
* to be tailored to our needs.
|
||||
*/
|
||||
class iFstream
|
||||
:
|
||||
public fileStream,
|
||||
|
@ -39,16 +41,18 @@ class iFstream
|
|||
{
|
||||
public:
|
||||
|
||||
// - Constructor
|
||||
//// - Constructors
|
||||
|
||||
/// From file path and format
|
||||
iFstream (const fileSystem& path, bool binary = false);
|
||||
|
||||
// no copy constructor
|
||||
/// No copy constructor
|
||||
iFstream( const iFstream& src) = delete;
|
||||
|
||||
// no assignment
|
||||
/// No assignment
|
||||
iFstream& operator = (const iFstream& rhs) = delete;
|
||||
|
||||
// - Destructor
|
||||
/// Destructor
|
||||
virtual ~iFstream() = default;
|
||||
|
||||
};
|
||||
|
|
|
@ -17,8 +17,6 @@ Licence:
|
|||
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
-----------------------------------------------------------------------------*/
|
||||
// based on OpenFOAM stream, with some modifications/simplifications
|
||||
// to be tailored to our needs
|
||||
|
||||
|
||||
#include "oFstream.hpp"
|
||||
|
|
|
@ -17,10 +17,6 @@ Licence:
|
|||
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 __oFstream_hpp__
|
||||
#define __oFstream_hpp__
|
||||
|
||||
|
@ -32,7 +28,13 @@ Licence:
|
|||
namespace pFlow
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* Output file stream to send binary or ascii data to a file.
|
||||
*
|
||||
* It is based on OpenFOAM stream, with some modifications/simplifications
|
||||
* to be tailored to our needs
|
||||
*
|
||||
*/
|
||||
class oFstream
|
||||
:
|
||||
public fileStream,
|
||||
|
@ -40,16 +42,18 @@ class oFstream
|
|||
{
|
||||
public:
|
||||
|
||||
// Constructor
|
||||
//// - Constructors
|
||||
|
||||
/// From file path and format
|
||||
oFstream (const fileSystem& path, bool binary = false);
|
||||
|
||||
// no copy constructor
|
||||
/// No copy constructor
|
||||
oFstream( const oFstream& src) = delete;
|
||||
|
||||
// no assignment
|
||||
/// No assignment
|
||||
oFstream& operator = (const oFstream& rhs) = delete;
|
||||
|
||||
// Destructor
|
||||
/// Destructor
|
||||
virtual ~oFstream() = default;
|
||||
|
||||
};
|
||||
|
|
|
@ -17,10 +17,6 @@ Licence:
|
|||
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
-----------------------------------------------------------------------------*/
|
||||
// based on OpenFOAM stream, with some modifications/simplifications
|
||||
// to be tailored to our needs
|
||||
|
||||
|
||||
#include "Istream.hpp"
|
||||
#include "token.hpp"
|
||||
#include "error.hpp"
|
||||
|
@ -797,12 +793,6 @@ pFlow::iIstream& pFlow::Istream::read(int32& val)
|
|||
return *this;
|
||||
}
|
||||
|
||||
pFlow::iIstream& pFlow::Istream::read(int16& val)
|
||||
{
|
||||
is_ >> val;
|
||||
setState(is_.rdstate());
|
||||
return *this;
|
||||
}
|
||||
|
||||
pFlow::iIstream& pFlow::Istream::read(int8& val)
|
||||
{
|
||||
|
@ -811,7 +801,7 @@ pFlow::iIstream& pFlow::Istream::read(int8& val)
|
|||
return *this;
|
||||
}
|
||||
|
||||
pFlow::iIstream& pFlow::Istream::read(label& val)
|
||||
pFlow::iIstream& pFlow::Istream::read(uint64& val)
|
||||
{
|
||||
is_ >> val;
|
||||
setState(is_.rdstate());
|
||||
|
@ -825,7 +815,7 @@ pFlow::iIstream& pFlow::Istream::read(uint32& val)
|
|||
return *this;
|
||||
}
|
||||
|
||||
pFlow::iIstream& pFlow::Istream::read(uint16& val)
|
||||
pFlow::iIstream& pFlow::Istream::read(uint8& val)
|
||||
{
|
||||
is_ >> val;
|
||||
setState(is_.rdstate());
|
||||
|
|
|
@ -17,10 +17,6 @@ Licence:
|
|||
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__
|
||||
|
||||
|
@ -34,15 +30,22 @@ Licence:
|
|||
namespace pFlow
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* Standard input stream for binary and ascii data
|
||||
*
|
||||
* It is based on OpenFOAM stream, with some modifications/simplifications
|
||||
* to be tailored to our needs.
|
||||
*/
|
||||
class Istream
|
||||
:
|
||||
public iIstream
|
||||
{
|
||||
// Private Data
|
||||
//- Private Data
|
||||
|
||||
/// Stream name
|
||||
word name_;
|
||||
|
||||
/// Input stream
|
||||
std::istream& is_;
|
||||
|
||||
|
||||
|
@ -63,6 +66,7 @@ class Istream
|
|||
|
||||
public:
|
||||
|
||||
//// - Constructors
|
||||
|
||||
/// Construct wrapper around std::istream, set stream status
|
||||
Istream( std::istream& is, const word& streamName, writeFormat wf = ASCII);
|
||||
|
@ -89,22 +93,22 @@ public:
|
|||
virtual ios_base::fmtflags flags() const;
|
||||
|
||||
|
||||
//// Read Functions
|
||||
//// - Read Functions
|
||||
|
||||
/// 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.
|
||||
/// 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
|
||||
/// return the number of characters extracted
|
||||
std::streamsize getLine(std::nullptr_t, char delim = '\n');
|
||||
|
||||
/// Raw, low-level putback character function.
|
||||
|
|
|
@ -17,8 +17,6 @@ Licence:
|
|||
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
-----------------------------------------------------------------------------*/
|
||||
// based on OpenFOAM stream, with some modifications/simplifications
|
||||
// to be tailored to our needs
|
||||
|
||||
#include "error.hpp"
|
||||
#include "token.hpp"
|
||||
|
@ -181,21 +179,14 @@ pFlow::iOstream& pFlow::Ostream::write(const int32 val)
|
|||
return *this;
|
||||
}
|
||||
|
||||
/*pFlow::iOstream& pFlow::Ostream::write(const int16 val)
|
||||
pFlow::iOstream& pFlow::Ostream::write(const int8 val)
|
||||
{
|
||||
os_ << val;
|
||||
setState(os_.rdstate());
|
||||
return *this;
|
||||
}
|
||||
|
||||
pFlow::iOstream& pFlow::Ostream::write(const int8 val)
|
||||
{
|
||||
os_ << val;
|
||||
setState(os_.rdstate());
|
||||
return *this;
|
||||
}*/
|
||||
|
||||
pFlow::iOstream& pFlow::Ostream::write(const label val)
|
||||
pFlow::iOstream& pFlow::Ostream::write(const uint64 val)
|
||||
{
|
||||
os_ << val;
|
||||
setState(os_.rdstate());
|
||||
|
@ -209,7 +200,7 @@ pFlow::iOstream& pFlow::Ostream::write(const uint32 val)
|
|||
return *this;
|
||||
}
|
||||
|
||||
pFlow::iOstream& pFlow::Ostream::write(const uint16 val)
|
||||
pFlow::iOstream& pFlow::Ostream::write(const uint8 val)
|
||||
{
|
||||
os_ << val;
|
||||
setState(os_.rdstate());
|
||||
|
@ -253,9 +244,6 @@ pFlow::iOstream& pFlow::Ostream::write
|
|||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void pFlow::Ostream::indent()
|
||||
{
|
||||
for (unsigned short i = 0; i < indentLevel_*indentSize_; ++i)
|
||||
|
@ -270,14 +258,12 @@ void pFlow::Ostream::flush()
|
|||
os_.flush();
|
||||
}
|
||||
|
||||
|
||||
void pFlow::Ostream::endl()
|
||||
{
|
||||
write('\n');
|
||||
os_.flush();
|
||||
}
|
||||
|
||||
|
||||
std::ios_base::fmtflags pFlow::Ostream::flags() const
|
||||
{
|
||||
return os_.flags();
|
||||
|
|
|
@ -30,25 +30,35 @@ Licence:
|
|||
namespace pFlow
|
||||
{
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Standard output stream for BINARY and ASCII formats
|
||||
*
|
||||
* It is based on OpenFOAM stream, with some modifications/simplifications
|
||||
* to be tailored to our needs
|
||||
*/
|
||||
class Ostream
|
||||
:
|
||||
public iOstream
|
||||
{
|
||||
private:
|
||||
|
||||
// - private data members
|
||||
|
||||
/// Stream name
|
||||
word name_;
|
||||
|
||||
/// Output stream
|
||||
std::ostream& os_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
///- Constructors
|
||||
|
||||
/// Construct from components
|
||||
Ostream ( std::ostream& os, const word& streamName, writeFormat wf = ASCII);
|
||||
|
||||
/// no copy construct
|
||||
/// No copy construct
|
||||
Ostream(const Ostream&) = delete;
|
||||
|
||||
/// No copy assignment
|
||||
|
@ -74,7 +84,7 @@ public:
|
|||
|
||||
|
||||
/// Write token to stream or otherwise handle it.
|
||||
// return false if the token type was not handled by this method
|
||||
/// return false if the token type was not handled by this method
|
||||
bool write(const token& tok)override;
|
||||
|
||||
/// Write character
|
||||
|
@ -87,7 +97,7 @@ public:
|
|||
iOstream& write(const word& str)override;
|
||||
|
||||
/// Write std::string surrounded by quotes.
|
||||
// Optional write without quotes.
|
||||
/// Optional write without quotes.
|
||||
iOstream& writeQuoted ( const word& str, const bool quoted=true ) override;
|
||||
|
||||
/// Write int64
|
||||
|
@ -133,21 +143,21 @@ public:
|
|||
char fill() const override;
|
||||
|
||||
/// Set padding character for formatted field up to field width
|
||||
// \return previous padding character
|
||||
/// \return previous padding character
|
||||
char fill(const char fillch) override;
|
||||
|
||||
/// Get width of output field
|
||||
int width() const override;
|
||||
|
||||
/// Set width of output field
|
||||
// \return previous width
|
||||
/// \return previous width
|
||||
int width(const int w) override;
|
||||
|
||||
/// Get precision of output field
|
||||
int precision() const override;
|
||||
|
||||
/// Set precision of output field
|
||||
// return old precision
|
||||
/// return old precision
|
||||
int precision(const int p) override;
|
||||
|
||||
/// Access to underlying std::ostream
|
||||
|
@ -165,10 +175,9 @@ public:
|
|||
};
|
||||
|
||||
|
||||
|
||||
} // pFlow
|
||||
|
||||
|
||||
#endif
|
||||
#endif //__Ostream_hpp__
|
||||
|
||||
|
||||
|
|
|
@ -1,8 +1,26 @@
|
|||
/*------------------------------- 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.
|
||||
|
||||
-----------------------------------------------------------------------------*/
|
||||
#ifndef __helperTstream_hpp__
|
||||
#define __helperTstream_hpp__
|
||||
|
||||
|
||||
|
||||
inline bool validTokenForStream(const token tok)
|
||||
{
|
||||
if( tok.good() && !tok.isPunctuation() )return true;
|
||||
|
|
|
@ -222,16 +222,6 @@ pFlow::iIstream& pFlow::iTstream::read
|
|||
return *this;
|
||||
}
|
||||
|
||||
pFlow::iIstream& pFlow::iTstream::read
|
||||
(
|
||||
int16& val
|
||||
)
|
||||
{
|
||||
notImplementedFunction;
|
||||
fatalExit;
|
||||
CONSUME_PARAM(val);
|
||||
return *this;
|
||||
}
|
||||
|
||||
pFlow::iIstream& pFlow::iTstream::read
|
||||
(
|
||||
|
@ -246,7 +236,7 @@ pFlow::iIstream& pFlow::iTstream::read
|
|||
|
||||
pFlow::iIstream& pFlow::iTstream::read
|
||||
(
|
||||
label& val
|
||||
uint64& val
|
||||
)
|
||||
{
|
||||
notImplementedFunction;
|
||||
|
@ -268,7 +258,7 @@ pFlow::iIstream& pFlow::iTstream::read
|
|||
|
||||
pFlow::iIstream& pFlow::iTstream::read
|
||||
(
|
||||
uint16& val
|
||||
uint8& val
|
||||
)
|
||||
{
|
||||
notImplementedFunction;
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
namespace pFlow
|
||||
{
|
||||
|
||||
// helper functions declearation
|
||||
//- helper functions declearation
|
||||
inline bool validTokenForStream(const token tok);
|
||||
|
||||
inline bool isBeginToken(const token& tok);
|
||||
|
@ -18,28 +18,34 @@ inline bool isBeginToken(const token& tok);
|
|||
inline bool isEndToken(const token& tok);
|
||||
|
||||
|
||||
/**
|
||||
* Input token stream.
|
||||
*
|
||||
* It is based on OpenFOAM stream, with some modifications/simplifications
|
||||
* to be tailored to our needs.
|
||||
*/
|
||||
class iTstream
|
||||
:
|
||||
public iIstream
|
||||
{
|
||||
protected:
|
||||
|
||||
// - name of the stream
|
||||
/// name of the stream
|
||||
word name_;
|
||||
|
||||
// - list of tokens in this stream
|
||||
/// list of tokens in this stream
|
||||
tokenList tokenList_;
|
||||
|
||||
// - current token
|
||||
/// current token
|
||||
tokenList::iterator currentToken_;
|
||||
|
||||
// - check if end of list is reached
|
||||
/// check if end of list is reached
|
||||
bool isLastToken();
|
||||
|
||||
// - rewind the stream
|
||||
/// rewind the stream
|
||||
void setFirstToken();
|
||||
|
||||
// - check for valid tokens in the tokenList
|
||||
/// check for valid tokens in the tokenList
|
||||
void validate();
|
||||
|
||||
public:
|
||||
|
@ -49,34 +55,35 @@ public:
|
|||
/// construct with a name
|
||||
iTstream(const word& streamName);
|
||||
|
||||
// - construct with name and copy
|
||||
/// construct with name and copy
|
||||
iTstream(const word& streamName, const tokenList& tList);
|
||||
|
||||
// - construct with name and move
|
||||
/// construct with name and move
|
||||
iTstream(const word& streamName, tokenList && tList);
|
||||
|
||||
// - copy construct
|
||||
/// copy construct
|
||||
iTstream(const iTstream&) = default;
|
||||
// - move construct
|
||||
|
||||
/// move construct
|
||||
iTstream(iTstream&&) = default;
|
||||
|
||||
// - copy assignment
|
||||
/// copy assignment
|
||||
iTstream& operator=(const iTstream&) = default;
|
||||
|
||||
// - move assignment
|
||||
/// move assignment
|
||||
iTstream& operator=(iTstream&&) = default;
|
||||
|
||||
// copy assignment from tokenList
|
||||
/// copy assignment from tokenList
|
||||
void operator=(const tokenList& tList);
|
||||
|
||||
// move assignment from tokenList
|
||||
/// move assignment from tokenList
|
||||
void operator=(tokenList&& tList);
|
||||
|
||||
/// Destructor
|
||||
virtual ~iTstream() = default;
|
||||
|
||||
|
||||
//// Member Functions
|
||||
//// - Member Functions
|
||||
|
||||
/// Return the name of the stream
|
||||
virtual const word& name() const;
|
||||
|
@ -122,26 +129,26 @@ public:
|
|||
|
||||
iIstream& read(char* buffer, std::streamsize count) override;
|
||||
|
||||
// - Rewind the stream so that it may be read again
|
||||
/// Rewind the stream so that it may be read again
|
||||
virtual void rewind();
|
||||
|
||||
// - reset the iTstream and make the stream empty
|
||||
/// reset the iTstream and make the stream empty
|
||||
virtual void reset();
|
||||
|
||||
// - const access to token list
|
||||
/// const access to token list
|
||||
const tokenList& tokens()const;
|
||||
|
||||
// - size
|
||||
/// size
|
||||
size_t size()const;
|
||||
|
||||
// - size
|
||||
/// size
|
||||
size_t numTokens()const;
|
||||
|
||||
// - append a list of tokens to the end of tokens
|
||||
/// append a list of tokens to the end of tokens
|
||||
// and rewind the stream
|
||||
void appendTokens(const tokenList & tList);
|
||||
|
||||
// - append token to the end of token and rewind the stream
|
||||
/// append token to the end of token and rewind the stream
|
||||
void appendToken(const token& t);
|
||||
|
||||
/// Return flags of output stream
|
||||
|
|
|
@ -108,10 +108,17 @@ pFlow::iOstream& pFlow::oTstream::write(const int32 val)
|
|||
return *this;
|
||||
}
|
||||
|
||||
pFlow::iOstream& pFlow::oTstream::write(const int8 val)
|
||||
{
|
||||
append(token(val)); // tokenType::INT64
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
pFlow::iOstream& pFlow::oTstream::write(const label val)
|
||||
|
||||
pFlow::iOstream& pFlow::oTstream::write(const uint64 val)
|
||||
{
|
||||
append(token(static_cast<int64>(val))); // tokenType::INT64
|
||||
|
||||
|
@ -125,7 +132,7 @@ pFlow::iOstream& pFlow::oTstream::write(const uint32 val)
|
|||
return *this;
|
||||
}
|
||||
|
||||
pFlow::iOstream& pFlow::oTstream::write(const uint16 val)
|
||||
pFlow::iOstream& pFlow::oTstream::write(const uint8 val)
|
||||
{
|
||||
append(token(static_cast<int64>(val))); // tokenType::INT64
|
||||
|
||||
|
|
|
@ -1,4 +1,22 @@
|
|||
/*------------------------------- 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.
|
||||
|
||||
-----------------------------------------------------------------------------*/
|
||||
#ifndef __oTstream_hpp__
|
||||
#define __oTstream_hpp__
|
||||
|
||||
|
@ -6,20 +24,27 @@
|
|||
#include "iOstream.hpp"
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
|
||||
// helper functions declearation
|
||||
//- Helper functions declearation
|
||||
|
||||
/// Is tok a valid token for this stream?
|
||||
inline bool validTokenForStream(const token tok);
|
||||
|
||||
/// Is tok a begin token?
|
||||
inline bool isBeginToken(const token& tok);
|
||||
|
||||
/// Is tok an end token?
|
||||
inline bool isEndToken(const token& tok);
|
||||
|
||||
|
||||
/**
|
||||
* Output token stream
|
||||
*
|
||||
* It is based on OpenFOAM stream, with some modifications/simplifications
|
||||
* to be tailored to our needs.
|
||||
*/
|
||||
class oTstream
|
||||
:
|
||||
public iOstream
|
||||
|
@ -27,49 +52,49 @@ class oTstream
|
|||
|
||||
protected:
|
||||
|
||||
// - name of stream
|
||||
/// name of stream
|
||||
word name_;
|
||||
|
||||
// - tokenList
|
||||
/// tokenList
|
||||
tokenList tokenList_;
|
||||
|
||||
public:
|
||||
|
||||
//// - Constructors
|
||||
|
||||
// - emtpy stream with a name
|
||||
/// emtpy stream with a name
|
||||
oTstream(const word& nm);
|
||||
|
||||
// - copy construcotr
|
||||
/// copy construcotr
|
||||
oTstream(const oTstream& src);
|
||||
|
||||
// - move construct
|
||||
/// move construct
|
||||
oTstream(oTstream&&) = default;
|
||||
|
||||
// - destructor
|
||||
/// destructor
|
||||
virtual ~oTstream() = default;
|
||||
|
||||
|
||||
//// - Methods
|
||||
|
||||
// give const access
|
||||
// Give const access
|
||||
const tokenList& tokens()const;
|
||||
|
||||
// give access
|
||||
// Give access
|
||||
tokenList& tokens();
|
||||
|
||||
|
||||
//// - Write
|
||||
|
||||
/// Write token to stream or otherwise handle it.
|
||||
// return false if the token type was not handled by this method
|
||||
/// return false if the token type was not handled by this method
|
||||
virtual bool write(const token& tok);
|
||||
|
||||
/// Write single character. Whitespace is suppressed.
|
||||
virtual iOstream& write(const char c);
|
||||
|
||||
/// Write the word-characters of a character string.
|
||||
// Sends as a single char, or as word.
|
||||
/// Sends as a single char, or as word.
|
||||
virtual iOstream& write(const char* str);
|
||||
|
||||
/// Write word
|
||||
|
@ -77,7 +102,7 @@ public:
|
|||
|
||||
|
||||
/// Write std::string surrounded by quotes.
|
||||
// Optional write without quotes.
|
||||
/// Optional write without quotes.
|
||||
virtual iOstream& writeQuoted(const std::string& str, const bool quoted=true );
|
||||
|
||||
/// Write int64
|
||||
|
@ -138,7 +163,7 @@ public:
|
|||
{}
|
||||
|
||||
/// Get the current padding character
|
||||
// \return previous padding character
|
||||
/// \return previous padding character
|
||||
virtual char fill() const
|
||||
{
|
||||
return 0;
|
||||
|
@ -157,7 +182,7 @@ public:
|
|||
}
|
||||
|
||||
/// Set width of output field
|
||||
// \return previous width
|
||||
/// \return previous width
|
||||
virtual int width(const int)
|
||||
{
|
||||
return 0;
|
||||
|
@ -170,7 +195,7 @@ public:
|
|||
}
|
||||
|
||||
/// Set precision of output field
|
||||
// \return old precision
|
||||
/// \return old precision
|
||||
virtual int precision(const int)
|
||||
{
|
||||
return 0;
|
||||
|
@ -192,12 +217,9 @@ public:
|
|||
|
||||
#include "helperTstream.hpp"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace pFlow
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
|
|
|
@ -17,13 +17,9 @@ Licence:
|
|||
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#ifndef __IOstream_hpp__
|
||||
#define __IOstream_hpp__
|
||||
|
||||
// based on OpenFOAM stream, with some modifications/simplifications
|
||||
// to be tailored to our needs
|
||||
|
||||
#include <iostream>
|
||||
|
||||
|
@ -42,6 +38,12 @@ using std::cerr;
|
|||
namespace pFlow
|
||||
{
|
||||
|
||||
/**
|
||||
* A base calss for input/output streams
|
||||
*
|
||||
* It is based on OpenFOAM stream, with some modifications/simplifications
|
||||
* to be tailored to our needs
|
||||
*/
|
||||
class IOstream
|
||||
{
|
||||
|
||||
|
@ -115,7 +117,7 @@ protected:
|
|||
|
||||
public:
|
||||
|
||||
//- Constructors
|
||||
////- Constructors
|
||||
|
||||
/// Default
|
||||
explicit IOstream():
|
||||
|
@ -144,7 +146,7 @@ public:
|
|||
virtual ~IOstream() = default;
|
||||
|
||||
|
||||
//- Member Functions
|
||||
////- Member Functions
|
||||
|
||||
/// Return the name of the stream
|
||||
virtual const word& name() const;
|
||||
|
@ -299,13 +301,13 @@ public:
|
|||
flags(flags() & ~f);
|
||||
}
|
||||
|
||||
|
||||
}; // end of IOstream
|
||||
|
||||
|
||||
/// An IOstream manipulator
|
||||
typedef IOstream& (*IOstreamManip)(IOstream&);
|
||||
|
||||
|
||||
inline IOstream& dec(IOstream& io)
|
||||
{
|
||||
io.setf(ios_base::dec, ios_base::dec|ios_base::hex|ios_base::oct);
|
||||
|
@ -337,7 +339,6 @@ inline IOstream& scientific(IOstream& io)
|
|||
}
|
||||
|
||||
|
||||
|
||||
} // pFlow
|
||||
|
||||
#endif // __IOstream__hpp__
|
||||
|
|
|
@ -1,4 +1,22 @@
|
|||
/*------------------------------- 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.
|
||||
|
||||
-----------------------------------------------------------------------------*/
|
||||
#include "iIstream.hpp"
|
||||
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@ Licence:
|
|||
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __iIstream_hpp__
|
||||
#define __iIstream_hpp__
|
||||
|
||||
|
@ -30,15 +29,17 @@ namespace pFlow
|
|||
{
|
||||
|
||||
/**
|
||||
* Interface input stream class
|
||||
* Interface class for any input stream
|
||||
*
|
||||
* It is based on OpenFOAM stream, with some modifications/simplifications
|
||||
* to be tailored to our needs
|
||||
*/
|
||||
class iIstream // interface class for input streams
|
||||
class iIstream
|
||||
:
|
||||
public IOstream
|
||||
{
|
||||
|
||||
// Private Data
|
||||
//- Private Data
|
||||
|
||||
/// Has a token been put back on the stream?
|
||||
bool putBack_;
|
||||
|
@ -48,7 +49,7 @@ class iIstream // interface class for input streams
|
|||
|
||||
public:
|
||||
|
||||
///// Constructors
|
||||
////- Constructors
|
||||
|
||||
/// default
|
||||
iIstream():
|
||||
|
@ -69,7 +70,7 @@ public:
|
|||
|
||||
|
||||
|
||||
//// member methods
|
||||
////- member methods
|
||||
|
||||
/// Put back token
|
||||
/// Only a single put back is permitted
|
||||
|
@ -134,7 +135,7 @@ public:
|
|||
virtual void rewind() = 0;
|
||||
|
||||
|
||||
///// find and lookups
|
||||
////- find and lookups
|
||||
|
||||
/// search for all tokesn and find the first word token tbat matchs w
|
||||
virtual bool findToken( const word & w );
|
||||
|
@ -231,8 +232,7 @@ inline iIstream& operator>>(iIstream& is, IOstreamManip f)
|
|||
}
|
||||
|
||||
|
||||
// read operation for basic types it gets from the
|
||||
// token stream
|
||||
// read operation for basic types it gets from the token stream
|
||||
inline iIstream& operator>>( iIstream& is, word & w);
|
||||
|
||||
inline iIstream& operator>>( iIstream& is, int64& val);
|
||||
|
@ -259,4 +259,4 @@ inline iIstream& operator>>( iIstream& is, double& val);
|
|||
#include "iIstreamI.hpp"
|
||||
|
||||
|
||||
#endif
|
||||
#endif //__iIstream_hpp__
|
||||
|
|
|
@ -17,17 +17,13 @@ Licence:
|
|||
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#ifndef __iOstream_hpp__
|
||||
#define __iOstream_hpp__
|
||||
|
||||
// based on OpenFOAM stream, with some modifications/simplifications
|
||||
// to be tailored to our needs
|
||||
|
||||
|
||||
#include "IOstream.hpp"
|
||||
|
||||
/// char constants to alter output format and color
|
||||
const inline char* defaultColor = "\033[0m";
|
||||
const inline char* blackColor = "\033[30m";
|
||||
const inline char* redColor = "\033[31m";
|
||||
|
@ -41,22 +37,25 @@ const inline char* whiteColor = "\033[37m";
|
|||
const inline char* boldChar = "\033[1m";
|
||||
|
||||
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
// Forward Declarations
|
||||
class token;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Interface class for any output stream.
|
||||
* It is based on OpenFOAM stream, with some modifications/simplifications
|
||||
* to be tailored to our needs
|
||||
*
|
||||
*/
|
||||
class iOstream
|
||||
:
|
||||
public IOstream
|
||||
{
|
||||
protected:
|
||||
|
||||
// Protected Data
|
||||
//- Protected Data
|
||||
|
||||
/// Indentation of the entry from the start of the keyword
|
||||
static constexpr const unsigned short entryIndentation_ = 16;
|
||||
|
@ -71,7 +70,7 @@ protected:
|
|||
public:
|
||||
|
||||
|
||||
// Constructors
|
||||
////- Constructors
|
||||
|
||||
/// Default
|
||||
explicit iOstream()
|
||||
|
@ -89,7 +88,7 @@ public:
|
|||
virtual ~iOstream() = default;
|
||||
|
||||
|
||||
/// Write Functions
|
||||
////- Write Functions
|
||||
|
||||
/// Write token to stream or otherwise handle it.
|
||||
/// return false if the token type was not handled by this method
|
||||
|
@ -140,7 +139,7 @@ public:
|
|||
virtual iOstream& write(const char* binaryData, std::streamsize count) = 0;
|
||||
|
||||
|
||||
// - Indent
|
||||
//// - Indent
|
||||
|
||||
/// Add indentation characters
|
||||
virtual void indent() = 0;
|
||||
|
@ -178,7 +177,7 @@ public:
|
|||
/// Decrement the indent level
|
||||
void decrIndent();
|
||||
|
||||
//- Punctuations
|
||||
////- Punctuations
|
||||
|
||||
/// Write begin block group with a name
|
||||
/// Increments indentation, adds newline.
|
||||
|
@ -231,7 +230,7 @@ public:
|
|||
}
|
||||
|
||||
|
||||
//- Stream state functions
|
||||
////- Stream state functions
|
||||
|
||||
/// Flush stream
|
||||
virtual void flush() = 0;
|
||||
|
@ -258,7 +257,7 @@ public:
|
|||
virtual int precision(const int p) = 0;
|
||||
|
||||
|
||||
//- Member Operators
|
||||
////- Member Operators
|
||||
|
||||
/// Return a non-const reference to const iOstream
|
||||
/// Needed for write functions where the stream argument is temporary:
|
||||
|
@ -411,16 +410,14 @@ inline iOstream& operator<<( iOstream& os, const double& val)
|
|||
{
|
||||
return os.write(val);
|
||||
}
|
||||
|
||||
// Useful aliases for tab and newline characters
|
||||
constexpr char tab = '\t';
|
||||
constexpr char nl = '\n';
|
||||
|
||||
|
||||
|
||||
|
||||
} // pFlow
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
|
|
|
@ -0,0 +1,178 @@
|
|||
/*------------------------------- 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.
|
||||
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#include "masterOstream.hpp"
|
||||
#include "token.hpp"
|
||||
|
||||
|
||||
pFlow::masterOstream::masterOstream
|
||||
(
|
||||
std::ostream& os,
|
||||
const word& streamName
|
||||
)
|
||||
:
|
||||
Ostream(os, streamName, writeFormat::ASCII)
|
||||
{}
|
||||
|
||||
|
||||
pFlow::iOstream& pFlow::masterOstream::write(const char c)
|
||||
{
|
||||
if(showOutput())
|
||||
{
|
||||
Ostream::write(c);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
pFlow::iOstream& pFlow::masterOstream::write(const char* str)
|
||||
{
|
||||
if(showOutput())
|
||||
{
|
||||
Ostream::write(str);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
pFlow::iOstream& pFlow::masterOstream::write(const word& str)
|
||||
{
|
||||
if(showOutput())
|
||||
{
|
||||
Ostream::write(str);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
pFlow::iOstream& pFlow::masterOstream::writeQuoted
|
||||
(
|
||||
const word& str,
|
||||
const bool quoted
|
||||
)
|
||||
{
|
||||
if(showOutput())
|
||||
{
|
||||
Ostream::writeQuoted(str, quoted);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
pFlow::iOstream& pFlow::masterOstream::write(const int64 val)
|
||||
{
|
||||
if(showOutput())
|
||||
{
|
||||
Ostream::write(val);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
pFlow::iOstream& pFlow::masterOstream::write(const int32 val)
|
||||
{
|
||||
if(showOutput())
|
||||
{
|
||||
Ostream::write(val);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
pFlow::iOstream& pFlow::masterOstream::write(const int8 val)
|
||||
{
|
||||
if(showOutput())
|
||||
{
|
||||
Ostream::write(val);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
pFlow::iOstream& pFlow::masterOstream::write(const uint64 val)
|
||||
{
|
||||
if(showOutput())
|
||||
{
|
||||
Ostream::write(val);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
pFlow::iOstream& pFlow::masterOstream::write(const uint32 val)
|
||||
{
|
||||
if(showOutput())
|
||||
{
|
||||
Ostream::write(val);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
pFlow::iOstream& pFlow::masterOstream::write(const uint8 val)
|
||||
{
|
||||
if(showOutput())
|
||||
{
|
||||
Ostream::write(val);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
pFlow::iOstream& pFlow::masterOstream::write(const float val)
|
||||
{
|
||||
if(showOutput())
|
||||
{
|
||||
Ostream::write(val);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
pFlow::iOstream& pFlow::masterOstream::write(const double val)
|
||||
{
|
||||
if(showOutput())
|
||||
{
|
||||
Ostream::write(val);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
pFlow::iOstream& pFlow::masterOstream::write
|
||||
(
|
||||
const char* binaryData,
|
||||
std::streamsize count
|
||||
)
|
||||
{
|
||||
if(showOutput())
|
||||
{
|
||||
Ostream::write(binaryData, count);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
void pFlow::masterOstream::indent()
|
||||
{
|
||||
|
||||
if(showOutput())
|
||||
{
|
||||
Ostream::indent();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,123 @@
|
|||
/*------------------------------- 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.
|
||||
|
||||
-----------------------------------------------------------------------------*/
|
||||
#ifndef __masterOstream_hpp__
|
||||
#define __masterOstream_hpp__
|
||||
|
||||
#include "Ostream.hpp"
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
/**
|
||||
* Output stream for MPI parallel run, when we need to
|
||||
* know which the processor number in the output line.
|
||||
* The processor number is shown as a prefix for the output line.
|
||||
*
|
||||
* It is based on OpenFOAM stream, with some modifications/simplifications
|
||||
* to be tailored to our needs.
|
||||
*/
|
||||
class masterOstream
|
||||
:
|
||||
public Ostream
|
||||
{
|
||||
protected:
|
||||
|
||||
/// Print prefix?
|
||||
bool isThisMaster_ = true;
|
||||
|
||||
|
||||
inline bool showOutput() const
|
||||
{
|
||||
return isThisMaster_;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
//// - Constructors
|
||||
|
||||
/// From components
|
||||
masterOstream(std::ostream& os, const word& streamName);
|
||||
|
||||
/// No copy construct
|
||||
masterOstream(const masterOstream&) = delete;
|
||||
|
||||
/// No copy assignment
|
||||
void operator=(const masterOstream&) = delete;
|
||||
|
||||
|
||||
|
||||
//// - Methods
|
||||
void setMasterSlave(bool master)
|
||||
{
|
||||
isThisMaster_ = master;
|
||||
}
|
||||
|
||||
/// Write character
|
||||
iOstream& write(const char c)override;
|
||||
|
||||
/// Write character string
|
||||
iOstream& write(const char* str)override;
|
||||
|
||||
/// Write word
|
||||
iOstream& write(const word& str)override;
|
||||
|
||||
/// Write std::string surrounded by quotes.
|
||||
// Optional write without quotes.
|
||||
iOstream& writeQuoted ( const word& str, const bool quoted=true ) override;
|
||||
|
||||
/// Write int64
|
||||
iOstream& write(const int64 val) override;
|
||||
|
||||
/// Write int32
|
||||
iOstream& write(const int32 val) override;
|
||||
|
||||
/// Write int32
|
||||
iOstream& write(const int8 val) override;
|
||||
|
||||
/// Write uint64
|
||||
iOstream& write(const uint64 val) override;
|
||||
|
||||
/// Write uint32
|
||||
iOstream& write(const uint32 val) override;
|
||||
|
||||
/// Write uint8
|
||||
iOstream& write(const uint8 val) override;
|
||||
|
||||
/// Write float
|
||||
iOstream& write(const float val) override;
|
||||
|
||||
/// Write double
|
||||
iOstream& write(const double val) override;
|
||||
|
||||
/// Write a block of binray data
|
||||
iOstream& write(const char* binaryData, std::streamsize count) override;
|
||||
|
||||
/// Add indentation characters
|
||||
void indent() override;
|
||||
|
||||
|
||||
}; // masterOstream
|
||||
|
||||
|
||||
|
||||
} // pFlow
|
||||
|
||||
|
||||
#endif // __masterOstream_hpp__
|
|
@ -0,0 +1,153 @@
|
|||
/*------------------------------- 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.
|
||||
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "processorOstream.hpp"
|
||||
#include "token.hpp"
|
||||
|
||||
|
||||
pFlow::processorOstream::processorOstream
|
||||
(
|
||||
std::ostream& os,
|
||||
const word& streamName
|
||||
)
|
||||
:
|
||||
Ostream(os, streamName, writeFormat::ASCII)
|
||||
{}
|
||||
|
||||
|
||||
pFlow::iOstream& pFlow::processorOstream::write(const char c)
|
||||
{
|
||||
checkForPrefix();
|
||||
Ostream::write(c);
|
||||
|
||||
if (c == token::NL)
|
||||
{
|
||||
printPrefix_ = true;
|
||||
}
|
||||
|
||||
return *this;
|
||||
|
||||
}
|
||||
|
||||
|
||||
pFlow::iOstream& pFlow::processorOstream::write(const char* str)
|
||||
{
|
||||
checkForPrefix();
|
||||
Ostream::write(str);
|
||||
|
||||
size_t len = std::strlen(str);
|
||||
if (len && str[len-1] == token::NL)
|
||||
{
|
||||
printPrefix_ = true;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
pFlow::iOstream& pFlow::processorOstream::write(const word& str)
|
||||
{
|
||||
checkForPrefix();
|
||||
return Ostream::write(str);
|
||||
}
|
||||
|
||||
|
||||
pFlow::iOstream& pFlow::processorOstream::writeQuoted
|
||||
(
|
||||
const word& str,
|
||||
const bool quoted
|
||||
)
|
||||
{
|
||||
checkForPrefix();
|
||||
return Ostream::writeQuoted(str, quoted);
|
||||
}
|
||||
|
||||
|
||||
|
||||
pFlow::iOstream& pFlow::processorOstream::write(const int64 val)
|
||||
{
|
||||
checkForPrefix();
|
||||
return Ostream::write(val);
|
||||
}
|
||||
|
||||
|
||||
pFlow::iOstream& pFlow::processorOstream::write(const int32 val)
|
||||
{
|
||||
checkForPrefix();
|
||||
return Ostream::write(val);
|
||||
}
|
||||
|
||||
|
||||
pFlow::iOstream& pFlow::processorOstream::write(const int8 val)
|
||||
{
|
||||
checkForPrefix();
|
||||
return Ostream::write(val);
|
||||
}
|
||||
|
||||
pFlow::iOstream& pFlow::processorOstream::write(const uint64 val)
|
||||
{
|
||||
checkForPrefix();
|
||||
return Ostream::write(val);
|
||||
}
|
||||
|
||||
pFlow::iOstream& pFlow::processorOstream::write(const uint32 val)
|
||||
{
|
||||
checkForPrefix();
|
||||
return Ostream::write(val);
|
||||
}
|
||||
|
||||
pFlow::iOstream& pFlow::processorOstream::write(const uint8 val)
|
||||
{
|
||||
checkForPrefix();
|
||||
return Ostream::write(val);
|
||||
}
|
||||
|
||||
pFlow::iOstream& pFlow::processorOstream::write(const float val)
|
||||
{
|
||||
checkForPrefix();
|
||||
return Ostream::write(val);
|
||||
}
|
||||
|
||||
|
||||
pFlow::iOstream& pFlow::processorOstream::write(const double val)
|
||||
{
|
||||
checkForPrefix();
|
||||
return Ostream::write(val);
|
||||
}
|
||||
|
||||
|
||||
pFlow::iOstream& pFlow::processorOstream::write
|
||||
(
|
||||
const char* binaryData,
|
||||
std::streamsize count
|
||||
)
|
||||
{
|
||||
checkForPrefix();
|
||||
return Ostream::write(binaryData, count);
|
||||
}
|
||||
|
||||
|
||||
void pFlow::processorOstream::indent()
|
||||
{
|
||||
checkForPrefix();
|
||||
Ostream::indent();
|
||||
}
|
|
@ -0,0 +1,139 @@
|
|||
/*------------------------------- 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.
|
||||
|
||||
-----------------------------------------------------------------------------*/
|
||||
#ifndef __processorOstream_hpp__
|
||||
#define __processorOstream_hpp__
|
||||
|
||||
#include "Ostream.hpp"
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
/**
|
||||
* Output stream for MPI parallel run, when we need to
|
||||
* know which the processor number in the output line.
|
||||
* The processor number is shown as a prefix for the output line.
|
||||
*
|
||||
* It is based on OpenFOAM stream, with some modifications/simplifications
|
||||
* to be tailored to our needs.
|
||||
*/
|
||||
class processorOstream
|
||||
:
|
||||
public Ostream
|
||||
{
|
||||
protected:
|
||||
|
||||
/// Print prefix?
|
||||
bool printPrefix_ = false;
|
||||
|
||||
/// Prefix word
|
||||
word prefix_ = "";
|
||||
|
||||
/// Output the prefix if required.
|
||||
inline
|
||||
void checkForPrefix()
|
||||
{
|
||||
if(printPrefix_ && prefix_.size())
|
||||
{
|
||||
Ostream::write(prefix_.c_str());
|
||||
printPrefix_ = false;
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
//// - Constructors
|
||||
|
||||
/// From components
|
||||
processorOstream(std::ostream& os, const word& streamName);
|
||||
|
||||
/// No copy construct
|
||||
processorOstream(const processorOstream&) = delete;
|
||||
|
||||
/// No copy assignment
|
||||
void operator=(const processorOstream&) = delete;
|
||||
|
||||
|
||||
//// - Methods
|
||||
|
||||
/// Set processor number to be used in the prefix.
|
||||
word setPrefixNum(int procNum)
|
||||
{
|
||||
prefix_ = word("[")+int322Word(procNum)+word("] ");
|
||||
return prefix_;
|
||||
}
|
||||
|
||||
/// Activate prefix for this stream.
|
||||
void activatePrefix()
|
||||
{
|
||||
printPrefix_ = true;
|
||||
}
|
||||
|
||||
/// Write character
|
||||
iOstream& write(const char c)override;
|
||||
|
||||
/// Write character string
|
||||
iOstream& write(const char* str)override;
|
||||
|
||||
/// Write word
|
||||
iOstream& write(const word& str)override;
|
||||
|
||||
/// Write std::string surrounded by quotes.
|
||||
// Optional write without quotes.
|
||||
iOstream& writeQuoted ( const word& str, const bool quoted=true ) override;
|
||||
|
||||
/// Write int64
|
||||
iOstream& write(const int64 val) override;
|
||||
|
||||
/// Write int32
|
||||
iOstream& write(const int32 val) override;
|
||||
|
||||
/// Write int32
|
||||
iOstream& write(const int8 val) override;
|
||||
|
||||
/// Write uint64
|
||||
iOstream& write(const uint64 val) override;
|
||||
|
||||
/// Write uint32
|
||||
iOstream& write(const uint32 val) override;
|
||||
|
||||
/// Write uint8
|
||||
iOstream& write(const uint8 val) override;
|
||||
|
||||
/// Write float
|
||||
iOstream& write(const float val) override;
|
||||
|
||||
/// Write double
|
||||
iOstream& write(const double val) override;
|
||||
|
||||
/// Write a block of binray data
|
||||
iOstream& write(const char* binaryData, std::streamsize count) override;
|
||||
|
||||
/// Add indentation characters
|
||||
void indent() override;
|
||||
|
||||
|
||||
}; // processorOstream
|
||||
|
||||
|
||||
|
||||
} // pFlow
|
||||
|
||||
|
||||
#endif // __processorOstream_hpp__
|
|
@ -3,6 +3,11 @@
|
|||
|
||||
pFlow::Ostream pFlow::output(std::cout, "pFlow Ostream");
|
||||
|
||||
pFlow::masterOstream pFlow::mOutput(cout, "pFlow masterOstream");
|
||||
|
||||
pFlow::processorOstream pFlow::pOutput(cout, "pFlow processorOstream");
|
||||
|
||||
pFlow::Istream pFlow::input( std::cin, "sFlow Istream");
|
||||
|
||||
pFlow::Ostream pFlow::errReport( std::cerr, "pFlow error report stream");
|
||||
pFlow::masterOstream pFlow::errReport( std::cerr, "pFlow error report stream");
|
||||
|
||||
|
|
|
@ -13,38 +13,44 @@
|
|||
|
||||
#include "iTstream.hpp"
|
||||
|
||||
#include "processorOstream.hpp"
|
||||
|
||||
#include "masterOstream.hpp"
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
|
||||
extern Ostream output;
|
||||
|
||||
extern masterOstream mOutput;
|
||||
|
||||
extern processorOstream pOutput;
|
||||
|
||||
extern Istream input;
|
||||
|
||||
extern Ostream errReport;
|
||||
|
||||
extern masterOstream errReport;
|
||||
|
||||
}
|
||||
|
||||
#define redText(text) redColor<<text<<defaultColor
|
||||
#define yellowText(text) yellowColor<<text<<defaultColor
|
||||
#define blueText(text) blueColor<<text<<defaultColor
|
||||
#define greenText(text) greenColor<<text<<defaultColor
|
||||
#define magentaText(text) magentaColor<<text<<defaultColor
|
||||
#define cyanText(text) cyanColor<<text<<defaultColor
|
||||
#define boldText(text) boldChar<<text<<defaultColor
|
||||
#define Red_Text(text) redColor<<text<<defaultColor
|
||||
#define Yellow_Text(text) yellowColor<<text<<defaultColor
|
||||
#define Blue_Text(text) blueColor<<text<<defaultColor
|
||||
#define Green_Text(text) greenColor<<text<<defaultColor
|
||||
#define Magenta_Text(text) magentaColor<<text<<defaultColor
|
||||
#define Cyan_Text(text) cyanColor<<text<<defaultColor
|
||||
#define Bold_Text(text) boldChar<<text<<defaultColor
|
||||
|
||||
#define INFORMATION pFlow::output<<boldChar<<magentaColor<<"> INFO: "<<defaultColor<<magentaColor
|
||||
#define endINFO defaultColor<<pFlow::nl
|
||||
#define INFORMATION pFlow::mOutput<<boldChar<<magentaColor<<"> INFO: "<<defaultColor<<magentaColor
|
||||
#define END_INFO defaultColor<<pFlow::endl
|
||||
|
||||
#define REPORT(n) pFlow::output.space(2*n)
|
||||
#define endREPORT pFlow::nl
|
||||
#define REPORT(n) pFlow::mOutput.space(2*n)
|
||||
#define END_REPORT pFlow::endl
|
||||
|
||||
|
||||
#define yWARNING pFlow::output<<boldChar<<yellowColor<<"> WARNING\n"<<defaultColor<<yellowColor<<" "
|
||||
#define endyWARNING defaultColor<<pFlow::nl
|
||||
#define WARNING pFlow::errReport<<boldChar<<yellowColor<<"> WARNING\n"<<defaultColor<<yellowColor<<" "
|
||||
#define END_WARNING defaultColor<<pFlow::endl
|
||||
|
||||
#define ERR pFlow::output<<boldChar<<redColor<<"> ERROR\n"<<defaultColor<<redColor<<" "
|
||||
#define endERR defaultColor<<pFlow::nl
|
||||
#define ERR pFlow::errReport<<boldChar<<redColor<<"> ERROR\n"<<defaultColor<<redColor<<" "
|
||||
#define END_ERR defaultColor<<pFlow::endl
|
||||
|
||||
#endif
|
|
@ -28,7 +28,7 @@ Licence:
|
|||
namespace pFlow
|
||||
{
|
||||
|
||||
//- Forward Declarations
|
||||
/// Forward Declarations
|
||||
class token;
|
||||
class iIstream;
|
||||
class iOstream;
|
||||
|
@ -45,69 +45,69 @@ class token
|
|||
{
|
||||
public:
|
||||
|
||||
//- Enumeration defining the types of token.
|
||||
// Since these values are also used to tag content in Pstream,
|
||||
// the maximum number of types is limited to 30.
|
||||
/// Enumeration defining the types of token.
|
||||
/// Since these values are also used to tag content in Pstream,
|
||||
/// the maximum number of types is limited to 30.
|
||||
enum tokenType
|
||||
{
|
||||
UNDEFINED = 0, //!< An undefined token-type
|
||||
|
||||
// Fundamental types
|
||||
FLAG, //!< stream flag (1-byte bitmask)
|
||||
PUNCTUATION, //!< single character punctuation
|
||||
BOOL, //!< boolean type
|
||||
INT64, //!< int64 (integer) type
|
||||
FLOAT, //!< float (single-precision) type
|
||||
DOUBLE, //!< double (double-precision) type
|
||||
FLAG, /// stream flag (1-byte bitmask)
|
||||
PUNCTUATION, /// single character punctuation
|
||||
BOOL, /// boolean type
|
||||
INT64, /// int64 (integer) type
|
||||
FLOAT, /// float (single-precision) type
|
||||
DOUBLE, /// double (double-precision) type
|
||||
|
||||
// Pointer types
|
||||
WORD, //!< A pFlow::word
|
||||
STRING, //!< A string whth double quuote
|
||||
DIRECTIVE, //!< A dictionary \c \#directive (word variant)
|
||||
VARIABLE, //!< A dictionary \c \$variable (string variant)
|
||||
WORD, /// A pFlow::word
|
||||
STRING, /// A string whth double quuote
|
||||
DIRECTIVE, /// A dictionary \c \#directive (word variant)
|
||||
VARIABLE, /// A dictionary \c \$variable (string variant)
|
||||
|
||||
ERROR, //!< A token error encountered
|
||||
ERROR, /// A token error encountered
|
||||
};
|
||||
|
||||
|
||||
//**************- Stream or output control flags (1-byte width)
|
||||
/// Stream or output control flags (1-byte width)
|
||||
enum flagType
|
||||
{
|
||||
NO_FLAG = 0, //!< No flags
|
||||
ASCII = 1, //!< ASCII-mode stream
|
||||
BINARY = 2 //!< BINARY-mode stream
|
||||
NO_FLAG = 0, /// No flags
|
||||
ASCII = 1, /// ASCII-mode stream
|
||||
BINARY = 2 /// BINARY-mode stream
|
||||
};
|
||||
|
||||
|
||||
//- Standard punctuation tokens (a character)
|
||||
/// Standard punctuation tokens (a character)
|
||||
enum punctuationToken : char
|
||||
{
|
||||
NULL_TOKEN = '\0', //!< Nul character
|
||||
SPACE = ' ', //!< Space [isspace]
|
||||
TAB = '\t', //!< Tab [isspace]
|
||||
NL = '\n', //!< Newline [isspace]
|
||||
NULL_TOKEN = '\0', /// Nul character
|
||||
SPACE = ' ', /// Space [isspace]
|
||||
TAB = '\t', /// Tab [isspace]
|
||||
NL = '\n', /// Newline [isspace]
|
||||
|
||||
END_STATEMENT = ';', //!< End entry [#isseparator]
|
||||
BEGIN_LIST = '(', //!< Begin list [#isseparator]
|
||||
END_LIST = ')', //!< End list [#isseparator]
|
||||
BEGIN_SQR = '[', //!< Begin dimensions [#isseparator]
|
||||
END_SQR = ']', //!< End dimensions [#isseparator]
|
||||
BEGIN_BLOCK = '{', //!< Begin block [#isseparator]
|
||||
END_BLOCK = '}', //!< End block [#isseparator]
|
||||
COLON = ':', //!< Colon [#isseparator]
|
||||
COMMA = ',', //!< Comma [#isseparator]
|
||||
DOLLAR = '$', //!< Dollar - start variable
|
||||
SQUOTE = '\'', //!< Single quote
|
||||
DQUOTE = '"', //!< Double quote
|
||||
END_STATEMENT = ';', /// End entry [#isseparator]
|
||||
BEGIN_LIST = '(', /// Begin list [#isseparator]
|
||||
END_LIST = ')', /// End list [#isseparator]
|
||||
BEGIN_SQR = '[', /// Begin dimensions [#isseparator]
|
||||
END_SQR = ']', /// End dimensions [#isseparator]
|
||||
BEGIN_BLOCK = '{', /// Begin block [#isseparator]
|
||||
END_BLOCK = '}', /// End block [#isseparator]
|
||||
COLON = ':', /// Colon [#isseparator]
|
||||
COMMA = ',', /// Comma [#isseparator]
|
||||
DOLLAR = '$', /// Dollar - start variable
|
||||
SQUOTE = '\'', /// Single quote
|
||||
DQUOTE = '"', /// Double quote
|
||||
|
||||
SUBTRACT = '-', //!< Subtract or start of negative number
|
||||
DIVIDE = '/', //!< Divide [#isseparator]
|
||||
SUBTRACT = '-', /// Subtract or start of negative number
|
||||
DIVIDE = '/', /// Divide [#isseparator]
|
||||
|
||||
BEGIN_STRING = DQUOTE, //!< Begin string with double quote
|
||||
END_STRING = DQUOTE //!< End string with double quote
|
||||
BEGIN_STRING = DQUOTE, /// Begin string with double quote
|
||||
END_STRING = DQUOTE /// End string with double quote
|
||||
};
|
||||
|
||||
//- An undefined token
|
||||
/// An undefined token
|
||||
static const inline token undefinedToken();
|
||||
|
||||
static token endList()
|
||||
|
@ -157,7 +157,7 @@ public:
|
|||
|
||||
private:
|
||||
|
||||
//- A %union of token types
|
||||
/// A %union of token types
|
||||
union content
|
||||
{
|
||||
// Fundamental values. Largest first for any {} initialization.
|
||||
|
@ -174,279 +174,285 @@ private:
|
|||
};
|
||||
|
||||
|
||||
// Private Data
|
||||
//// - Private Data
|
||||
|
||||
//- The data content (as a union).
|
||||
/// The data content (as a union).
|
||||
// For memory alignment this should appear as the first member.
|
||||
content data_;
|
||||
|
||||
//- The token type
|
||||
/// The token type
|
||||
tokenType type_;
|
||||
|
||||
//- Line number in the file the token was read from
|
||||
/// Line number in the file the token was read from
|
||||
int32 lineNumber_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Set as UNDEFINED and zero the union content without any checking
|
||||
/// Set as UNDEFINED and zero the union content without any checking
|
||||
inline void setUndefined();
|
||||
|
||||
// Parse error, expected 'expected', found ...
|
||||
/// Parse error, expected 'expected', found ...
|
||||
void parseError(const char* expected) const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Static Data Members
|
||||
|
||||
// Constructors
|
||||
//// - Constructors
|
||||
|
||||
//- Default construct, initialized to an UNDEFINED token.
|
||||
/// Default construct, initialized to an UNDEFINED token.
|
||||
inline constexpr token() noexcept;
|
||||
|
||||
//- Copy construct
|
||||
/// Copy construct
|
||||
inline token(const token& t);
|
||||
|
||||
//- Move construct. The original token is left as UNDEFINED.
|
||||
/// Move construct. The original token is left as UNDEFINED.
|
||||
inline token(token&& t);
|
||||
|
||||
//- Construct punctuation character token
|
||||
/// Construct punctuation character token
|
||||
inline explicit token(punctuationToken p, int32 lineNumber=0);
|
||||
|
||||
//- Construct uint64 token
|
||||
/// Construct int64 token
|
||||
inline explicit token(const uint64 val, int32 lineNumber=0);
|
||||
|
||||
//- Construct uint32 token
|
||||
/// Construct int64 token
|
||||
inline explicit token(const uint32 val, int32 lineNumber=0);
|
||||
|
||||
//- Construct int64 token
|
||||
/// Construct int8 token
|
||||
inline explicit token(const uint8 val, int32 lineNumber=0);
|
||||
|
||||
/// Construct int64 token
|
||||
inline explicit token(const int64 val, int32 lineNumber=0);
|
||||
|
||||
//- Construct int64 token
|
||||
/// Construct int64 token
|
||||
inline explicit token(const int32 val, int32 lineNumber=0);
|
||||
|
||||
//- Construct float token
|
||||
/// Construct int64 token
|
||||
inline explicit token(const int8 val, int32 lineNumber=0);
|
||||
|
||||
/// Construct float token
|
||||
inline explicit token(const float val, int32 lineNumber=0);
|
||||
|
||||
//- Construct double token
|
||||
/// Construct double token
|
||||
inline explicit token(const double val, int32 lineNumber=0);
|
||||
|
||||
//- Copy construct word & string token
|
||||
/// Copy construct word & string token
|
||||
inline explicit token(const word& w, int32 lineNumber=0, bool isString = false);
|
||||
|
||||
|
||||
//- Move construct word & string token
|
||||
/// Move construct word & string token
|
||||
inline explicit token(word&& w, int32 lineNumber=0, bool isString = false);
|
||||
|
||||
//- Construct from iIstream
|
||||
/// Construct from iIstream
|
||||
explicit token(iIstream& is);
|
||||
|
||||
|
||||
//- Destructor
|
||||
/// Destructor
|
||||
inline ~token();
|
||||
|
||||
|
||||
// Static Functions
|
||||
//// - Static Functions
|
||||
|
||||
//- Create a bool token.
|
||||
/// Create a bool token.
|
||||
inline static token boolean(bool on);
|
||||
|
||||
//- Create a token with stream flags, no sanity check
|
||||
//
|
||||
// \param bitmask the flags to set
|
||||
/// Create a token with stream flags, no sanity check
|
||||
///
|
||||
/// \param bitmask the flags to set
|
||||
inline static token flag(int bitmask);
|
||||
|
||||
//- True if the character is a punctuation separator (eg, in ISstream).
|
||||
// Since it could also start a number, SUBTRACT is not included as
|
||||
// a separator.
|
||||
//
|
||||
// \param c the character to test, passed as int for consistency with
|
||||
// isdigit, isspace etc.
|
||||
/// True if the character is a punctuation separator (eg, in ISstream).
|
||||
/// Since it could also start a number, SUBTRACT is not included as
|
||||
/// a separator.
|
||||
///
|
||||
/// \param c the character to test, passed as int for consistency with
|
||||
/// isdigit, isspace etc.
|
||||
inline static bool isseparator(int c);
|
||||
|
||||
|
||||
// Member Functions
|
||||
//// - Member Functions
|
||||
|
||||
// Status
|
||||
// - Status
|
||||
|
||||
//- Return the name of the token type
|
||||
/// Return the name of the token type
|
||||
word name() const;
|
||||
|
||||
//- Return the token type
|
||||
/// Return the token type
|
||||
inline tokenType type() const;
|
||||
|
||||
//- Change the token type, for similar types.
|
||||
// This can be used to change between string-like variants
|
||||
// (eg, STRING, VARIABLE, etc)
|
||||
// To change types entirely (eg, STRING to DOUBLE),
|
||||
// use the corresponding assignment operator.
|
||||
//
|
||||
// \return true if the change was successful or no change was required
|
||||
/// Change the token type, for similar types.
|
||||
/// This can be used to change between string-like variants
|
||||
/// (eg, STRING, VARIABLE, etc)
|
||||
/// To change types entirely (eg, STRING to DOUBLE),
|
||||
/// use the corresponding assignment operator.
|
||||
///
|
||||
/// \return true if the change was successful or no change was required
|
||||
inline bool setType(const tokenType tokType);
|
||||
|
||||
//- The line number for the token
|
||||
/// The line number for the token
|
||||
inline int32 lineNumber() const;
|
||||
|
||||
//- The line number for the token
|
||||
/// The line number for the token
|
||||
inline int32& lineNumber();
|
||||
|
||||
//- True if token is not UNDEFINED or ERROR
|
||||
/// True if token is not UNDEFINED or ERROR
|
||||
inline bool good() const;
|
||||
|
||||
//- Token is UNDEFINED
|
||||
/// Token is UNDEFINED
|
||||
inline bool undefined() const;
|
||||
|
||||
//- Token is ERROR
|
||||
/// Token is ERROR
|
||||
inline bool error() const;
|
||||
|
||||
//- Token is BOOL
|
||||
/// Token is BOOL
|
||||
inline bool isBool() const;
|
||||
|
||||
//- Token is FLAG
|
||||
/// Token is FLAG
|
||||
inline bool isFlag() const;
|
||||
|
||||
//- Token is PUNCTUATION
|
||||
/// Token is PUNCTUATION
|
||||
inline bool isPunctuation() const;
|
||||
|
||||
//- Token is PUNCTUATION and isseparator
|
||||
/// Token is PUNCTUATION and isseparator
|
||||
inline bool isSeparator() const;
|
||||
|
||||
//- Tolen is end statement
|
||||
/// Token is end statement
|
||||
inline bool isEndStatement() const;
|
||||
|
||||
/// Token is end endBlock
|
||||
inline bool isEndBlock()const;
|
||||
|
||||
//- Token is INT64
|
||||
/// Token is int64
|
||||
inline bool isInt64() const;
|
||||
|
||||
//- Token is INT32
|
||||
/// Token is int32
|
||||
inline bool isInt32() const;
|
||||
|
||||
//- Token is FLOAT
|
||||
/// Token is float
|
||||
inline bool isFloat() const;
|
||||
|
||||
//- Token is DOUBLE
|
||||
/// Token is double
|
||||
inline bool isDouble() const;
|
||||
|
||||
//- Token is FLOAT or DOUBLE
|
||||
/// Token is float or double
|
||||
inline bool isReal() const;
|
||||
|
||||
//- Token is INT64, FLOAT or DOUBLE
|
||||
/// Token is int, float or duble
|
||||
inline bool isNumber() const;
|
||||
|
||||
//- Token is WORD or DIRECTIVE word
|
||||
/// Token is word or DIRECTIVE word
|
||||
inline bool isWord() const;
|
||||
|
||||
//- Token is DIRECTIVE (word variant)
|
||||
/// Token is DIRECTIVE (word variant)
|
||||
inline bool isDirective() const;
|
||||
|
||||
//- Token is STRING, VARIABLE or VERBATIM string
|
||||
/// Token is STRING, VARIABLE or VERBATIM string
|
||||
inline bool isString() const;
|
||||
|
||||
//- Token is VARIABLE (string variant)
|
||||
/// Token is VARIABLE (string variant)
|
||||
inline bool isVariable() const;
|
||||
|
||||
//- Token is WORD, DIRECTIVE, STRING, VARIABLE or VERBATIM
|
||||
/// Token is WORD, DIRECTIVE, STRING, VARIABLE or VERBATIM
|
||||
inline bool isStringType() const;
|
||||
|
||||
|
||||
// Access
|
||||
//- Access
|
||||
|
||||
//- Return boolean token value.
|
||||
// Report FatalIOError and return false if token is not BOOL or INT64
|
||||
/// Return boolean token value.
|
||||
/// Report FatalIOError and return false if token is not BOOL or INT64
|
||||
inline bool boolToken() const;
|
||||
|
||||
//- Return flag bitmask value.
|
||||
// Report FatalIOError and return NO_FLAG if token is not FLAG
|
||||
/// Return flag bitmask value.
|
||||
/// Report FatalIOError and return NO_FLAG if token is not FLAG
|
||||
inline int flagToken() const;
|
||||
|
||||
//- Return punctuation character.
|
||||
// Report FatalIOError and return \b \\0 if token is not PUNCTUATION
|
||||
/// Return punctuation character.
|
||||
/// Report FatalIOError and return \b \\0 if token is not PUNCTUATION
|
||||
inline punctuationToken pToken() const;
|
||||
|
||||
//- Return int64 value.
|
||||
/// Return int64 value.
|
||||
// Report FatalIOError and return \b 0 if token is not INT64
|
||||
inline int64 int64Token() const;
|
||||
|
||||
//- Return int32 value.
|
||||
// Report FatalIOError and return \b 0 if token is not INT64
|
||||
/// Return int32 value.
|
||||
/// Report FatalIOError and return \b 0 if token is not INT64
|
||||
inline int32 int32Token() const;
|
||||
|
||||
//- Return float value.
|
||||
// Report FatalIOError and return \b 0 if token is not FLOAT
|
||||
/// Return float value.
|
||||
/// Report FatalIOError and return \b 0 if token is not FLOAT
|
||||
inline float floatToken() const;
|
||||
|
||||
//- Return double value.
|
||||
// Report FatalIOError and return \b 0 if token is not DOUBLE
|
||||
/// Return double value.
|
||||
/// Report FatalIOError and return \b 0 if token is not DOUBLE
|
||||
inline double doubleToken() const;
|
||||
|
||||
//- Return float or double value.
|
||||
// Report FatalIOError and return \b 0 if token is not a
|
||||
// FLOAT or DOUBLE
|
||||
/// Return float or double value.
|
||||
/// Report FatalIOError and return \b 0 if token is not a
|
||||
/// FLOAT or DOUBLE
|
||||
inline real realToken() const;
|
||||
|
||||
//- Return int64, float or double value.
|
||||
// Report FatalIOError and return \b 0 if token is not a
|
||||
// INT64, FLOAT or DOUBLE
|
||||
/// Return int64, float or double value.
|
||||
/// Report FatalIOError and return \b 0 if token is not a
|
||||
/// INT64, FLOAT or DOUBLE
|
||||
inline real number() const;
|
||||
|
||||
//- Return const reference to the word contents.
|
||||
// Report FatalIOError and return \b "" if token is not a
|
||||
// WORD or DIRECTIVE
|
||||
/// Return const reference to the word contents.
|
||||
/// Report FatalIOError and return \b "" if token is not a
|
||||
/// WORD or DIRECTIVE
|
||||
inline const word& wordToken() const;
|
||||
|
||||
//- Return const reference to the string contents.
|
||||
// Report FatalIOError and return \b "" if token is not a
|
||||
// STRING, VARIABLE, VERBATIM or an upcast WORD or DIRECTIVE
|
||||
/// Return const reference to the string contents.
|
||||
/// Report FatalIOError and return \b "" if token is not a
|
||||
/// STRING, VARIABLE, VERBATIM or an upcast WORD or DIRECTIVE
|
||||
inline const word& stringToken() const;
|
||||
|
||||
|
||||
// Edit
|
||||
//- Edit
|
||||
|
||||
//- Reset token to UNDEFINED and clear any allocated storage
|
||||
/// Reset token to UNDEFINED and clear any allocated storage
|
||||
inline void reset();
|
||||
|
||||
//- Clear token and set to be ERROR.
|
||||
/// Clear token and set to be ERROR.
|
||||
inline void setBad();
|
||||
|
||||
//- Swap token contents: type, data, line-number
|
||||
/// Swap token contents: type, data, line-number
|
||||
inline void swap(token& tok);
|
||||
|
||||
|
||||
// Assignment
|
||||
//- Assignment
|
||||
|
||||
//- Copy assign
|
||||
/// Copy assign
|
||||
inline void operator=(const token& tok);
|
||||
|
||||
//- Move assign
|
||||
/// Move assign
|
||||
inline void operator=(token&& tok);
|
||||
|
||||
//- Copy assign from punctuation
|
||||
/// Copy assign from punctuation
|
||||
inline void operator=(const punctuationToken p);
|
||||
|
||||
//- Copy assign from int64
|
||||
/// Copy assign from int64
|
||||
inline void operator=(const int64 val);
|
||||
|
||||
//- Copy assign from int32
|
||||
/// Copy assign from int32
|
||||
inline void operator=(const int32 val);
|
||||
|
||||
//- Copy assign from float
|
||||
/// Copy assign from float
|
||||
inline void operator=(const float val);
|
||||
|
||||
//- Copy assign from double
|
||||
/// Copy assign from double
|
||||
inline void operator=(const double val);
|
||||
|
||||
//- Copy assign from word
|
||||
/// Copy assign from word
|
||||
inline void operator=(const word& w);
|
||||
|
||||
|
||||
|
||||
//- Move assign from word
|
||||
/// Move assign from word
|
||||
inline void operator=(word&& w);
|
||||
|
||||
|
||||
// Equality
|
||||
//- Equality
|
||||
|
||||
inline bool operator==(const token& tok) const;
|
||||
inline bool operator==(const punctuationToken p) const;
|
||||
|
@ -457,7 +463,7 @@ public:
|
|||
inline bool operator==(const word& w) const;
|
||||
|
||||
|
||||
// Inequality
|
||||
//- Inequality
|
||||
|
||||
inline bool operator!=(const token& tok) const;
|
||||
inline bool operator!=(const punctuationToken p) const;
|
||||
|
@ -470,7 +476,8 @@ public:
|
|||
iOstream& printInfo(iOstream& os)const;
|
||||
|
||||
std::ostream& printInfo(std::ostream& os)const;
|
||||
// IOstream Operators
|
||||
|
||||
//- IOstream Operators
|
||||
|
||||
friend iOstream& operator<<(iOstream& os, const token& tok);
|
||||
friend iOstream& operator<<(iOstream& os, const punctuationToken& pt);
|
||||
|
@ -529,18 +536,10 @@ inline token newLineToken()
|
|||
}
|
||||
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace pFlow
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "tokenI.hpp"
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
|
|
|
@ -162,6 +162,15 @@ inline pFlow::token::token(const uint32 val, int32 lineNumber)
|
|||
data_.int64Val = static_cast<int64>(val);
|
||||
}
|
||||
|
||||
inline pFlow::token::token(const uint8 val, int32 lineNumber)
|
||||
:
|
||||
data_(),
|
||||
type_(tokenType::INT64),
|
||||
lineNumber_(lineNumber)
|
||||
{
|
||||
data_.int64Val = static_cast<int64>(val);
|
||||
}
|
||||
|
||||
inline pFlow::token::token(const int64 val, int32 lineNumber)
|
||||
:
|
||||
data_(),
|
||||
|
@ -180,6 +189,15 @@ inline pFlow::token::token(const int32 val, int32 lineNumber)
|
|||
data_.int64Val = static_cast<int64>(val);
|
||||
}
|
||||
|
||||
inline pFlow::token::token(const int8 val, int32 lineNumber)
|
||||
:
|
||||
data_(),
|
||||
type_(tokenType::INT64),
|
||||
lineNumber_(lineNumber)
|
||||
{
|
||||
data_.int64Val = static_cast<int64>(val);
|
||||
}
|
||||
|
||||
inline pFlow::token::token(const float val, int32 lineNumber)
|
||||
:
|
||||
data_(),
|
||||
|
|
|
@ -276,6 +276,17 @@ bool pFlow::readInt32( const char* buf, int32 & val)
|
|||
return readInt32(w, val);
|
||||
}
|
||||
|
||||
bool pFlow::readInt8( const word& w, int8 & val)
|
||||
{
|
||||
try{
|
||||
val = std::stoi(w);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool pFlow::readInt8( const char* buf, int8 & val)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue