Update contrib.
2 * Copyright (c) 2003-2006 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of the License "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
29 #ifndef __CAFVIRTUALPATH_H__
30 #define __CAFVIRTUALPATH_H__
34 #include <caf/virtualpathptr.h>
39 namespace ContentAccess
41 class TVirtualPathPtr;
43 /** A virtual path describes the location of the file (URI) and the location of
44 a content object within that file (Unique Id).
46 The URI must conform to the standard defined in RFC2396, found at http://www.ietf.org/.
48 CVirtualPath makes a copy of the URI and UniqueId used to identify a particular content
51 The TVirtualPathPtr cast operator allows the CVirtualPath object to be used with
52 CAF functions requiring a TVirtualPathPtr.
54 The GetCombinedUriUniqueId() function allows it to "flatten" a virtual
55 path into a single URI. The combined virtual path will be the URI concatenated with the UniqueId
56 seperated by the KCafVirtualPathSeparator character taking the format.
58 <URI><KCafVirtualPathSeparator><UniqueID>
61 An example of this format is shown below:
63 // Create a CVirtualPath object to point to OBJECT1 inside file.dcf
64 CVirtualPath *path = CVirtualPath::NewL(_L("C:\\directory\file.dcf"), _L("OBJECT1"));
66 // convert the URI and unique ID into a single URI.
67 TVirtualPathPtr aPath = path->GetCombinedUriUniqueId();
70 If a URI is supplied which contains multiple KCafVirtualPathSeparator characters
71 the rightmost KCafVirtualPathSeparator character will be taken as marking the end
72 of the URI and the start of the UniqueId. When multiple KCafVirtualPathSeparator
73 characters are present, under certain situations this will result in an invalid
74 URI and UniqueId being created for the virtual path and can lead to an undefined failure.
77 class CVirtualPath : public CBase
80 /** Create a CVirtualPath object from a TVirtualPathPtr
81 @param aPtr The location of the content object
82 @return a new CVirtualPath object
84 IMPORT_C static CVirtualPath* NewL(const TVirtualPathPtr& aPtr);
86 /** Create a virtual path object from a combined Uri and UniqueId
88 This constructs a CVirtual path from a single descriptor.
90 Note that the descriptor here may be just a URI or it could be a URI
91 concatenated with the file's UniqueId. If it is a concatenated URI and
92 UniqueId the URI and UniqueId will be seperated by the KCasfVirtualPathSeparator character.
93 For more information see above.
94 @param aCombinedUriUniqueId The location of the content object
95 @return a new CVirtualPath object
97 IMPORT_C static CVirtualPath* NewL(const TDesC& aCombinedUriUniqueId);
99 /** Create a virtual path object for a specific content object within a file
100 @param aURI The location of the file
101 @param aUniqueId The location of the content within the file
102 @return a new CVirtualPath object
104 IMPORT_C static CVirtualPath* NewL(const TDesC& aURI, const TDesC& aUniqueId);
106 /** Construct and read a CVirtualPath object from a stream
107 @param aStream The stream to read frin
109 IMPORT_C static CVirtualPath* NewL(RReadStream& aStream);
112 virtual ~CVirtualPath();
114 /** The location of the file containing the content object
115 @return The location of the file
117 IMPORT_C const TDesC& URI() const;
119 /** UniqueId supplied by a CAF Agent to identify the object within the
121 @return The uniqueId of the object within the file
123 IMPORT_C const TDesC& UniqueId() const;
125 /** Allows the class to write itself to a stream
126 @param aStream The stream to write to
128 IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
130 /** Convert the CVirtualPath to a single URI representing a particular
131 content object. The URI and UniqueId will be separated by a KCafVirtualPathSeparator()
132 @return A descriptor contaning the URI and UniqueId concatenated together
134 IMPORT_C const TDesC& GetCombinedUriUniqueId();
136 /** Cast operator allowing the CVirtualPath to be used as a TVirtualPathPtr
137 @return a TVirtualPathPtr with the same value as this object
139 inline operator const TVirtualPathPtr& () const;
142 CVirtualPath(const TVirtualPathPtr& aPtr);
144 /** Allow derived classes to call 2nd phase constructor
148 /** Used to continue initialisation and setup iCombinedPtr */
149 void CreateCombinedUriUniqueIdL(const TDesC& aUri, const TDesC& aUniqueId);
151 void InternalizeL(RReadStream& aStream);
157 HBufC* iCombinedUriUniqueId;
158 TPtrC iCombinedUriUniqueIdPtr;
159 TVirtualPathPtr iVirtualPathPtr;
163 // Cast operator for treating a CVirtualPath as a TVirtualPathPtr
164 inline CVirtualPath::operator const TVirtualPathPtr& () const
166 return iVirtualPathPtr;