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