author | William Roberts <williamr@symbian.org> |
Wed, 31 Mar 2010 12:33:34 +0100 | |
branch | Symbian3 |
changeset 4 | 837f303aceeb |
parent 2 | 2fe1408b6811 |
permissions | -rw-r--r-- |
williamr@2 | 1 |
/* |
williamr@2 | 2 |
* Copyright (c) 2003-2006 Nokia Corporation and/or its subsidiary(-ies). |
williamr@2 | 3 |
* All rights reserved. |
williamr@2 | 4 |
* This component and the accompanying materials are made available |
williamr@2 | 5 |
* under the terms of the License "Eclipse Public License v1.0" |
williamr@2 | 6 |
* which accompanies this distribution, and is available |
williamr@2 | 7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
williamr@2 | 8 |
* |
williamr@2 | 9 |
* Initial Contributors: |
williamr@2 | 10 |
* Nokia Corporation - initial contribution. |
williamr@2 | 11 |
* |
williamr@2 | 12 |
* Contributors: |
williamr@2 | 13 |
* |
williamr@2 | 14 |
* Description: |
williamr@2 | 15 |
* |
williamr@2 | 16 |
*/ |
williamr@2 | 17 |
|
williamr@2 | 18 |
|
williamr@2 | 19 |
|
williamr@2 | 20 |
/** |
williamr@2 | 21 |
@file |
williamr@2 | 22 |
|
williamr@4 | 23 |
@publishedAll |
williamr@2 | 24 |
@released |
williamr@2 | 25 |
*/ |
williamr@2 | 26 |
|
williamr@2 | 27 |
|
williamr@2 | 28 |
|
williamr@2 | 29 |
#ifndef __CAFVIRTUALPATH_H__ |
williamr@2 | 30 |
#define __CAFVIRTUALPATH_H__ |
williamr@2 | 31 |
|
williamr@2 | 32 |
#include <e32base.h> |
williamr@2 | 33 |
|
williamr@2 | 34 |
#include <caf/virtualpathptr.h> |
williamr@2 | 35 |
|
williamr@2 | 36 |
class RReadStream; |
williamr@2 | 37 |
class RWriteStream; |
williamr@2 | 38 |
|
williamr@2 | 39 |
namespace ContentAccess |
williamr@2 | 40 |
{ |
williamr@2 | 41 |
class TVirtualPathPtr; |
williamr@2 | 42 |
|
williamr@2 | 43 |
/** A virtual path describes the location of the file (URI) and the location of |
williamr@2 | 44 |
a content object within that file (Unique Id). |
williamr@2 | 45 |
|
williamr@2 | 46 |
The URI must conform to the standard defined in RFC2396, found at http://www.ietf.org/. |
williamr@2 | 47 |
|
williamr@2 | 48 |
CVirtualPath makes a copy of the URI and UniqueId used to identify a particular content |
williamr@2 | 49 |
object within a file. |
williamr@2 | 50 |
|
williamr@2 | 51 |
The TVirtualPathPtr cast operator allows the CVirtualPath object to be used with |
williamr@2 | 52 |
CAF functions requiring a TVirtualPathPtr. |
williamr@2 | 53 |
|
williamr@2 | 54 |
The GetCombinedUriUniqueId() function allows it to "flatten" a virtual |
williamr@2 | 55 |
path into a single URI. The combined virtual path will be the URI concatenated with the UniqueId |
williamr@2 | 56 |
seperated by the KCafVirtualPathSeparator character taking the format. |
williamr@2 | 57 |
@code |
williamr@2 | 58 |
<URI><KCafVirtualPathSeparator><UniqueID> |
williamr@2 | 59 |
@endcode |
williamr@2 | 60 |
|
williamr@2 | 61 |
An example of this format is shown below: |
williamr@2 | 62 |
@code |
williamr@2 | 63 |
// Create a CVirtualPath object to point to OBJECT1 inside file.dcf |
williamr@2 | 64 |
CVirtualPath *path = CVirtualPath::NewL(_L("C:\\directory\file.dcf"), _L("OBJECT1")); |
williamr@2 | 65 |
|
williamr@2 | 66 |
// convert the URI and unique ID into a single URI. |
williamr@2 | 67 |
TVirtualPathPtr aPath = path->GetCombinedUriUniqueId(); |
williamr@2 | 68 |
@endcode |
williamr@2 | 69 |
@note |
williamr@2 | 70 |
If a URI is supplied which contains multiple KCafVirtualPathSeparator characters |
williamr@2 | 71 |
the rightmost KCafVirtualPathSeparator character will be taken as marking the end |
williamr@2 | 72 |
of the URI and the start of the UniqueId. When multiple KCafVirtualPathSeparator |
williamr@2 | 73 |
characters are present, under certain situations this will result in an invalid |
williamr@2 | 74 |
URI and UniqueId being created for the virtual path and can lead to an undefined failure. |
williamr@2 | 75 |
|
williamr@2 | 76 |
*/ |
williamr@2 | 77 |
class CVirtualPath : public CBase |
williamr@2 | 78 |
{ |
williamr@2 | 79 |
public: |
williamr@2 | 80 |
/** Create a CVirtualPath object from a TVirtualPathPtr |
williamr@2 | 81 |
@param aPtr The location of the content object |
williamr@2 | 82 |
@return a new CVirtualPath object |
williamr@2 | 83 |
*/ |
williamr@2 | 84 |
IMPORT_C static CVirtualPath* NewL(const TVirtualPathPtr& aPtr); |
williamr@2 | 85 |
|
williamr@2 | 86 |
/** Create a virtual path object from a combined Uri and UniqueId |
williamr@2 | 87 |
|
williamr@2 | 88 |
This constructs a CVirtual path from a single descriptor. |
williamr@2 | 89 |
|
williamr@2 | 90 |
Note that the descriptor here may be just a URI or it could be a URI |
williamr@2 | 91 |
concatenated with the file's UniqueId. If it is a concatenated URI and |
williamr@2 | 92 |
UniqueId the URI and UniqueId will be seperated by the KCasfVirtualPathSeparator character. |
williamr@2 | 93 |
For more information see above. |
williamr@2 | 94 |
@param aCombinedUriUniqueId The location of the content object |
williamr@2 | 95 |
@return a new CVirtualPath object |
williamr@2 | 96 |
*/ |
williamr@2 | 97 |
IMPORT_C static CVirtualPath* NewL(const TDesC& aCombinedUriUniqueId); |
williamr@2 | 98 |
|
williamr@2 | 99 |
/** Create a virtual path object for a specific content object within a file |
williamr@2 | 100 |
@param aURI The location of the file |
williamr@2 | 101 |
@param aUniqueId The location of the content within the file |
williamr@2 | 102 |
@return a new CVirtualPath object |
williamr@2 | 103 |
*/ |
williamr@2 | 104 |
IMPORT_C static CVirtualPath* NewL(const TDesC& aURI, const TDesC& aUniqueId); |
williamr@2 | 105 |
|
williamr@2 | 106 |
/** Construct and read a CVirtualPath object from a stream |
williamr@2 | 107 |
@param aStream The stream to read frin |
williamr@2 | 108 |
*/ |
williamr@2 | 109 |
IMPORT_C static CVirtualPath* NewL(RReadStream& aStream); |
williamr@2 | 110 |
|
williamr@2 | 111 |
|
williamr@2 | 112 |
virtual ~CVirtualPath(); |
williamr@2 | 113 |
|
williamr@2 | 114 |
/** The location of the file containing the content object |
williamr@2 | 115 |
@return The location of the file |
williamr@2 | 116 |
*/ |
williamr@2 | 117 |
IMPORT_C const TDesC& URI() const; |
williamr@2 | 118 |
|
williamr@2 | 119 |
/** UniqueId supplied by a CAF Agent to identify the object within the |
williamr@2 | 120 |
file. |
williamr@2 | 121 |
@return The uniqueId of the object within the file |
williamr@2 | 122 |
*/ |
williamr@2 | 123 |
IMPORT_C const TDesC& UniqueId() const; |
williamr@2 | 124 |
|
williamr@2 | 125 |
/** Allows the class to write itself to a stream |
williamr@2 | 126 |
@param aStream The stream to write to |
williamr@2 | 127 |
*/ |
williamr@2 | 128 |
IMPORT_C void ExternalizeL(RWriteStream& aStream) const; |
williamr@2 | 129 |
|
williamr@2 | 130 |
/** Convert the CVirtualPath to a single URI representing a particular |
williamr@2 | 131 |
content object. The URI and UniqueId will be separated by a KCafVirtualPathSeparator() |
williamr@2 | 132 |
@return A descriptor contaning the URI and UniqueId concatenated together |
williamr@2 | 133 |
*/ |
williamr@2 | 134 |
IMPORT_C const TDesC& GetCombinedUriUniqueId(); |
williamr@2 | 135 |
|
williamr@2 | 136 |
/** Cast operator allowing the CVirtualPath to be used as a TVirtualPathPtr |
williamr@2 | 137 |
@return a TVirtualPathPtr with the same value as this object |
williamr@2 | 138 |
*/ |
williamr@2 | 139 |
inline operator const TVirtualPathPtr& () const; |
williamr@2 | 140 |
|
williamr@2 | 141 |
private: |
williamr@2 | 142 |
CVirtualPath(const TVirtualPathPtr& aPtr); |
williamr@2 | 143 |
|
williamr@2 | 144 |
/** Allow derived classes to call 2nd phase constructor |
williamr@2 | 145 |
*/ |
williamr@2 | 146 |
void ConstructL(); |
williamr@2 | 147 |
|
williamr@2 | 148 |
/** Used to continue initialisation and setup iCombinedPtr */ |
williamr@2 | 149 |
void CreateCombinedUriUniqueIdL(const TDesC& aUri, const TDesC& aUniqueId); |
williamr@2 | 150 |
|
williamr@2 | 151 |
void InternalizeL(RReadStream& aStream); |
williamr@2 | 152 |
|
williamr@2 | 153 |
private: |
williamr@2 | 154 |
|
williamr@2 | 155 |
HBufC* iURI; |
williamr@2 | 156 |
HBufC* iUniqueId; |
williamr@2 | 157 |
HBufC* iCombinedUriUniqueId; |
williamr@2 | 158 |
TPtrC iCombinedUriUniqueIdPtr; |
williamr@2 | 159 |
TVirtualPathPtr iVirtualPathPtr; |
williamr@2 | 160 |
}; |
williamr@2 | 161 |
|
williamr@2 | 162 |
|
williamr@2 | 163 |
// Cast operator for treating a CVirtualPath as a TVirtualPathPtr |
williamr@2 | 164 |
inline CVirtualPath::operator const TVirtualPathPtr& () const |
williamr@2 | 165 |
{ |
williamr@2 | 166 |
return iVirtualPathPtr; |
williamr@2 | 167 |
} |
williamr@2 | 168 |
} |
williamr@2 | 169 |
|
williamr@2 | 170 |
#endif |