Index: base/json/json_value_converter.h |
diff --git a/base/json/json_value_converter.h b/base/json/json_value_converter.h |
index 0bb131cba39ee6ba95db4be48d5c73eb1d33935f..0464f3c4d69c2dc81e9b0c8ed96a2efa57c091f4 100644 |
--- a/base/json/json_value_converter.h |
+++ b/base/json/json_value_converter.h |
@@ -92,11 +92,13 @@ class JSONValueConverter; |
namespace internal { |
+template<typename StructType> |
class FieldConverterBase { |
public: |
- BASE_EXPORT explicit FieldConverterBase(const std::string& path); |
- BASE_EXPORT virtual ~FieldConverterBase(); |
- virtual bool ConvertField(const base::Value& value, void* obj) const = 0; |
+ explicit FieldConverterBase(const std::string& path) : field_path_(path) {} |
+ virtual ~FieldConverterBase() {} |
+ virtual bool ConvertField(const base::Value& value, StructType* obj) |
+ const = 0; |
const std::string& field_path() const { return field_path_; } |
private: |
@@ -112,19 +114,18 @@ class ValueConverter { |
}; |
template <typename StructType, typename FieldType> |
-class FieldConverter : public FieldConverterBase { |
+class FieldConverter : public FieldConverterBase<StructType> { |
public: |
explicit FieldConverter(const std::string& path, |
FieldType StructType::* field, |
ValueConverter<FieldType>* converter) |
- : FieldConverterBase(path), |
+ : FieldConverterBase<StructType>(path), |
field_pointer_(field), |
value_converter_(converter) { |
} |
virtual bool ConvertField( |
- const base::Value& value, void* obj) const OVERRIDE { |
- StructType* dst = reinterpret_cast<StructType*>(obj); |
+ const base::Value& value, StructType* dst) const OVERRIDE { |
return value_converter_->Convert(value, &(dst->*field_pointer_)); |
} |
@@ -423,7 +424,8 @@ class JSONValueConverter { |
return false; |
for(size_t i = 0; i < fields_.size(); ++i) { |
- const internal::FieldConverterBase* field_converter = fields_[i]; |
+ const internal::FieldConverterBase<StructType>* field_converter = |
+ fields_[i]; |
base::Value* field = NULL; |
if (dictionary_value->Get(field_converter->field_path(), &field)) { |
if (!field_converter->ConvertField(*field, output)) { |
@@ -436,7 +438,7 @@ class JSONValueConverter { |
} |
private: |
- ScopedVector<internal::FieldConverterBase> fields_; |
+ ScopedVector<internal::FieldConverterBase<StructType> > fields_; |
DISALLOW_COPY_AND_ASSIGN(JSONValueConverter); |
}; |