aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cpp/include/libaddressinput/address_validator.h3
-rw-r--r--cpp/include/libaddressinput/callback.h19
-rw-r--r--cpp/include/libaddressinput/downloader.h3
-rw-r--r--cpp/include/libaddressinput/preload_supplier.h2
-rw-r--r--cpp/include/libaddressinput/storage.h3
-rw-r--r--cpp/include/libaddressinput/supplier.h3
-rw-r--r--cpp/src/retriever.h3
-rw-r--r--cpp/src/rule_retriever.h3
-rw-r--r--cpp/test/address_input_helper_test.cc4
-rw-r--r--cpp/test/address_normalizer_test.cc4
-rw-r--r--cpp/test/address_validator_test.cc2
-rw-r--r--cpp/test/preload_supplier_test.cc4
-rw-r--r--cpp/test/region_data_builder_test.cc4
-rw-r--r--cpp/test/supplier_test.cc2
14 files changed, 26 insertions, 33 deletions
diff --git a/cpp/include/libaddressinput/address_validator.h b/cpp/include/libaddressinput/address_validator.h
index bd8d4e9..d3a09f3 100644
--- a/cpp/include/libaddressinput/address_validator.h
+++ b/cpp/include/libaddressinput/address_validator.h
@@ -66,7 +66,8 @@ typedef std::multimap<AddressField, AddressProblem> FieldProblemMap;
// };
class AddressValidator {
public:
- typedef i18n::addressinput::Callback<AddressData, FieldProblemMap> Callback;
+ typedef i18n::addressinput::Callback<const AddressData&,
+ const FieldProblemMap&> Callback;
// Does not take ownership of |supplier|.
AddressValidator(Supplier* supplier);
diff --git a/cpp/include/libaddressinput/callback.h b/cpp/include/libaddressinput/callback.h
index 681c087..d8c4ea6 100644
--- a/cpp/include/libaddressinput/callback.h
+++ b/cpp/include/libaddressinput/callback.h
@@ -15,9 +15,7 @@
// An object to store a pointer to a method in an object with the following
// signature:
//
-// void Observer::ObserveEvent(bool success,
-// const Key& key,
-// const Data& data);
+// void Observer::ObserveEvent(bool success, Key key, Data data);
#ifndef I18N_ADDRESSINPUT_CALLBACK_H_
#define I18N_ADDRESSINPUT_CALLBACK_H_
@@ -31,7 +29,7 @@ namespace addressinput {
// Stores a pointer to a method in an object. Sample usage:
// class MyClass {
// public:
-// typedef Callback<MyType, MyDataType> MyCallback;
+// typedef Callback<const MyType&, const MyDataType&> MyCallback;
//
// void GetDataAsynchronously() {
// scoped_ptr<MyCallback> callback(BuildCallback(
@@ -52,10 +50,7 @@ template <typename Key, typename Data>
class Callback {
public:
virtual ~Callback() {}
-
- virtual void operator()(bool success,
- const Key& key,
- const Data& data) const = 0;
+ virtual void operator()(bool success, Key key, Data data) const = 0;
};
namespace {
@@ -63,7 +58,7 @@ namespace {
template <typename Observer, typename Key, typename Data>
class CallbackImpl : public Callback<Key, Data> {
public:
- typedef void (Observer::*ObserveEvent)(bool, const Key&, const Data&);
+ typedef void (Observer::*ObserveEvent)(bool, Key, Data);
CallbackImpl(Observer* observer, ObserveEvent observe_event)
: observer_(observer),
@@ -74,9 +69,7 @@ class CallbackImpl : public Callback<Key, Data> {
virtual ~CallbackImpl() {}
- virtual void operator()(bool success,
- const Key& key,
- const Data& data) const {
+ virtual void operator()(bool success, Key key, Data data) const {
(observer_->*observe_event_)(success, key, data);
}
@@ -92,7 +85,7 @@ class CallbackImpl : public Callback<Key, Data> {
template <typename Observer, typename Key, typename Data>
Callback<Key, Data>* BuildCallback(
Observer* observer,
- void (Observer::*observe_event)(bool, const Key&, const Data&)) {
+ void (Observer::*observe_event)(bool, Key, Data)) {
return new CallbackImpl<Observer, Key, Data>(observer, observe_event);
}
diff --git a/cpp/include/libaddressinput/downloader.h b/cpp/include/libaddressinput/downloader.h
index 6614635..175b883 100644
--- a/cpp/include/libaddressinput/downloader.h
+++ b/cpp/include/libaddressinput/downloader.h
@@ -37,7 +37,8 @@ namespace addressinput {
// };
class Downloader {
public:
- typedef i18n::addressinput::Callback<std::string, std::string> Callback;
+ typedef i18n::addressinput::Callback<const std::string&,
+ const std::string&> Callback;
virtual ~Downloader() {}
diff --git a/cpp/include/libaddressinput/preload_supplier.h b/cpp/include/libaddressinput/preload_supplier.h
index 447911f..f7654ab 100644
--- a/cpp/include/libaddressinput/preload_supplier.h
+++ b/cpp/include/libaddressinput/preload_supplier.h
@@ -48,7 +48,7 @@ class Storage;
// in total less than 2 MB of JSON data.)
class PreloadSupplier : public Supplier {
public:
- typedef i18n::addressinput::Callback<std::string, int> Callback;
+ typedef i18n::addressinput::Callback<const std::string&, int> Callback;
// Takes ownership of |downloader| and |storage|. The |validation_data_url|
// should be a URL to a service that returns address metadata aggregated per
diff --git a/cpp/include/libaddressinput/storage.h b/cpp/include/libaddressinput/storage.h
index eb06445..de05d00 100644
--- a/cpp/include/libaddressinput/storage.h
+++ b/cpp/include/libaddressinput/storage.h
@@ -41,7 +41,8 @@ namespace addressinput {
// };
class Storage {
public:
- typedef i18n::addressinput::Callback<std::string, std::string> Callback;
+ typedef i18n::addressinput::Callback<const std::string&,
+ const std::string&> Callback;
virtual ~Storage() {}
diff --git a/cpp/include/libaddressinput/supplier.h b/cpp/include/libaddressinput/supplier.h
index 8f67550..fcd64ad 100644
--- a/cpp/include/libaddressinput/supplier.h
+++ b/cpp/include/libaddressinput/supplier.h
@@ -29,7 +29,8 @@ class Rule;
class Supplier {
public:
struct RuleHierarchy;
- typedef i18n::addressinput::Callback<LookupKey, RuleHierarchy> Callback;
+ typedef i18n::addressinput::Callback<const LookupKey&,
+ const RuleHierarchy&> Callback;
virtual ~Supplier() {}
diff --git a/cpp/src/retriever.h b/cpp/src/retriever.h
index f3f7e18..17d17ec 100644
--- a/cpp/src/retriever.h
+++ b/cpp/src/retriever.h
@@ -42,7 +42,8 @@ class ValidatingStorage;
// retriever.Retrieve("data/CA/AB--fr", *retrieved);
class Retriever {
public:
- typedef i18n::addressinput::Callback<std::string, std::string> Callback;
+ typedef i18n::addressinput::Callback<const std::string&,
+ const std::string&> Callback;
// Takes ownership of |downloader| and |storage|.
Retriever(const std::string& validation_data_url,
diff --git a/cpp/src/rule_retriever.h b/cpp/src/rule_retriever.h
index a44fb63..ba3b4c7 100644
--- a/cpp/src/rule_retriever.h
+++ b/cpp/src/rule_retriever.h
@@ -37,7 +37,8 @@ class Rule;
// rules.RetrieveRule("data/CA/AB--fr", *rule_ready);
class RuleRetriever {
public:
- typedef i18n::addressinput::Callback<std::string, Rule> Callback;
+ typedef i18n::addressinput::Callback<const std::string&,
+ const Rule&> Callback;
// Takes ownership of |retriever|.
explicit RuleRetriever(const Retriever* retriever);
diff --git a/cpp/test/address_input_helper_test.cc b/cpp/test/address_input_helper_test.cc
index ebb0fa1..84a2286 100644
--- a/cpp/test/address_input_helper_test.cc
+++ b/cpp/test/address_input_helper_test.cc
@@ -65,7 +65,7 @@ class AddressInputHelperTest : public testing::Test {
private:
// Used to preload data that we need.
- void Loaded(bool success, const std::string&, const int&) {
+ void Loaded(bool success, const std::string&, int) {
ASSERT_TRUE(success);
}
@@ -271,7 +271,7 @@ class AddressInputHelperMockDataTest : public testing::Test {
private:
// Our mock downloader we assume will always succeed.
- void Loaded(bool success, const std::string&, const int&) {
+ void Loaded(bool success, const std::string&, int) {
ASSERT_TRUE(success);
}
diff --git a/cpp/test/address_normalizer_test.cc b/cpp/test/address_normalizer_test.cc
index d859250..6f2d9f4 100644
--- a/cpp/test/address_normalizer_test.cc
+++ b/cpp/test/address_normalizer_test.cc
@@ -51,9 +51,7 @@ class AddressNormalizerTest : public testing::Test {
const AddressNormalizer normalizer_;
private:
- void OnLoaded(bool success,
- const std::string& region_code,
- const int& num_rules) {
+ void OnLoaded(bool success, const std::string& region_code, int num_rules) {
ASSERT_TRUE(success);
ASSERT_FALSE(region_code.empty());
ASSERT_LT(0, num_rules);
diff --git a/cpp/test/address_validator_test.cc b/cpp/test/address_validator_test.cc
index 20ede92..5250502 100644
--- a/cpp/test/address_validator_test.cc
+++ b/cpp/test/address_validator_test.cc
@@ -131,7 +131,7 @@ class PreloadValidatorWrapper : public ValidatorWrapper {
validator_(&supplier_),
loaded_(BuildCallback(this, &PreloadValidatorWrapper::Loaded)) {}
- void Loaded(bool success, const std::string&, const int&) {
+ void Loaded(bool success, const std::string&, int) {
ASSERT_TRUE(success);
}
diff --git a/cpp/test/preload_supplier_test.cc b/cpp/test/preload_supplier_test.cc
index b812ef1..ab787d8 100644
--- a/cpp/test/preload_supplier_test.cc
+++ b/cpp/test/preload_supplier_test.cc
@@ -54,9 +54,7 @@ class PreloadSupplierTest : public testing::Test {
scoped_ptr<PreloadSupplier::Callback> loaded_callback_;
private:
- void OnLoaded(bool success,
- const std::string& region_code,
- const int& num_rules) {
+ void OnLoaded(bool success, const std::string& region_code, int num_rules) {
ASSERT_TRUE(success);
ASSERT_FALSE(region_code.empty());
ASSERT_LT(0, num_rules);
diff --git a/cpp/test/region_data_builder_test.cc b/cpp/test/region_data_builder_test.cc
index 8856630..03b0981 100644
--- a/cpp/test/region_data_builder_test.cc
+++ b/cpp/test/region_data_builder_test.cc
@@ -55,9 +55,7 @@ class RegionDataBuilderTest : public testing::Test {
std::string best_language_;
private:
- void OnLoaded(bool success,
- const std::string& region_code,
- const int& num_rules) {
+ void OnLoaded(bool success, const std::string& region_code, int num_rules) {
ASSERT_TRUE(success);
ASSERT_FALSE(region_code.empty());
ASSERT_LT(0, num_rules);
diff --git a/cpp/test/supplier_test.cc b/cpp/test/supplier_test.cc
index 22a8f7b..13913c3 100644
--- a/cpp/test/supplier_test.cc
+++ b/cpp/test/supplier_test.cc
@@ -116,7 +116,7 @@ class PreloadSupplierWrapper : public SupplierWrapper {
new NullStorage),
loaded_(BuildCallback(this, &PreloadSupplierWrapper::Loaded)) {}
- void Loaded(bool success, const std::string&, const int&) {
+ void Loaded(bool success, const std::string&, int) {
ASSERT_TRUE(success);
}