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

Side by Side Diff: mojo/public/cpp/bindings/struct_ptr.h

Issue 1358353002: * Change C++ serialization/deserialization to not be move-only operations (with the except of |Ha… (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: (*it).get() to it->, and other formatting Created 5 years, 2 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
« no previous file with comments | « mojo/public/cpp/bindings/map.h ('k') | mojo/public/cpp/bindings/tests/array_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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 MOJO_PUBLIC_CPP_BINDINGS_STRUCT_PTR_H_ 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_STRUCT_PTR_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_STRUCT_PTR_H_ 6 #define MOJO_PUBLIC_CPP_BINDINGS_STRUCT_PTR_H_
7 7
8 #include <new> 8 #include <new>
9 9
10 #include "mojo/public/cpp/bindings/type_converter.h" 10 #include "mojo/public/cpp/bindings/type_converter.h"
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 bool is_null() const { return is_null_; } 143 bool is_null() const { return is_null_; }
144 144
145 Struct& operator*() const { 145 Struct& operator*() const {
146 MOJO_DCHECK(!is_null_); 146 MOJO_DCHECK(!is_null_);
147 return value_; 147 return value_;
148 } 148 }
149 Struct* operator->() const { 149 Struct* operator->() const {
150 MOJO_DCHECK(!is_null_); 150 MOJO_DCHECK(!is_null_);
151 return &value_; 151 return &value_;
152 } 152 }
153 Struct* get() const { return &value_; } 153 Struct* get() const { return is_null() ? nullptr : &value_; }
154 154
155 void Swap(InlinedStructPtr* other) { 155 void Swap(InlinedStructPtr* other) {
156 std::swap(value_, other->value_); 156 std::swap(value_, other->value_);
157 std::swap(is_null_, other->is_null_); 157 std::swap(is_null_, other->is_null_);
158 } 158 }
159 159
160 InlinedStructPtr Clone() const { 160 InlinedStructPtr Clone() const {
161 return is_null() ? InlinedStructPtr() : value_.Clone(); 161 return is_null() ? InlinedStructPtr() : value_.Clone();
162 } 162 }
163 bool Equals(const InlinedStructPtr& other) const { 163 bool Equals(const InlinedStructPtr& other) const {
(...skipping 17 matching lines...) Expand all
181 Swap(other); 181 Swap(other);
182 } 182 }
183 183
184 mutable Struct value_; 184 mutable Struct value_;
185 bool is_null_; 185 bool is_null_;
186 }; 186 };
187 187
188 } // namespace mojo 188 } // namespace mojo
189 189
190 #endif // MOJO_PUBLIC_CPP_BINDINGS_STRUCT_PTR_H_ 190 #endif // MOJO_PUBLIC_CPP_BINDINGS_STRUCT_PTR_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/map.h ('k') | mojo/public/cpp/bindings/tests/array_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698