Merge from Widevine repo of http://go/wvgerrit/58200 This CL removes code from the testbed that is duplicated in the reference code using inheritance. bug: 76393338 Split mock into reference code and testbed code test: unit tests Change-Id: I7b5f5330a595fa1756e6dfdf75bc07addb6107a8
49 lines
1.1 KiB
C++
49 lines
1.1 KiB
C++
// Copyright 2018 Google LLC. All Rights Reserved. This file and proprietary
|
|
// source code may only be used and distributed under the Widevine Master
|
|
// License Agreement.
|
|
#ifndef OEMCRYPTO_SCOPED_PTR_H_
|
|
#define OEMCRYPTO_SCOPED_PTR_H_
|
|
|
|
#include <stddef.h>
|
|
#include <memory>
|
|
|
|
#include <arpa/inet.h>
|
|
|
|
namespace wvoec_ref {
|
|
|
|
// TODO(fredgc, jfore): scoped_ptr may not be the best name for this smart
|
|
// pointer type. It basically works like auto_ptr which is deprecated.
|
|
#if __cplusplus < 201103L
|
|
|
|
template <typename T>
|
|
class scoped_ptr {
|
|
public:
|
|
explicit scoped_ptr(T* p = NULL) : ptr_(p) {}
|
|
T* get() const { return ptr_.get(); }
|
|
void reset(T* p = NULL) { ptr_.reset(p); }
|
|
|
|
private:
|
|
std::auto_ptr<T> ptr_;
|
|
};
|
|
|
|
#else
|
|
|
|
template <typename T>
|
|
class scoped_ptr {
|
|
public:
|
|
explicit scoped_ptr(T* p = nullptr) : ptr_(p) {}
|
|
scoped_ptr(scoped_ptr& r) { ptr_ = std::move(r.ptr_); }
|
|
T& operator*() const { return *ptr_; }
|
|
T* operator->() const { return ptr_.get(); }
|
|
T* get() const { return ptr_.get(); }
|
|
void reset(T* p = NULL) { ptr_.reset(p); }
|
|
|
|
private:
|
|
std::unique_ptr<T> ptr_;
|
|
};
|
|
#endif
|
|
|
|
} // namespace wvoec_ref
|
|
|
|
#endif // OEMCRYPTO_SCOPED_PTR_H_
|