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