[Liblas-commits] laszip: 2 new changesets
liblas-commits at liblas.org
liblas-commits at liblas.org
Sat Dec 18 14:50:13 EST 2010
changeset e9118cc24a18 in /Volumes/Data/www/liblas.org/laszip
details: http://hg.liblas.orglaszip?cmd=changeset;node=e9118cc24a18
summary: consolidated all IO paths
changeset 5aaa3c648f10 in /Volumes/Data/www/liblas.org/laszip
details: http://hg.liblas.orglaszip?cmd=changeset;node=5aaa3c648f10
summary: consolidated all IO paths
diffstat:
include/laszip/laszip.hpp | 4 ++
src/bytestreamin_file.hpp | 12 ++++----
src/bytestreamin_istream.hpp | 58 +++++++++++++++++++++++-------------------
src/bytestreamout.hpp | 8 ++--
src/bytestreamout_file.hpp | 40 ++++++++++++++--------------
src/bytestreamout_ostream.hpp | 48 +++++++++++++++--------------------
6 files changed, 87 insertions(+), 83 deletions(-)
diffs (truncated from 397 to 300 lines):
diff -r df98c890f766 -r 5aaa3c648f10 include/laszip/laszip.hpp
--- a/include/laszip/laszip.hpp Fri Dec 17 19:44:46 2010 -0800
+++ b/include/laszip/laszip.hpp Sat Dec 18 11:49:15 2010 -0800
@@ -51,6 +51,10 @@
#define LZ_WIN32_VC6
#endif
+#define LASZIP_VERSION_MAJOR 1
+#define LASZIP_VERSION_MINOR 0
+#define LASZIP_VERSION_REVISION 0
+
#define LASZIP_COMPRESSION_NONE 0
#define LASZIP_COMPRESSION_RANGE 1
#define LASZIP_COMPRESSION_ARITHMETIC 2
diff -r df98c890f766 -r 5aaa3c648f10 src/bytestreamin_file.hpp
--- a/src/bytestreamin_file.hpp Fri Dec 17 19:44:46 2010 -0800
+++ b/src/bytestreamin_file.hpp Sat Dec 18 11:49:15 2010 -0800
@@ -122,17 +122,17 @@
inline bool ByteStreamInFile::get16bits(unsigned char* bytes)
{
- return (fread(bytes, 1, 2, file) == 2);
+ return getBytes(bytes, 2);
}
inline bool ByteStreamInFile::get32bits(unsigned char* bytes)
{
- return (fread(bytes, 1, 4, file) == 4);
+ return getBytes(bytes, 4);
}
inline bool ByteStreamInFile::get64bits(unsigned char* bytes)
{
- return (fread(bytes, 1, 8, file) == 8);
+ return getBytes(bytes, 8);
}
inline bool ByteStreamInFile::isSeekable() const
@@ -167,7 +167,7 @@
inline bool ByteStreamInFileEndianSwapped::get16bits(unsigned char* bytes)
{
- if (fread(swapped, 1, 2, file) == 2)
+ if (getBytes(swapped, 2))
{
bytes[0] = swapped[1];
bytes[1] = swapped[0];
@@ -178,7 +178,7 @@
inline bool ByteStreamInFileEndianSwapped::get32bits(unsigned char* bytes)
{
- if (fread(swapped, 1, 4, file) == 4)
+ if (getBytes(swapped, 4))
{
bytes[0] = swapped[3];
bytes[1] = swapped[2];
@@ -191,7 +191,7 @@
inline bool ByteStreamInFileEndianSwapped::get64bits(unsigned char* bytes)
{
- if (fread(swapped, 1, 8, file) == 8)
+ if (getBytes(swapped, 8))
{
bytes[0] = swapped[7];
bytes[1] = swapped[6];
diff -r df98c890f766 -r 5aaa3c648f10 src/bytestreamin_istream.hpp
--- a/src/bytestreamin_istream.hpp Fri Dec 17 19:44:46 2010 -0800
+++ b/src/bytestreamin_istream.hpp Sat Dec 18 11:49:15 2010 -0800
@@ -125,20 +125,17 @@
inline bool ByteStreamInIstream::get16bits(unsigned char* bytes)
{
- stream->read((char*)bytes, 2);
- return !!(stream->good());
+ return getBytes(bytes, 2);
}
inline bool ByteStreamInIstream::get32bits(unsigned char* bytes)
{
- stream->read((char*)bytes, 4);
- return !!(stream->good());
+ return getBytes(bytes, 4);
}
inline bool ByteStreamInIstream::get64bits(unsigned char* bytes)
{
- stream->read((char*)bytes, 8);
- return !!(stream->good());
+ return getBytes(bytes, 8);
}
inline bool ByteStreamInIstream::isSeekable() const
@@ -168,34 +165,43 @@
inline bool ByteStreamInIstreamEndianSwapped::get16bits(unsigned char* bytes)
{
- stream->read((char*)swapped, 2);
- bytes[0] = swapped[1];
- bytes[1] = swapped[0];
- return !!(stream->good());
+ if (getBytes(swapped, 2))
+ {
+ bytes[0] = swapped[1];
+ bytes[1] = swapped[0];
+ return true;
+ }
+ return false;
}
inline bool ByteStreamInIstreamEndianSwapped::get32bits(unsigned char* bytes)
{
- stream->read((char*)swapped, 4);
- bytes[0] = swapped[3];
- bytes[1] = swapped[2];
- bytes[2] = swapped[1];
- bytes[3] = swapped[0];
- return !!(stream->good());
+ if (getBytes(swapped, 4))
+ {
+ bytes[0] = swapped[3];
+ bytes[1] = swapped[2];
+ bytes[2] = swapped[1];
+ bytes[3] = swapped[0];
+ return true;
+ }
+ return false;
}
inline bool ByteStreamInIstreamEndianSwapped::get64bits(unsigned char* bytes)
{
- stream->read((char*)swapped, 8);
- bytes[0] = swapped[7];
- bytes[1] = swapped[6];
- bytes[2] = swapped[5];
- bytes[3] = swapped[4];
- bytes[4] = swapped[3];
- bytes[5] = swapped[2];
- bytes[6] = swapped[1];
- bytes[7] = swapped[0];
- return !!(stream->good());
+ if (getBytes(swapped, 8))
+ {
+ bytes[0] = swapped[7];
+ bytes[1] = swapped[6];
+ bytes[2] = swapped[5];
+ bytes[3] = swapped[4];
+ bytes[4] = swapped[3];
+ bytes[5] = swapped[2];
+ bytes[6] = swapped[1];
+ bytes[7] = swapped[0];
+ return true;
+ }
+ return false;
}
#endif
diff -r df98c890f766 -r 5aaa3c648f10 src/bytestreamout.hpp
--- a/src/bytestreamout.hpp Fri Dec 17 19:44:46 2010 -0800
+++ b/src/bytestreamout.hpp Sat Dec 18 11:49:15 2010 -0800
@@ -52,13 +52,13 @@
/* write a single byte */
virtual bool putByte(unsigned char byte) = 0;
/* write an array of bytes */
- virtual bool putBytes(unsigned char* bytes, unsigned int num_bytes) = 0;
+ virtual bool putBytes(const unsigned char* bytes, unsigned int num_bytes) = 0;
/* write 16 bit field (for implementing endian swap) */
- virtual bool put16bits(unsigned char* bytes) = 0;
+ virtual bool put16bits(const unsigned char* bytes) = 0;
/* write 32 bit field (for implementing endian swap) */
- virtual bool put32bits(unsigned char* bytes) = 0;
+ virtual bool put32bits(const unsigned char* bytes) = 0;
/* write 64 bit field (for implementing endian swap) */
- virtual bool put64bits(unsigned char* bytes) = 0;
+ virtual bool put64bits(const unsigned char* bytes) = 0;
/* is the stream seekable (e.g. standard out is not) */
virtual bool isSeekable() const = 0;
/* save position in the stream for (forward) seeking later */
diff -r df98c890f766 -r 5aaa3c648f10 src/bytestreamout_file.hpp
--- a/src/bytestreamout_file.hpp Fri Dec 17 19:44:46 2010 -0800
+++ b/src/bytestreamout_file.hpp Sat Dec 18 11:49:15 2010 -0800
@@ -55,13 +55,13 @@
/* write a single byte */
bool putByte(unsigned char byte);
/* write an array of bytes */
- bool putBytes(unsigned char* bytes, unsigned int num_bytes);
+ bool putBytes(const unsigned char* bytes, unsigned int num_bytes);
/* write 16 bit field (for implementing endian swap) */
- virtual bool put16bits(unsigned char* bytes);
+ virtual bool put16bits(const unsigned char* bytes);
/* write 32 bit field (for implementing endian swap) */
- virtual bool put32bits(unsigned char* bytes);
+ virtual bool put32bits(const unsigned char* bytes);
/* write 64 bit field (for implementing endian swap) */
- virtual bool put64bits(unsigned char* bytes);
+ virtual bool put64bits(const unsigned char* bytes);
/* is the stream seekable (e.g. standard out is not) */
bool isSeekable() const;
/* save position in the stream for (forward) seeking later */
@@ -88,11 +88,11 @@
public:
ByteStreamOutFileEndianSwapped(FILE* file);
/* write 16 bit field (for implementing endian swap) */
- bool put16bits(unsigned char* bytes);
+ bool put16bits(const unsigned char* bytes);
/* write 32 bit field (for implementing endian swap) */
- bool put32bits(unsigned char* bytes);
+ bool put32bits(const unsigned char* bytes);
/* write 64 bit field (for implementing endian swap) */
- bool put64bits(unsigned char* bytes);
+ bool put64bits(const unsigned char* bytes);
private:
unsigned char swapped[8];
};
@@ -109,24 +109,24 @@
return (fputc(byte, file) == byte);
}
-inline bool ByteStreamOutFile::putBytes(unsigned char* bytes, unsigned int num_bytes)
+inline bool ByteStreamOutFile::putBytes(const unsigned char* bytes, unsigned int num_bytes)
{
return (fwrite(bytes, 1, num_bytes, file) == num_bytes);
}
-inline bool ByteStreamOutFile::put16bits(unsigned char* bytes)
+inline bool ByteStreamOutFile::put16bits(const unsigned char* bytes)
{
- return (fwrite(bytes, 1, 2, file) == 2);
+ return putBytes(bytes, 2);
}
-inline bool ByteStreamOutFile::put32bits(unsigned char* bytes)
+inline bool ByteStreamOutFile::put32bits(const unsigned char* bytes)
{
- return (fwrite(bytes, 1, 4, file) == 4);
+ return putBytes(bytes, 4);
}
-inline bool ByteStreamOutFile::put64bits(unsigned char* bytes)
+inline bool ByteStreamOutFile::put64bits(const unsigned char* bytes)
{
- return (fwrite(bytes, 1, 8, file) == 8);
+ return putBytes(bytes, 8);
}
inline bool ByteStreamOutFile::isSeekable() const
@@ -164,23 +164,23 @@
{
}
-inline bool ByteStreamOutFileEndianSwapped::put16bits(unsigned char* bytes)
+inline bool ByteStreamOutFileEndianSwapped::put16bits(const unsigned char* bytes)
{
swapped[0] = bytes[1];
swapped[1] = bytes[0];
- return (fwrite(swapped, 1, 2, file) == 2);
+ return putBytes(swapped, 2);
}
-inline bool ByteStreamOutFileEndianSwapped::put32bits(unsigned char* bytes)
+inline bool ByteStreamOutFileEndianSwapped::put32bits(const unsigned char* bytes)
{
swapped[0] = bytes[3];
swapped[1] = bytes[2];
swapped[2] = bytes[1];
swapped[3] = bytes[0];
- return (fwrite(swapped, 1, 4, file) == 4);
+ return putBytes(swapped, 4);
}
-inline bool ByteStreamOutFileEndianSwapped::put64bits(unsigned char* bytes)
+inline bool ByteStreamOutFileEndianSwapped::put64bits(const unsigned char* bytes)
{
swapped[0] = bytes[7];
swapped[1] = bytes[6];
@@ -190,7 +190,7 @@
swapped[5] = bytes[2];
swapped[6] = bytes[1];
swapped[7] = bytes[0];
- return (fwrite(swapped, 1, 8, file) == 8);
+ return putBytes(swapped, 8);
}
#endif
diff -r df98c890f766 -r 5aaa3c648f10 src/bytestreamout_ostream.hpp
--- a/src/bytestreamout_ostream.hpp Fri Dec 17 19:44:46 2010 -0800
+++ b/src/bytestreamout_ostream.hpp Sat Dec 18 11:49:15 2010 -0800
@@ -61,13 +61,13 @@
/* write a single byte */
bool putByte(unsigned char byte);
/* write an array of bytes */
- bool putBytes(unsigned char* bytes, unsigned int num_bytes);
+ bool putBytes(const unsigned char* bytes, unsigned int num_bytes);
/* write 16 bit field (for implementing endian swap) */
- virtual bool put16bits(unsigned char* bytes);
+ virtual bool put16bits(const unsigned char* bytes);
/* write 32 bit field (for implementing endian swap) */
- virtual bool put32bits(unsigned char* bytes);
+ virtual bool put32bits(const unsigned char* bytes);
/* write 64 bit field (for implementing endian swap) */
- virtual bool put64bits(unsigned char* bytes);
More information about the Liblas-commits
mailing list