Skip to content

Commit

Permalink
Squashed 'externals/coda-oss/' changes from 5e0f5d614..f1ad69fd4
Browse files Browse the repository at this point in the history
f1ad69fd4 Merge branch 'main' into cpp17
ba8547621 don't put 'struct' in the macro
fd75f84b6 Merge branch 'main' into cpp17
bd79aa11f require Python 3.7, do MD5 check
ce34286c8 Merge branch 'main' into cpp17
ecfa687c5 use std::filesystem (instead of sys::filesystem) where possible (#652)
89df1b508 Merge branch 'main' into cpp17
243bc9991 add 'override'
c0fd2124d wrap common "file open" routines to support sys::expandEnviromentVariables() (#651)
8d7de5125 restore C++17
02f488f3a Merge branch 'main' into cpp17
0657f3297 adjust compiler flags for clean CMake builds (#650)

git-subtree-dir: externals/coda-oss
git-subtree-split: f1ad69fd4c578c5c3ac9f110a7a75ce9f53e44a9
  • Loading branch information
Dan Smith authored and Dan Smith committed Feb 17, 2023
1 parent 8fab46b commit 0cc8943
Show file tree
Hide file tree
Showing 69 changed files with 664 additions and 193 deletions.
15 changes: 6 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
# Author: Scott A. Colcord

cmake_minimum_required(VERSION 3.14)
project(coda-oss)

set(TARGET_LANGUAGE c++)
set(CMAKE_CXX_STANDARD 17)
set(CXX_STANDARD_REQUIRED true)

project(coda-oss)

if (EXISTS "${CMAKE_BINARY_DIR}/conanbuildinfo.cmake")
# build and package with conan
include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake")
Expand All @@ -21,14 +19,13 @@ endif()
if (${CMAKE_PROJECT_NAME} STREQUAL coda-oss)
# this is the top level project

# set up warnings
# Always turn on "warnings as errors" to avoid lots of (meaningless?) build output;
# we'll dial-back warnings as necessary.
if (MSVC)
# set warning level to /W3
string(REGEX REPLACE "/W[0-4]" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
string(REGEX REPLACE "/W[0-4]" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
add_compile_options(/std:c++17)
add_compile_options(/WX) # warnings as errors
add_compile_options(/MP) # multi-processor compile
elseif (UNIX)
add_compile_options(-std=c++17)
add_compile_options(-Werror) # warnings as errors
endif()

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
Expand Down
21 changes: 18 additions & 3 deletions modules/c++/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,25 @@
set(TARGET_LANGUAGE c++)

# turn on warnings as errors
# turn on maximum warnings
if (MSVC)
add_compile_options(/WX /W4) # /Wall
add_compile_options(/std:c++17)

# By default, there is a /W3 on the command-line from somewhere (?); adding
# /Wn results in a compiler warning.
#add_compile_options(/W4) # /Wall
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") # /Wall

elseif (UNIX)
add_compile_options(-Werror -Wall -Wpedantic -Wextra)
add_compile_options(-std=c++17)

add_compile_options(-Wall -pedantic -Wextra)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wregister") # -Wvolatile
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Weffc++")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wzero-as-null-pointer-constant")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Woverloaded-virtual")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wold-style-cast")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wsuggest-final-types -Wsuggest-final-methods")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wsuggest-override")
endif()

# add an interface library for unittests
Expand Down
1 change: 1 addition & 0 deletions modules/c++/coda-oss-lite.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@
<ClCompile Include="sys\source\ErrWin32.cpp" />
<ClCompile Include="sys\source\ExecUnix.cpp" />
<ClCompile Include="sys\source\ExecWin32.cpp" />
<ClCompile Include="sys\source\File.cpp" />
<ClCompile Include="sys\source\FileFinder.cpp" />
<ClCompile Include="sys\source\FileUnix.cpp" />
<ClCompile Include="sys\source\FileWin32.cpp" />
Expand Down
3 changes: 3 additions & 0 deletions modules/c++/coda-oss-lite.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -1062,6 +1062,9 @@
<ClCompile Include="sys\source\MutexCpp11.cpp">
<Filter>sys</Filter>
</ClCompile>
<ClCompile Include="sys\source\File.cpp">
<Filter>sys</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<Filter Include="config">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

#include "compiler_extensions.h"

#if _MSC_VER
#if defined(_MSC_VER)
// We don't care about any padding added to structs
#pragma warning(disable: 4820) // '...': '...' bytes padding added after data member '...'

Expand All @@ -38,6 +38,12 @@
// ???
#pragma warning(disable: 5045) // Compiler will insert Spectre mitigation for memory load if /Qspectre switch specified


#elif defined(__GNUC__) || defined(__clang__)

// don't care about compatibility between different -std=c++nn values
CODA_OSS_disable_warning(-Wnoexcept-type)

#endif // _MSC_VER

#endif // CODA_OSS_config_disable_compiler_warnings_h_INCLUDED_
10 changes: 5 additions & 5 deletions modules/c++/io/include/io/ByteStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,20 @@ struct CODA_OSS_API ByteStream : public SeekableInputStream, public SeekableOutp
}

virtual
sys::Off_T tell()
sys::Off_T tell() override
{
return mPosition;
}

virtual
sys::Off_T seek(sys::Off_T offset, Whence whence);
sys::Off_T seek(sys::Off_T offset, Whence whence) override;

/*!
* Returns the available bytes to read from the stream
* \return the available bytes to read
*/
virtual
sys::Off_T available();
sys::Off_T available() override;

using OutputStream::write;
using InputStream::streamTo;
Expand All @@ -92,7 +92,7 @@ struct CODA_OSS_API ByteStream : public SeekableInputStream, public SeekableOutp
* \param size the number of bytes to write to the stream
*/
virtual
void write(const void* buffer, size_t size);
void write(const void* buffer, size_t size) override;

void reset()
{
Expand Down Expand Up @@ -132,7 +132,7 @@ struct CODA_OSS_API ByteStream : public SeekableInputStream, public SeekableOutp
* \throw IoException
* \return The number of bytes read
*/
virtual sys::SSize_T readImpl(void* buffer, size_t len);
virtual sys::SSize_T readImpl(void* buffer, size_t len) override;

private:
std::vector<sys::ubyte> mData;
Expand Down
2 changes: 1 addition & 1 deletion modules/c++/io/include/io/CountingStreams.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ struct CODA_OSS_API CountingOutputStream : public ProxyOutputStream
* \param buffer The byte array to write to the stream
* \param len The length of the byte array to write to the stream
*/
virtual void write(const void* buffer, size_t len)
virtual void write(const void* buffer, size_t len) override
{
ProxyOutputStream::write(buffer, len);
mByteCount += len;
Expand Down
4 changes: 2 additions & 2 deletions modules/c++/io/include/io/DataStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ struct DataStream: public io::Serializable
* Outputs this object into an output stream.
* \param os the OutputStream to write to
*/
virtual void serialize(io::OutputStream& os)
virtual void serialize(io::OutputStream& os) override
{
mStringStream.streamTo(os);
}
Expand All @@ -85,7 +85,7 @@ struct DataStream: public io::Serializable
* Unpack this input stream to the object
* \param is Stream to read object from
*/
virtual void deserialize(io::InputStream& is)
virtual void deserialize(io::InputStream& is) override
{
is.streamTo(mStringStream);
}
Expand Down
2 changes: 1 addition & 1 deletion modules/c++/io/include/io/DbgStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ struct DbgStream : public OutputStream
* \param len The length
* \throw IOException
*/
virtual void write(const void* buffer, sys::Size_T len)
virtual void write(const void* buffer, sys::Size_T len) override
{
if (mOn)
{
Expand Down
8 changes: 4 additions & 4 deletions modules/c++/io/include/io/FileInputStreamOS.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ struct CODA_OSS_API FileInputStreamOS : public SeekableInputStream
* \return number of bytes which are readable
*
*/
virtual sys::Off_T available();
virtual sys::Off_T available() override;

/*!
* Report whether or not the file is open
Expand Down Expand Up @@ -130,7 +130,7 @@ struct CODA_OSS_API FileInputStreamOS : public SeekableInputStream
* Go to the offset at the location specified.
* \return The number of bytes between off and our origin.
*/
virtual sys::Off_T seek(sys::Off_T off, Whence whence)
virtual sys::Off_T seek(sys::Off_T off, Whence whence) override
{
int from = sys::File::FROM_CURRENT;
switch (whence)
Expand All @@ -154,7 +154,7 @@ struct CODA_OSS_API FileInputStreamOS : public SeekableInputStream
* Tell the current offset
* \return The byte offset
*/
virtual sys::Off_T tell()
virtual sys::Off_T tell() override
{
return mFile.getCurrentOffset();
}
Expand All @@ -175,7 +175,7 @@ struct CODA_OSS_API FileInputStreamOS : public SeekableInputStream
* \return The number of bytes read
*
*/
virtual sys::SSize_T readImpl(void* buffer, size_t len);
virtual sys::SSize_T readImpl(void* buffer, size_t len) override;
};
}

Expand Down
10 changes: 5 additions & 5 deletions modules/c++/io/include/io/FileOutputStreamOS.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,16 @@ class FileOutputStreamOS : public SeekableOutputStream
int creationFlags = sys::File::CREATE | sys::File::TRUNCATE);

//! Close the file
void close()
void close() override
{
mFile.close();
}

virtual void flush();
virtual void flush() override;

sys::Off_T seek(sys::Off_T offset, io::Seekable::Whence whence);
sys::Off_T seek(sys::Off_T offset, io::Seekable::Whence whence) override;

sys::Off_T tell();
sys::Off_T tell() override;

using OutputStream::write;

Expand All @@ -116,7 +116,7 @@ class FileOutputStreamOS : public SeekableOutputStream
* \param len the length of bytes to write
* \throw IoException
*/
virtual void write(const void* buffer, size_t len);
virtual void write(const void* buffer, size_t len) override;
};
}

Expand Down
12 changes: 6 additions & 6 deletions modules/c++/io/include/io/NullStreams.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,19 @@ struct NullInputStream : public InputStream
{
}

virtual sys::Off_T available()
virtual sys::Off_T available() override
{
return mAvailable;
}

virtual sys::SSize_T readln(sys::byte *cStr,
const sys::Size_T strLenPlusNullByte)
const sys::Size_T strLenPlusNullByte) override
{
return read(cStr, strLenPlusNullByte);
}

