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 // A fake storage object to use in tests. Stores data in memory instead of
16 // writing it to disk. All operations are synchronous.
18 #ifndef I18N_ADDRESSINPUT_FAKE_STORAGE_H_
19 #define I18N_ADDRESSINPUT_FAKE_STORAGE_H_
21 #include <libaddressinput/storage.h>
27 namespace addressinput {
29 // Stores data in memory. Sample usage:
37 // storage_.Put("key", "value");
41 // storage_.Get("key", BuildCallback(this, &Myclass:OnDataReady));
45 // void OnDataReady(bool success,
46 // const std::string& key,
47 // const std::string& data) {
51 // FakeStorage storage_;
53 // DISALLOW_COPY_AND_ASSIGN(MyClass);
55 class FakeStorage : public Storage {
58 virtual ~FakeStorage();
60 // Storage implementation.
61 virtual void Put(const std::string& key, const std::string& data);
62 virtual void Get(const std::string& key, scoped_ptr<Callback> data_ready)
66 std::map<std::string, std::string> data_;
69 } // namespace addressinput
72 #endif // I18N_ADDRESSINPUT_FAKE_STORAGE_H_