Skip to content

Commit

Permalink
restore changes from "main"
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Smith committed Jan 17, 2023
1 parent 8bbfcbf commit 67aa42b
Show file tree
Hide file tree
Showing 19 changed files with 43 additions and 64 deletions.
2 changes: 1 addition & 1 deletion modules/c++/cli/source/ArgumentParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ std::unique_ptr<cli::Results> cli::ArgumentParser::parse(const std::string& prog
}
}

auto results = coda_oss::make_unique<cli::Results>();
auto results = std::make_unique<cli::Results>();
cli::Results *currentResults = NULL;
for (size_t i = 0, s = explodedArgs.size(); i < s; ++i)
{
Expand Down
5 changes: 3 additions & 2 deletions modules/c++/io/include/io/PipeStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
#ifndef __IO_PIPE_STREAM_H__
#define __IO_PIPE_STREAM_H__

#include <coda_oss/memory.h>
#include <std/memory>

#include <import/except.h>
#include <str/Convert.h>
#include <sys/Err.h>
Expand Down Expand Up @@ -53,7 +54,7 @@ struct PipeStream : InputStream
size_t streamBufferSize = DEFAULT_CHUNK_SIZE) :
InputStream(),
mExecPipe(cmd),
mCharString(coda_oss::make_unique<char[]>(streamBufferSize)),
mCharString(std::make_unique<char[]>(streamBufferSize)),
mBufferSize(streamBufferSize)
{
mExecPipe.run();
Expand Down
4 changes: 2 additions & 2 deletions modules/c++/logging/include/logging/FileHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@

#include <string>
#include <iostream>
#include <std/memory>

#include <coda_oss/memory.h>
#include "logging/LogRecord.h"
#include "logging/StreamHandler.h"
#include <import/io.h>
Expand All @@ -47,7 +47,7 @@ struct FileHandler : public StreamHandler
{
FileHandler(const coda_oss::filesystem::path& fname, LogLevel level = LogLevel::LOG_NOTSET,
int creationFlags = sys::File::CREATE | sys::File::TRUNCATE) :
StreamHandler(coda_oss::make_unique<io::FileOutputStream>(fname.string(), creationFlags), level)
StreamHandler(std::make_unique<io::FileOutputStream>(fname.string(), creationFlags), level)
{
// In case we are in append mode
if (auto pStream = dynamic_cast<io::FileOutputStream*>(mStream.get()))
Expand Down
4 changes: 2 additions & 2 deletions modules/c++/logging/unittests/test_rotating_log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ TEST_CASE(testRotate)
{
logging::Logger log("test");

auto logHandler = coda_oss::make_unique<logging::RotatingFileHandler>(outFile, 10, maxFiles);
auto logHandler = std::make_unique<logging::RotatingFileHandler>(outFile, 10, maxFiles);
logHandler->setLevel(logging::LogLevel::LOG_DEBUG);
logHandler->setFormatter(coda_oss::make_unique<logging::StandardFormatter>("%m"));
logHandler->setFormatter(std::make_unique<logging::StandardFormatter>("%m"));
log.addHandler(std::move(logHandler));

log.debug("0123456789");
Expand Down
4 changes: 2 additions & 2 deletions modules/c++/math.linear/include/math/linear/Matrix2D.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
#include <cmath>
#include <algorithm>
#include <functional>
#include <std/memory>
#include <cstddef>

#include <coda_oss/memory.h>
#include <import/sys.h>
#include <import/gsl.h>
#include <mem/ScopedArray.h>
Expand Down Expand Up @@ -80,7 +80,7 @@ class Matrix2D

void reset()
{
mStorage = coda_oss::make_unique<_T[]>(mMN);
mStorage = std::make_unique<_T[]>(mMN);
mRaw = mStorage.get();
}
Matrix2D(size_t M, size_t N, std::nullptr_t) :
Expand Down
4 changes: 2 additions & 2 deletions modules/c++/mem/include/mem/ScopedPtr.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
#pragma once

#include <cstddef>
#include <std/memory>
#include <type_traits>

#include "coda_oss/memory.h"
#include "sys/Conf.h"
#include "mem/SharedPtr.h"

Expand Down Expand Up @@ -64,7 +64,7 @@ class ScopedPtr
}
void duplicate(const T& from, std::false_type)
{
reset(coda_oss::make_unique<T>(from));
reset(std::make_unique<T>(from));
}

public:
Expand Down
2 changes: 1 addition & 1 deletion modules/c++/mem/unittests/test_scoped_cloneable_ptr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ struct Foo final
std::unique_ptr<Foo> clone() const
{
// compiler has a hard time resolving overload ... probably because =deletes
//return coda_oss::make_unique<Foo>(val1, val2);
//return std::make_unique<Foo>(val1, val2);
return std::unique_ptr<Foo>(new Foo(val1, val2));
}
};
Expand Down
12 changes: 6 additions & 6 deletions modules/c++/mem/unittests/test_unique_ptr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ TEST_CASE(testStdUniquePtr)
TEST_ASSERT_EQ(123, fooCtor->mVal);
}
{
auto fooCtor = coda_oss::make_unique<Foo>(123);
auto fooCtor = std::make_unique<Foo>(123);
TEST_ASSERT_NOT_EQ(nullptr, fooCtor.get());
TEST_ASSERT_EQ(123, fooCtor->mVal);
}
{
auto pFoos = coda_oss::make_unique<Foo[]>(123); // 123 instances of Foo
auto pFoos = std::make_unique<Foo[]>(123); // 123 instances of Foo
TEST_ASSERT_NOT_EQ(nullptr, pFoos.get());
TEST_ASSERT_EQ(0, pFoos[0].mVal);
TEST_ASSERT_EQ(0, pFoos[122].mVal);
Expand All @@ -64,24 +64,24 @@ TEST_CASE(testStdUniquePtr)
TEST_CASE(test_make_unique)
{
{
auto fooCtor = coda_oss::make_unique<Foo>(123);
auto fooCtor = std::make_unique<Foo>(123);
TEST_ASSERT_NOT_EQ(nullptr, fooCtor.get());
TEST_ASSERT_EQ(123, fooCtor->mVal);
}
{
auto pFoos = coda_oss::make_unique<Foo[]>(123); // 123 instances of Foo
auto pFoos = std::make_unique<Foo[]>(123); // 123 instances of Foo
TEST_ASSERT_NOT_EQ(nullptr, pFoos.get());
TEST_ASSERT_EQ(0, pFoos[0].mVal);
TEST_ASSERT_EQ(0, pFoos[122].mVal);
}

{
auto fooCtor = coda_oss::make_unique<Foo>(123);
auto fooCtor = std::make_unique<Foo>(123);
TEST_ASSERT_NOT_EQ(nullptr, fooCtor.get());
TEST_ASSERT_EQ(123, fooCtor->mVal);
}
{
auto pFoos = coda_oss::make_unique<Foo[]>(123); // 123 instances of Foo
auto pFoos = std::make_unique<Foo[]>(123); // 123 instances of Foo
TEST_ASSERT_NOT_EQ(nullptr, pFoos.get());
TEST_ASSERT_EQ(0, pFoos[0].mVal);
TEST_ASSERT_EQ(0, pFoos[122].mVal);
Expand Down
4 changes: 2 additions & 2 deletions modules/c++/mt/include/mt/BasicThreadPool.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
#define __MT_BASIC_THREAD_POOL_H__

#include <vector>
#include <std/memory>

#include "coda_oss/memory.h"
#include "except/Exception.h"
#include "sys/Mutex.h"
#include "sys/Thread.h"
Expand Down Expand Up @@ -139,7 +139,7 @@ struct BasicThreadPool
// For instance, you may want an IterativeRequestHandler
virtual RequestHandler_T *newRequestHandler()
{
return coda_oss::make_unique<RequestHandler_T>(&mHandlerQueue).release();
return std::make_unique<RequestHandler_T>(&mHandlerQueue).release();
}

void destroy()
Expand Down
4 changes: 2 additions & 2 deletions modules/c++/mt/include/mt/Singleton.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
#define __MT_SINGLETON_H__

#include <mutex>
#include <std/memory>

#include <coda_oss/memory.h>
#include <import/sys.h>
#include <config/compiler_extensions.h>
#include <mem/SharedPtr.h>
Expand Down Expand Up @@ -140,7 +140,7 @@ T& Singleton<T, AutoDestroy>::getInstance()
std::lock_guard<std::mutex> obtainLock(mMutex);
if (mInstance == nullptr)
{
mInstance = coda_oss::make_unique<T>().release(); //create the instance
mInstance = std::make_unique<T>().release(); //create the instance
SingletonAutoDestroyer<AutoDestroy>::registerAtExit(destroy);
}
}
Expand Down
24 changes: 6 additions & 18 deletions modules/c++/sys/include/sys/Dbg.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,23 +95,20 @@
#include <stdlib.h>
#include <assert.h>
#include <iostream>
#include <cstdarg>

#if defined(__sgi) || defined(__sgi__)
# include <stdarg.h>
#else
# include <cstdarg>
#endif

namespace sys
{
#if _MSC_VER
#pragma warning(push)
#pragma warning(disable : 5264) // '...': '...' variable is not used
#endif // _MSC_VER

// compile-time for Dbg.h
constexpr auto debug = CODA_OSS_DEBUG ? true : false;
constexpr auto release = !debug;

#if _MSC_VER
#pragma warning(pop)
#endif // _MSC_VER

// build-time for Dbg.cpp; may (although shouldn't) be different than above.
// C++ says little about debug/release/optimize/etc. (there's NDEBUG inherited from C);
// but mixing is likely to cause all kinds of problems.
Expand Down Expand Up @@ -181,16 +178,7 @@ namespace sys

namespace sys
{
#if _MSC_VER
#pragma warning(push)
#pragma warning(disable : 5264) // '...': '...' variable is not used
#endif // _MSC_VER

constexpr bool debugging = CODA_OSS_debugging ? true : false;

#if _MSC_VER
#pragma warning(pop)
#endif // _MSC_VER
}

namespace sys
Expand Down
9 changes: 0 additions & 9 deletions modules/c++/sys/include/sys/OS.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,11 @@ namespace sys
//MacOS
};

#if _MSC_VER
#pragma warning(push)
#pragma warning(disable : 5264) // '...': '...' variable is not used
#endif // _MSC_VER

#if _WIN32
constexpr auto Platform = PlatformType::Windows;
#else
constexpr auto Platform = PlatformType::Linux;
#endif

#if _MSC_VER
#pragma warning(pop)
#endif // _MSC_VER
}

#endif
Expand Down
5 changes: 2 additions & 3 deletions modules/c++/sys/source/ConditionVarPosix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,15 @@
* see <http://www.gnu.org/licenses/>.
*
*/
#include <sys/ConditionVarPosix.h>

#include <coda_oss/memory.h>
#include <sys/ConditionVarPosix.h>

#if CODA_OSS_POSIX_SOURCE

#include <pthread.h>

sys::ConditionVarPosix::ConditionVarPosix() :
mMutexOwned(coda_oss::make_unique<sys::MutexPosix>()),
mMutexOwned(std::make_unique<sys::MutexPosix>()),
mMutex(mMutexOwned.get())
{
if ( ::pthread_cond_init(&mNative, NULL) != 0)
Expand Down
4 changes: 1 addition & 3 deletions modules/c++/sys/source/ConditionVarWin32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
*
*/

#include <coda_oss/memory.h>


#if defined(_WIN32)
#include "sys/ConditionVarWin32.h"
Expand Down Expand Up @@ -201,7 +199,7 @@ void sys::ConditionVarDataWin32::broadcast()
}

sys::ConditionVarWin32::ConditionVarWin32() :
mMutexOwned(coda_oss::make_unique<sys::MutexWin32>()),
mMutexOwned(std::make_unique<sys::MutexWin32>()),
mMutex(mMutexOwned.get())
{}

Expand Down
2 changes: 1 addition & 1 deletion modules/c++/tiff/source/TiffFileWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ tiff::ImageWriter *tiff::FileWriter::addImage()
if (!mImages.empty())
mIFDOffset = mImages.back()->getNextIFDOffset();

auto image = coda_oss::make_unique<tiff::ImageWriter>(&mOutput, mIFDOffset);
auto image = std::make_unique<tiff::ImageWriter>(&mOutput, mIFDOffset);
mImages.push_back(image.get());
tiff::ImageWriter* const writer = image.release();

Expand Down
5 changes: 3 additions & 2 deletions modules/c++/xml.lite/include/xml/lite/Document.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include <assert.h>

#include <utility>
#include <std/memory>
#include "coda_oss/string.h"
#include "coda_oss/memory.h"

Expand Down Expand Up @@ -82,9 +83,9 @@ struct Document // SOAPDocument derives :-(
#ifndef SWIG // SWIG doesn't like std::unique_ptr
std::unique_ptr<Document>& clone(std::unique_ptr<Document>& doc) const
{
doc = coda_oss::make_unique<Document>();
doc = std::make_unique<Document>();

auto cloneRoot = coda_oss::make_unique<Element>();
auto cloneRoot = std::make_unique<Element>();
cloneRoot->clone(*mRootNode);
doc->setRootElement(std::move(cloneRoot));
return doc;
Expand Down
3 changes: 2 additions & 1 deletion modules/c++/xml.lite/include/xml/lite/MinidomHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
*/

#include <stack>
#include <std/memory>
#include "coda_oss/string.h"
#include "coda_oss/memory.h"

Expand Down Expand Up @@ -73,7 +74,7 @@ struct MinidomHandler final : public ContentHandler
//! Constructor. Uses default document
MinidomHandler()
{
setDocument(coda_oss::make_unique<Document>());
setDocument(std::make_unique<Document>());
}

//! Destructor
Expand Down
4 changes: 2 additions & 2 deletions modules/c++/xml.lite/source/Element.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@

std::unique_ptr<xml::lite::Element> xml::lite::Element::create(const std::string& qname, const std::string& uri, const std::string& characterData)
{
return coda_oss::make_unique<Element>(qname, uri, characterData);
return std::make_unique<Element>(qname, uri, characterData);
}
std::unique_ptr<xml::lite::Element> xml::lite::Element::create(const QName& qname, const std::string& characterData)
{
return create(qname.getName(), qname.getUri().value, characterData);
}
std::unique_ptr<xml::lite::Element> xml::lite::Element::create(const QName& qname, const coda_oss::u8string& characterData)
{
return coda_oss::make_unique<Element>(qname, characterData);
return std::make_unique<Element>(qname, characterData);
}

xml::lite::Element::Element(const xml::lite::Element& node)
Expand Down
6 changes: 3 additions & 3 deletions modules/c++/xml.lite/source/ValidatorXerces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ using XMLCh_t = wchar_t;
static_assert(std::is_same<::XMLCh, XMLCh_t>::value, "XMLCh should be wchar_t");
inline void reset(str::EncodedStringView xmlView, std::unique_ptr<std::wstring>& pWString)
{
pWString = coda_oss::make_unique<std::wstring>(xmlView.wstring());
pWString = std::make_unique<std::wstring>(xmlView.wstring());
}
#else
using XMLCh_t = char16_t;
Expand All @@ -194,11 +194,11 @@ static_assert(std::is_same<::XMLCh, XMLCh_t>::value, "XMLCh should be char16_t")

inline void reset(str::EncodedStringView xmlView, std::unique_ptr<std::u16string>& pWString)
{
pWString = coda_oss::make_unique<std::u16string>(xmlView.u16string());
pWString = std::make_unique<std::u16string>(xmlView.u16string());
}
inline void reset(str::EncodedStringView xmlView, std::unique_ptr<str::ui16string>& pWString)
{
pWString = coda_oss::make_unique<str::ui16string>(xmlView.ui16string_());
pWString = std::make_unique<str::ui16string>(xmlView.ui16string_());
}

using XMLCh_string = std::basic_string<XMLCh_t>;
Expand Down

0 comments on commit 67aa42b

Please sign in to comment.