virtual sys::SSize_T streamTo(OutputStream& soi,
sys::SSize_T numBytes = IS_END)
sys::SSize_T numBytes = IS_END) override
{
const sys::SSize_T toProcess = (numBytes == IS_END) ? numBytes : (mAvailable
>= numBytes ? numBytes : mAvailable);
Expand All @@ -77,7 +77,7 @@ struct NullInputStream : public InputStream
memset(buffer, 0, len);
}

virtual sys::SSize_T readImpl(void* buffer, size_t len)
virtual sys::SSize_T readImpl(void* buffer, size_t len) override
{
const auto numToRead =
mAvailable >= gsl::narrow<sys::SSize_T>(len) ? len : gsl::narrow<size_t>(mAvailable);
Expand Down Expand Up @@ -108,11 +108,11 @@ struct NullOutputStream : public OutputStream
{
}

virtual void write(const void* , size_t )
virtual void write(const void* , size_t ) override
{
}

virtual void flush()
virtual void flush() override
{
}
};
Expand Down
6 changes: 3 additions & 3 deletions modules/c++/io/include/io/PipeStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ struct PipeStream : InputStream
* (default 0 means read until max or newline)
*/
virtual sys::SSize_T readln(sys::byte *cStr,
const sys::Size_T strLenPlusNullByte = 0);
const sys::Size_T strLenPlusNullByte = 0) override;

