• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List

ByteOrderDataInStream.h

00001 /**********************************************************************
00002  * $Id: ByteOrderDataInStream.h 2579 2009-06-15 14:03:52Z 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  * Last port: io/ByteOrderDataInStream.java rev. 1.1 (JTS-1.10)
00018  *
00019  **********************************************************************/
00020 
00021 #ifndef GEOS_IO_BYTEORDERDATAINSTREAM_H
00022 #define GEOS_IO_BYTEORDERDATAINSTREAM_H
00023 
00024 #include <geos/export.h>
00025 
00026 //#include <geos/platform.h>
00027 //#include <geos/io/ParseException.h>
00028 //#include <geos/io/ByteOrderValues.h>
00029 #include <geos/inline.h>
00030 
00031 #include <iosfwd> // ostream, istream (if we remove inlines)
00032 
00033 namespace geos {
00034 namespace io {
00035 
00036 /*
00037  * \class ByteOrderDataInStream io.h geos.h
00038  * 
00039  * Allows reading an stream of primitive datatypes from an underlying
00040  * istream, with the representation being in either common byte ordering.
00041  *
00042  */
00043 class GEOS_DLL ByteOrderDataInStream {
00044 
00045 public:
00046 
00047         ByteOrderDataInStream(std::istream *s=NULL);
00048 
00049         ~ByteOrderDataInStream();
00050 
00055         void setInStream(std::istream *s);
00056 
00057         void setOrder(int order);
00058 
00059         unsigned char readByte(); // throws ParseException
00060 
00061         int readInt(); // throws ParseException
00062 
00063         long readLong(); // throws ParseException
00064 
00065         double readDouble(); // throws ParseException
00066 
00067 private:
00068         int byteOrder;
00069         std::istream *stream;
00070 
00071         // buffers to hold primitive datatypes
00072         unsigned char buf[8];
00073 
00074 };
00075 
00076 } // namespace io
00077 } // namespace geos
00078 
00079 #ifdef GEOS_INLINE
00080 #include <geos/io/ByteOrderDataInStream.inl>
00081 #endif
00082 
00083 #endif // #ifndef GEOS_IO_BYTEORDERDATAINSTREAM_H
00084 
00085 /**********************************************************************
00086  * $Log$
00087  * Revision 1.2  2006/03/28 11:26:13  strk
00088  * ByteOrderDataInStream inlines moved to .inl file, updated
00089  * implementation files includes.
00090  *
00091  * Revision 1.1  2006/03/20 18:18:14  strk
00092  * io.h header split
00093  *
00094  **********************************************************************/

Generated on Thu Jul 22 2010 for GEOS by  doxygen 1.7.1