$treeview $search $mathjax
Palabos  Version 1.1
$projectbrief
$projectbrief
$searchbox

serializerIO.h

Go to the documentation of this file.
00001 /* This file is part of the Palabos library.
00002  *
00003  * Copyright (C) 2011 FlowKit Sarl
00004  * Avenue de Chailly 23
00005  * 1012 Lausanne, Switzerland
00006  * E-mail contact: contact@flowkit.com
00007  *
00008  * The most recent release of Palabos can be downloaded at 
00009  * <http://www.palabos.org/>
00010  *
00011  * The library Palabos is free software: you can redistribute it and/or
00012  * modify it under the terms of the GNU Affero General Public License as
00013  * published by the Free Software Foundation, either version 3 of the
00014  * License, or (at your option) any later version.
00015  *
00016  * The library is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU Affero General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU Affero General Public License
00022  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00023 */
00024 
00025 #ifndef SERIALIZER_IO_H
00026 #define SERIALIZER_IO_H
00027 
00028 #include "core/globalDefs.h"
00029 #include "core/serializer.h"
00030 #include <iosfwd>
00031 #include <iomanip>
00032 
00033 namespace plb {
00034 
00036 
00042 void serializerToBase64Stream(DataSerializer const* serializer, std::ostream* ostr, bool enforceUint=false);
00043 
00045 
00049 void base64StreamToUnSerializer(std::istream* istr, DataUnSerializer* unSerializer, bool enforceUint=false);
00050 
00052 
00054 template<typename T>
00055 void serializerToAsciiStream(DataSerializer const* serializer, std::ostream* ostr, plint numDigits=8);
00056 
00057 
00059 
00061 template<typename T>
00062 void asciiStreamToUnSerializer(std::istream* istr, DataUnSerializer* unSerializer);
00063 
00064 
00065 /* *************** Class AsciiWriter ******************************** */
00066 
00067 template<typename T>
00068 class AsciiWriter : public SerializedWriter {
00069 public:
00070     AsciiWriter(std::ostream* ostr_, plint numDigits_);
00071     virtual AsciiWriter<T>* clone() const;
00072     virtual void writeHeader(pluint dataSize);
00073     virtual void writeData(char const* dataBuffer, pluint bufferSize);
00074 private:
00075     std::ostream* ostr;
00076     plint numDigits;
00077 };
00078 
00079 /* *************** Class AsciiReader ******************************** */
00080 
00081 template<typename T>
00082 class AsciiReader : public SerializedReader {
00083 public:
00084     AsciiReader(std::istream* istr_);
00085     virtual AsciiReader<T>* clone() const;
00086     virtual void readHeader(pluint dataSize) const;
00087     virtual void readData(char* dataBuffer, pluint bufferSize) const;
00088 private:
00089     std::istream* istr;
00090 };
00091 
00092 
00093 template<typename T>
00094 void serializerToAsciiStream(DataSerializer const* serializer, std::ostream* ostr, plint numDigits);
00095 
00096 template<typename T>
00097 void asciiStreamToUnSerializer(std::istream* istr, DataUnSerializer* unSerializer);
00098 
00099 } // namespace plb
00100 
00101 #endif  // SERIALIZER_IO_H