Remote Call Framework 3.3
QHash.hpp
1 
2 //******************************************************************************
3 // RCF - Remote Call Framework
4 //
5 // Copyright (c) 2005 - 2022, Delta V Software. All rights reserved.
6 // https://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 under GPL terms.
12 //
13 // Version: 3.3
14 // Contact: support <at> deltavsoft.com
15 //
16 //******************************************************************************
17 
18 #ifndef INCLUDE_SF_QHASH_HPP
19 #define INCLUDE_SF_QHASH_HPP
20 
21 #include <QHash>
22 
23 #include <SF/SerializeStl.hpp>
24 
25 namespace SF {
26 
27  // QHash
28  template<typename K, typename T>
29  inline void serialize_vc6(Archive &ar, QHash<K,T> &t, const unsigned int)
30  {
31  typedef typename QHash<K,T>::iterator Iterator;
32  typedef typename QHash<K,T>::key_type Key;
33  typedef typename QHash<K,T>::mapped_type Value;
34 
35  if (ar.isRead())
36  {
37  t.clear();
38  std::uint32_t count = 0;
39  ar & count;
40 
41  for (std::uint32_t i=0; i<count; i++)
42  {
43  Key key;
44  ar & key;
45  Value value;
46  ar & value;
47  t.insert(key, value);
48  }
49  }
50  else if (ar.isWrite())
51  {
52  std::uint32_t count = static_cast<std::uint32_t>(t.size());
53  ar & count;
54  Iterator it = t.begin();
55  for (std::uint32_t i=0; i<count; i++)
56  {
57  ar & it.key();
58  ar & it.value();
59  it++;
60  }
61  }
62  }
63 
64 }
65 
66 #endif // ! INCLUDE_SF_QHASH_HPP
Definition: ByteBuffer.hpp:188