persistentstorage/store/UMEM/UM_STRM.CPP
changeset 0 08ec8eefde2f
equal deleted inserted replaced
-1:000000000000 0:08ec8eefde2f
       
     1 // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include "UM_STD.H"
       
    17 
       
    18 /**
       
    19 Constructs the RMemReadStream object and prepares the stream hosted
       
    20 in the specified plain memory location for reading.
       
    21 
       
    22 @param aPtr The start address for the area of memory that will be
       
    23 the source of this stream.
       
    24 @param aLength The length of the area of memory.
       
    25 
       
    26 @see RMemReadStream::Open
       
    27 */
       
    28 EXPORT_C RMemReadStream::RMemReadStream(const TAny* aPtr,TInt aLength)
       
    29 	{
       
    30 	Open(aPtr,aLength);
       
    31 	}
       
    32 
       
    33 /**
       
    34 Open a stream that reads from a pointer of any type.
       
    35 
       
    36 To close the stream and free its resources call Close()
       
    37 
       
    38 @param aPtr The start address for the area of memory that will be
       
    39 the source of this stream.
       
    40 @param aLength The length of the area of memory.
       
    41 
       
    42 @see TMemBuf::Set
       
    43 @see RReadStream::Attach
       
    44 */
       
    45 EXPORT_C void RMemReadStream::Open(const TAny* aPtr,TInt aLength)
       
    46 	{
       
    47 	iSource.Set((TUint8*)aPtr,(TUint8*)aPtr+aLength,iSource.ERead);
       
    48 	RReadStream::Attach(&iSource);
       
    49 	}
       
    50 
       
    51 /**
       
    52 Constructs the RMemWriteStream object and prepares a stream to be hosted
       
    53 in the specified memory location (described by the TAny aPtr argument)
       
    54 for writing using the Open() function.
       
    55 
       
    56 @param aPtr The start address for the area of memory that is the sink of
       
    57 this stream.
       
    58 @param aMaxLength The maximum length of the area of memory.
       
    59 
       
    60 @see RMemWriteStream::Open
       
    61 */
       
    62 EXPORT_C RMemWriteStream::RMemWriteStream(TAny* aPtr,TInt aMaxLength)
       
    63 	{
       
    64 	Open(aPtr,aMaxLength);
       
    65 	}
       
    66 
       
    67 /**
       
    68 Prepares a stream for writing.
       
    69 
       
    70 When streaming takes place any existing data in the memory location will
       
    71 be replaced. Note that the length of memory must be big enough to accommodate
       
    72 the expected streamed data otherwise the subsequent streaming operation will
       
    73 leave with KErrOverFlow.
       
    74 
       
    75 To close the stream and free its resources call Close()
       
    76 
       
    77 @param aPtr The start address for the area of memory that is the sink of
       
    78 this stream.
       
    79 @param aMaxLength The maximum length of the area of memory.
       
    80 
       
    81 @see TMemBuf::Set
       
    82 @see RWriteStream::Attach
       
    83 */
       
    84 EXPORT_C void RMemWriteStream::Open(TAny* aPtr,TInt aMaxLength)
       
    85 	{
       
    86 	iSink.Set((TUint8*)aPtr,(TUint8*)aPtr+aMaxLength,iSink.EWrite);
       
    87 	RWriteStream::Attach(&iSink);
       
    88 	}
       
    89 
       
    90 /**
       
    91 Constructs the RDesReadStream object and prepares the stream hosted
       
    92 by the specified descriptor for reading.
       
    93 
       
    94 @param aDes The descriptor that will be the source of this stream.
       
    95 
       
    96 @see RDesReadStream::Open
       
    97 */
       
    98 EXPORT_C RDesReadStream::RDesReadStream(const TDesC8& aDes)
       
    99 	{
       
   100 	Open(aDes);
       
   101 	}
       
   102 
       
   103 /**
       
   104 Open a stream that reads from a descriptor.
       
   105 
       
   106 To close the stream and free its resources call Close()
       
   107 
       
   108 @param aDes The descriptor that will be the source of this stream.
       
   109 
       
   110 @see TDesBuf::Set
       
   111 @see RReadStream::Attach
       
   112 */
       
   113 EXPORT_C void RDesReadStream::Open(const TDesC8& aDes)
       
   114 	{
       
   115 	TUint8* ptr=(TUint8*)aDes.Ptr();
       
   116 	iSource.Set(ptr,ptr+aDes.Length(),iSource.ERead);
       
   117 	RReadStream::Attach(&iSource);
       
   118 	}
       
   119 
       
   120 /**
       
   121 Constructs the RDesWriteStream object and prepares a stream to be
       
   122 hosted by the specified 8-bit descriptor for writing using the Open()
       
   123 function.
       
   124 
       
   125 
       
   126 @param aDes The descriptor hosting the stream.
       
   127 
       
   128 @see RDesWriteStream::Open
       
   129 */
       
   130 EXPORT_C RDesWriteStream::RDesWriteStream(TDes8& aDes)
       
   131 	{
       
   132 	Open(aDes);
       
   133 	}
       
   134 
       
   135 /**
       
   136 Prepares a stream for writing.
       
   137 
       
   138 When streaming takes place, any existing data in the descriptor will
       
   139 be replaced. Note that the maximum length of the descriptor must be
       
   140 big enough to accommodate the expected streamed data, otherwise the
       
   141 subsequent streaming operation will leave with KErrOverFlow.
       
   142 
       
   143 A subsequent call to CommitL() sets the length of the descriptor.
       
   144 
       
   145 To close the stream and free its resources call Close()
       
   146 
       
   147 @param aDes The descriptor that will be the sink of this stream.
       
   148 
       
   149 @see TDesBuf::Set
       
   150 @see RWriteStream::Attach
       
   151 */
       
   152 EXPORT_C void RDesWriteStream::Open(TDes8& aDes)
       
   153 	{
       
   154 	aDes.SetLength(0);
       
   155 	iSink.Set(aDes,iSink.EWrite);
       
   156 	RWriteStream::Attach(&iSink);
       
   157 	}
       
   158 
       
   159 /**
       
   160 Constructs the RBufReadStream object and opens the stream hosted by the
       
   161 specified dynamic buffer for reading using the Open() method.
       
   162 
       
   163 @param aBuf The dynamic buffer that will be the source of this stream.
       
   164 @param aPos The offset within the dynamic buffer where the stream starts.
       
   165 
       
   166 @see RBufReadStream::Open
       
   167 */
       
   168 EXPORT_C RBufReadStream::RBufReadStream(const CBufBase& aBuf,TInt aPos)
       
   169 	{
       
   170 	Open(aBuf,aPos);
       
   171 	}
       
   172 
       
   173 /**
       
   174 Prepares the stream hosted by the specified dynamic buffer for reading.
       
   175 
       
   176 To close the stream and free its resources call Close()
       
   177 
       
   178 @param aBuf The dynamic buffer that will be the source of this stream.
       
   179 @param aPos The offset within the dynamic buffer where the stream starts.
       
   180 
       
   181 @see TBufBuf::Set
       
   182 @see RReadStream::Attach
       
   183 */
       
   184 EXPORT_C void RBufReadStream::Open(const CBufBase& aBuf,TInt aPos)
       
   185 	{
       
   186 	iSource.Set((CBufBase&)aBuf,aPos,iSource.ERead);
       
   187 	RReadStream::Attach(&iSource);
       
   188 	}
       
   189 
       
   190 /**
       
   191 Constructs the RBufWriteStream object and opens a stream that writes to
       
   192 the specified dynamic buffer using the Open() function.
       
   193 
       
   194 @param aBuf The dynamic buffer hosting the stream.
       
   195 @param aPos The offset within the dynamic buffer where the stream is to
       
   196 start. Defaults to zero, if not explicitly specified. The value cannot
       
   197 be greater than the current size of the buffer, otherwise a E32USER-CBase 5
       
   198 panic will be raised when streaming starts.
       
   199 
       
   200 @see RBufWriteStream::Open
       
   201 */
       
   202 EXPORT_C RBufWriteStream::RBufWriteStream(CBufBase& aBuf,TInt aPos)
       
   203 	{
       
   204 	Open(aBuf,aPos);
       
   205 	}
       
   206 
       
   207 /**
       
   208 Open a stream that writes to the dynamic buffer specified in the aBuf argument.
       
   209 
       
   210 To close the stream and free its resources call Close()
       
   211 
       
   212 @param aBuf The dynamic buffer hosting the stream.
       
   213 @param aPos The offset within the dynamic buffer where the stream is to
       
   214 start. Defaults to zero, if not explicitly specified. The value cannot
       
   215 be greater than the current size of the buffer, otherwise a E32USER-CBase 5
       
   216 panic will be raised when streaming starts.
       
   217 
       
   218 @see TBufBuf::Set
       
   219 @see RWriteStream::Attach
       
   220 */
       
   221 EXPORT_C void RBufWriteStream::Open(CBufBase& aBuf,TInt aPos)
       
   222 	{
       
   223 	iSink.Set(aBuf,aPos,iSink.EWrite);
       
   224 	RWriteStream::Attach(&iSink);
       
   225 	}
       
   226 
       
   227 /**
       
   228 Open a stream that writes into the dynamic buffer specified in the aBuf argument
       
   229 using truncate mode.
       
   230 
       
   231 @param aBuf The dynamic buffer hosting the stream.
       
   232 @param aPos The offset within the dynamic buffer where the stream is to
       
   233 start. Defaults to zero, if not explicitly specified. The value cannot
       
   234 be greater than the current size of the buffer, otherwise a E32USER-CBase 5
       
   235 panic will be raised when streaming starts.
       
   236 
       
   237 @see TBufBuf::Set
       
   238 @see TBufBuf::ETruncate
       
   239 @see RWriteStream::Attach
       
   240 */
       
   241 EXPORT_C void RBufWriteStream::Truncate(CBufBase& aBuf,TInt aPos)
       
   242 	{
       
   243 	iSink.Set(aBuf,aPos,iSink.ETruncate);
       
   244 	RWriteStream::Attach(&iSink);
       
   245 	}
       
   246 
       
   247 /**
       
   248 Open a stream that writes into the dynamic buffer specified in the aBuf argument
       
   249 using insert mode.
       
   250 
       
   251 @param aBuf The dynamic buffer hosting the stream.
       
   252 @param aPos The offset within the dynamic buffer where the stream is to
       
   253 start. Defaults to zero, if not explicitly specified. The value cannot
       
   254 be greater than the current size of the buffer, otherwise a E32USER-CBase 5
       
   255 panic will be raised when streaming starts.
       
   256 
       
   257 @see TBufBuf::Set
       
   258 @see TBufBuf::EInsert
       
   259 @see RWriteStream::Attach
       
   260 */
       
   261 EXPORT_C void RBufWriteStream::Insert(CBufBase& aBuf,TInt aPos)
       
   262 	{
       
   263 	iSink.Set(aBuf,aPos,iSink.EInsert);
       
   264 	RWriteStream::Attach(&iSink);
       
   265 	}
       
   266