#include <fstream>
#include "matpackI.h"
#include "mystring.h"
Go to the source code of this file.
Functions | |
void | filename_ascii (String &filename, const String &varname) |
Gives the default file name for the ASCII formats. | |
void | filename_bin (String &filename, const String &varname) |
void | open_output_file (ofstream &file, const String &name) |
Open a file for writing. | |
void | open_input_file (ifstream &file, const String &name) |
Open a file for reading. | |
void | read_text_from_stream (ArrayOfString &text, istream &is) |
Read an ASCII stream and append the contents to the String array text. | |
void | read_text_from_file (ArrayOfString &text, const String &name) |
Reads an ASCII file and appends the contents to the String vector text. | |
void | replace_all (String &s, const String &what, const String &with) |
Replace all occurances of `what' in `s' with `with'. | |
int | check_newline (const String &s) |
Checks if there is exactly one newline character at the end of the string. | |
bool | file_exists (const String &filename) |
Checks if the given file exists. | |
bool | find_file (String &filename, const char *extension) |
Find the given file. |
Definition in file file.h.
int check_newline | ( | const String & | s | ) |
Checks if there is exactly one newline character at the end of the string.
s | The String to check. |
Definition at line 262 of file file.cc.
References replace_all().
Referenced by md_sanity_checks().
bool file_exists | ( | const String & | filename | ) |
Checks if the given file exists.
filename | File to check. |
Definition at line 298 of file file.cc.
Referenced by find_file().
Gives the default file name for the ASCII formats.
The default name is only used if the file name is empty.
filename | Output: file name | |
varname | variable name |
Definition at line 64 of file file.cc.
References out_basename.
bool find_file | ( | String & | filename, | |
const char * | extension | |||
) |
Find the given file.
If it doesn't exist in the current directory, also search the include path.
filename | File to check. | |
extension | Extension tried to be appended to the filename. |
Definition at line 324 of file file.cc.
References file_exists(), Parameters::includepath, Array< base >::nelem(), and parameters.
Referenced by ArtsParser::parse_agenda(), xml_read_arts_catalogue_from_file(), and xml_read_from_file().
void open_input_file | ( | ifstream & | file, | |
const String & | name | |||
) |
Open a file for reading.
If the file cannot be opened, the exception IOError is thrown.
file | File pointer | |
name | Name of the file to open |
ios_base::failure | Somehow the file cannot be opened. |
Definition at line 130 of file file.cc.
Referenced by abs_linesReadFromArtsObsolete(), abs_linesReadFromHitran(), abs_linesReadFromHitran2004(), abs_linesReadFromJpl(), abs_linesReadFromMytran2(), abs_speciesDefineAllInScenario(), and read_text_from_file().
void open_output_file | ( | ofstream & | file, | |
const String & | name | |||
) |
Open a file for writing.
If the file cannot be opened, the exception IOError is thrown.
file | File pointer | |
name | Name of the file to open |
ios_base::failure | Could for example mean that the directory is read only. |
Definition at line 91 of file file.cc.
Referenced by main().
void read_text_from_file | ( | ArrayOfString & | text, | |
const String & | name | |||
) |
Reads an ASCII file and appends the contents to the String vector text.
This uses the function
text | Output. The contents fo the file | |
name | Name of file to read |
IOError |
Definition at line 206 of file file.cc.
References open_input_file(), and read_text_from_stream().
Referenced by SourceText::AppendFile().
void read_text_from_stream | ( | ArrayOfString & | text, | |
istream & | is | |||
) |
Read an ASCII stream and append the contents to the String array text.
TEXT IS NOT OVERWRITTEN, BUT APPENDED!
text | Output. The contents fo the file | |
is | Stream from which to read |
IOError | Some error occured during the read |
Definition at line 165 of file file.cc.
Referenced by read_text_from_file().
Replace all occurances of `what' in `s' with `with'.
s | Output. The String to act on. | |
what | The String to replace. | |
with | The replacement. |
Definition at line 241 of file file.cc.
References my_basic_string< charT >::npos.
Referenced by check_newline().