webengine/wmlengine/src/utils/include/nwx_buffer.h
changeset 74 91031d3aab7d
parent 68 92a765b5b3e7
child 85 e358f2276d3f
equal deleted inserted replaced
68:92a765b5b3e7 74:91031d3aab7d
     1 /*
       
     2 * Copyright (c) 1999 - 2001 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     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".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 /***************************************************************************
       
    20 **   File: nwx_buffer.h
       
    21 **   Purpose:  Provides the interface to a managerd buffer of bytes.
       
    22 **              The buffer contains an allocated size and an in use size (length)
       
    23 **              and also a pointer to a data array.
       
    24 **************************************************************************/
       
    25 #ifndef NWX_BUFFER_H
       
    26 #define NWX_BUFFER_H
       
    27 
       
    28 #ifdef __cplusplus
       
    29 extern "C" {
       
    30 #endif
       
    31 
       
    32 /*
       
    33 ** Includes
       
    34 */
       
    35 #include "nwx_defs.h"
       
    36 #include "BrsrStatusCodes.h"
       
    37 
       
    38 /*
       
    39 ** Type Declarations
       
    40 */
       
    41 typedef struct {
       
    42   NW_Uint32  length;           /* length of the used part of the buffer */
       
    43   NW_Uint32  allocatedLength;  /* How much space was really allocated */
       
    44   NW_Byte    *data;            /* the real data */
       
    45 } NW_Buffer_t;
       
    46 
       
    47 /*
       
    48 ** Global Function Declarations
       
    49 */
       
    50 
       
    51 /* create a buffer struct and allocate some space */
       
    52 NW_Buffer_t *NW_Buffer_New(const NW_Uint32 size);
       
    53 
       
    54 /* free the space allocated for the buffer */
       
    55 void NW_Buffer_Free(NW_Buffer_t *buffer);
       
    56 
       
    57 /* free the space allocated for the buffer, do not free the data */
       
    58 void NW_Buffer_FreeNotData(NW_Buffer_t *buffer);
       
    59 
       
    60 /*copy string into buffer */
       
    61 TBrowserStatusCode NW_Buffer_CopyStr(NW_Buffer_t *buffer, const NW_Ucs2 *str);
       
    62 
       
    63 /*copy NW_buffer to NW_Buffer*/
       
    64 TBrowserStatusCode NW_Buffer_CopyBuffers(NW_Buffer_t *to, const NW_Buffer_t *from);
       
    65 
       
    66 /*append NW_buffer to NW_Buffer*/
       
    67 TBrowserStatusCode NW_Buffer_AppendBuffers(NW_Buffer_t *to, const NW_Buffer_t *from);
       
    68 
       
    69 /*set ascii string into buffer */
       
    70 void NW_Buffer_SetData(NW_Buffer_t *buffer, char *str);
       
    71 
       
    72 
       
    73 #define NW_Buffer_Len(buf)  ((buf)->length)
       
    74 #define NW_Buffer_Data(buf) ((buf)->data)
       
    75 
       
    76 
       
    77 #ifdef __cplusplus
       
    78 } /* extern "C" */
       
    79 #endif
       
    80 
       
    81 #endif  /* NWX_BUFFER_H */