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