Skip to content

Commit

Permalink
Quiet windows compiler.
Browse files Browse the repository at this point in the history
  • Loading branch information
abellgithub committed Mar 10, 2016
1 parent f6ae1e8 commit 94960ea
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 48 deletions.
9 changes: 5 additions & 4 deletions cmake/win32_compiler_options.cmake
Expand Up @@ -26,11 +26,12 @@ if (MSVC)
# numerous warnings when compiling in MSVC. We will ignore them for
# now.
add_definitions("/wd4290")
add_definitions("/wd4800")
add_definitions("/wd4800")

# Windows still warns about nameless struct/union, but we assume
# that all of our compilers support this
#add_definitions("/wd4201")
# Windows warns about integer narrowing like crazy and it's annoying.
# In most cases the programmer knows what they're doing. A good
# static analysis tool would be better than turning this warning off.
add_definitions("/wd4267")
endif()

if (CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
Expand Down
10 changes: 5 additions & 5 deletions include/pdal/util/Charbuf.hpp
Expand Up @@ -46,13 +46,13 @@ namespace pdal
/**
Allow a data buffer to be used at a std::streambuf.
*/
class PDAL_DLL Charbuf : public std::streambuf
class Charbuf : public std::streambuf
{
public:
/**
Construct an empty Charbuf.
*/
Charbuf() : m_bufOffset(0)
PDAL_DLL Charbuf() : m_bufOffset(0)
{}

/**
Expand All @@ -61,7 +61,7 @@ class PDAL_DLL Charbuf : public std::streambuf
\param v Byte vector to back streambuf.
\param bufOffset Offset in vector (ignore bytes before offset).
*/
Charbuf (std::vector<char>& v, pos_type bufOffset = 0)
PDAL_DLL Charbuf (std::vector<char>& v, pos_type bufOffset = 0)
{ initialize(v.data(), v.size(), bufOffset); }

/**
Expand All @@ -71,7 +71,7 @@ class PDAL_DLL Charbuf : public std::streambuf
\param count Size of buffer.
\param bufOffset Offset in vector (ignore bytes before offset).
*/
Charbuf (char *buf, size_t count, pos_type bufOffset = 0)
PDAL_DLL Charbuf (char *buf, size_t count, pos_type bufOffset = 0)
{ initialize(buf, count, bufOffset); }

/**
Expand All @@ -81,7 +81,7 @@ class PDAL_DLL Charbuf : public std::streambuf
\param count Size of buffer.
\param bufOffset Offset in vector (ignore bytes before offset).
*/
void initialize(char *buf, size_t count, pos_type bufOffset = 0);
PDAL_DLL void initialize(char *buf, size_t count, pos_type bufOffset = 0);

protected:
/**
Expand Down
71 changes: 36 additions & 35 deletions include/pdal/util/OStream.hpp
Expand Up @@ -46,61 +46,62 @@
namespace pdal
{

class PDAL_DLL OStream
class OStream
{
public:
OStream() : m_stream(NULL), m_fstream(NULL)
PDAL_DLL OStream() : m_stream(NULL), m_fstream(NULL)
{}
OStream(const std::string& filename) : m_stream(NULL), m_fstream(NULL)
PDAL_DLL OStream(const std::string& filename) :
m_stream(NULL), m_fstream(NULL)
{ open(filename); }
OStream(std::ostream *stream) : m_stream(stream), m_fstream(NULL)
PDAL_DLL OStream(std::ostream *stream) : m_stream(stream), m_fstream(NULL)
{}
~OStream()
PDAL_DLL ~OStream()
{ delete m_fstream; }

int open(const std::string& filename)
PDAL_DLL int open(const std::string& filename)
{
if (m_stream)
return -1;
m_stream = m_fstream = new std::ofstream(filename,
std::ios_base::out | std::ios_base::binary);
return 0;
}
void close()
PDAL_DLL void close()
{
flush();
delete m_fstream;
m_fstream = NULL;
m_stream = NULL;
}
bool isOpen() const
PDAL_DLL bool isOpen() const
{ return (bool)m_stream; }
void flush()
PDAL_DLL void flush()
{ m_stream->flush(); }
operator bool ()
PDAL_DLL operator bool ()
{ return (bool)(*m_stream); }
void seek(std::streampos pos)
PDAL_DLL void seek(std::streampos pos)
{ m_stream->seekp(pos, std::ostream::beg); }
void put(const std::string& s)
PDAL_DLL void put(const std::string& s)
{ put(s, s.size()); }
void put(const std::string& s, size_t len)
PDAL_DLL void put(const std::string& s, size_t len)
{
std::string os = s;
os.resize(len);
m_stream->write(os.c_str(), len);
}
void put(const char *c, size_t len)
PDAL_DLL void put(const char *c, size_t len)
{ m_stream->write(c, len); }
void put(const unsigned char *c, size_t len)
PDAL_DLL void put(const unsigned char *c, size_t len)
{ m_stream->write((const char *)c, len); }
std::streampos position() const
PDAL_DLL std::streampos position() const
{ return m_stream->tellp(); }
void pushStream(std::ostream *strm)
PDAL_DLL void pushStream(std::ostream *strm)
{
m_streams.push(m_stream);
m_stream = strm;
}
std::ostream *popStream()
PDAL_DLL std::ostream *popStream()
{
// Can't pop the last stream for now.
if (m_streams.empty())
Expand All @@ -122,71 +123,71 @@ class PDAL_DLL OStream

/// Stream wrapper for output of binary data that converts from host ordering
/// to little endian format
class PDAL_DLL OLeStream : public OStream
class OLeStream : public OStream
{
public:
OLeStream()
PDAL_DLL OLeStream()
{}
OLeStream(const std::string& filename) : OStream(filename)
PDAL_DLL OLeStream(const std::string& filename) : OStream(filename)
{}
OLeStream(std::ostream *stream) : OStream(stream)
PDAL_DLL OLeStream(std::ostream *stream) : OStream(stream)
{}

OLeStream& operator << (uint8_t v)
PDAL_DLL OLeStream& operator << (uint8_t v)
{
m_stream->put((char)v);
return *this;
}

OLeStream& operator << (int8_t v)
PDAL_DLL OLeStream& operator << (int8_t v)
{
m_stream->put((char)v);
return *this;
}

OLeStream& operator << (uint16_t v)
PDAL_DLL OLeStream& operator << (uint16_t v)
{
v = htole16(v);
m_stream->write((char *)&v, sizeof(v));
return *this;
}

OLeStream& operator << (int16_t v)
PDAL_DLL OLeStream& operator << (int16_t v)
{
v = (int16_t)htole16((uint16_t)v);
m_stream->write((char *)&v, sizeof(v));
return *this;
}

OLeStream& operator << (uint32_t v)
PDAL_DLL OLeStream& operator << (uint32_t v)
{
v = htole32(v);
m_stream->write((char *)&v, sizeof(v));
return *this;
}

OLeStream& operator << (int32_t v)
PDAL_DLL OLeStream& operator << (int32_t v)
{
v = (int32_t)htole32((uint32_t)v);
m_stream->write((char *)&v, sizeof(v));
return *this;
}

OLeStream& operator << (uint64_t v)
PDAL_DLL OLeStream& operator << (uint64_t v)
{
v = htole64(v);
m_stream->write((char *)&v, sizeof(v));
return *this;
}

OLeStream& operator << (int64_t v)
PDAL_DLL OLeStream& operator << (int64_t v)
{
v = (int64_t)htole64((uint64_t)v);
m_stream->write((char *)&v, sizeof(v));
return *this;
}

OLeStream& operator << (float v)
PDAL_DLL OLeStream& operator << (float v)
{
uint32_t tmp(0);
std::memcpy(&tmp, &v, sizeof(v));
Expand All @@ -195,7 +196,7 @@ class PDAL_DLL OLeStream : public OStream
return *this;
}

OLeStream& operator << (double v)
PDAL_DLL OLeStream& operator << (double v)
{
uint64_t tmp(0);
std::memcpy(&tmp, &v, sizeof(v));
Expand All @@ -209,17 +210,17 @@ class PDAL_DLL OLeStream : public OStream
class OStreamMarker
{
public:
OStreamMarker(OStream& stream) : m_stream(stream)
PDAL_DLL OStreamMarker(OStream& stream) : m_stream(stream)
{
if (m_stream.isOpen())
m_pos = m_stream.position();
else
m_pos = 0;
}

void mark()
PDAL_DLL void mark()
{ m_pos = m_stream.position(); }
void rewind()
PDAL_DLL void rewind()
{ m_stream.seek(m_pos); }

private:
Expand Down
2 changes: 1 addition & 1 deletion io/bpf/BpfCompressor.cpp
Expand Up @@ -69,7 +69,7 @@ void BpfCompressor::startBlock()
void BpfCompressor::compress()
{
// Note our position so that we know how much we've written.
std::size_t rawWritten = m_out.position();
uint32_t rawWritten = (uint32_t)m_out.position();

// Pop our temp stream so that we can write the real output file.
m_out.popStream();
Expand Down
3 changes: 2 additions & 1 deletion io/bpf/BpfReader.cpp
Expand Up @@ -575,7 +575,8 @@ void BpfReader::seekByteMajor(size_t dimIdx, size_t byteIdx, PointId ptIdx)
}


int BpfReader::inflate(char *buf, size_t insize, char *outbuf, size_t outsize)
int BpfReader::inflate(char *buf, uint32_t insize,
char *outbuf, uint32_t outsize)
{
if (insize == 0)
return 0;
Expand Down
2 changes: 1 addition & 1 deletion io/bpf/BpfReader.hpp
Expand Up @@ -105,7 +105,7 @@ class PDAL_DLL BpfReader : public Reader
size_t readBlock(std::vector<char>& outBuf, size_t index);
bool eof();

int inflate(char *inbuf, size_t insize, char *outbuf, size_t outsize);
int inflate(char *inbuf, uint32_t insize, char *outbuf, uint32_t outsize);

void seekPointMajor(PointId ptIdx);
void seekDimMajor(size_t dimIdx, PointId ptIdx);
Expand Down
2 changes: 1 addition & 1 deletion io/text/TextReader.hpp
Expand Up @@ -85,7 +85,7 @@ class PDAL_DLL TextReader : public Reader
\param numPts Maximum number of points to read.
\return Number of points read.
*/
virtual point_count_t read(const PointViewPtr view, point_count_t numPts);
virtual point_count_t read(PointViewPtr view, point_count_t numPts);

/**
Close input file.
Expand Down

0 comments on commit 94960ea

Please sign in to comment.