OLD | NEW |
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 MOJO_PUBLIC_CPP_BINDINGS_TESTS_STRUCT_WITH_TRAITS_IMPL_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_TESTS_STRUCT_WITH_TRAITS_IMPL_H_ |
6 #define MOJO_PUBLIC_CPP_BINDINGS_TESTS_STRUCT_WITH_TRAITS_IMPL_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_TESTS_STRUCT_WITH_TRAITS_IMPL_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
| 10 #include <map> |
10 #include <string> | 11 #include <string> |
11 #include <vector> | 12 #include <vector> |
12 | 13 |
13 #include "base/strings/string_piece.h" | 14 #include "base/strings/string_piece.h" |
14 #include "mojo/public/cpp/system/handle.h" | 15 #include "mojo/public/cpp/system/handle.h" |
15 | 16 |
16 namespace mojo { | 17 namespace mojo { |
17 namespace test { | 18 namespace test { |
18 | 19 |
19 struct NestedStructWithTraitsImpl { | 20 struct NestedStructWithTraitsImpl { |
20 public: | 21 public: |
| 22 NestedStructWithTraitsImpl(); |
| 23 explicit NestedStructWithTraitsImpl(int32_t in_value); |
| 24 |
21 bool operator==(const NestedStructWithTraitsImpl& other) const { | 25 bool operator==(const NestedStructWithTraitsImpl& other) const { |
22 return value == other.value; | 26 return value == other.value; |
23 } | 27 } |
24 | 28 |
25 int32_t value = 0; | 29 int32_t value = 0; |
26 }; | 30 }; |
27 | 31 |
28 // A type which knows how to look like a mojo::test::StructWithTraits mojom type | 32 // A type which knows how to look like a mojo::test::StructWithTraits mojom type |
29 // by way of mojo::StructTraits. | 33 // by way of mojo::StructTraits. |
30 class StructWithTraitsImpl { | 34 class StructWithTraitsImpl { |
(...skipping 22 matching lines...) Expand all Loading... |
53 const NestedStructWithTraitsImpl& get_struct() const { return struct_; } | 57 const NestedStructWithTraitsImpl& get_struct() const { return struct_; } |
54 NestedStructWithTraitsImpl& get_mutable_struct() { return struct_; } | 58 NestedStructWithTraitsImpl& get_mutable_struct() { return struct_; } |
55 | 59 |
56 const std::vector<NestedStructWithTraitsImpl>& get_struct_array() const { | 60 const std::vector<NestedStructWithTraitsImpl>& get_struct_array() const { |
57 return struct_array_; | 61 return struct_array_; |
58 } | 62 } |
59 std::vector<NestedStructWithTraitsImpl>& get_mutable_struct_array() { | 63 std::vector<NestedStructWithTraitsImpl>& get_mutable_struct_array() { |
60 return struct_array_; | 64 return struct_array_; |
61 } | 65 } |
62 | 66 |
| 67 const std::map<std::string, NestedStructWithTraitsImpl>& get_struct_map() |
| 68 const { |
| 69 return struct_map_; |
| 70 } |
| 71 std::map<std::string, NestedStructWithTraitsImpl>& get_mutable_struct_map() { |
| 72 return struct_map_; |
| 73 } |
| 74 |
63 private: | 75 private: |
64 bool bool_ = false; | 76 bool bool_ = false; |
65 uint32_t uint32_ = 0; | 77 uint32_t uint32_ = 0; |
66 uint64_t uint64_ = 0; | 78 uint64_t uint64_ = 0; |
67 std::string string_; | 79 std::string string_; |
68 std::vector<std::string> string_array_; | 80 std::vector<std::string> string_array_; |
69 NestedStructWithTraitsImpl struct_; | 81 NestedStructWithTraitsImpl struct_; |
70 std::vector<NestedStructWithTraitsImpl> struct_array_; | 82 std::vector<NestedStructWithTraitsImpl> struct_array_; |
| 83 std::map<std::string, NestedStructWithTraitsImpl> struct_map_; |
71 }; | 84 }; |
72 | 85 |
73 // A type which knows how to look like a mojo::test::PassByValueStructWithTraits | 86 // A type which knows how to look like a mojo::test::PassByValueStructWithTraits |
74 // mojom type by way of mojo::StructTraits. | 87 // mojom type by way of mojo::StructTraits. |
75 class PassByValueStructWithTraitsImpl { | 88 class PassByValueStructWithTraitsImpl { |
76 public: | 89 public: |
77 PassByValueStructWithTraitsImpl(); | 90 PassByValueStructWithTraitsImpl(); |
78 PassByValueStructWithTraitsImpl(PassByValueStructWithTraitsImpl&& other); | 91 PassByValueStructWithTraitsImpl(PassByValueStructWithTraitsImpl&& other); |
79 ~PassByValueStructWithTraitsImpl(); | 92 ~PassByValueStructWithTraitsImpl(); |
80 | 93 |
81 ScopedHandle& get_mutable_handle() { return handle_; } | 94 ScopedHandle& get_mutable_handle() { return handle_; } |
82 | 95 |
83 private: | 96 private: |
84 ScopedHandle handle_; | 97 ScopedHandle handle_; |
85 }; | 98 }; |
86 | 99 |
87 } // namespace test | 100 } // namespace test |
88 } // namespace mojo | 101 } // namespace mojo |
89 | 102 |
90 #endif // MOJO_PUBLIC_CPP_BINDINGS_TESTS_STRUCT_WITH_TRAITS_IMPL_H_ | 103 #endif // MOJO_PUBLIC_CPP_BINDINGS_TESTS_STRUCT_WITH_TRAITS_IMPL_H_ |
OLD | NEW |