ug4
|
Classes | |
class | ug::Base64FileWriter |
File writer allowing selective base64 encoding of arbitrary data. More... | |
class | ug::BinaryBuffer |
A Buffer for binary data. More... | |
class | ug::BinaryStream |
a specialzation of std::iostream, that uses a More... | |
class | ug::BinaryStreamBuffer |
A special version of a std::streambuf, writes data directly into a buffer that is accessible at any time. More... | |
class | ug::EmptyOStream |
a specialization of std::ostream, which doesn't write anything More... | |
class | ug::EmptyStreamBuffer |
Used by EmptyStream, to send tokens into nirvana! More... | |
class | ug::OStreamBufferSplitter |
forwards data written to this stream-buffer to other stream buffers. More... | |
Enumerations | |
enum | ug::Base64FileWriter::fmtflag { ug::Base64FileWriter::base64_ascii , ug::Base64FileWriter::base64_binary , ug::Base64FileWriter::normal } |
Format flags to enable deactivation of base64 encoding selectivly. More... | |
Functions | |
void | ug::Base64FileWriter::assertFileOpen () |
Check on readiness of the file stream. More... | |
ug::Base64FileWriter::Base64FileWriter () | |
ug::Base64FileWriter::Base64FileWriter (const char *filename, const std::ios_base::openmode mode=(std::ios_base::out|std::ios_base::trunc)) | |
Constructor with name of file to write to. More... | |
UG_API void | ug::ChangeDirectory (std::string dir) |
Changes the current directory. More... | |
void | ug::Base64FileWriter::close () |
Closes the file writer properly and encodes any remaining buffer content. More... | |
UG_API bool | ug::CreateDirectory (const char *directory) |
Creates a directory. More... | |
UG_API bool | ug::CreateDirectory (const char *directory, int mode) |
Creates a directory. More... | |
static bool | ug::CreateDirectory (std::string directory) |
Creates a directory. More... | |
UG_API bool | ug::CreateDirectoryTMP (const char *directory) |
Creates a directory. More... | |
std::string | ug::CurrentWorkingDirectory () |
UG_API bool | ug::DirectoryExists (const char *dirname) |
Checks the existence of a given directory. More... | |
static bool | ug::DirectoryExists (std::string filename) |
template<typename T > | |
void | ug::Base64FileWriter::dispatch (const T &value) |
Writes given data to the output file and encodes it if Base64FileWriter::base64 is set. More... | |
UG_API bool | ug::FileCompare (const char *file1, const char *file2) |
!!! Serial i/o version !!! More... | |
UG_API bool | ug::FileExists (const char *filename) |
!!! Serial i/o version !!! More... | |
static bool | ug::FileExists (std::string filename) |
UG_API size_t | ug::FileSize (const char *filename) |
Returns size of the specified file in bytes. More... | |
static size_t | ug::FileSize (std::string filename) |
bool | ug::FileTypeIs (const char *filename, const char *extension) |
!!! Serial i/o version !!! More... | |
std::string | ug::FindDirInStandardPaths (const char *dirname) |
searches the directory in the standard paths. More... | |
std::string | ug::FindFileInStandardPaths (const char *filename) |
searches the file in the standard paths. More... | |
void | ug::Base64FileWriter::flushInputBuffer (bool force=false) |
Flushes input buffer. More... | |
fmtflag | ug::Base64FileWriter::format () const |
gets the current set format More... | |
UG_API bool | ug::GetDirectoriesInDirectory (std::vector< std::string > &dirsOut, const char *dir) |
Returns a list of all directories in a directory. More... | |
UG_API bool | ug::GetFilesInDirectory (std::vector< std::string > &filesOut, const char *dir) |
Returns a list of all files in a directory. More... | |
UG_API std::string | ug::GetTmpPath () |
Returns a path to which an application may write temporary files. More... | |
UG_API std::string | ug::MakeTmpFile (std::string filename, const std::string &extension, bool &bSuccess) |
void | ug::Base64FileWriter::open (const char *filename, const std::ios_base::openmode mode=std::ios_base::out) |
Base64FileWriter & | ug::Base64FileWriter::operator<< (char c) |
Base64FileWriter & | ug::Base64FileWriter::operator<< (const char *cstr) |
Base64FileWriter & | ug::Base64FileWriter::operator<< (const fmtflag format) |
Switch between normal and base64 encoded output. More... | |
Base64FileWriter & | ug::Base64FileWriter::operator<< (const std::string &str) |
Base64FileWriter & | ug::Base64FileWriter::operator<< (double d) |
Base64FileWriter & | ug::Base64FileWriter::operator<< (float f) |
Base64FileWriter & | ug::Base64FileWriter::operator<< (int i) |
Base64FileWriter & | ug::Base64FileWriter::operator<< (long l) |
Base64FileWriter & | ug::Base64FileWriter::operator<< (size_t s) |
UG_API bool | ug::ReadFile (const char *filename, std::vector< char > &file, bool bText) |
static std::ios_base & | ug::reset_floats (std::ios_base &o) |
used to unset flags set by std::scientific or std::fixed. More... | |
ug::Base64FileWriter::~Base64FileWriter () | |
Destructor, which properly flushs encoder's internal buffer and closes file stream. More... | |
Variables | |
fmtflag | ug::Base64FileWriter::m_currFormat |
Current write format (base64 or normal ) More... | |
std::fstream | ug::Base64FileWriter::m_fStream |
File stream to write everything to. More... | |
std::stringstream | ug::Base64FileWriter::m_inBuffer |
Internal input buffer for the encoder. More... | |
size_t | ug::Base64FileWriter::m_lastInputByteSize |
size_t | ug::Base64FileWriter::m_numBytesWritten |
std::vector< char > | ug::Base64FileWriter::m_tmpBuff |
Format flags to enable deactivation of base64 encoding selectivly.
Enumerator | |
---|---|
base64_ascii | enables base64 encoding of all following data until Base64FileWriter::normal is set |
base64_binary | encode given values in binary base64 |
normal | behaves as usual std::ofstream |
|
inlineprivate |
Check on readiness of the file stream.
UGError | if either the filestream's badbit is set or the file stream is not open. |
References ug::Base64FileWriter::m_fStream, and UG_THROW.
Referenced by ug::Base64FileWriter::dispatch().
ug::Base64FileWriter::Base64FileWriter | ( | ) |
ug::Base64FileWriter::Base64FileWriter | ( | const char * | filename, |
const std::ios_base::openmode | mode = (std::ios_base::out|std::ios_base::trunc) |
||
) |
Constructor with name of file to write to.
[in] | filename | name of the output file |
[in] | mode | openmode for the file as defined in std::ios_base . Defaults to out | trunc , i.e. create new file or truncate existing. |
UGError | if filename can not be opened or is not writeable |
void ug::ChangeDirectory | ( | std::string | dir | ) |
Changes the current directory.
References UG_THROW.
Referenced by ug::bridge::RegisterBridge_Util().
void ug::Base64FileWriter::close | ( | ) |
Closes the file writer properly and encodes any remaining buffer content.
References ug::Base64FileWriter::flushInputBuffer(), ug::Base64FileWriter::m_fStream, PROFILE_FUNC, and UG_ASSERT.
bool ug::CreateDirectory | ( | const char * | directory | ) |
Creates a directory.
[in] | directory | name of the directory |
[in] | mode | (optional, default 0777) Sets ownership options for the file. Ignored on windows. |
Referenced by ug::DebugWriterContext::compose_file_path(), ug::bridge::LUACompiler::createC(), ug::CreateDirectoryTMP(), and ug::SchurComplementOperator< TAlgebra >::set_debug_dim().
bool ug::CreateDirectory | ( | const char * | directory, |
int | mode | ||
) |
Creates a directory.
[in] | directory | name of the directory |
[in] | mode | (optional, default 0777) Sets ownership options for the file. Ignored on windows. |
|
inlinestatic |
Creates a directory.
[in] | directory | name of the directory |
References ug::CreateDirectoryTMP().
bool ug::CreateDirectoryTMP | ( | const char * | directory | ) |
Creates a directory.
This is a hack. This function does the same as CreateDirectory. But there is a linking problem in MS VC, so that the name CreateDirectory cannot be used.
[in] | directory | name of the directory |
References ug::CreateDirectory().
Referenced by ug::CreateDirectory(), and ug::bridge::RegisterBridge_Util().
std::string ug::CurrentWorkingDirectory | ( | ) |
Current working directory
References PATH_MAX, and UG_THROW.
Referenced by ug::bridge::RegisterBridge_Util().
bool ug::DirectoryExists | ( | const char * | dirname | ) |
Checks the existence of a given directory.
[in] | name | of the directory to be checked |
true
if the specified directory exists, false
otherwise Referenced by ug::bridge::LUACompiler::createC(), ug::DirectoryExists(), ug::FindDirInStandardPaths(), ug::PathProvider::get_dirname_relative_to_current_path(), ug::PathProvider::get_dirname_relative_to_path(), and ug::bridge::RegisterBridge_Util().
|
inlinestatic |
References ug::DirectoryExists().
|
private |
Writes given data to the output file and encodes it if Base64FileWriter::base64 is set.
value | arbitrary data to write to the output file |
T | type of the data to write |
UGError | if Base64FileWriter::fmtflag is not set to Base64FileWriter::normal or Base64FileWriter::base64 |
References ug::Base64FileWriter::assertFileOpen(), ug::Base64FileWriter::base64_ascii, ug::Base64FileWriter::base64_binary, ug::Base64FileWriter::flushInputBuffer(), ug::Base64FileWriter::m_currFormat, ug::Base64FileWriter::m_fStream, ug::Base64FileWriter::m_inBuffer, ug::Base64FileWriter::m_lastInputByteSize, ug::Base64FileWriter::m_numBytesWritten, ug::Base64FileWriter::normal, and UG_ASSERT.
UG_API bool ug::FileCompare | ( | const char * | file1, |
const char * | file2 | ||
) |
!!! Serial i/o version !!!
Compares two files by their content.
Comparison is first done on file size using ug::FileSize. If the two files have same size, then the comparison is done line wise based on std::string comparison.
[in] | file1 | Path and name of the first file |
[in] | file2 | Path and name of the second file |
true
if they are the same one or different ones but with same content; false
otherwise std::runtim_error | if one or both files can not be found or opened for reading. |
References ug::FileExists(), ug::FileSize(), PROFILE_FUNC, and UG_THROW.
Referenced by ug::bridge::RegisterBridge_Util().
UG_API bool ug::FileExists | ( | const char * | filename | ) |
!!! Serial i/o version !!!
Checks the existence of a given file.
[in] | filename | path and name of the file to be checked |
true
if the specified file exists, false
otherwise References PROFILE_FUNC.
Referenced by ug::DebugWriterContext::compose_file_path(), ug::FileCompare(), ug::FileExists(), ug::FileSize(), ug::FindFileInStandardPaths(), ug::PathProvider::get_filename_relative_to_current_path(), ug::PathProvider::get_filename_relative_to_path(), ug::script::GetNormalFilename(), ug::MakeTmpFile(), ug::bridge::RegisterBridge_Util(), ug::SaveMatrixToMTX(), ug::MatrixIO::set_mat_file_name(), and ug::MatrixIOMtx::set_mat_file_name().
|
inlinestatic |
References ug::FileExists().
size_t ug::FileSize | ( | const char * | filename | ) |
Returns size of the specified file in bytes.
[in] | filename | Path and name of the file |
filename
in bytes std::runtime_error | if the specified file does not exist or could not be opened for reading. |
References ug::FileExists(), PROFILE_FUNC, and UG_THROW.
Referenced by ug::FileCompare(), ug::FileSize(), and ug::ReadFile().
|
inlinestatic |
References ug::FileSize().
UG_API bool ug::FileTypeIs | ( | const char * | filename, |
const char * | extension | ||
) |
!!! Serial i/o version !!!
Check filename extension.
[in] | filename | path and anme of the file |
[in] | extension | desired file extension (including leading dot) |
true
if filename
has given extension, false
otherwise References name, and PROFILE_FUNC.
Referenced by ug::SaveMatrixToMTX(), ug::AlgebraDebugWriter< TAlgebra >::write_matrix(), ug::GridFunctionDebugWriter< TDomain, TAlgebra >::write_matrix(), ug::GridFunctionDebugWriter< TDomain, TAlgebra >::write_vector_to_conn_viewer(), ug::WriteMatrixToConnectionViewer(), ug::WriteVectorCSV(), and ug::WriteVectorToConnectionViewer().
std::string ug::FindDirInStandardPaths | ( | const char * | dirname | ) |
searches the directory in the standard paths.
The checking order is the following:
References ug::APPS_PATH, ug::DirectoryExists(), ug::ROOT_PATH, and ug::SCRIPT_PATH.
std::string ug::FindFileInStandardPaths | ( | const char * | filename | ) |
searches the file in the standard paths.
The checking order is the following:
References ug::APPS_PATH, ug::FileExists(), ug::ROOT_PATH, and ug::SCRIPT_PATH.
Referenced by ug::Raster< T, TDIM >::load_from_asc(), ug::LoadGrid(), ug::LoadHeightfieldFromASC(), ug::UGXFileInfo::parse_file(), and ug::bridge::RegisterBridge_Util().
|
private |
Flushes input buffer.
force | whether to forcefully flush the buffer |
References ug::Base64FileWriter::m_fStream, ug::Base64FileWriter::m_inBuffer, ug::Base64FileWriter::m_lastInputByteSize, ug::Base64FileWriter::m_numBytesWritten, ug::Base64FileWriter::m_tmpBuff, and UG_THROW.
Referenced by ug::Base64FileWriter::close(), ug::Base64FileWriter::dispatch(), and ug::Base64FileWriter::~Base64FileWriter().
Base64FileWriter::fmtflag ug::Base64FileWriter::format | ( | ) | const |
gets the current set format
bool ug::GetDirectoriesInDirectory | ( | std::vector< std::string > & | dirsOut, |
const char * | dir | ||
) |
Returns a list of all directories in a directory.
The returned list contains as well the directory scanned as .
and its parent directory as ..
.
[out] | dirsOut | string vector for holding the list of directories |
[in] | dir | path and name of the directory to scan |
References PROFILE_FUNC.
Referenced by ug::bridge::GetDirsInDir().
bool ug::GetFilesInDirectory | ( | std::vector< std::string > & | filesOut, |
const char * | dir | ||
) |
Returns a list of all files in a directory.
[out] | filesOut | string vector for holding the list of files |
[in] | dir | path and name of the directory to scan |
References PROFILE_FUNC.
Referenced by ug::bridge::GetFilesInDir(), and ug::LoadPlugins().
std::string ug::GetTmpPath | ( | ) |
Returns a path to which an application may write temporary files.
On unix systems, this is normally "/tmp". On windows the users AppData path or something similar is returned.
Referenced by ug::bridge::RegisterBridge_Util().
UG_API std::string ug::MakeTmpFile | ( | std::string | filename, |
const std::string & | extension, | ||
bool & | bSuccess | ||
) |
filename | filename including path (e.g. /Users/horst/file1) |
extension | the extension to be added to the file e.g. txt |
bSuccess | true if successful, false otherwise |
void ug::Base64FileWriter::open | ( | const char * | filename, |
const std::ios_base::openmode | mode = std::ios_base::out |
||
) |
References ug::Base64FileWriter::m_fStream, and UG_THROW.
Base64FileWriter & ug::Base64FileWriter::operator<< | ( | char | c | ) |
Base64FileWriter & ug::Base64FileWriter::operator<< | ( | const char * | cstr | ) |
Base64FileWriter & ug::Base64FileWriter::operator<< | ( | const fmtflag | format | ) |
Switch between normal and base64 encoded output.
format | one of the values defined in Base64FileWriter::fmtflag |
References PROFILE_FUNC.
Base64FileWriter& ug::Base64FileWriter::operator<< | ( | const std::string & | str | ) |
Base64FileWriter & ug::Base64FileWriter::operator<< | ( | double | d | ) |
Base64FileWriter & ug::Base64FileWriter::operator<< | ( | float | f | ) |
Base64FileWriter & ug::Base64FileWriter::operator<< | ( | int | i | ) |
Base64FileWriter & ug::Base64FileWriter::operator<< | ( | long | l | ) |
Base64FileWriter & ug::Base64FileWriter::operator<< | ( | size_t | s | ) |
UG_API bool ug::ReadFile | ( | const char * | filename, |
vector< char > & | file, | ||
bool | bText | ||
) |
filename | filename to read |
file | vector to put whole file into |
bText | if true, open file with r, otherwise rb used in |
!!! Serial i/o version !!! in parallel, see ParallelReadFile.
References ug::FileSize(), PROFILE_FUNC, and UG_COND_THROW.
Referenced by ug::script::LoadUGScript(), and pcl::ParallelReadFile().
|
inlinestatic |
used to unset flags set by std::scientific or std::fixed.
example: std::cout << std::scienfitic << myDouble << "\n"; std::cout << reset_floats << myPrecentage << "\n"; also in UG_LOG: UG_LOG(reset_floats << myValue);
Referenced by ug::AutoLinearSolver< TVector >::apply_return_defect(), ug::checksub(), ug::PILUTPreconditioner< TAlgebra >::preprocess(), ug::ILUTPreconditioner< TAlgebra >::preprocess_mat2(), ug::AutoLinearSolver< TVector >::print_information(), ug::Progress::stop(), and ug::ParallelProgress::stop().
ug::Base64FileWriter::~Base64FileWriter | ( | ) |
Destructor, which properly flushs encoder's internal buffer and closes file stream.
References ug::Base64FileWriter::flushInputBuffer(), and ug::Base64FileWriter::m_fStream.
|
private |
Current write format (base64
or normal
)
Referenced by ug::Base64FileWriter::dispatch().
|
private |
File stream to write everything to.
Referenced by ug::Base64FileWriter::assertFileOpen(), ug::Base64FileWriter::close(), ug::Base64FileWriter::dispatch(), ug::Base64FileWriter::flushInputBuffer(), ug::Base64FileWriter::open(), and ug::Base64FileWriter::~Base64FileWriter().
|
private |
Internal input buffer for the encoder.
Referenced by ug::Base64FileWriter::dispatch(), and ug::Base64FileWriter::flushInputBuffer().
|
private |
Referenced by ug::Base64FileWriter::dispatch(), and ug::Base64FileWriter::flushInputBuffer().
|
private |
number of bytes written between flushes
Referenced by ug::Base64FileWriter::dispatch(), and ug::Base64FileWriter::flushInputBuffer().
|
private |
buffer used while flushing
Referenced by ug::Base64FileWriter::flushInputBuffer().