197f048d19e51da4ea6ff98d8a9daf38f2577f182Christopher Wiley/* 297f048d19e51da4ea6ff98d8a9daf38f2577f182Christopher Wiley * Copyright (C) 2015 The Android Open Source Project 397f048d19e51da4ea6ff98d8a9daf38f2577f182Christopher Wiley * 497f048d19e51da4ea6ff98d8a9daf38f2577f182Christopher Wiley * Licensed under the Apache License, Version 2.0 (the "License"); 597f048d19e51da4ea6ff98d8a9daf38f2577f182Christopher Wiley * you may not use this file except in compliance with the License. 697f048d19e51da4ea6ff98d8a9daf38f2577f182Christopher Wiley * You may obtain a copy of the License at 797f048d19e51da4ea6ff98d8a9daf38f2577f182Christopher Wiley * 897f048d19e51da4ea6ff98d8a9daf38f2577f182Christopher Wiley * http://www.apache.org/licenses/LICENSE-2.0 997f048d19e51da4ea6ff98d8a9daf38f2577f182Christopher Wiley * 1097f048d19e51da4ea6ff98d8a9daf38f2577f182Christopher Wiley * Unless required by applicable law or agreed to in writing, software 1197f048d19e51da4ea6ff98d8a9daf38f2577f182Christopher Wiley * distributed under the License is distributed on an "AS IS" BASIS, 1297f048d19e51da4ea6ff98d8a9daf38f2577f182Christopher Wiley * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1397f048d19e51da4ea6ff98d8a9daf38f2577f182Christopher Wiley * See the License for the specific language governing permissions and 1497f048d19e51da4ea6ff98d8a9daf38f2577f182Christopher Wiley * limitations under the License. 1597f048d19e51da4ea6ff98d8a9daf38f2577f182Christopher Wiley */ 1697f048d19e51da4ea6ff98d8a9daf38f2577f182Christopher Wiley 1797f048d19e51da4ea6ff98d8a9daf38f2577f182Christopher Wiley#ifndef ANDROID_PARCELABLE_H 1897f048d19e51da4ea6ff98d8a9daf38f2577f182Christopher Wiley#define ANDROID_PARCELABLE_H 1997f048d19e51da4ea6ff98d8a9daf38f2577f182Christopher Wiley 2097f048d19e51da4ea6ff98d8a9daf38f2577f182Christopher Wiley#include <vector> 2197f048d19e51da4ea6ff98d8a9daf38f2577f182Christopher Wiley 2297f048d19e51da4ea6ff98d8a9daf38f2577f182Christopher Wiley#include <utils/Errors.h> 2397f048d19e51da4ea6ff98d8a9daf38f2577f182Christopher Wiley#include <utils/String16.h> 2497f048d19e51da4ea6ff98d8a9daf38f2577f182Christopher Wiley 2597f048d19e51da4ea6ff98d8a9daf38f2577f182Christopher Wileynamespace android { 2697f048d19e51da4ea6ff98d8a9daf38f2577f182Christopher Wiley 2797f048d19e51da4ea6ff98d8a9daf38f2577f182Christopher Wileyclass Parcel; 2897f048d19e51da4ea6ff98d8a9daf38f2577f182Christopher Wiley 2997b64dbe717b7daf29962f44c1b621c633473556Colin Cross#if defined(__clang__) 3097b64dbe717b7daf29962f44c1b621c633473556Colin Cross#pragma clang diagnostic push 3197b64dbe717b7daf29962f44c1b621c633473556Colin Cross#pragma clang diagnostic ignored "-Wweak-vtables" 3297b64dbe717b7daf29962f44c1b621c633473556Colin Cross#endif 3397b64dbe717b7daf29962f44c1b621c633473556Colin Cross 3497f048d19e51da4ea6ff98d8a9daf38f2577f182Christopher Wiley// Abstract interface of all parcelables. 3597f048d19e51da4ea6ff98d8a9daf38f2577f182Christopher Wileyclass Parcelable { 3697f048d19e51da4ea6ff98d8a9daf38f2577f182Christopher Wileypublic: 3797f048d19e51da4ea6ff98d8a9daf38f2577f182Christopher Wiley virtual ~Parcelable() = default; 3897f048d19e51da4ea6ff98d8a9daf38f2577f182Christopher Wiley 39b5619e8c46bcb06aa42a30b7487cd36d4107432dYi Kong Parcelable() = default; 40b5619e8c46bcb06aa42a30b7487cd36d4107432dYi Kong Parcelable(const Parcelable&) = default; 41b5619e8c46bcb06aa42a30b7487cd36d4107432dYi Kong 4297f048d19e51da4ea6ff98d8a9daf38f2577f182Christopher Wiley // Write |this| parcelable to the given |parcel|. Keep in mind that 4397f048d19e51da4ea6ff98d8a9daf38f2577f182Christopher Wiley // implementations of writeToParcel must be manually kept in sync 4497f048d19e51da4ea6ff98d8a9daf38f2577f182Christopher Wiley // with readFromParcel and the Java equivalent versions of these methods. 4597f048d19e51da4ea6ff98d8a9daf38f2577f182Christopher Wiley // 4697f048d19e51da4ea6ff98d8a9daf38f2577f182Christopher Wiley // Returns android::OK on success and an appropriate error otherwise. 4797f048d19e51da4ea6ff98d8a9daf38f2577f182Christopher Wiley virtual status_t writeToParcel(Parcel* parcel) const = 0; 4897f048d19e51da4ea6ff98d8a9daf38f2577f182Christopher Wiley 4997f048d19e51da4ea6ff98d8a9daf38f2577f182Christopher Wiley // Read data from the given |parcel| into |this|. After readFromParcel 5097f048d19e51da4ea6ff98d8a9daf38f2577f182Christopher Wiley // completes, |this| should have equivalent state to the object that 5197f048d19e51da4ea6ff98d8a9daf38f2577f182Christopher Wiley // wrote itself to the parcel. 5297f048d19e51da4ea6ff98d8a9daf38f2577f182Christopher Wiley // 5397f048d19e51da4ea6ff98d8a9daf38f2577f182Christopher Wiley // Returns android::OK on success and an appropriate error otherwise. 5497f048d19e51da4ea6ff98d8a9daf38f2577f182Christopher Wiley virtual status_t readFromParcel(const Parcel* parcel) = 0; 5597f048d19e51da4ea6ff98d8a9daf38f2577f182Christopher Wiley}; // class Parcelable 5697f048d19e51da4ea6ff98d8a9daf38f2577f182Christopher Wiley 5797b64dbe717b7daf29962f44c1b621c633473556Colin Cross#if defined(__clang__) 5897b64dbe717b7daf29962f44c1b621c633473556Colin Cross#pragma clang diagnostic pop 5997b64dbe717b7daf29962f44c1b621c633473556Colin Cross#endif 6097b64dbe717b7daf29962f44c1b621c633473556Colin Cross 6197f048d19e51da4ea6ff98d8a9daf38f2577f182Christopher Wiley} // namespace android 6297f048d19e51da4ea6ff98d8a9daf38f2577f182Christopher Wiley 6397f048d19e51da4ea6ff98d8a9daf38f2577f182Christopher Wiley#endif // ANDROID_PARCELABLE_H 64