InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
IDFile.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner: Michael Easter
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 // Description:
24 // This class is a wrapper around the AFile class which provides InDesign specific
25 // implementations and extensions to the AFile class.
26 //
27 //========================================================================================
28 
29 #ifndef __IDFile__
30 #define __IDFile__
31 
32 // ----- Includes -----
33 #include "AFile.h"
34 #include "IDPath.h"
35 #include "PMString.h"
36 #include "WideString.h"
37 #include "IDThreading.h"
38 
39 class IPMStream;
40 
41 using namespace adobe::afl;
42 
47 class IDFile : public AFile
48 {
49 public:
50  typedef AFile inherited;
51  typedef object_type data_type;
52 
57  IDFile();
58 
64  IDFile(const APath& path);
65 
71  IDFile(const IDPath& path);
72 
80  IDFile(const AString& pathStr);
81 
89  explicit IDFile(const WideString& pathStr);
90 
96  IDFile(const AFile& file);
97 
103  IDFile(const IDFile& file);
104 
109  virtual ~IDFile();
110 
116  friend void swap(IDFile &a, IDFile &b) noexcept;
117 
124  IDFile& operator=(const IDFile& rhs);
125 
126  IDFile(IDFile&& rhs) noexcept
127  : AFile(std::move(rhs))
128 #ifdef DEBUG
129  , fDebugPath(std::move(rhs.fDebugPath))
130 #endif
131 #ifdef WINDOWS
132  , fTmpPathStr(std::move(rhs.fTmpPathStr))
133 #endif
134  {
135 #ifdef DEBUG
136  rhs.fDebugPath = 0;
137 #endif
138  }
139 
140  IDFile& operator=(IDFile&& rhs) noexcept;
141 
148  IDFile& operator=(const AFile& rhs);
149 
156  bool operator==(const IDFile& rhs) const;
157 
164  bool operator!=(const IDFile& rhs) const;
165 
171  void SetPath(const IDPath& path);
172 
180  void SetPath(const WideString& pathStr);
181 
188  bool IsStationary() const;
189 
195  bool SetStationary(bool bStationary);
196 
202  void ReadWrite(IPMStream* s);
203 
204 
205  //====================================================================================
206  //
207  // DEPRECATED Methods
208  //
209  // The following deprecated methods are provided to aid in the integration of the
210  // new file library (AFL) architecture into InDesign. New code should avoid using
211  // the following methods.
212  //
213  //====================================================================================
214 
222  explicit IDFile(const PMString& pathStr);
223 
230  PMString GetFileName() const;
231 
239  bool16 SetFileName(const PMString& nameStr);
240 
241 #ifdef WINDOWS
242 
244 
256  void ReadWriteDeprecated(IPMStream* iPMStream);
257 
263  void SetString(const PMString& str);
264 
270  void SetCString(ConstCString cStr);
271 
277  void SetTString(const TCHAR* xStr);
278 
286  void SetXString(const char* xStr, int32 nBytes);
287 
295  void SetXString(const UTF16TextChar* xStr, int32 nDblBytes);
296 
301  PMString GetString() const;
302 
307  TCHAR* GrabTString();
308 
313  const TCHAR* GrabTString() const;
314 
319  const UTF16TextChar* GrabWString() const;
320 
322 #elif defined MACINTOSH
323 
328  uint32 GetParId() const;
329 
335  uint32 GetNodeId() const;
337 #elif defined WASM
338 
343  void SetString(const PMString& str);
344 
349  PMString GetString() const;
350 
351 #endif
352 
353 private:
354 #ifdef DEBUG
355 
359  void PathChanged(const AString& path);
360 
368 #ifdef WINDOWS
369  wchar_t* fDebugPath;
370 #elif defined MACINTOSH
371  char* fDebugPath;
372 #elif WASM
373  char* fDebugPath;
374 #endif
375 #endif
376 
377 #ifdef WINDOWS
378 
384  PMString fTmpPathStr;
385  mutable IDThreading::spin_mutex fTmpPathStrMutex;
386 #endif
387 };
388 
389 inline void swap(IDFile &lhs, IDFile &rhs) noexcept
390 {
391  using std::swap;
392 
393  swap(static_cast<AFile &>(lhs), static_cast<AFile &>(rhs));
394 #ifdef DEBUG
395  swap(lhs.fDebugPath, rhs.fDebugPath);
396 #endif
397 #ifdef WINDOWS
398  swap(lhs.fTmpPathStr, rhs.fTmpPathStr);
399 #endif
400 }
401 
402 inline IDFile& IDFile::operator=(IDFile&& rhs) noexcept
403 {
404  swap(*this, rhs);
405 
406  return *this;
407 }
408 
409 // define adobe::type_info<IDFile> to avoid typeid classes when moving across DLL boundaries
410 ADOBE_NAME_TYPE_0("idfile:indesign:adobe", IDFile)
411 
412 #endif // __IDFile__