STIR
6.2.0
|
This file declares various utility functions. More...
#include "stir/common.h"
#include <stdio.h>
#include <iostream>
#include <string>
#include "stir/utilities.inl"
Go to the source code of this file.
Namespaces | |
stir | |
Namespace for the STIR library (and some/most of its applications) | |
Functions | |
char * | stir::strupr (char *const str) |
make C-string uppercase | |
Functions for user input | |
template<class NUMBER > | |
NUMBER | stir::ask_num (const std::string &prompt, NUMBER minimum_value, NUMBER maximum_value, NUMBER default_value) |
A function to ask a number 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. | |
bool | stir::ask (const std::string &prompt, bool default_value) |
A function to ask a yes/no question from the user. 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... | |
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... | |
template<class FSTREAM > | |
void | stir::ask_filename_and_open (FSTREAM &s, const std::string &prompt, const std::string &default_extension, std::ios::openmode mode, bool abort_if_failed) |
Asks for a filename (with default extension) and opens the stream s with mode giving the specifics. More... | |
template<class FSTREAM > | |
void | stir::ask_filename_and_open (FSTREAM &s, const std::string &prompt, const std::string &default_extension, std::ios::openmode mode) |
as above, but with default abort_if_failed = true | |
Functions for stream/file manipulations | |
void * | stir::read_stream_in_memory (std::istream &input, std::streamsize &file_size) |
reads data into memory, returning a pointer to the memory More... | |
streamsize | stir::find_remaining_size (std::istream &input) |
Find number of remaining characters in the stream. More... | |
template<class IFSTREAM > | |
IFSTREAM & | stir::open_read_binary (IFSTREAM &s, const std::string &name) |
opens a stream for reading binary data. Calls error() when it does not succeed. More... | |
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... | |
template<class OFSTREAM > | |
OFSTREAM & | stir::open_write_binary (OFSTREAM &s, const std::string &name) |
opens a stream for writing 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... | |
template<class FSTREAM > | |
void | stir::close_file (FSTREAM &s) |
closes a stream without error checking. More... | |
void | stir::close_file (FILE *&fptr) |
closes a FILE without error checking. More... | |
Functions for filename manipulations | |
These functions work on different platforms, i.e. Unix, VAX, Windows. Also on older MacOS versions.
| |
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... | |
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. | |
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. | |
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... | |
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) | |
Variables | |
const int | stir::max_filename_length = 1000 |
some large value to say how long filenames can be in the (deprecated) function ask_filename_with_extension(char *,const std::string&, const std::string&) | |
This file declares various utility functions.