STIR  6.2.0
Namespaces | Functions
utilities.cxx File Reference

non-inline implementations for utility.h More...

#include "stir/utilities.h"
#include "stir/IndexRange3D.h"
#include "stir/error.h"
#include <iostream>
#include <fstream>

Namespaces

 stir
 Namespace for the STIR library (and some/most of its applications)
 

Functions

template<class FSTREAM >
void stir::ask_filename_and_open (FSTREAM &s, const string &prompt, const string &default_extension, ios::openmode mode, bool abort_if_failed)
 
template void stir::ask_filename_and_open (ifstream &s, const string &prompt, const string &default_extension, ios::openmode mode, bool abort_if_failed)
 
template void stir::ask_filename_and_open (ofstream &s, const string &prompt, const string &default_extension, ios::openmode mode, bool abort_if_failed)
 
template void stir::ask_filename_and_open (fstream &s, const string &prompt, const string &default_extension, ios::openmode mode, bool abort_if_failed)
 
void * stir::read_stream_in_memory (istream &input, streamsize &file_size)
 
Functions for user input
bool stir::ask (const std::string &prompt, bool default_value)
 A function to ask a yes/no question from the user. More...
 
string stir::ask_string (const std::string &prompt, const std::string &default_value="")
 A function to ask a string from the user.
 
string stir::ask_filename_with_extension (const std::string &prompt, const std::string &default_extension)
 Asks for a filename (appending an extension if none is provided). More...
 
char * stir::ask_filename_with_extension (char *file_in_directory_name, const std::string &prompt, const std::string &default_extension)
 Asks for a filename (appending an extension if none is provided) and stores the string where file_in_directory_name points to. More...
 
Functions for stream/file manipulations
FILE *& stir::open_read_binary (FILE *&fptr, const std::string &name)
 opens a FILE for reading binary data. Calls error() when it does not succeed. More...
 
FILE *& stir::open_write_binary (FILE *&fptr, const std::string &name)
 opens a FILE for writing binary data. Calls error() when it does not succeed. More...
 
void stir::close_file (FILE *&fptr)
 closes a FILE without error checking. More...
 
streamsize stir::find_remaining_size (std::istream &input)
 Find number of remaining characters in the stream. More...
 
Functions for filename manipulations

These functions work on different platforms, i.e. Unix, VAX, Windows. Also on older MacOS versions.

Warning
Functions that work on char* might be removed at some point.
const char * stir::find_filename (const char *const filename_with_directory)
 return a pointer to the start of the filename (i.e. after directory specifications) More...
 
string::size_type stir::find_pos_of_filename (const std::string &filename_with_directory)
 return the position of the start of the filename (i.e. after directory specifications) More...
 
string stir::get_filename (const std::string &filename_with_directory)
 return a std::string containing only the filename (i.e. after directory specifications) More...
 
char * stir::get_directory_name (char *directory_name, const char *const filename_with_directory)
 Copies the directory part from 'filename_with_directory' into 'directory_name' and returns the 'directory_name' pointer. More...
 
string stir::get_directory_name (const std::string &filename_with_directory)
 Returns a string with the directory part from 'filename_with_directory'. More...
 
string::size_type stir::find_pos_of_extension (const std::string &file_in_directory_name)
 find the position of the '.' of the extension More...
 
string & stir::add_extension (std::string &file_in_directory_name, const std::string &extension)
 Append extension if none present.
 
string & stir::replace_extension (std::string &file_in_directory_name, const std::string &extension)
 Replace extension (or append if none present)
 
bool stir::is_absolute_pathname (const char *const filename_with_directory)
 Checks if the filename points to an absolute location, or is a relative (e.g. to current directory) pathname.
 
bool stir::is_absolute_pathname (const std::string &filename_with_directory)
 Checks if the filename points to an absolute location, or is a relative (e.g. to current directory) pathname.
 
char * stir::prepend_directory_name (char *filename_with_directory, const char *const directory_name)
 Prepend directory_name to the filename, but only if !is_absolute_pathname(filename_with_directory) More...
 

Detailed Description

non-inline implementations for utility.h

Author
Kris Thielemans
Sanida Mustafovic
PARAPET project