summaryrefslogtreecommitdiffstats
path: root/chromium/ppapi/cpp/extensions/optional.h
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/ppapi/cpp/extensions/optional.h')
-rw-r--r--chromium/ppapi/cpp/extensions/optional.h97
1 files changed, 0 insertions, 97 deletions
diff --git a/chromium/ppapi/cpp/extensions/optional.h b/chromium/ppapi/cpp/extensions/optional.h
deleted file mode 100644
index fdef839aa1c..00000000000
--- a/chromium/ppapi/cpp/extensions/optional.h
+++ /dev/null
@@ -1,97 +0,0 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef PPAPI_CPP_EXTENSIONS_OPTIONAL_H_
-#define PPAPI_CPP_EXTENSIONS_OPTIONAL_H_
-
-namespace pp {
-namespace ext {
-
-template <class T>
-class Optional {
- public:
- Optional() : value_(NULL) {
- }
- // Takes ownership of |value|.
- explicit Optional(T* value) : value_(value) {
- }
- Optional(const T& value) : value_(new T(value)) {
- }
- Optional(const Optional<T>& other)
- : value_(other.value_ ? new T(*other.value_) : NULL) {
- }
-
- ~Optional() {
- Reset();
- }
-
- Optional<T>& operator=(const T& other) {
- if (value_ == &other)
- return *this;
-
- Reset();
- value_ = new T(other);
-
- return *this;
- }
-
- Optional<T>& operator=(const Optional<T>& other) {
- if (value_ == other.value_)
- return *this;
-
- Reset();
- if (other.value_)
- value_ = new T(*other.value_);
-
- return *this;
- }
-
- bool IsSet() const {
- return !!value_;
- }
-
- T* Get() const {
- return value_;
- }
-
- // Should only be used when IsSet() is true.
- T& operator*() const {
- return *value_;
- }
-
- // Should only be used when IsSet() is true.
- T* operator->() const {
- PP_DCHECK(value_);
- return value_;
- }
-
- // Takes ownership of |value|.
- void Set(T* value) {
- if (value == value_)
- return;
-
- Reset();
- *value_ = value;
- }
-
- void Reset() {
- T* value = value_;
- value_ = NULL;
- delete value;
- }
-
- void Swap(Optional<T>* other) {
- T* temp = value_;
- value_ = other->value_;
- other->value_ = temp;
- }
-
- private:
- T* value_;
-};
-
-} // namespace ext
-} // namespace pp
-
-#endif // PPAPI_CPP_EXTENSIONS_OPTIONAL_H_