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 // address metadata (e.g. on disk).
18 #ifndef I18N_ADDRESSINPUT_STORAGE_H_
19 #define I18N_ADDRESSINPUT_STORAGE_H_
21 #include <libaddressinput/callback.h>
26 namespace addressinput {
28 // Stores address metadata. The data must be allocated on the heap, passing
29 // ownership to the called function. Sample usage:
31 // class MyStorage : public Storage {
33 // virtual void Put(const std::string& key, std::string* data) {
38 // virtual void Get(const std::string& key,
39 // const Callback& data_ready) const {
41 // std::string* data = new ...
42 // data_ready(success, key, data);
47 typedef i18n::addressinput::Callback<const std::string&,
48 std::string*> Callback;
52 // Stores |data| for |key|, where |data| is an object allocated on the heap,
53 // which Storage takes ownership of.
54 virtual void Put(const std::string& key, std::string* data) = 0;
56 // Retrieves the data for |key| and invokes the |data_ready| callback.
57 virtual void Get(const std::string& key,
58 const Callback& data_ready) const = 0;
61 } // namespace addressinput
64 #endif // I18N_ADDRESSINPUT_STORAGE_H_