casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EndianStream.h
Go to the documentation of this file.
1 #ifndef EndianStream_CLASS
2 #define EndianStream_CLASS
3 
4 #include <stdint.h>
5 #include <iostream>
6 #include <fstream>
7 #include <sstream>
8 #include <string>
9 
10 #include <alma/ASDM/Misc.h>
11 
12 namespace asdm {
13 
14  class EndianOSStream : public std::ostringstream {
15  protected :
16  //ostringstream _oss(stringstream::out | stringstream::binary);
17 
18  public :
19  EndianOSStream() ;
22 
23  const asdm::ByteOrder* byteOrder() const;
24 
25  void writeBoolean(bool b);
26  void writeBool(bool b);
27  void writeByte(char c);
28  void writeShort(short int s);
29  void writeUShort(unsigned short int s);
30  void writeInt(int i);
31  void writeUInt(unsigned int ui);
32  void writeLongLong(int64_t li);
33  void writeLong(int64_t li);
34  void writeULongLong(uint64_t li);
35  void writeFloat(float f);
36  void writeDouble(double d);
37  void writeString(const std::string& s);
38 
39  private:
41 
42  };
43 
44  class EndianIStream {
45  public:
46  virtual const asdm::ByteOrder* byteOrder() const = 0;
47  virtual bool readBoolean() = 0;
48  virtual char readByte() = 0;
49  virtual short int readShort() = 0;
50  virtual unsigned short int readUShort() = 0;
51  virtual int readInt() = 0 ;
52  virtual unsigned int readUInt() = 0 ;
53  virtual int64_t readLongLong() = 0 ;
54  virtual int64_t readLong() = 0 ;
55  virtual uint64_t readULongLong() = 0 ;
56  virtual float readFloat() = 0 ;
57  virtual double readDouble() = 0 ;
58  virtual std::string readString() = 0 ;
59  virtual ~EndianIStream() { ; }
60  };
61 
62  class EndianISStream : public std::istringstream, EndianIStream {
63  public :
64  EndianISStream(const std::string& s) ;
65  EndianISStream(const std::string& s, const asdm::ByteOrder* byteOrder);
67 
68  const asdm::ByteOrder* byteOrder() const ;
69  bool readBoolean();
70  char readByte();
71  short int readShort();
72  unsigned short int readUShort();
73  int readInt();
74  unsigned int readUInt();
75  int64_t readLongLong();
76  int64_t readLong();
77  uint64_t readULongLong();
78  float readFloat();
79  double readDouble();
80  std::string readString();
81 
82  private :
84  };
85 
87  public :
89  EndianIFStream(std::ifstream* ifs_p) ;
90  EndianIFStream(std::ifstream* ifs_p, const asdm::ByteOrder* byteOrder);
92 
93  const asdm::ByteOrder* byteOrder() const ;
94  bool readBoolean();
95  char readByte();
96  short int readShort();
97  unsigned short int readUShort();
98  int readInt();
99  unsigned int readUInt();
100  int64_t readLongLong();
101  int64_t readLong();
102  uint64_t readULongLong();
103  float readFloat();
104  double readDouble();
105  std::string readString();
106 
107  private :
108  std::ifstream* ifs_p;
110  };
111 
118  public :
119  virtual void operator()(EndianIStream& eis) = 0;
120  virtual ~BinaryAttributeReaderFunctor() = 0;
121  };
122 
123 }; // end namespace asdm
124 
125 #endif // EndianStream_CLASS
virtual short int readShort()=0
unsigned int readUInt()
virtual unsigned short int readUShort()=0
const asdm::ByteOrder * byteOrder() const
std::string readString()
short int readShort()
uint64_t readULongLong()
std::ifstream * ifs_p
Definition: EndianStream.h:108
const asdm::ByteOrder * byteOrder_
Definition: EndianStream.h:83
A class to represent byte order information.
Definition: Misc.h:115
const asdm::ByteOrder * byteOrder() const
unsigned short int readUShort()
EndianOSStream()
ostringstream _oss(stringstream::out | stringstream::binary);
std::string readString()
virtual void operator()(EndianIStream &eis)=0
uint64_t readULongLong()
void writeLongLong(int64_t li)
virtual float readFloat()=0
virtual ~EndianIStream()
Definition: EndianStream.h:59
virtual int64_t readLongLong()=0
void writeBool(bool b)
const asdm::ByteOrder * byteOrder_
Definition: EndianStream.h:109
void writeString(const std::string &s)
short int readShort()
virtual const asdm::ByteOrder * byteOrder() const =0
EndianISStream(const std::string &s)
virtual uint64_t readULongLong()=0
void writeLong(int64_t li)
void writeInt(int i)
void writeULongLong(uint64_t li)
void writeShort(short int s)
unsigned short int readUShort()
void writeBoolean(bool b)
virtual double readDouble()=0
virtual bool readBoolean()=0
virtual char readByte()=0
void writeDouble(double d)
unsigned int readUInt()
void writeUShort(unsigned short int s)
A pure virtual class whose derived classes are expected to be functors whose behaviours will be to re...
Definition: EndianStream.h:117
void writeByte(char c)
void writeUInt(unsigned int ui)
const Double c
Fundamental physical constants (SI units):
const asdm::ByteOrder * byteOrder() const
const asdm::ByteOrder * byteOrder_
Definition: EndianStream.h:40
virtual int64_t readLong()=0
virtual unsigned int readUInt()=0
virtual int readInt()=0
void writeFloat(float f)
virtual std::string readString()=0