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