Remote Call Framework 3.2
QHash.hpp
1 
2 //******************************************************************************
3 // RCF - Remote Call Framework
4 //
5 // Copyright (c) 2005 - 2020, Delta V Software. All rights reserved.
6 // http://www.deltavsoft.com
7 //
8 // RCF is distributed under dual licenses - closed source or GPL.
9 // Consult your particular license for conditions of use.
10 //
11 // If you have not purchased a commercial license, you are using RCF
12 // under GPL terms.
13 //
14 // Version: 3.2
15 // Contact: support <at> deltavsoft.com
16 //
17 //******************************************************************************
18 
19 #ifndef INCLUDE_SF_QHASH_HPP
20 #define INCLUDE_SF_QHASH_HPP
21 
22 #include <QHash>
23 
24 #include <SF/SerializeStl.hpp>
25 
26 namespace SF {
27 
28  // QHash
29  template<typename K, typename T>
30  inline void serialize_vc6(Archive &ar, QHash<K,T> &t, const unsigned int)
31  {
32  typedef typename QHash<K,T>::iterator Iterator;
33  typedef typename QHash<K,T>::key_type Key;
34  typedef typename QHash<K,T>::mapped_type Value;
35 
36  if (ar.isRead())
37  {
38  t.clear();
39  std::uint32_t count = 0;
40  ar & count;
41 
42  for (std::uint32_t i=0; i<count; i++)
43  {
44  Key key;
45  ar & key;
46  Value value;
47  ar & value;
48  t.insert(key, value);
49  }
50  }
51  else if (ar.isWrite())
52  {
53  std::uint32_t count = static_cast<std::uint32_t>(t.size());
54  ar & count;
55  Iterator it = t.begin();
56  for (std::uint32_t i=0; i<count; i++)
57  {
58  ar & it.key();
59  ar & it.value();
60  it++;
61  }
62  }
63  }
64 
65 }
66 
67 #endif // ! INCLUDE_SF_QHASH_HPP
Definition: ByteBuffer.hpp:189