1 // Copyright (C) 2013 Google Inc.
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 // The interface to be implemented by the user of the library to enable storing
16 // the downloaded validation rules (e.g. on disk).
18 #ifndef I18N_ADDRESSINPUT_STORAGE_H_
19 #define I18N_ADDRESSINPUT_STORAGE_H_
21 #include <libaddressinput/callback.h>
22 #include <libaddressinput/util/scoped_ptr.h>
27 namespace addressinput {
29 // Stores downloaded validation rules. Sample usage:
30 // class MyStorage : public Storage {
32 // virtual void Put(const std::string& key, const std::string& data) {
36 // virtual void Get(const std::string& key,
37 // scoped_ptr<Callback> data_ready) const {
39 // std::string data = ...
40 // (*data_ready)(success, key, data);
45 typedef i18n::addressinput::Callback<std::string, std::string> Callback;
49 // Stores |data| for |key|.
50 virtual void Put(const std::string& key, scoped_ptr<std::string> data) = 0;
52 // Retrieves the data for |key| and invokes the |data_ready| callback.
53 virtual void Get(const std::string& key,
54 scoped_ptr<Callback> data_ready) const = 0;
57 } // namespace addressinput
60 #endif // I18N_ADDRESSINPUT_STORAGE_H_