Home | History | Annotate | Download | only in common
      1 // Copyright (C) 2016 and later: Unicode, Inc. and others.
      2 // License & terms of use: http://www.unicode.org/copyright.html
      3 /*
      4 ******************************************************************************
      5 *
      6 *   Copyright (C) 1999-2010, International Business Machines
      7 *   Corporation and others.  All Rights Reserved.
      8 *
      9 ******************************************************************************/
     10 
     11 
     12 /*----------------------------------------------------------------------------------
     13  *
     14  *  UDataMemory     A class-like struct that serves as a handle to a piece of memory
     15  *                  that contains some ICU data (resource, converters, whatever.)
     16  *
     17  *                  When an application opens ICU data (with udata_open, for example,
     18  *                  a UDataMemory * is returned.
     19  *
     20  *----------------------------------------------------------------------------------*/
     21 #ifndef __UDATAMEM_H__
     22 #define __UDATAMEM_H__
     23 
     24 #include "unicode/udata.h"
     25 #include "ucmndata.h"
     26 
     27 struct UDataMemory {
     28     const commonDataFuncs  *vFuncs;      /* Function Pointers for accessing TOC             */
     29 
     30     const DataHeader *pHeader;     /* Header of the memory being described by this    */
     31                                    /*   UDataMemory object.                           */
     32     const void       *toc;         /* For common memory, table of contents for        */
     33                                    /*   the pieces within.                            */
     34     UBool             heapAllocated;  /* True if this UDataMemory Object is on the    */
     35                                    /*  heap and thus needs to be deleted when closed. */
     36 
     37     void             *mapAddr;     /* For mapped or allocated memory, the start addr. */
     38                                    /* Only non-null if a close operation should unmap */
     39                                    /*  the associated data.                           */
     40     void             *map;         /* Handle, or other data, OS dependent.            */
     41                                    /* Only non-null if a close operation should unmap */
     42                                    /*  the associated data, and additional info       */
     43                                    /*   beyond the mapAddr is needed to do that.      */
     44     int32_t           length;      /* Length of the data in bytes; -1 if unknown.     */
     45 };
     46 
     47 U_CFUNC UDataMemory *UDataMemory_createNewInstance(UErrorCode *pErr);
     48 U_CFUNC void         UDatamemory_assign  (UDataMemory *dest, UDataMemory *source);
     49 U_CFUNC void         UDataMemory_init    (UDataMemory *This);
     50 U_CFUNC UBool        UDataMemory_isLoaded(const UDataMemory *This);
     51 U_CFUNC void         UDataMemory_setData (UDataMemory *This, const void *dataAddr);
     52 
     53 U_CFUNC const DataHeader *UDataMemory_normalizeDataPointer(const void *p);
     54 
     55 U_CAPI int32_t U_EXPORT2
     56 udata_getLength(const UDataMemory *pData);
     57 
     58 U_CAPI const void * U_EXPORT2
     59 udata_getRawMemory(const UDataMemory *pData);
     60 
     61 #endif
     62