summaryrefslogtreecommitdiffstats
path: root/chromeos/network/onc/onc_mapper.h
diff options
context:
space:
mode:
Diffstat (limited to 'chromeos/network/onc/onc_mapper.h')
-rw-r--r--chromeos/network/onc/onc_mapper.h72
1 files changed, 40 insertions, 32 deletions
diff --git a/chromeos/network/onc/onc_mapper.h b/chromeos/network/onc/onc_mapper.h
index e8d42a9..142af70 100644
--- a/chromeos/network/onc/onc_mapper.h
+++ b/chromeos/network/onc/onc_mapper.h
@@ -11,9 +11,9 @@
#include "chromeos/chromeos_export.h"
namespace base {
-class Value;
class DictionaryValue;
class ListValue;
+class Value;
}
namespace chromeos {
@@ -41,58 +41,66 @@ class Mapper {
protected:
// Calls |MapObject|, |MapArray| and |MapPrimitive| according to |onc_value|'s
- // type. By default aborts on nested errors in arrays. Result of the mapping
- // is returned. On error returns NULL.
- virtual scoped_ptr<base::Value> MapValue(
- const OncValueSignature& signature,
- const base::Value& onc_value);
+ // type, which always return an object of the according type. Result of the
+ // mapping is returned. On error sets |error| to true.
+ virtual scoped_ptr<base::Value> MapValue(const OncValueSignature& signature,
+ const base::Value& onc_value,
+ bool* error);
// Maps objects/dictionaries. By default calls |MapFields|, which recurses
- // into each field of |onc_object|, and aborts on unknown fields. Result of
- // the mapping is returned. On error returns NULL.
+ // into each field of |onc_object|, and drops unknown fields. Result of the
+ // mapping is returned. On error sets |error| to true. In this implementation
+ // only unknown fields are errors.
virtual scoped_ptr<base::DictionaryValue> MapObject(
const OncValueSignature& signature,
- const base::DictionaryValue& onc_object);
+ const base::DictionaryValue& onc_object,
+ bool* error);
// Maps primitive values like BinaryValue, StringValue, IntegerValue... (all
// but dictionaries and lists). By default copies |onc_primitive|. Result of
- // the mapping is returned. On error returns NULL.
+ // the mapping is returned. On error sets |error| to true.
virtual scoped_ptr<base::Value> MapPrimitive(
- const OncValueSignature& signature,
- const base::Value& onc_primitive);
-
- // Maps each field of the given |onc_object| according to
- // |object_signature|. Adds the mapping of each field to |result| using
- // |MapField| and drops unknown fields by default. Sets
- // |found_unknown_field| to true if this dictionary contains any unknown
- // fields. Set |nested_error_occured| to true if nested errors occured.
- virtual void MapFields(
- const OncValueSignature& object_signature,
- const base::DictionaryValue& onc_object,
- bool* found_unknown_field,
- bool* nested_error_occured,
- base::DictionaryValue* result);
+ const OncValueSignature& signature,
+ const base::Value& onc_primitive,
+ bool* error);
+
+ // Maps each field of the given |onc_object| according to |object_signature|.
+ // Adds the mapping of each field to |result| using |MapField| and drops
+ // unknown fields by default. Sets |found_unknown_field| to true if this
+ // dictionary contains any unknown fields. Set |nested_error| to true if
+ // nested errors occured.
+ virtual void MapFields(const OncValueSignature& object_signature,
+ const base::DictionaryValue& onc_object,
+ bool* found_unknown_field,
+ bool* nested_error,
+ base::DictionaryValue* result);
// Maps the value |onc_value| of field |field_name| according to its field
// signature in |object_signature| using |MapValue|. Sets
- // |found_unknown_field| to true if |field_name| cannot be found in
- // |object_signature|, which by default is an error. Result of the mapping is
- // returned. On error returns NULL.
+ // |found_unknown_field| to true and returns NULL if |field_name| cannot be
+ // found in |object_signature|. Otherwise returns the mapping of |onc_value|.
virtual scoped_ptr<base::Value> MapField(
const std::string& field_name,
const OncValueSignature& object_signature,
const base::Value& onc_value,
- bool* found_unknown_field);
+ bool* found_unknown_field,
+ bool* error);
// Maps the array |onc_array| according to |array_signature|, which defines
// the type of the entries. Maps each entry by calling |MapValue|. If any of
- // the nested mappings failed, the flag |nested_error_occured| is set to true
- // and the entry is dropped from the result. The resulting array is
- // returned. On error returns NULL.
+ // the nested mappings failed, the flag |nested_error| is set to true and the
+ // entry is dropped from the result. The resulting array is returned.
virtual scoped_ptr<base::ListValue> MapArray(
const OncValueSignature& array_signature,
const base::ListValue& onc_array,
- bool* nested_error_occured);
+ bool* nested_error);
+
+ // Calls |MapValue| and returns its result. Called by |MapArray| for each
+ // entry and its index in the enclosing array.
+ virtual scoped_ptr<base::Value> MapEntry(int index,
+ const OncValueSignature& signature,
+ const base::Value& onc_value,
+ bool* error);
private:
DISALLOW_COPY_AND_ASSIGN(Mapper);