GEOS
3.4.2
|
00001 /********************************************************************** 00002 * 00003 * GEOS - Geometry Engine Open Source 00004 * http://geos.osgeo.org 00005 * 00006 * Copyright (C) 2005-2006 Refractions Research Inc. 00007 * Copyright (C) 2001-2002 Vivid Solutions Inc. 00008 * 00009 * This is free software; you can redistribute and/or modify it under 00010 * the terms of the GNU Lesser General Public Licence as published 00011 * by the Free Software Foundation. 00012 * See the COPYING file for more information. 00013 * 00014 ********************************************************************** 00015 * 00016 * Last port: io/ByteOrderDataInStream.java rev. 1.1 (JTS-1.10) 00017 * 00018 **********************************************************************/ 00019 00020 #ifndef GEOS_IO_BYTEORDERDATAINSTREAM_H 00021 #define GEOS_IO_BYTEORDERDATAINSTREAM_H 00022 00023 #include <geos/export.h> 00024 00025 //#include <geos/platform.h> 00026 //#include <geos/io/ParseException.h> 00027 //#include <geos/io/ByteOrderValues.h> 00028 #include <geos/inline.h> 00029 00030 #include <iosfwd> // ostream, istream (if we remove inlines) 00031 00032 namespace geos { 00033 namespace io { 00034 00035 /* 00036 * \class ByteOrderDataInStream io.h geos.h 00037 * 00038 * Allows reading an stream of primitive datatypes from an underlying 00039 * istream, with the representation being in either common byte ordering. 00040 * 00041 */ 00042 class GEOS_DLL ByteOrderDataInStream { 00043 00044 public: 00045 00046 ByteOrderDataInStream(std::istream *s=NULL); 00047 00048 ~ByteOrderDataInStream(); 00049 00054 void setInStream(std::istream *s); 00055 00056 void setOrder(int order); 00057 00058 unsigned char readByte(); // throws ParseException 00059 00060 int readInt(); // throws ParseException 00061 00062 long readLong(); // throws ParseException 00063 00064 double readDouble(); // throws ParseException 00065 00066 private: 00067 int byteOrder; 00068 std::istream *stream; 00069 00070 // buffers to hold primitive datatypes 00071 unsigned char buf[8]; 00072 00073 }; 00074 00075 } // namespace io 00076 } // namespace geos 00077 00078 #ifdef GEOS_INLINE 00079 #include <geos/io/ByteOrderDataInStream.inl> 00080 #endif 00081 00082 #endif // #ifndef GEOS_IO_BYTEORDERDATAINSTREAM_H