GEOS 3.4.2

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List

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/platform.h>
26 //#include <geos/io/ParseException.h>
27 //#include <geos/io/ByteOrderValues.h>
28 #include <geos/inline.h>
29
30 #include <iosfwd> // ostream, istream (if we remove inlines)
31
32 namespace geos {
33 namespace io {
34
35 /*
36 * \class ByteOrderDataInStream io.h geos.h
37 *
38 * Allows reading an stream of primitive datatypes from an underlying
39 * istream, with the representation being in either common byte ordering.
40 *
41 */
42 class GEOS_DLL ByteOrderDataInStream {
43
44 public:
45
46 ByteOrderDataInStream(std::istream *s=NULL);
47
48 ~ByteOrderDataInStream();
49
54 void setInStream(std::istream *s);
55
56 void setOrder(int order);
57
58 unsigned char readByte(); // throws ParseException
59
60 int readInt(); // throws ParseException
61
62 long readLong(); // throws ParseException
63
64 double readDouble(); // throws ParseException
65
66 private:
67 int byteOrder;
68 std::istream *stream;
69
70 // buffers to hold primitive datatypes
71 unsigned char buf[8];
72
73 };
74
75 } // namespace io
76 } // namespace geos
77
78 #ifdef GEOS_INLINE
79 #include <geos/io/ByteOrderDataInStream.inl>
80 #endif
81
82 #endif // #ifndef GEOS_IO_BYTEORDERDATAINSTREAM_H