GEOS  3.3.3
ByteOrderDataInStream.h
1 /**********************************************************************
2  * $Id: ByteOrderDataInStream.h 2579 2009-06-15 14:03:52Z strk $
3  *
4  * GEOS - Geometry Engine Open Source
5  * http://geos.refractions.net
6  *
7  * Copyright (C) 2005-2006 Refractions Research Inc.
8  * Copyright (C) 2001-2002 Vivid Solutions Inc.
9  *
10  * This is free software; you can redistribute and/or modify it under
11  * the terms of the GNU Lesser General Public Licence as published
12  * by the Free Software Foundation.
13  * See the COPYING file for more information.
14  *
15  **********************************************************************
16  *
17  * Last port: io/ByteOrderDataInStream.java rev. 1.1 (JTS-1.10)
18  *
19  **********************************************************************/
20 
21 #ifndef GEOS_IO_BYTEORDERDATAINSTREAM_H
22 #define GEOS_IO_BYTEORDERDATAINSTREAM_H
23 
24 #include <geos/export.h>
25 
26 //#include <geos/platform.h>
27 //#include <geos/io/ParseException.h>
28 //#include <geos/io/ByteOrderValues.h>
29 #include <geos/inline.h>
30 
31 #include <iosfwd> // ostream, istream (if we remove inlines)
32 
33 namespace geos {
34 namespace io {
35 
36 /*
37  * \class ByteOrderDataInStream io.h geos.h
38  *
39  * Allows reading an stream of primitive datatypes from an underlying
40  * istream, with the representation being in either common byte ordering.
41  *
42  */
43 class GEOS_DLL ByteOrderDataInStream {
44 
45 public:
46 
47  ByteOrderDataInStream(std::istream *s=NULL);
48 
49  ~ByteOrderDataInStream();
50 
55  void setInStream(std::istream *s);
56 
57  void setOrder(int order);
58 
59  unsigned char readByte(); // throws ParseException
60 
61  int readInt(); // throws ParseException
62 
63  long readLong(); // throws ParseException
64 
65  double readDouble(); // throws ParseException
66 
67 private:
68  int byteOrder;
69  std::istream *stream;
70 
71  // buffers to hold primitive datatypes
72  unsigned char buf[8];
73 
74 };
75 
76 } // namespace io
77 } // namespace geos
78 
79 #ifdef GEOS_INLINE
80 #include <geos/io/ByteOrderDataInStream.inl>
81 #endif
82 
83 #endif // #ifndef GEOS_IO_BYTEORDERDATAINSTREAM_H
84 
85 /**********************************************************************
86  * $Log$
87  * Revision 1.2 2006/03/28 11:26:13 strk
88  * ByteOrderDataInStream inlines moved to .inl file, updated
89  * implementation files includes.
90  *
91  * Revision 1.1 2006/03/20 18:18:14 strk
92  * io.h header split
93  *
94  **********************************************************************/