[Liblas-commits] laszip: Use explicit std:: prefix for streams,
move laszippertes...
liblas-commits at liblas.org
liblas-commits at liblas.org
Tue Dec 14 11:12:49 EST 2010
changeset ab8bf5e582b0 in /Volumes/Data/www/liblas.org/laszip
details: http://hg.liblas.orglaszip?cmd=changeset;node=ab8bf5e582b0
summary: Use explicit std:: prefix for streams, move laszippertest into the tools directory, turn off lasdiff and laszip for now, as these depend on LAStools.
diffstat:
include/laszip/laszipper.hpp | 74 +++++-----
src/CMakeLists.txt | 6 +-
src/bytestreamin_istream.hpp | 9 +-
src/bytestreamout_ostream.hpp | 84 ++++++-----
src/laszipper.cpp | 80 +++++-----
src/laszippertest.cpp | 279 -----------------------------------------
tools/CMakeLists.txt | 13 +-
tools/laszippertest.cpp | 284 ++++++++++++++++++++++++++++++++++++++++++
8 files changed, 430 insertions(+), 399 deletions(-)
diffs (truncated from 988 to 300 lines):
diff -r b33531f25c48 -r ab8bf5e582b0 include/laszip/laszipper.hpp
--- a/include/laszip/laszipper.hpp Tue Dec 14 09:46:42 2010 -0600
+++ b/include/laszip/laszipper.hpp Tue Dec 14 10:12:41 2010 -0600
@@ -1,21 +1,21 @@
-/******************************************************************************
- *
- * 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.
- *
- ****************************************************************************/
-
+/******************************************************************************
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
/*
===============================================================================
@@ -39,38 +39,44 @@
CHANGE HISTORY:
- 12 December 2010 -- created from LASwriter/LASreader after Howard got pushy (-;
+ 12 December 2010 -- created from LASwriter/LASreader after Howard got pushy (-;
===============================================================================
*/
#ifndef LAS_ZIPPER_H
#define LAS_ZIPPER_H
-#include <stdio.h>
-#include <ostream.h>
-
-#include "laszip.hpp"
+#include <stdio.h>
-class ByteStreamOut;
-class LASwritePoint;
-
+#ifdef _MSC_VER
+#include <ostream.h>
+#else
+#include <fstream>
+#endif
+
+
+#include "laszip.hpp"
+
+class ByteStreamOut;
+class LASwritePoint;
+
class LASzipper
{
public:
- bool open(FILE* outfile, unsigned int num_items, LASitem* items, unsigned int compression=0);
- bool open(ostream* outstream, unsigned int num_items, LASitem* items, unsigned int compression=0);
- bool write(unsigned char** point);
- bool chunk(LASchunk* chunk);
- bool close(LASchunk* chunk=0);
+ bool open(FILE* outfile, unsigned int num_items, LASitem* items, unsigned int compression=0);
+ bool open(std::ostream* outstream, unsigned int num_items, LASitem* items, unsigned int compression=0);
+ bool write(unsigned char** point);
+ bool chunk(LASchunk* chunk);
+ bool close(LASchunk* chunk=0);
LASzipper();
~LASzipper();
-private:
+private:
int count;
- ByteStreamOut* stream;
- LASwritePoint* writer;
+ ByteStreamOut* stream;
+ LASwritePoint* writer;
};
#endif
diff -r b33531f25c48 -r ab8bf5e582b0 src/CMakeLists.txt
--- a/src/CMakeLists.txt Tue Dec 14 09:46:42 2010 -0600
+++ b/src/CMakeLists.txt Tue Dec 14 10:12:41 2010 -0600
@@ -37,14 +37,14 @@
set(LASZIP_CPP
arithmeticdecoder.cpp
arithmeticencoder.cpp
- integercompressor.cpp
+ arithmeticmodel.cpp
+ integercompressor.cpp
lasreaditemcompressed_v1.cpp
lasreadpoint.cpp
lasunzipper.cpp
laswriteitemcompressed_v1.cpp
laswritepoint.cpp
- laszipper.cpp
- laszippertest.cpp
+ laszipper.cpp
)
set(LASZIP_SOURCES
diff -r b33531f25c48 -r ab8bf5e582b0 src/bytestreamin_istream.hpp
--- a/src/bytestreamin_istream.hpp Tue Dec 14 09:46:42 2010 -0600
+++ b/src/bytestreamin_istream.hpp Tue Dec 14 10:12:41 2010 -0600
@@ -46,7 +46,11 @@
#include "bytestreamin.hpp"
+#ifdef _MSC_VER
+#include <istream.h>
+#else
#include <fstream>
+#endif
class ByteStreamInIstream : public ByteStreamIn
{
@@ -81,7 +85,10 @@
{
// http://stackoverflow.com/questions/604431/c-reading-unsigned-char-from-file-stream
// std::ifstream only provides a specialization for char, not unsigned char.
- stream->read(bytes, num_bytes);
+
+ // WARNING, unsafe cast!!! -- hobu
+
+ stream->read( (char*)bytes, num_bytes);
return !!(stream->good());
}
diff -r b33531f25c48 -r ab8bf5e582b0 src/bytestreamout_ostream.hpp
--- a/src/bytestreamout_ostream.hpp Tue Dec 14 09:46:42 2010 -0600
+++ b/src/bytestreamout_ostream.hpp Tue Dec 14 10:12:41 2010 -0600
@@ -16,44 +16,48 @@
*
****************************************************************************/
-/*
-===============================================================================
-
- FILE: bytestreamout_ostream.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:
-
+/*
+===============================================================================
+
+ FILE: bytestreamout_ostream.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 ByteStreamOutOstream after Howard got pushy (-;
-
-===============================================================================
-*/
-#ifndef BYTE_STREAM_OUT_OSTREAM_H
-#define BYTE_STREAM_OUT_OSTREAM_H
+
+===============================================================================
+*/
+#ifndef BYTE_STREAM_OUT_OSTREAM_H
+#define BYTE_STREAM_OUT_OSTREAM_H
#include "bytestreamout.hpp"
+#ifdef _MSC_VER
#include <ostream.h>
-
-class ByteStreamOutOstream : public ByteStreamOut
-{
+#else
+#include <fstream>
+#endif
+
+class ByteStreamOutOstream : public ByteStreamOut
+{
public:
- ByteStreamOutOstream(ostream* stream);
+ ByteStreamOutOstream(std::ostream* stream);
/* write a single byte */
- bool putByte(unsigned char byte);
+ bool putByte(unsigned char byte);
/* write an array of bytes */
bool putBytes(unsigned char* bytes, unsigned int num_bytes);
/* returns how many bytes were written */
@@ -63,11 +67,11 @@
/* destructor */
~ByteStreamOutOstream(){};
private:
- ostream* stream;
- long start;
-};
+ std::ostream* stream;
+ std::ios::pos_type start;
+};
-ByteStreamOutOstream::ByteStreamOutOstream(ostream* stream)
+ByteStreamOutOstream::ByteStreamOutOstream(std::ostream* stream)
{
this->stream = stream;
resetCount();
@@ -81,18 +85,20 @@
bool ByteStreamOutOstream::putBytes(unsigned char* bytes, unsigned int num_bytes)
{
- stream->write(bytes, num_bytes);
+ stream->write((char*)bytes, num_bytes);
return !!(stream->good());
}
unsigned int ByteStreamOutOstream::byteCount() const
{
- return (stream->tellp() - start);
+ std::ios::pos_type end = stream->tellp();
+ std::ios::off_type size = end - start;
+ return static_cast<unsigned int>(size);
}
void ByteStreamOutOstream::resetCount()
{
start = stream->tellp();
}
-
-#endif
+
+#endif
diff -r b33531f25c48 -r ab8bf5e582b0 src/laszipper.cpp
--- a/src/laszipper.cpp Tue Dec 14 09:46:42 2010 -0600
+++ b/src/laszipper.cpp Tue Dec 14 10:12:41 2010 -0600
@@ -16,33 +16,33 @@
*
****************************************************************************/
-/*
-===============================================================================
-
- FILE: laszipper.cpp
-
- CONTENTS:
-
- see corresponding header file
-
- PROGRAMMERS:
-
- martin isenburg at cs.unc.edu
-
- COPYRIGHT:
-
- copyright (C) 2010 martin isenburg at cs.unc.edu
-
More information about the Liblas-commits
mailing list