Add Parcel Library
[platform/core/base/bundle.git] / parcel / parcel_implementation.hh
1 /*
2  * Copyright (c) 2020 Samsung Electronics Co., Ltd. All rights reserved.
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 PARCEL_PARCEL_IMPLEMENTATION_HH_
18 #define PARCEL_PARCEL_IMPLEMENTATION_HH_
19
20 #include <string>
21 #include <vector>
22
23 #include "parcel/parcel.hh"
24 #include "parcel/parcelable.hh"
25
26 namespace tizen_base {
27
28 class Parcel::Impl {
29  public:
30   virtual ~Impl();
31
32   void Write(const void* buf, uint32_t size);
33   int Read(void* buf, uint32_t size);
34   const std::vector<uint8_t>& GetRaw();
35   void ResetReader();
36   void Clear();
37   void Reset(const void* buf, uint32_t size);
38   bool IsEmpty();
39   void WriteSize(uint32_t size);
40   int ReadSize(uint32_t* size);
41
42   template <typename T>
43   void Write(T d);
44   template <typename T>
45   int Read(T* d);
46
47  private:
48   friend class Parcel;
49   explicit Impl(Parcel* parent);
50
51  private:
52   Parcel* parent_;
53   std::vector<uint8_t> data_;
54   uint64_t reader_ = 0;
55 };
56
57 }  // naemspace tizen_base
58
59 #endif  // PARCEL_PARCEL_IMPLEMENTATION_HH_