blob: d5b57ac5871edbb7e7d4dac3bbd7c05fc036d350 [file] [log] [blame]
Christopher Wiley97f048d2015-11-19 06:49:05 -08001/*
2 * Copyright (C) 2015 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef ANDROID_PARCELABLE_H
18#define ANDROID_PARCELABLE_H
19
20#include <vector>
21
22#include <utils/Errors.h>
23#include <utils/String16.h>
24
25namespace android {
26
27class Parcel;
28
Colin Cross97b64db2016-09-26 13:48:02 -070029#if defined(__clang__)
30#pragma clang diagnostic push
31#pragma clang diagnostic ignored "-Wweak-vtables"
32#endif
33
Christopher Wiley97f048d2015-11-19 06:49:05 -080034// Abstract interface of all parcelables.
35class Parcelable {
36public:
37 virtual ~Parcelable() = default;
38
39 // Write |this| parcelable to the given |parcel|. Keep in mind that
40 // implementations of writeToParcel must be manually kept in sync
41 // with readFromParcel and the Java equivalent versions of these methods.
42 //
43 // Returns android::OK on success and an appropriate error otherwise.
44 virtual status_t writeToParcel(Parcel* parcel) const = 0;
45
46 // Read data from the given |parcel| into |this|. After readFromParcel
47 // completes, |this| should have equivalent state to the object that
48 // wrote itself to the parcel.
49 //
50 // Returns android::OK on success and an appropriate error otherwise.
51 virtual status_t readFromParcel(const Parcel* parcel) = 0;
52}; // class Parcelable
53
Colin Cross97b64db2016-09-26 13:48:02 -070054#if defined(__clang__)
55#pragma clang diagnostic pop
56#endif
57
Christopher Wiley97f048d2015-11-19 06:49:05 -080058} // namespace android
59
60#endif // ANDROID_PARCELABLE_H