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

Unified Diff: mojo/public/cpp/bindings/tests/struct_with_traits_impl.h

Issue 1967703004: Mojo C++ bindings: add StringTraits and ArrayTraits for STL types. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@27_update_users
Patch Set: Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: mojo/public/cpp/bindings/tests/struct_with_traits_impl.h
diff --git a/mojo/public/cpp/bindings/tests/struct_with_traits_impl.h b/mojo/public/cpp/bindings/tests/struct_with_traits_impl.h
index 3ba8ef6430abf59f925d9450e4d5ff2cc4928ca6..25a17f403152430c0fdab23aa4a5e0972cc17c56 100644
--- a/mojo/public/cpp/bindings/tests/struct_with_traits_impl.h
+++ b/mojo/public/cpp/bindings/tests/struct_with_traits_impl.h
@@ -8,12 +8,22 @@
#include <stdint.h>
#include <string>
+#include <vector>
#include "base/strings/string_piece.h"
namespace mojo {
namespace test {
+struct NestedStructWithTraitsImpl {
+ public:
+ bool operator==(const NestedStructWithTraitsImpl& other) const {
+ return value == other.value;
+ }
+
+ int32_t value = 0;
+};
+
// A type which knows how to look like a mojo::test::StructWithTraits mojom type
// by way of mojo::StructTraits.
class StructWithTraitsImpl {
@@ -31,13 +41,32 @@ class StructWithTraitsImpl {
uint64_t get_uint64() const { return uint64_; }
void set_string(std::string value) { string_ = value; }
- base::StringPiece get_string() const { return string_; }
+ base::StringPiece get_string_as_string_piece() const { return string_; }
+ const std::string& get_string() const { return string_; }
+
+ const std::vector<std::string>& get_string_array() const {
+ return string_array_;
+ }
+ std::vector<std::string>& get_mutable_string_array() { return string_array_; }
+
+ const NestedStructWithTraitsImpl& get_struct() const { return struct_; }
+ NestedStructWithTraitsImpl& get_mutable_struct() { return struct_; }
+
+ const std::vector<NestedStructWithTraitsImpl>& get_struct_array() const {
+ return struct_array_;
+ }
+ std::vector<NestedStructWithTraitsImpl>& get_mutable_struct_array() {
+ return struct_array_;
+ }
private:
bool bool_ = false;
uint32_t uint32_ = 0;
uint64_t uint64_ = 0;
std::string string_;
+ std::vector<std::string> string_array_;
+ NestedStructWithTraitsImpl struct_;
+ std::vector<NestedStructWithTraitsImpl> struct_array_;
};
} // namespace test

Powered by Google App Engine
This is Rietveld 408576698