InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
MediaLocation.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner: wtislar
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 // ADOBE CONFIDENTIAL
24 //
25 //========================================================================================
26 
27 #ifndef __MediaLocation__
28 #define __MediaLocation__
29 
30 
39 {
40 public:
43  : fLocationIsURL(kFalse),
44  fLocation(PMString("")) {}
45 
47  MediaLocation( PMString locationString, bool16 isURL = kFalse )
48  : fLocationIsURL(isURL),
49  fLocation(locationString) {}
50 
53  : fLocationIsURL(orig.fLocationIsURL),
54  fLocation(orig.fLocation) {}
55 
56  //----------OPERATORS---------------
57 
60  { Set(copy); return *this; }
61 
63  bool16 operator == (const MediaLocation &ml) const
64  { return fLocationIsURL == ml.fLocationIsURL &&
65  fLocation == ml.fLocation; }
66 
68  inline bool16 operator != (const MediaLocation &ml) const
69  { return (!(*this == ml)); }
70 
74  virtual PMString GetString() const { return fLocation; }
75 
79  virtual PMString GetExtensionString() const
80  {
81  PMString extension("");
82  PMString locStr(fLocation);
83  CharCounter delimIndex = locStr.LastIndexOfCharacter('.');
84  int32 extensionCharCount = delimIndex >= 0 ? locStr.CharCount() - delimIndex - 1 : 0;
85 
86  if ( extensionCharCount > 0 )
87  {
88  for ( CharCounter i = delimIndex + 1; i < locStr.CharCount(); i++ )
89  {
90  PlatformChar ch = locStr.GetChar( i );
91  extension.Append( ch );
92  }
93  }
94  return extension;
95  }
96 
100  virtual bool16 IsFile() const { return !fLocationIsURL; }
101 
105  virtual bool16 IsURL() const { return fLocationIsURL; }
106 
107 private:
108  bool16 fLocationIsURL;
109  PMString fLocation; // fully-qualified location (URL or file path)
110 
111  void Set( const MediaLocation & copy )
112  { fLocationIsURL = copy.fLocationIsURL; fLocation = copy.fLocation; }
113 }; // end MediaLocation class
114 
115 
116 #endif // __MediaLocation__