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

Side by Side Diff: third_party/WebKit/Source/platform/inspector_protocol/Maybe_h.template

Issue 2251343003: [DevTools] Generate separate copies of inspector_protocol. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef Maybe_h 5 #ifndef {{"_".join(config.protocol.namespace)}}_Maybe_h
6 #define Maybe_h 6 #define {{"_".join(config.protocol.namespace)}}_Maybe_h
7 7
8 //#include "Platform.h" 8 //#include "Platform.h"
9 //#include "String16.h" 9 //#include "String.h"
10 10
11 namespace blink { 11 {% for namespace in config.protocol.namespace %}
12 namespace protocol { 12 namespace {{namespace}} {
13 {% endfor %}
13 14
14 template<typename T> 15 template<typename T>
15 class Maybe { 16 class Maybe {
16 public: 17 public:
17 Maybe() : m_value() { } 18 Maybe() : m_value() { }
18 Maybe(std::unique_ptr<T> value) : m_value(std::move(value)) { } 19 Maybe(std::unique_ptr<T> value) : m_value(std::move(value)) { }
19 void operator=(std::unique_ptr<T> value) { m_value = std::move(value); } 20 void operator=(std::unique_ptr<T> value) { m_value = std::move(value); }
20 T* fromJust() const { DCHECK(m_value); return m_value.get(); } 21 T* fromJust() const { DCHECK(m_value); return m_value.get(); }
21 T* fromMaybe(T* defaultValue) const { return m_value ? m_value.get() : defau ltValue; } 22 T* fromMaybe(T* defaultValue) const { return m_value ? m_value.get() : defau ltValue; }
22 bool isJust() const { return !!m_value; } 23 bool isJust() const { return !!m_value; }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 60
60 template<> 61 template<>
61 class Maybe<double> : public MaybeBase<double> { 62 class Maybe<double> : public MaybeBase<double> {
62 public: 63 public:
63 Maybe() { } 64 Maybe() { }
64 Maybe(double value) : MaybeBase(value) { } 65 Maybe(double value) : MaybeBase(value) { }
65 using MaybeBase::operator=; 66 using MaybeBase::operator=;
66 }; 67 };
67 68
68 template<> 69 template<>
69 class Maybe<InspectorProtocolConvenienceStringType> : public MaybeBase<Inspector ProtocolConvenienceStringType> { 70 class Maybe<String> : public MaybeBase<String> {
70 public: 71 public:
71 Maybe() { } 72 Maybe() { }
72 Maybe(const InspectorProtocolConvenienceStringType& value) : MaybeBase(value ) { } 73 Maybe(const String& value) : MaybeBase(value) { }
73 using MaybeBase::operator=; 74 using MaybeBase::operator=;
74 }; 75 };
75 76
76 template<> 77 {% for namespace in config.protocol.namespace %}
77 class Maybe<String16> : public MaybeBase<String16> { 78 } // namespace {{namespace}}
78 public: 79 {% endfor %}
79 Maybe() { }
80 Maybe(const String16& value) : MaybeBase(value) { }
81 using MaybeBase::operator=;
82 };
83 80
84 } // namespace platform 81 #endif // !defined({{"_".join(config.protocol.namespace)}}_Maybe_h)
85 } // namespace blink
86
87 #endif // !defined(Maybe_h)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698