1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
|
/*
* Copyright (c) 2002-2006 Samit Basu
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef __Serialize_hpp__
#define __Serialize_hpp__
#include "Stream.hpp"
#include "Array.hpp"
#include <QIODevice>
// This is the cross-platform serialization object...
class Serialize {
QIODevice *s;
bool endianSwap;
public:
Serialize(QIODevice*);
~Serialize();
// Handshake between two serialize objects
void handshakeServer();
void handshakeClient();
// Send a signature
void sendSignature(char sig, int count);
// Check a signature
void checkSignature(char sig, int count);
// Send a stream of base objects
void putBytes(const char* ptr, int count);
void putShorts(const short* ptr, int count);
void putInts(const int* ptr, int count);
void putI64s(const int64* ptr, int count);
void putFloats(const float* ptr, int count);
void putDoubles(const double* ptr, int count);
// Send a scalar object
void putString(QString t);
void putByte(char t);
void putShort(short t);
void putInt(int t);
void putFloat(float t);
void putDouble(double t);
void putBool(bool t);
void putStringVector(StringVector t);
// Receive a stream of base objects
void getBytes(char* ptr, int count);
void getShorts(short* ptr, int count);
void getInts(int* ptr, int count);
void getI64s(int64* ptr, int count);
void getFloats(float* ptr, int count);
void getDoubles(double* ptr, int count);
// Get a scalar object
QString getString();
char getByte();
short getShort();
int getInt();
float getFloat();
double getDouble();
bool getBool();
StringVector getStringVector();
// Put an array
void putDataClass(DataClass cls, bool sparseflag, bool isuserclass, StringVector className, bool complexflag);
void putArray(const Array& dat);
void putDimensions(const NTuple& dim);
// Get an array
DataClass getDataClass(bool& sparseflag, StringVector& className, bool& complexflag);
void getArray(Array& dat);
NTuple getDimensions();
};
#endif
|