[Liblas-commits] laszip: getting annoyed at hg

liblas-commits at liblas.org liblas-commits at liblas.org
Wed Dec 15 11:03:07 EST 2010


changeset f9bbc9504f92 in /Volumes/Data/www/liblas.org/laszip
details: http://hg.liblas.orglaszip?cmd=changeset;node=f9bbc9504f92
summary: getting annoyed at hg

diffstat:

 src/bytestreamin_istream.hpp |  115 +++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 115 insertions(+), 0 deletions(-)

diffs (119 lines):

diff -r 874ca24b3890 -r f9bbc9504f92 src/bytestreamin_istream.hpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/bytestreamin_istream.hpp	Wed Dec 15 08:02:55 2010 -0800
@@ -0,0 +1,115 @@
+/******************************************************************************
+ *
+ * Project:  integrating laszip into liblas - http://liblas.org -
+ * Purpose:
+ * Author:   Martin Isenburg
+ *           isenburg at cs.unc.edu
+ *
+ ******************************************************************************
+ * Copyright (c) 2010, Martin Isenburg
+ *
+ * This is free software; you can redistribute and/or modify it under
+ * the terms of the GNU Lesser General Licence as published
+ * by the Free Software Foundation.
+ *
+ * See the COPYING file for more information.
+ *
+ ****************************************************************************/
+
+/*
+===============================================================================
+
+  FILE:  bytestreamin_istream.hpp
+  
+  CONTENTS:
+      
+  PROGRAMMERS:
+  
+    martin isenburg at cs.unc.edu
+  
+  COPYRIGHT:
+  
+    copyright (C) 2010  martin isenburg at cs.unc.edu
+    
+    This software is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+  
+  CHANGE HISTORY:
+  
+    12 December 2010 -- created from ByteStreamOutFile after Howard got pushy (-;
+  
+===============================================================================
+*/
+#ifndef BYTE_STREAM_IN_ISTREAM_H
+#define BYTE_STREAM_IN_ISTREAM_H
+
+#include "bytestreamin.hpp"
+
+#if _MSC_VER < 1300
+#include <istream.h>
+#else
+#include <fstream>
+#endif
+
+using namespace std;
+
+class ByteStreamInIstream : public ByteStreamIn
+{
+public:
+  ByteStreamInIstream(istream* stream);
+/* read a single byte                                        */
+  unsigned int getByte();
+/* read an array of bytes                                    */
+  bool getBytes(unsigned char* bytes, unsigned int num_bytes);
+/* returns how many bytes were read since last reset         */
+  unsigned int byteCount() const;
+/* reset byte counter                                        */
+  void resetCount();
+/* destructor                                                */
+  ~ByteStreamInIstream(){};
+private:
+  istream* stream;
+  ios::off_type start;
+};
+
+inline ByteStreamInIstream::ByteStreamInIstream(istream* stream)
+{
+  this->stream = stream;
+  resetCount();
+}
+
+inline unsigned int ByteStreamInIstream::getByte()
+{
+  int byte = stream->get();
+  if (stream->bad())
+  {
+    byte = 0;
+  }
+  return (unsigned int)byte;
+}
+
+inline bool ByteStreamInIstream::getBytes(unsigned char* bytes, unsigned int num_bytes)
+{
+    // http://stackoverflow.com/questions/604431/c-reading-unsigned-char-from-file-stream
+    // std::ifstream only provides a specialization for char, not unsigned char.  
+    
+    // WARNING, unsafe cast!!! -- hobu
+    
+  stream->read( (char*)bytes, num_bytes);
+  return !!(stream->good());
+}
+
+unsigned int ByteStreamInIstream::byteCount() const
+{
+  ios::pos_type end = stream->tellg();
+  ios::off_type size = end - start;
+  return static_cast<unsigned int>(size);
+}
+
+void ByteStreamInIstream::resetCount()
+{
+  start = stream->tellg();
+}
+
+#endif


More information about the Liblas-commits mailing list