2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file message-port-param-traits.h
20 * @brief This is the header file for message port param traits for IPC.
23 #ifndef _APPFW_MESSAGE_PORT_PARAM_TRAITS_H_
24 #define _APPFW_MESSAGE_PORT_PARAM_TRAITS_H_
27 #include <base/tuple.h>
28 #include <ipc/ipc_param_traits.h>
32 #include "message-port-data-types.h"
38 struct ParamTraits <BundleBuffer>
40 typedef BundleBuffer param_type;
42 static void Write(Message* m, const param_type& p)
45 bundle_raw* raw = NULL;
46 bundle_encode_raw(p.b, &raw, &len);
50 m->WriteBytes((const void*) raw, len);
54 bundle_free_encoded_rawdata(&raw);
57 static bool Read(const Message* m, void** iter, param_type* r)
60 const char* pBuffer = NULL;
62 if (!m->ReadLength(iter, &len))
67 if (!m->ReadBytes(iter, &pBuffer, len))
72 if (!m->ReadLength(iter, &len))
80 ((char*)pBuffer)[len] = '\0';
87 r->b = bundle_decode_raw((const bundle_raw*)pBuffer, len);
92 static void Log(const param_type& p, std::string* l)
99 #endif //_APPFW_MESSAGE_PORT_PARAM_TRAITS_H_