libchromeos: Move Any from Buffet to libchromeos.
Move the Any class from Buffet to libchromeos and
changed its namespace from buffet:: to chromeos::
Updated the rest of Buffet code to with the changes
to the class's namespace and header file location.
Also, now that move constructors are officially allowed by
Google C++ coding style for project with C++11 feature
support, added back the move constructor to Any as
per http://crbug.com/387902
BUG=chromium:405714,chromium:387902
TEST=USE=buffet ./build_packages
Change-Id: Id007f51b874934e4f6428fe90674495edeb79107
Reviewed-on: https://chromium-review.googlesource.com/213831
Tested-by: Alex Vakulenko <avakulenko@chromium.org>
Reviewed-by: Ben Chan <benchan@chromium.org>
Commit-Queue: Alex Vakulenko <avakulenko@chromium.org>
diff --git a/buffet/commands/prop_types.cc b/buffet/commands/prop_types.cc
index 694d74e..f4de059 100644
--- a/buffet/commands/prop_types.cc
+++ b/buffet/commands/prop_types.cc
@@ -11,6 +11,7 @@
#include <base/json/json_writer.h>
#include <base/logging.h>
#include <base/values.h>
+#include <chromeos/any.h>
#include <chromeos/string_utils.h>
#include "buffet/commands/object_schema.h"
@@ -149,7 +150,7 @@
return val->FromJson(value, error) && ValidateConstraints(*val, error);
}
-bool PropType::ValidateValue(const Any& value,
+bool PropType::ValidateValue(const chromeos::Any& value,
chromeos::ErrorPtr* error) const {
std::shared_ptr<PropValue> val = CreateValue(value);
CHECK(val) << "Failed to create value object";
diff --git a/buffet/commands/prop_types.h b/buffet/commands/prop_types.h
index 506c822..86a2960 100644
--- a/buffet/commands/prop_types.h
+++ b/buffet/commands/prop_types.h
@@ -13,6 +13,7 @@
#include <utility>
#include <vector>
+#include <chromeos/any.h>
#include <chromeos/error.h>
#include "buffet/commands/prop_constraints.h"
@@ -81,7 +82,8 @@
// Creates an instance of associated value object, using the parameter
// type as a factory class.
virtual std::shared_ptr<PropValue> CreateValue() const = 0;
- virtual std::shared_ptr<PropValue> CreateValue(const Any& val) const = 0;
+ virtual std::shared_ptr<PropValue> CreateValue(
+ const chromeos::Any& val) const = 0;
// Saves the parameter type definition as a JSON object.
// If |full_schema| is set to true, the full type definition is saved,
@@ -122,7 +124,8 @@
bool ValidateValue(const base::Value* value, chromeos::ErrorPtr* error) const;
// Similar to the above method, but uses Any as the value container.
- bool ValidateValue(const Any& value, chromeos::ErrorPtr* error) const;
+ bool ValidateValue(const chromeos::Any& value,
+ chromeos::ErrorPtr* error) const;
// Additional helper static methods to help with converting a type enum
// value into a string and back.
@@ -186,7 +189,8 @@
std::shared_ptr<PropValue> CreateValue() const override {
return std::make_shared<Value>(this);
}
- std::shared_ptr<PropValue> CreateValue(const Any& v) const override {
+ std::shared_ptr<PropValue> CreateValue(
+ const chromeos::Any& v) const override {
auto value = std::make_shared<Value>(this);
value->SetValue(v.Get<T>());
return std::move(value);
diff --git a/buffet/commands/prop_values.h b/buffet/commands/prop_values.h
index f568dd8..106ab1d 100644
--- a/buffet/commands/prop_values.h
+++ b/buffet/commands/prop_values.h
@@ -9,9 +9,9 @@
#include <memory>
#include <string>
+#include <chromeos/any.h>
#include <chromeos/error.h>
-#include "buffet/any.h"
#include "buffet/commands/schema_utils.h"
namespace base {
@@ -103,7 +103,7 @@
chromeos::ErrorPtr* error) = 0;
// Returns the contained C++ value as Any.
- virtual Any GetValueAsAny() const = 0;
+ virtual chromeos::Any GetValueAsAny() const = 0;
// Return the type definition of this value.
const PropType* GetPropType() const { return type_; }
@@ -149,7 +149,7 @@
}
// Helper methods to get and set the C++ representation of the value.
- Any GetValueAsAny() const override { return value_; }
+ chromeos::Any GetValueAsAny() const override { return value_; }
const T& GetValue() const { return value_; }
void SetValue(T value) { value_ = std::move(value); }