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
16 // downloading validation rules from a server.
18 #ifndef I18N_ADDRESSINPUT_DOWNLOADER_H_
19 #define I18N_ADDRESSINPUT_DOWNLOADER_H_
21 #include <libaddressinput/callback.h>
26 namespace addressinput {
28 // Downloads validation rules from the server. The downloaded data must be
29 // allocated on the heap, passing ownership to the callback. Sample usage:
31 // class MyDownloader : public Downloader {
33 // virtual void Download(const std::string& url,
34 // const Callback& downloaded) const {
36 // std::string* data = new ...
37 // downloaded(success, url, data);
42 typedef i18n::addressinput::Callback<const std::string&,
43 std::string*> Callback;
45 virtual ~Downloader() {}
47 // Downloads |url| and invokes the |downloaded| callback.
48 virtual void Download(const std::string& url,
49 const Callback& downloaded) const = 0;
52 } // namespace addressinput
55 #endif // I18N_ADDRESSINPUT_DOWNLOADER_H_