libdballe  6.8
aoffile.h
Go to the documentation of this file.
1 /*
2  * dballe/aoffile - AOF File I/O
3  *
4  * Copyright (C) 2005--2010 ARPA-SIM <urpsim@smr.arpa.emr.it>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18  *
19  * Author: Enrico Zini <enrico@enricozini.com>
20  */
21 
22 #ifndef DBA_CORE_AOFFILE_H
23 #define DBA_CORE_AOFFILE_H
24 
32 #include <dballe/core/file.h>
33 #include <stdint.h>
34 
35 namespace dballe {
36 
37 class AofFile : public dballe::File
38 {
39 protected:
48  bool read_record(std::string& res);
49 
57  void write_record(const std::string& res);
58 
66  void write_record(const uint32_t* words, size_t wordcount);
67 
71  void write_word(uint32_t word);
72 
73 public:
74  AofFile(const std::string& name, FILE* fd, bool close_on_exit=true);
75  virtual ~AofFile();
76 
77  virtual Encoding type() const throw () { return AOF; }
78 
79  bool read(Rawmsg& msg);
80  void write(const Rawmsg& msg);
81 
82 
87  void read_header();
88 
90  void write_dummy_header();
91 
95  void fix_header();
96 };
97 
98 } // namespace dballe
99 
100 /* vim:set ts=4 sw=4: */
101 #endif
bool read_record(std::string &res)
Read a Fortran Unformatted Sequential Binary record from a file.
void read_header()
Read the file header, perform some consistency checks then discard the data.
FILE * fd
FILE structure used to read or write to the file.
Definition: file.h:52
void write_word(uint32_t word)
Write a word to the file, byteswapping it for endianness if needed.
void write_record(const std::string &res)
Write a Fortran Unformatted Sequential Binary record to a file.
File I/O for files containing meterorological messages.
virtual Encoding type() const
Get the name of the dba_file.
Definition: aoffile.h:77
Definition: cmdline.h:34
Definition: file.h:46
void write(const Rawmsg &msg)
Write the encoded message data to the file.
void write_dummy_header()
Write a dummy file header.
Definition: aoffile.h:37
const std::string & name() const
Get the type of the dba_file.
Definition: file.h:73
Annotated string buffer for encoded messages.
Definition: rawmsg.h:38
bool read(Rawmsg &msg)
Read a message from the file.
void fix_header()
Rewrite the file header, scanning the file to compute a correct one.
bool close_on_exit
Set to true if fd should be closed when dba_file_delete() is called.
Definition: file.h:54