Remote Call Framework 3.3
SerializeStaticArray.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_SERIALIZESTATICARRAY_HPP
19 #define INCLUDE_SF_SERIALIZESTATICARRAY_HPP
20 
21 #include <SF/Archive.hpp>
22 
23 namespace SF {
24 
25  // serialize C-style static arrays
26 
27  template<typename T, unsigned int N>
28  inline void serializeFundamentalStaticArray(
29  Archive & ar,
30  T (*pt)[N])
31  {
32  serializeFundamental(ar, (*pt)[0], N);
33  }
34 
35  template<typename T, unsigned int N>
36  inline void serializeNonfundamentalStaticArray(
37  Archive & ar,
38  T (*pt)[N])
39  {
40  for (unsigned int i=0; i<N; i++)
41  ar & (*pt)[i];
42  }
43 
44 
45  template<bool IsFundamental>
46  class SerializeStaticArray;
47 
48  template<>
49  class SerializeStaticArray<true>
50  {
51  public:
52  template<typename T, unsigned int N>
53  void operator()(Archive &ar, T (*pt)[N])
54  {
55  serializeFundamentalStaticArray(ar, pt);
56  }
57  };
58 
59  template<>
60  class SerializeStaticArray<false>
61  {
62  public:
63  template<typename T, unsigned int N>
64  void operator()(Archive &ar, T (*pt)[N])
65  {
66  serializeNonfundamentalStaticArray(ar, pt);
67  }
68  };
69 
70 
71  template<typename T, unsigned int N>
72  inline void preserialize(SF::Archive &ar, T (*pt)[N], const unsigned int)
73  {
74  static const bool IsFundamental = RCF::IsFundamental<T>::value;
75  SerializeStaticArray<IsFundamental>()(ar, pt);
76  }
77 
78 } // namespace SF
79 
80 #endif // ! INCLUDE_SF_SERIALIZESTATICARRAY_HPP
Represents an archive, in which serialized objects are stored.
Definition: Archive.hpp:31
Definition: ByteBuffer.hpp:188