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