| OLD | NEW |
| (Empty) |
| 1 // Copyright (C) 2013 Google Inc. | |
| 2 // | |
| 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 | |
| 6 // | |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | |
| 8 // | |
| 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. | |
| 14 // | |
| 15 // A wrapper object for Storage that stores data with a checksum and a | |
| 16 // timestamp. The existence of checksum and timestamp fields is transparent to | |
| 17 // the user of the object. | |
| 18 | |
| 19 #ifndef I18N_ADDRESSINPUT_VALIDATING_STORAGE_H_ | |
| 20 #define I18N_ADDRESSINPUT_VALIDATING_STORAGE_H_ | |
| 21 | |
| 22 #include <libaddressinput/storage.h> | |
| 23 #include <libaddressinput/util/basictypes.h> | |
| 24 #include <libaddressinput/util/scoped_ptr.h> | |
| 25 | |
| 26 #include <string> | |
| 27 | |
| 28 namespace i18n { | |
| 29 namespace addressinput { | |
| 30 | |
| 31 // Wraps Storage to add checksum and timestamp to stored data. Sample usage: | |
| 32 // Storage file_storage = ...; | |
| 33 // scoped_ptr<Storage> storage(new ValidatingStorage(file_storage.Pass())); | |
| 34 // storage->Put("key", "data"); | |
| 35 // storage->Get("key", BuildCallback(this, &MyClass::OnDataReady)); | |
| 36 class ValidatingStorage : public Storage { | |
| 37 public: | |
| 38 explicit ValidatingStorage(scoped_ptr<Storage> storage); | |
| 39 virtual ~ValidatingStorage(); | |
| 40 | |
| 41 // Storage implementation. | |
| 42 virtual void Put(const std::string& key, const std::string& data); | |
| 43 virtual void Get(const std::string& key, scoped_ptr<Callback> data_ready) | |
| 44 const; | |
| 45 | |
| 46 private: | |
| 47 // The storage being wrapped. | |
| 48 scoped_ptr<Storage> wrapped_storage_; | |
| 49 | |
| 50 DISALLOW_COPY_AND_ASSIGN(ValidatingStorage); | |
| 51 }; | |
| 52 | |
| 53 } // namespace addressinput | |
| 54 } // namespace i18n | |
| 55 | |
| 56 #endif // I18N_ADDRESSINPUT_VALIDATING_STORAGE_H_ | |
| OLD | NEW |