Skip to content

Commit

Permalink
latest from coda-oss
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Smith committed Feb 9, 2022
1 parent a0d7cb5 commit c125ae2
Show file tree
Hide file tree
Showing 19 changed files with 214 additions and 140 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* (C) Copyright 2021, 2022, Maxar Technologies, Inc.
*
* sys-c++ is free software; you can redistribute it and/or modify
* 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.
Expand Down Expand Up @@ -47,10 +47,16 @@
#endif // _MSVC_LANG

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

#endif // CODA_OSS_cplusplus
#if CODA_OSS_cplusplus < 202002L
// oops ... try to fix
#if defined(__GNUC__) && (__cplusplus >= 201709L) // note > C++ 17 of 201703L
// Enough C++20 for our needs
#undef CODA_OSS_cplusplus
#define CODA_OSS_cplusplus 202002L
#endif
#endif // CODA_OSS_cplusplus

#if CODA_OSS_cplusplus < 201103L
#error "Must compile with C++11 or greater."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* (C) Copyright 2020-2022, Maxar Technologies, Inc.
*
* sys-c++ is free software; you can redistribute it and/or modify
* 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/* =========================================================================
* This file is part of sys-c++
* 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
* 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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* (C) Copyright 2020, Maxar Technologies, Inc.
*
* sys-c++ is free software; you can redistribute it and/or modify
* 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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* (C) Copyright 2020, Maxar Technologies, Inc.
*
* sys-c++ is free software; you can redistribute it and/or modify
* 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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* (C) Copyright 2020, Maxar Technologies, Inc.
*
* sys-c++ is free software; you can redistribute it and/or modify
* 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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* (C) Copyright 2004 - 2014, MDA Information Systems LLC
*
* mem-c++ is free software; you can redistribute it and/or modify
* 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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* (C) Copyright 2004 - 2014, MDA Information Systems LLC
*
* mem-c++ is free software; you can redistribute it and/or modify
* 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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* (C) Copyright 2020-2022, Maxar Technologies, Inc.
*
* sys-c++ is free software; you can redistribute it and/or modify
* 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.
Expand Down Expand Up @@ -36,7 +36,9 @@ namespace coda_oss
#if _MSC_VER
#pragma warning(disable: 5052) // Keyword '...' was introduced in C++20 and requires use of the '...' command-line option
#endif
#if !defined(__cpp_char8_t) // https://en.cppreference.com/w/cpp/feature_test
enum class char8_t : unsigned char { }; // https://en.cppreference.com/w/cpp/language/types
#endif
using u8string = std::basic_string<char8_t>; // https://en.cppreference.com/w/cpp/string
CODA_OSS_disable_warning_pop
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/* =========================================================================
* This file is part of sys-c++
* This file is part of coda_oss-c++
* =========================================================================
*
* (C) Copyright 2022, Maxar Technologies, Inc.
*
* sys-c++ is free software; you can redistribute it and/or modify
* 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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ namespace io
template<typename CharT>
struct StringStreamT final : public SeekableBidirectionalStream
{
StringStreamT() = default;
StringStreamT(){} // "=default" causes error with old GCC

StringStreamT(const StringStreamT&) = delete;
StringStreamT& operator=(const StringStreamT&) = delete;
Expand Down
4 changes: 2 additions & 2 deletions externals/coda-oss/modules/c++/std/include/std/filesystem
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/* =========================================================================
* This file is part of sys-c++
* This file is part of std-c++
* =========================================================================
*
* (C) Copyright 2021, Maxar Technologies, Inc.
*
* sys-c++ is free software; you can redistribute it and/or modify
* std-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.
Expand Down
143 changes: 33 additions & 110 deletions externals/coda-oss/modules/c++/sys/include/sys/filesystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,119 +22,42 @@
#define CODA_OSS_sys_filesystem_h_INCLUDED_
#pragma once

//
// For now, these are just some wrappers around the CODA-OSS routines ...
// eventually, this should be replaced with C++17's <filesystem>.
//
// This does not even TRY to be a complete implementation of std::filesystem.
//

#include <string>
#include <ostream>
// always implement sys::filesystem::path
#include "sys/sys_filesystem.h"

#include "sys/CPlusPlus.h"
#include "coda_oss/namespace_.h" // get something in the "coda_oss" namespace

namespace coda_oss // should be in coda_oss, but implementation needs sys::Path
{
// http://en.cppreference.com/w/cpp/filesystem
namespace filesystem
{
struct path; // forward
namespace details
{
extern bool Equals(const path& lhs, const path& rhs) noexcept;
extern std::ostream& Ostream(std::ostream& os, const path& p);
}

// https://en.cppreference.com/w/cpp/filesystem/file_type
enum class file_type // match C++17 spelling for easier transition from our C++11 work-around
{
none = 0,
not_found = 1,
regular,
directory,
unknown
};

// http://en.cppreference.com/w/cpp/filesystem/path
struct path final // N.B. this is an INCOMPLETE and NON-STANDARD implementation!
#if CODA_OSS_cpp17
// Some versions of G++ say they're C++17 but don't have <filesystem>
#if __has_include(<filesystem>) // __has_include is C++17
#include <filesystem>
#define CODA_OSS_has_std_filesystem_ 1
#endif
#else
#define CODA_OSS_has_std_filesystem_ 0
#endif

namespace coda_oss
{
// character type used by the native encoding of the filesystem: char on POSIX, wchar_t on Windows
#ifdef _WIN32
using value_type = wchar_t;
#else
using value_type = char;
#endif
using string_type = std::basic_string<value_type>;

// http://en.cppreference.com/w/cpp/filesystem/path/path
path() noexcept;
path(const path&);
path(const string_type&);
template<typename TSource>
path(const TSource& source)
{
p_ = to_native(source);
}

path& operator/=(const path&); // http://en.cppreference.com/w/cpp/filesystem/path/append
template <typename TSource>
path& operator/=(const TSource& source) // http://en.cppreference.com/w/cpp/filesystem/path/append
{
return (*this) /= path(to_native(source));
}
void clear() noexcept; // http://en.cppreference.com/w/cpp/filesystem/path/clear

// http://en.cppreference.com/w/cpp/filesystem/path/native
const value_type* c_str() const noexcept;
const string_type& native() const noexcept;
operator string_type() const;

std::string string() const; // http://en.cppreference.com/w/cpp/filesystem/path/string

path root_path() const; // https://en.cppreference.com/w/cpp/filesystem/path/root_path
path parent_path() const; // http://en.cppreference.com/w/cpp/filesystem/path/parent_path
path filename() const; // http://en.cppreference.com/w/cpp/filesystem/path/filename
path stem() const; // http://en.cppreference.com/w/cpp/filesystem/path/stem
path extension() const; // https://en.cppreference.com/w/cpp/filesystem/path/extension

bool empty() const noexcept; // http://en.cppreference.com/w/cpp/filesystem/path/empty
bool is_absolute() const; // http://en.cppreference.com/w/cpp/filesystem/path/is_absrel
bool is_relative() const; // http://en.cppreference.com/w/cpp/filesystem/path/is_absrel

friend bool operator==(const path& lhs, const path& rhs) noexcept // https://en.cppreference.com/w/cpp/filesystem/path/operator_cmp
{
return details::Equals(lhs, rhs);
}
friend bool operator!=(const path& lhs, const path& rhs) noexcept // https://en.cppreference.com/w/cpp/filesystem/path/operator_cmp
{
return !(lhs == rhs);
}
friend std::ostream& operator<<(std::ostream& os, const path& p) // https://en.cppreference.com/w/cpp/filesystem/path/operator_ltltgtgt
{
return details::Ostream(os, p);
}

private:
string_type p_;
static string_type to_native(const std::string& s);
};

path operator/(const path& lhs, const path& rhs); // http://en.cppreference.com/w/cpp/filesystem/path/operator_slash

path absolute(const path&); // http://en.cppreference.com/w/cpp/filesystem/absolute
bool create_directory(const path&); // https://en.cppreference.com/w/cpp/filesystem/create_directory
path current_path(); // https://en.cppreference.com/w/cpp/filesystem/current_path
bool remove(const path& p); // https://en.cppreference.com/w/cpp/filesystem/remove
path temp_directory_path(); // https://en.cppreference.com/w/cpp/filesystem/temp_directory_path

bool is_regular_file(const path& p); // https://en.cppreference.com/w/cpp/filesystem/is_regular_file
bool is_directory(const path& p); // https://en.cppreference.com/w/cpp/filesystem/is_directory
bool exists(const path& p); // https://en.cppreference.com/w/cpp/filesystem/exists
}

#define CODA_OSS_coda_oss_filesystem 201703L // c.f., __cpp_lib_filesystem
// Allow coda_oss::filesystem to compile; used in .h files
namespace filesystem
{
#if CODA_OSS_has_std_filesystem_
#define CODA_OSS_coda_oss_filesystem_impl_ std
#else
#define CODA_OSS_coda_oss_filesystem_impl_ sys
#endif
using CODA_OSS_coda_oss_filesystem_impl_::filesystem::file_type;
using CODA_OSS_coda_oss_filesystem_impl_::filesystem::path;

using CODA_OSS_coda_oss_filesystem_impl_::filesystem::absolute;
using CODA_OSS_coda_oss_filesystem_impl_::filesystem::create_directory;
using CODA_OSS_coda_oss_filesystem_impl_::filesystem::current_path;
using CODA_OSS_coda_oss_filesystem_impl_::filesystem::remove;
using CODA_OSS_coda_oss_filesystem_impl_::filesystem::temp_directory_path;
using CODA_OSS_coda_oss_filesystem_impl_::filesystem::is_regular_file;
using CODA_OSS_coda_oss_filesystem_impl_::filesystem::is_directory;
using CODA_OSS_coda_oss_filesystem_impl_::filesystem::exists;
}
}

#endif // CODA_OSS_sys_filesystem_h_INCLUDED_
Loading

0 comments on commit c125ae2

Please sign in to comment.