InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
PersistASLTypes.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner: Florin Trofin
6 //
7 // $Author$
8 //
9 // $DateTime$
10 //
11 // $Revision$
12 //
13 // $Change$
14 //
15 // ADOBE CONFIDENTIAL
16 //
17 // Copyright 1997-2010 Adobe Systems Incorporated. All rights reserved.
18 //
19 // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance
20 // with the terms of the Adobe license agreement accompanying it. If you have received
21 // this file from a source other than Adobe, then your use, modification, or
22 // distribution of it requires the prior written permission of Adobe.
23 //
24 // Implements persistence support for ASL (Adobe Source Library) types
25 //
26 //========================================================================================
27 
28 
29 #ifndef __PersistASLTypes__
30 #define __PersistASLTypes__
31 
32 #include "IPMStream.h"
33 #include <adobe/vector.hpp>
34 
35 namespace Persist
36 {
40  template <typename T>
41  struct Serializer < adobe::vector<T> >
42  {
43  inline static void Read (IPMStream* stream, adobe::vector<T>& v)
44  {
45  ASSERT (stream && stream->IsReading());
46 
47  v.clear();
48 
49  int32 size;
50  Persist::Read (stream, size);
51 
52  v.resize(size);
53  for (typename adobe::vector<T>::iterator i = v.begin(); i != v.end(); ++i)
54  {
55  Persist::Read(stream, *i);
56  }
57  }
58 
59  inline static void Write (IPMStream* stream, const adobe::vector<T>& v)
60  {
61  ASSERT (stream && stream->IsWriting());
62 
63  const int32 size = static_cast<int32>(v.size());
64  Persist::Write (stream, size);
65 
66  for (typename adobe::vector<T>::const_iterator i = v.begin(); i != v.end(); ++i)
67  {
68  Persist::Write(stream, *i);
69  }
70  }
71  };
72 }
73 
74 #endif //__PersistASLTypes__