InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
UIDListInternal.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner: Robin_Briggs
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 #ifndef __UIDLISTINTERNAL__
25 #define __UIDLISTINTERNAL__
26 
27 class IDataBase;
28 class SortedUIDList;
29 
30 const int32 kUIDDefaultChunkSize = 8;
31 
36 {
37  friend class SortedUIDList;
38  friend class UIDList;
39 
40 #if defined(DEBUG) && defined(MACINTOSH)
41 
42  friend void GetUIDListDescriptionHelper(void* uidListInternalArg, char* buffer, uint32 bufferSize);
43 
44 #endif
45 
46 private:
48  UIDListInternal(IDataBase *db) :fRefCount(1), fArray(), fDB(db)
49  { fArray.reserve(kUIDDefaultChunkSize); }
50 
52  UIDListInternal(const UIDListInternal& copy) :fRefCount(1), fArray(copy.fArray), fDB(copy.fDB)
53  {;}
55  UIDListInternal(IDataBase *db, const UID singleEntry) : fRefCount(1), fArray(), fDB(db)
56  { fArray.push_back(singleEntry); ;}
58  UIDListInternal(const IPMUnknown *obj) : fRefCount(1), fArray(), fDB(::GetDataBase(obj))
59  { fArray.push_back(::GetUID(obj)); ;}
61  UIDListInternal(const UIDRef& obj) : fRefCount(1), fArray(), fDB(obj.GetDataBase())
62  { fArray.push_back(obj.GetUID()); ;}
63 public:
65  void AddRef() { fRefCount++; }
66 
68  void Release();
69 
72  {;}
73 
74 private:
75  // Types
76  typedef K2Vector<UID> UIDArray;
77  typedef UIDArray::value_type value_type;
78  typedef UIDArray::size_type size_type;
79  typedef UIDArray::const_reference const_reference;
80  typedef UIDArray::reference reference;
81  typedef UIDArray::difference_type difference_type;
82  typedef UIDArray::pointer pointer;
83  typedef UIDArray::const_pointer const_pointer;
84 
89  { fArray = other.fArray; fDB = other.fDB; return *this; }
94  bool16 operator==(const UIDListInternal& other) const
95  { return fArray == other.fArray; }
100  bool16 operator!=(const UIDListInternal& other) const
101  { return fArray != other.fArray; }
102 
107  const_reference operator[](int32 i) const
108  { return fArray[i]; }
109 
114  reference operator[](int32 i)
115  { return (fArray[i]); }
116 
120  void SetChunkSize(int32 chunk)
121  { fArray.reserve(chunk); }
122 
127  bool16 Preallocate(int32 newlen)
128  { fArray.reserve(newlen); return kTrue; }
129 
131  void Clear()
132  { fArray.clear(); }
133 
137  void Insert(const UID t)
138  { fArray.insert(fArray.begin(),t); }
139 
144  void Insert(const UID t, int32 before)
145  { fArray.insert(fArray.begin() + before, t); }
146 
151  void Insert(const UIDListInternal& list, int32 before);
152 
156  void Append(const UID t)
157  { fArray.push_back(t); }
158 
163  void Append(const UID t, int32 after)
164  { fArray.insert(fArray.begin() + after + 1, t); }
165 
169  void Append(const UIDListInternal& list);
170 
174  void Remove(int32 at)
175  { fArray.erase(fArray.begin() + at); }
176 
181  void Replace(int32 at, const UID t)
182  { fArray[at] = t; }
183 
185  int32 ChunkSize() const
186  { return 8; } //AW_TODO: Possibly deprecate this?
187 
189  int32 Length() const
190  { return fArray.size(); }
191 
193  bool16 IsEmpty() const
194  { return fArray.empty(); }
195 
197  const_reference First() const
198  { return fArray.front(); }
199 
201  reference First()
202  { return fArray.front(); }
203 
205  const_reference Last() const
206  { return fArray.back(); }
207 
209  reference Last()
210  { return fArray.back(); }
211 
216  int32 Location(UID t) const
217  {
218  UIDArray::const_iterator iter = K2find(fArray, t);
219  return (iter != fArray.end() ? iter - fArray.begin() : -1);
220  }
221 
223  IDataBase *GetDataBase() const { return fDB; }
224 
229  UIDRef GetRef(int32 at) const
230  { return UIDRef(fDB, fArray[at]); }
231 
233  int32 GetReferenceCount() { return fRefCount;}
234 
235  // Data
236  int32 fRefCount;
237  UIDArray fArray;
238  IDataBase *fDB;
239 };
240 
241 #if defined(DEBUG) && defined(MACINTOSH)
242 void GetUIDListDescriptionHelper(void* uidListInternalArg, char* buffer, uint32 bufferSize);
243 #endif
244 
245 #endif // __UIDLISTINTERNAL__