From c241fac38e8c926d44ce4aa775c5fd2e50d62429 Mon Sep 17 00:00:00 2001 From: Sunwook Bae Date: Wed, 28 Aug 2013 19:01:31 +0900 Subject: [PATCH] Add to support a _StringMap type in internal IPC Change-Id: Id0c42b6e9014562e373ed0c2d406a2292b75d6a4 Signed-off-by: Sunwook Bae --- src/io/inc/FIo_IpcCommonDataTypes.h | 47 +++++++++++++++++++++++++++ src/io/inc/FIo_IpcCommonParamTraits.h | 61 +++++++++++++++++++++++++++++++++++ 2 files changed, 108 insertions(+) diff --git a/src/io/inc/FIo_IpcCommonDataTypes.h b/src/io/inc/FIo_IpcCommonDataTypes.h index e1ace79..ecc3581 100644 --- a/src/io/inc/FIo_IpcCommonDataTypes.h +++ b/src/io/inc/FIo_IpcCommonDataTypes.h @@ -22,6 +22,11 @@ #ifndef _FIO_INTERNAL_IPC_COMMON_DATA_TYPES_H #define _FIO_INTERNAL_IPC_COMMON_DATA_TYPES_H +#include +#include +#include +#include + namespace Tizen { namespace Io { @@ -31,6 +36,48 @@ typedef struct void* pBuffer; }_IpcBuffer; +static const Tizen::Base::ComparerT comparer; +static const Tizen::Base::StringHashCodeProvider provider; + +class _StringMap +{ +public: + _StringMap(void) + { + __map.Construct(0, 0, provider, comparer); + } + + ~_StringMap(void) {} + + int GetCount(void) const + { + return __map.GetCount(); + } + + result Add(const Tizen::Base::String& key, const Tizen::Base::String& value) + { + return __map.Add(key, value); + } + + result GetValue(const Tizen::Base::String& key, Tizen::Base::String& value) + { + return __map.GetValue(key, value); + } + + result GetValue(const Tizen::Base::String& key, Tizen::Base::String& value) const + { + return __map.GetValue(key, value); + } + + Tizen::Base::Collection::IMapEnumeratorT* GetMapEnumeratorN(void) const + { + return __map.GetMapEnumeratorN(); + } + +private: + Tizen::Base::Collection::HashMapT __map; +}; + } } // Tizen::Io #endif // _FIO_INTERNAL_CLIENT_CHANNEL_H_ diff --git a/src/io/inc/FIo_IpcCommonParamTraits.h b/src/io/inc/FIo_IpcCommonParamTraits.h index babed4e..070fdaa 100644 --- a/src/io/inc/FIo_IpcCommonParamTraits.h +++ b/src/io/inc/FIo_IpcCommonParamTraits.h @@ -344,6 +344,67 @@ struct ParamTraits }; template<> +struct ParamTraits +{ + typedef Tizen::Io::_StringMap param_type; + + static void Write(Message* m, const param_type& p) + { + int count = p.GetCount(); + Tizen::Base::String key; + Tizen::Base::String value; + + WriteParam(m, count); + + Tizen::Base::Collection::IMapEnumeratorT* pEnum = p.GetMapEnumeratorN(); + + while (pEnum->MoveNext() == E_SUCCESS) + { + pEnum->GetKey(key); + WriteParam(m, key); + + pEnum->GetValue(value); + WriteParam(m, value); + } + + delete pEnum; + } + + static bool Read(const Message* m, void** iter, param_type* r) + { + int count = 0; + Tizen::Base::String key; + Tizen::Base::String value; + + if (!m->ReadLength(iter, &count)) + { + return false; + } + + for (int i = 0; i < count; i++) + { + if (!ReadParam(m, iter, &key)) + { + return false; + } + + if (!ReadParam(m, iter, &value)) + { + return false; + } + + r->Add(key, value); + } + + return true; + } + + static void Log(const param_type& p, std::string* l) + { + } +}; + +template<> struct ParamTraits { typedef Tizen::Io::_IpcBuffer param_type; -- 2.7.4