中间件底层,websocket

QMap.hpp 1.6KB

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