• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 
25 namespace android {
26 
27 class Parcel;
28 
29 // Abstract interface of all parcelables.
30 class Parcelable {
31 public:
32     virtual ~Parcelable() = default;
33 
34     // Write |this| parcelable to the given |parcel|.  Keep in mind that
35     // implementations of writeToParcel must be manually kept in sync
36     // with readFromParcel and the Java equivalent versions of these methods.
37     //
38     // Returns android::OK on success and an appropriate error otherwise.
39     virtual status_t writeToParcel(Parcel* parcel) const = 0;
40 
41     // Read data from the given |parcel| into |this|.  After readFromParcel
42     // completes, |this| should have equivalent state to the object that
43     // wrote itself to the parcel.
44     //
45     // Returns android::OK on success and an appropriate error otherwise.
46     virtual status_t readFromParcel(const Parcel* parcel) = 0;
47 };  // class Parcelable
48 
49 }  // namespace android
50 
51 #endif // ANDROID_PARCELABLE_H
52