buffet: Add Array type support for Buffet command and state props

Added definition of ArrayPropType and ArrayPropValue, added
parsing code to ObjectSchema to parse the array object type as well
as type detection code to detect array types from 'items', 'enum',
'default' properties of object schema definition.

Added a bunch of unit tests to verify that array definitions can
be parsed, values of type arrays can be constructuted and value
validation code works with arrays.

BUG=brillo:107
TEST=`FEATURES=test emerge-link buffet`

Change-Id: I0f7bbed012792e0a49fa1b071bb56fee512825a9
Reviewed-on: https://chromium-review.googlesource.com/261616
Reviewed-by: Vitaly Buka <vitalybuka@chromium.org>
Commit-Queue: Alex Vakulenko <avakulenko@chromium.org>
Tested-by: Alex Vakulenko <avakulenko@chromium.org>
Trybot-Ready: Alex Vakulenko <avakulenko@chromium.org>
diff --git a/buffet/commands/schema_utils.h b/buffet/commands/schema_utils.h
index 5709ebc..625b854 100644
--- a/buffet/commands/schema_utils.h
+++ b/buffet/commands/schema_utils.h
@@ -27,10 +27,16 @@
 namespace native_types {
 // C++ representation of object values.
 using Object = std::map<std::string, std::shared_ptr<const PropValue>>;
+// C++ representation of array of values.
+using Array = std::vector<std::shared_ptr<const PropValue>>;
 }  // namespace native_types
+
 // Converts an object to string.
 std::string ToString(const native_types::Object& obj);
 
+// Converts an array to string.
+std::string ToString(const native_types::Array& arr);
+
 // InheritableAttribute class is used for specifying various command parameter
 // attributes that can be inherited from a base (parent) schema.
 // The |value| still specifies the actual attribute values, whether it
@@ -61,6 +67,8 @@
                                               chromeos::ErrorPtr* error);
 std::unique_ptr<base::Value> TypedValueToJson(const native_types::Object& value,
                                               chromeos::ErrorPtr* error);
+std::unique_ptr<base::Value> TypedValueToJson(const native_types::Array& value,
+                                              chromeos::ErrorPtr* error);
 template<typename T>
 std::unique_ptr<base::Value> TypedValueToJson(const std::vector<T>& values,
                                               chromeos::ErrorPtr* error) {
@@ -97,9 +105,15 @@
                         const PropType* type,
                         native_types::Object* value_out,
                         chromeos::ErrorPtr* error);
+bool TypedValueFromJson(const base::Value* value_in,
+                        const PropType* type,
+                        native_types::Array* value_out,
+                        chromeos::ErrorPtr* error);
 
 bool operator==(const native_types::Object& obj1,
                 const native_types::Object& obj2);
+bool operator==(const native_types::Array& arr1,
+                const native_types::Array& arr2);
 
 // CompareValue is a helper function to help with implementing EqualsTo operator
 // for various data types. For most scalar types it is using operator==(),