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

Unified Diff: base/json/json_value_converter.h

Issue 9289040: Remove reinterpret_cast on JSONValueConverter (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: omit base_export Created 8 years, 11 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
« no previous file with comments | « base/base.gypi ('k') | base/json/json_value_converter.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..4ae8b8eff1dc433c61ef7eed60afe1b7e0c15ff8 100644
--- a/base/json/json_value_converter.h
+++ b/base/json/json_value_converter.h
@@ -9,7 +9,6 @@
#include <string>
#include <vector>
-#include "base/base_export.h"
#include "base/basictypes.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
@@ -92,11 +91,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 +113,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 +423,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 +437,7 @@ class JSONValueConverter {
}
private:
- ScopedVector<internal::FieldConverterBase> fields_;
+ ScopedVector<internal::FieldConverterBase<StructType> > fields_;
DISALLOW_COPY_AND_ASSIGN(JSONValueConverter);
};
« no previous file with comments | « base/base.gypi ('k') | base/json/json_value_converter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698