libdballe 5.10
aoffile.h
Go to the documentation of this file.
00001 /*
00002  * dballe/aoffile - AOF File I/O
00003  *
00004  * Copyright (C) 2005--2010  ARPA-SIM <urpsim@smr.arpa.emr.it>
00005  *
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00018  *
00019  * Author: Enrico Zini <enrico@enricozini.com>
00020  */
00021 
00022 #ifndef DBA_CORE_AOFFILE_H
00023 #define DBA_CORE_AOFFILE_H
00024 
00032 #include <dballe/core/file.h>
00033 #include <stdint.h>
00034 
00035 namespace dballe {
00036 
00037 class AofFile : public dballe::File
00038 {
00039 protected:
00048     bool read_record(std::string& res);
00049 
00057     void write_record(const std::string& res);
00058 
00066     void write_record(const uint32_t* words, size_t wordcount);
00067 
00071     void write_word(uint32_t word);
00072 
00073 public:
00074     AofFile(const std::string& name, FILE* fd, bool close_on_exit=true);
00075     virtual ~AofFile();
00076 
00077     virtual Encoding type() const throw () { return AOF; }
00078 
00079     bool read(Rawmsg& msg);
00080     void write(const Rawmsg& msg);
00081 
00082 
00087     void read_header();
00088 
00090     void write_dummy_header();
00091 
00095     void fix_header();
00096 };
00097 
00098 } // namespace dballe
00099 
00100 /* vim:set ts=4 sw=4: */
00101 #endif