Skip to content

Commit

Permalink
latest drop from coda-oss
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Smith committed Jan 17, 2022
1 parent 92632ef commit 2863272
Show file tree
Hide file tree
Showing 90 changed files with 1,291 additions and 733 deletions.
1 change: 1 addition & 0 deletions externals/coda-oss/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ cmake_minimum_required(VERSION 3.14)
project(coda-oss)

set(CMAKE_CXX_STANDARD 11)
set(CXX_STANDARD_REQUIRED true)

if (EXISTS "${CMAKE_BINARY_DIR}/conanbuildinfo.cmake")
# build and package with conan
Expand Down
1 change: 1 addition & 0 deletions externals/coda-oss/modules/c++/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ check_cxx_source_compiles(
HAVE_ATTRIBUTE_ALIGNED)

add_subdirectory("config")
add_subdirectory("coda_oss")
add_subdirectory("avx")
add_subdirectory("serialize")
add_subdirectory("except")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ cli::Results* cli::ArgumentParser::parse(const std::vector<std::string>& args)
}
}

auto results = mem::make::unique<cli::Results>();
auto results = coda_oss::make_unique<cli::Results>();
cli::Results *currentResults = NULL;
for (size_t i = 0, s = explodedArgs.size(); i < s; ++i)
{
Expand Down
13 changes: 13 additions & 0 deletions externals/coda-oss/modules/c++/coda_oss/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
set(MODULE_NAME coda_oss)

coda_generate_module_config_header(${MODULE_NAME})

coda_add_module(
${MODULE_NAME}
VERSION 1.0
DEPS config-c++ gsl-c++)

coda_add_tests(
MODULE_NAME ${MODULE_NAME}
DIRECTORY "unittests"
UNITTEST)
9 changes: 9 additions & 0 deletions externals/coda-oss/modules/c++/coda_oss/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
This is our implementation of various C++11/14/17/20 routines that work with the ancient compilers
we sometimes still need to use. It's called `coda_oss` instead of `std_` only because some people
won't like the name `coda_oss` (of course, it "can't" be `std`); `coda_oss` is far less likely
to collide with other code (someone else could *also* be trying to do the same thing we are).

By making this a very low-level module with very few other dependencies, it is easier to use
in other code and avoid circular dependencies. For example, the `sys` and `mem` modules can't
be used in `str`.

Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/* =========================================================================
* This file is part of coda_oss-c++
* =========================================================================
*
* (C) Copyright 2021, 2022, Maxar Technologies, Inc.
*
* sys-c++ is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program 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. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; If not,
* see <http://www.gnu.org/licenses/>.
*
*/

#ifndef CODA_OSS_coda_oss_CPlusPlus_h_INCLUDED_
#define CODA_OSS_coda_oss_CPlusPlus_h_INCLUDED_
#pragma once

#ifdef CODA_OSS_cplusplus
#error "CODA_OSS_cplusplus already #define'd."
#endif

#ifndef __cplusplus
#error "Only C++ compilation is supported."
#endif
#define CODA_OSS_cplusplus __cplusplus

#if CODA_OSS_cplusplus < 201103L // We need at least C++11
#undef CODA_OSS_cplusplus // oops...try to fix

// MSVC only sets __cplusplus >199711L with the /Zc:__cplusplus command-line option.
// https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/
#if defined(_MSVC_LANG)
// https://docs.microsoft.com/en-us/cpp/preprocessor/predefined-macros?view=msvc-160
// "Defined as an integer literal that specifies the C++ language standard targeted by the compiler."
#define CODA_OSS_cplusplus _MSVC_LANG
#elif defined(_MSC_VER)
#error "_MSVC_LANG should be #define'd."
#endif // _MSVC_LANG

#if defined(__GNUC__)
// ... similar things needed for other compilers ... ?
#endif // __GNUC__

#endif // CODA_OSS_cplusplus

#if CODA_OSS_cplusplus < 201103L
#error "Must compile with C++11 or greater."
#endif

// Define a few macros as that's less verbose than testing against a version number
#define CODA_OSS_cpp11 (CODA_OSS_cplusplus >= 201103L)
#define CODA_OSS_cpp14 (CODA_OSS_cplusplus >= 201402L)
#define CODA_OSS_cpp17 (CODA_OSS_cplusplus >= 201703L)
#define CODA_OSS_cpp20 (CODA_OSS_cplusplus >= 202002L)
#define CODA_OSS_cpp23 0

#endif // CODA_OSS_coda_oss_CPlusPlus_h_INCLUDED_
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* =========================================================================
* This file is part of sys-c++
* This file is part of coda_oss-c++
* =========================================================================
*
* (C) Copyright 2020, Maxar Technologies, Inc.
* (C) Copyright 2020-2022, Maxar Technologies, Inc.
*
* sys-c++ is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
Expand All @@ -18,16 +18,15 @@
* License along with this program; If not, http://www.gnu.org/licenses/.
*
*/
#ifndef CODA_OSS_sys_Bit_h_INCLUDED_
#define CODA_OSS_sys_Bit_h_INCLUDED_
#ifndef CODA_OSS_coda_oss_bit_h_INCLUDED_
#define CODA_OSS_coda_oss_bit_h_INCLUDED_
#pragma once

#include "CPlusPlus.h"

namespace sys
#include "coda_oss/namespace_.h"
namespace coda_oss
{
// https://en.cppreference.com/w/cpp/types/endian
enum class Endian
enum class endian
{
#ifdef _WIN32
little = 0,
Expand All @@ -39,7 +38,7 @@ namespace sys
native = __BYTE_ORDER__
#endif
};
#define CODA_OSS_sys_Endian 201907L // __cpp_lib_endian
#define CODA_OSS_coda_oss_endian 201907L // __cpp_lib_endian
}

#endif // CODA_OSS_sys_Bit_h_INCLUDED_
#endif // CODA_OSS_coda_oss_bit_h_INCLUDED_
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,19 @@
* License along with this program; If not, http://www.gnu.org/licenses/.
*
*/
#ifndef CODA_OSS_sys_CStdDef_h_INCLUDED_
#define CODA_OSS_sys_CStdDef_h_INCLUDED_
#ifndef CODA_OSS_coda_oss_cstddef_h_INCLUDED_
#define CODA_OSS_coda_oss_cstddef_h_INCLUDED_
#pragma once

#include <cstddef>

#include "CPlusPlus.h"

namespace sys
#include "coda_oss/namespace_.h"
namespace coda_oss
{
// https://en.cppreference.com/w/cpp/types/byte
enum class Byte : unsigned char {};
enum class byte : unsigned char {};

#define CODA_OSS_sys_Byte 201603L // __cpp_lib_byte
#define CODA_OSS_coda_oss_byte 201603L // __cpp_lib_byte
}

#endif // CODA_OSS_sys_CStdDef_h_INCLUDED_
#endif // CODA_OSS_coda_oss_cstddef_h_INCLUDED_
69 changes: 69 additions & 0 deletions externals/coda-oss/modules/c++/coda_oss/include/coda_oss/memory.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/* =========================================================================
* This file is part of coda_oss-c++
* =========================================================================
*
* (C) Copyright 2004 - 2018, MDA Information Systems LLC
* (C) Copyright 2022, Maxar Technologies, Inc.
*
* coda_oss-c++ is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program 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. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; If not,
* see <http://www.gnu.org/licenses/>.
*
*/

#ifndef CODA_OSS_coda_oss_memory_h_INCLUDED_
#define CODA_OSS_coda_oss_memory_h_INCLUDED_
#pragma once

#include <memory>
#include <type_traits>
#include <utility>

#include "config/compiler_extensions.h"

#include "coda_oss/namespace_.h"
namespace coda_oss
{
// C++11 inadvertently ommitted make_unique; provide it here. (Swiped from <memory>.)
template <typename T, typename... TArgs, typename std::enable_if<!std::is_array<T>::value, int>::type = 0>
std::unique_ptr<T> make_unique(TArgs&&... args)
{
CODA_OSS_disable_warning_push
#if _MSC_VER
#pragma warning(disable: 26409) // Avoid calling new and delete explicitly, use std::make_unique<T> instead (r .11).
#endif
return std::unique_ptr<T>(new T(std::forward<TArgs>(args)...));
CODA_OSS_disable_warning_pop
}

template <typename T, typename std::enable_if<std::is_array<T>::value && std::extent<T>::value == 0, int>::type = 0>
std::unique_ptr<T> make_unique(size_t size)
{
using element_t = typename std::remove_extent<T>::type;

CODA_OSS_disable_warning_push
#if _MSC_VER
#pragma warning(disable: 26409) // Avoid calling new and delete explicitly, use std::make_unique<T> instead (r .11).
#endif
return std::unique_ptr<T>(new element_t[size]());
CODA_OSS_disable_warning_pop
}

template <typename T, typename... TArgs, typename std::enable_if<std::extent<T>::value != 0, int>::type = 0>
void make_unique(TArgs&&...) = delete;

#define CODA_OSS_coda_oss_make_unique 201304L // c.f., __cpp_lib_make_unique

} // namespace coda_oss

#endif // CODA_OSS_coda_oss_memory_h_INCLUDED_
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/* =========================================================================
* This file is part of coda_oss-c++
* =========================================================================
*
* (C) Copyright 2020, Maxar Technologies, Inc.
*
* sys-c++ is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program 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. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; If not, http://www.gnu.org/licenses/.
*
*/
#ifndef CODA_OSS_coda_oss_namespace__h_INCLUDED_
#define CODA_OSS_coda_oss_namespace__h_INCLUDED_
#pragma once

namespace coda_oss
{
}

#endif // CODA_OSS_coda_oss_namespace__h_INCLUDED_
Loading

0 comments on commit 2863272

Please sign in to comment.