ARTS  2.0.49
file.h
Go to the documentation of this file.
1 /* Copyright (C) 2000-2008 Stefan Buehler <sbuehler@ltu.se>
2 
3  This program is free software; you can redistribute it and/or modify it
4  under the terms of the GNU General Public License as published by the
5  Free Software Foundation; either version 2, or (at your option) any
6  later version.
7 
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  GNU General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License
14  along with this program; if not, write to the Free Software
15  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
16  USA. */
17 
18 
20 // File description
22 
32 #ifndef file_h
33 #define file_h
34 
35 #include <fstream>
36 #include "matpackI.h"
37 #include "mystring.h"
38 
40 // Default file names
42 
43 void filename_ascii(
44  String& filename,
45  const String& varname );
46 
48  String& filename,
49  const String& varname );
50 
51 
52 
54 // Functions to open and read ASCII files
56 
57 void open_output_file(ofstream& file, const String& name);
58 
59 void cleanup_output_file(ofstream& file, const String& name);
60 
61 void open_input_file(ifstream& file, const String& name);
62 
63 void read_text_from_stream(ArrayOfString& text, istream& is);
64 
65 void read_text_from_file(ArrayOfString& text, const String& name);
66 
67 String expand_path(const String& path);
68 
69 void replace_all(String& s, const String& what, const String& with);
70 
71 int check_newline(const String& s);
72 
73 bool file_exists (const String& filename);
74 
75 bool find_file (String& filename, const char* extension);
76 
77 #endif
open_output_file
void open_output_file(ofstream &file, const String &name)
Open a file for writing.
Definition: file.cc:97
replace_all
void replace_all(String &s, const String &what, const String &with)
Replace all occurances of ‘what’ in ‘s’ with ‘with’.
Definition: file.cc:296
cleanup_output_file
void cleanup_output_file(ofstream &file, const String &name)
Closes the file.
Definition: file.cc:146
matpackI.h
Array
This can be used to make arrays out of anything.
Definition: array.h:103
filename_bin
void filename_bin(String &filename, const String &varname)
read_text_from_stream
void read_text_from_stream(ArrayOfString &text, istream &is)
Read an ASCII stream and append the contents to the String array text.
Definition: file.cc:197
open_input_file
void open_input_file(ifstream &file, const String &name)
Open a file for reading.
Definition: file.cc:160
my_basic_string
The implementation for String, the ARTS string class.
Definition: mystring.h:62
read_text_from_file
void read_text_from_file(ArrayOfString &text, const String &name)
Reads an ASCII file and appends the contents to the String vector text.
Definition: file.cc:238
expand_path
String expand_path(const String &path)
Definition: file.cc:274
find_file
bool find_file(String &filename, const char *extension)
Find the given file.
Definition: file.cc:379
check_newline
int check_newline(const String &s)
Checks if there is exactly one newline character at the end of the string.
Definition: file.cc:317
filename_ascii
void filename_ascii(String &filename, const String &varname)
Gives the default file name for the ASCII formats.
Definition: file.cc:71
file_exists
bool file_exists(const String &filename)
Checks if the given file exists.
Definition: file.cc:353
mystring.h
This file contains the definition of String, the ARTS string class.