kv_store_inl.h
Upload User: zhongxx05
Upload Date: 2007-06-06
Package Size: 33641k
Code Size: 3k
Category:

Symbian

Development Platform:

C/C++

  1. /* ***** BEGIN LICENSE BLOCK ***** 
  2.  * Version: RCSL 1.0/RPSL 1.0 
  3.  *  
  4.  * Portions Copyright (c) 1995-2002 RealNetworks, Inc. All Rights Reserved. 
  5.  *      
  6.  * The contents of this file, and the files included with this file, are 
  7.  * subject to the current version of the RealNetworks Public Source License 
  8.  * Version 1.0 (the "RPSL") available at 
  9.  * http://www.helixcommunity.org/content/rpsl unless you have licensed 
  10.  * the file under the RealNetworks Community Source License Version 1.0 
  11.  * (the "RCSL") available at http://www.helixcommunity.org/content/rcsl, 
  12.  * in which case the RCSL will apply. You may also obtain the license terms 
  13.  * directly from RealNetworks.  You may not use this file except in 
  14.  * compliance with the RPSL or, if you have a valid RCSL with RealNetworks 
  15.  * applicable to this file, the RCSL.  Please see the applicable RPSL or 
  16.  * RCSL for the rights, obligations and limitations governing use of the 
  17.  * contents of the file.  
  18.  *  
  19.  * This file is part of the Helix DNA Technology. RealNetworks is the 
  20.  * developer of the Original Code and owns the copyrights in the portions 
  21.  * it created. 
  22.  *  
  23.  * This file, and the files included with this file, is distributed and made 
  24.  * available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 
  25.  * EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL SUCH WARRANTIES, 
  26.  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS 
  27.  * FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 
  28.  * 
  29.  * Technology Compatibility Kit Test Suite(s) Location: 
  30.  *    http://www.helixcommunity.org/content/tck 
  31.  * 
  32.  * Contributor(s): 
  33.  *  
  34.  * ***** END LICENSE BLOCK ***** */ 
  35. #ifndef KV_STORE_I
  36. #define KV_STORE_I
  37. template <class K, class V>
  38. inline
  39. KeyValueStore<K,V>::KeyValueStore()
  40. {}
  41. template <class K, class V>
  42. inline
  43. KeyValueStore<K,V>::~KeyValueStore()
  44. {
  45.     Clear();
  46. }
  47. template <class K, class V>
  48. inline
  49. int KeyValueStore<K,V>::GetCount() const
  50. {
  51.     return m_array.GetSize();
  52. }
  53. template <class K, class V>
  54. inline
  55. void KeyValueStore<K,V>::Clear()
  56. {}
  57. template <class K, class V>
  58. inline
  59. void KeyValueStore<K,V>::Create(int index)
  60. {
  61.     m_array.SetAtGrow(index, KeyValuePair<K, V>());
  62. /*
  63.     const KeyValuePair<K, V>& kvPair = m_array[index];
  64.     char* pKeyStr = ClassOps<K>().Print(kvPair.Key());
  65.     char* pValueStr = ClassOps<V>().Print(kvPair.Value());
  66.     DPRINTF (D_ERROR,("KeyValueStore<K,V>::Create(%d) : '%s' = '%s'n",
  67.                       index,
  68.                       pKeyStr,
  69.                       pValueStr));
  70.     delete [] pKeyStr;
  71.     delete [] pValueStr;
  72. */
  73. }
  74. template <class K, class V>
  75. inline
  76. bool KeyValueStore<K,V>::IsSet(int index) const
  77. {
  78.     bool ret = false;
  79.     if (m_array.IsSet(index))
  80. ret = true;
  81.     
  82.     return ret;
  83. }
  84. template <class K, class V>
  85. inline
  86. const K& KeyValueStore<K,V>::GetKey(int index) const
  87. {
  88.     return m_array.GetAt(index).Key();
  89. }
  90. template <class K, class V>
  91. inline
  92. const V& KeyValueStore<K,V>::GetValue(int index) const
  93. {
  94.     return m_array.GetAt(index).Value();
  95. }
  96. template <class K, class V>
  97. inline
  98. void KeyValueStore<K,V>::Print() const
  99. {
  100.     DPRINTF (D_ERROR, ("KeyValueStore<K,V>::Print()n"));
  101.     for (int i = 0; i < m_array.GetSize(); i++)
  102.     {
  103. if (m_array.IsSet(i))
  104.             m_array.GetAt(i).Print();
  105. else
  106.     DPRINTF (D_ERROR, ("KeyValueStore<K,V>::Print() : %d is emptyn",
  107.        i));
  108.     }
  109. }
  110. #endif // KV_STORE_I