InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
PersistBaseTypes.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner: Abhishek Gulati
6 //
7 // $Author$
8 //
9 // $DateTime$
10 //
11 // $Revision$
12 //
13 // $Change$
14 //
15 // Copyright 1997-2010 Adobe Systems Incorporated. All rights reserved.
16 //
17 // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance
18 // with the terms of the Adobe license agreement accompanying it. If you have received
19 // this file from a source other than Adobe, then your use, modification, or
20 // distribution of it requires the prior written permission of Adobe.
21 //
22 //========================================================================================
23 
24 
25 #ifndef __PersistBasic__
26 #define __PersistBasic__
27 
28 #include "IPMStream.h"
29 #include "k2VectorStreaming.h"
30 #include "BaseType.h"
31 
42 namespace Persist
43 {
50  template<>
51  inline void Read<uint8>(IPMStream* stream, uint8& n)
52  {
53  ASSERT (stream && stream->IsReading());
54  K2Read (stream, n);
55  }
56 
63  template<>
64  inline void Write<uint8>(IPMStream* stream, const uint8& n)
65  {
66  ASSERT (stream && stream->IsWriting());
67  K2Write (stream, n);
68  }
69 
76  template<>
77  inline void Read<uint16>(IPMStream* stream, uint16& n)
78  {
79  ASSERT (stream && stream->IsReading());
80  K2Read (stream, n);
81  }
82 
89  template<>
90  inline void Write<uint16>(IPMStream* stream, const uint16& n)
91  {
92  ASSERT (stream && stream->IsWriting());
93  K2Write (stream, n);
94  }
95 
102  template<>
103  inline void Read<uint32>(IPMStream* stream, uint32& n)
104  {
105  ASSERT (stream && stream->IsReading());
106  K2Read (stream, n);
107  }
108 
115  template<>
116  inline void Write<uint32>(IPMStream* stream, const uint32& n)
117  {
118  ASSERT (stream && stream->IsWriting());
119  K2Write (stream, n);
120  }
121 
128  template<>
129  inline void Read<uint64>(IPMStream* stream, uint64& i)
130  {
131  ASSERT (stream && stream->IsReading());
132  int64 temp(0);
133  stream->XferInt64(temp);
134  i = temp;
135  }
136 
143  template<>
144  inline void Write<uint64>(IPMStream* stream, const uint64& i)
145  {
146  ASSERT (stream && stream->IsWriting());
147  // Copy to a non-const int64 to match XferID signature.
148  int64 iNonConst = i;
149  stream->XferInt64(iNonConst);
150  }
151 
158  template<>
159  inline void Read<int16>(IPMStream* stream, int16& i)
160  {
161  ASSERT (stream && stream->IsReading());
162  K2Read (stream, i);
163  }
164 
171  template<>
172  inline void Write<int16>(IPMStream* stream, const int16& i)
173  {
174  ASSERT (stream && stream->IsWriting());
175  K2Write (stream, i);
176  }
177 
184  template<>
185  inline void Read<int32>(IPMStream* stream, int32& i)
186  {
187  ASSERT (stream && stream->IsReading());
188  K2Read (stream, i);
189  }
190 
197  template<>
198  inline void Write<int32>(IPMStream* stream, const int32& i)
199  {
200  ASSERT (stream && stream->IsWriting());
201  K2Write (stream, i);
202  }
203 
210  template<>
211  inline void Read<int64>(IPMStream* stream, int64& i)
212  {
213  ASSERT (stream && stream->IsReading());
214  stream->XferInt64(i);
215  }
216 
223  template<>
224  inline void Write<int64>(IPMStream* stream, const int64& i)
225  {
226  ASSERT (stream && stream->IsWriting());
227  // Copy to a non-const int64 to match XferID signature.
228  int64 iNonConst = i;
229  stream->XferInt64(iNonConst);
230  }
231 
238  template<>
239  inline void Read<PMReal>(IPMStream* stream, PMReal& n)
240  {
241  ASSERT (stream && stream->IsReading());
242  K2Read (stream, n);
243  }
244 
251  template<>
252  inline void Write<PMReal>(IPMStream* stream, const PMReal& n)
253  {
254  ASSERT (stream && stream->IsWriting());
255  K2Write (stream, n);
256  }
257 
264  template<>
265  inline void Read<PMPoint>(IPMStream* stream, PMPoint& n)
266  {
267  ASSERT (stream && stream->IsReading());
268  K2Read (stream, n);
269  }
270 
277  template<>
278  inline void Write<PMPoint>(IPMStream* stream, const PMPoint& n)
279  {
280  ASSERT (stream && stream->IsWriting());
281  K2Write (stream, n);
282  }
283 
290  template<>
291  inline void Read(IPMStream* stream, PMRect& n)
292  {
293  ASSERT (stream && stream->IsReading());
294  K2Read (stream, n);
295  }
296 
303  template<>
304  inline void Write(IPMStream* stream, const PMRect& n)
305  {
306  ASSERT (stream && stream->IsWriting());
307  K2Write (stream, n);
308  }
309 
310 
314  template <typename T>
315  struct Serializer < IDType<T> >
316  {
317  inline static void Read (IPMStream* stream, IDType<T>& id)
318  {
319  stream->XferID(id);
320  }
321 
322  inline static void Write (IPMStream* stream, const IDType<T>& id)
323  {
324  // Cast constness away to to match XferID signature. This should be safe since
325  // XferID does not modify the object when the stream is being written to.
326  stream->XferID(const_cast<IDType<T>&>(id));
327  }
328  };
329 
330 
337  template<>
338  inline void Read<UTF32TextChar>(IPMStream* stream, UTF32TextChar& u)
339  {
340  ASSERT (stream && stream->IsReading());
341  u.ReadWriteUTF16(stream);
342  }
343 
350  template<>
351  inline void Write<UTF32TextChar>(IPMStream* stream, const UTF32TextChar& u)
352  {
353  ASSERT (stream && stream->IsWriting());
354  // Cast constness away to to match XferID signature. This should be safe since
355  // ReadWriteUTF16 does not modify the object when the stream is being written to.
356  UTF32TextChar& uNonConst = const_cast<UTF32TextChar&> (u);
357  uNonConst.ReadWriteUTF16(stream);
358  }
359 }
360 
361 #endif