/*!
* The streaming occurs as follows: If the numBytes is IS_END,
Expand All @@ -90,7 +90,7 @@ struct PipeStream : InputStream
* input stream to the output stream
*/
virtual sys::SSize_T streamTo(OutputStream& soi,
sys::SSize_T numBytes = IS_END);
sys::SSize_T numBytes = IS_END) override;

PipeStream(const PipeStream&) = delete;
PipeStream& operator=(const PipeStream&) = delete;
Expand All @@ -99,7 +99,7 @@ struct PipeStream : InputStream
/*!
* \brief returns the requested size in bytes from the stream
*/
virtual sys::SSize_T readImpl(void* buffer, size_t len);
virtual sys::SSize_T readImpl(void* buffer, size_t len) override;


sys::ExecPipe mExecPipe;
Expand Down
12 changes: 6 additions & 6 deletions modules/c++/io/include/io/ProxyStreams.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ struct CODA_OSS_API ProxyInputStream : public InputStream
mProxy.release();
}

virtual sys::Off_T available()
virtual sys::Off_T available() override
{
return mProxy->available();
}
Expand All @@ -61,7 +61,7 @@ struct CODA_OSS_API ProxyInputStream : public InputStream
}

protected:
virtual sys::SSize_T readImpl(void* buffer, size_t len)
virtual sys::SSize_T readImpl(void* buffer, size_t len) override
{
return mProxy->read(buffer, len);
}
Expand Down Expand Up @@ -93,17 +93,17 @@ struct CODA_OSS_API ProxyOutputStream : public OutputStream

using OutputStream::write;

virtual void write(const void* buffer, size_t len)
virtual void write(const void* buffer, size_t len) override
{
mProxy->write(buffer, len);
}

virtual void flush()
virtual void flush() override
{
mProxy->flush();
}

virtual void close()
virtual void close() override
{
mProxy->close();
}
Expand Down Expand Up @@ -152,7 +152,7 @@ struct CODA_OSS_API ToggleOutputStream : public io::ProxyOutputStream
return mEnabled;
}

void close()
void close() override
{
if (mEnabled && mPtr)
mPtr->close();
Expand Down
2 changes: 1 addition & 1 deletion modules/c++/io/include/io/RotatingFileOutputStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ struct CODA_OSS_API RotatingFileOutputStream : public CountingOutputStream

using CountingOutputStream::write;

virtual void write(const void* buffer, size_t len);
virtual void write(const void* buffer, size_t len) override;

protected:
std::string mFilename;
Expand Down
4 changes: 2 additions & 2 deletions modules/c++/io/include/io/SerializableFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ class SerializableFile: public Serializable
/*!
* Transfer this object into a byte stream
*/
void serialize(io::OutputStream& os);
void serialize(io::OutputStream& os) override;

/*!
* Unpack this input stream to the object
* \param is Stream to read object from
*/
void deserialize(io::InputStream& is);
void deserialize(io::InputStream& is) override;

protected:
std::string mFilename;
Expand Down
Loading

0 comments on commit 0cc8943

Please sign in to comment.