Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: Source/bindings/v8/Nullable.h

Issue 351423002: Moved files under Source/bindings/v8 to Source/bindings/core/v8. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/bindings/v8/NPV8Object.cpp ('k') | Source/bindings/v8/PageScriptDebugServer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef Nullable_h
6 #define Nullable_h
7
8 #include "wtf/Assertions.h"
9
10 namespace WebCore {
11
12 template <typename T>
13 class Nullable {
14 public:
15 Nullable()
16 : m_value()
17 , m_isNull(true) { }
18
19 Nullable(const T& value)
20 : m_value(value)
21 , m_isNull(false) { }
22
23 Nullable(const Nullable& other)
24 : m_value(other.m_value)
25 , m_isNull(other.m_isNull) { }
26
27 Nullable& operator=(const Nullable& other)
28 {
29 m_value = other.m_value;
30 m_isNull = other.m_isNull;
31 return *this;
32 }
33
34 T get() const { ASSERT(!m_isNull); return m_value; }
35 bool isNull() const { return m_isNull; }
36
37 operator bool() const { return !m_isNull && m_value; }
38
39 bool operator==(const Nullable& other) const
40 {
41 return (m_isNull && other.m_isNull) || (!m_isNull && !other.m_isNull && m_value == other.m_value);
42 }
43
44 private:
45 T m_value;
46 bool m_isNull;
47 };
48
49 } // namespace WebCore
50
51 #endif // Nullable_h
OLDNEW
« no previous file with comments | « Source/bindings/v8/NPV8Object.cpp ('k') | Source/bindings/v8/PageScriptDebugServer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698