udata.h
Go to the documentation of this file.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
******************************************************************************
*
* Copyright (C) 1999-2014, International Business Machines
* Corporation and others. All Rights Reserved.
*
******************************************************************************
* file name: udata.h
* encoding: UTF-8
* tab size: 8 (not used)
* indentation:4
*
* created on: 1999oct25
* created by: Markus W. Scherer
*/
#ifndef __UDATA_H__
#define __UDATA_H__
#include "unicode/utypes.h"
#if U_SHOW_CPLUSPLUS_API
#include "unicode/localpointer.h"
#endif // U_SHOW_CPLUSPLUS_API
U_CDECL_BEGIN
#ifndef U_HIDE_INTERNAL_API
#define U_TREE_SEPARATOR '-'
#define U_TREE_SEPARATOR_STRING "-"
#define U_TREE_ENTRY_SEP_CHAR '/'
#define U_TREE_ENTRY_SEP_STRING "/"
#define U_ICUDATA_ALIAS "ICUDATA"
#endif /* U_HIDE_INTERNAL_API */
typedef struct {
uint16_t size;
uint16_t reservedWord;
/* platform data properties */
uint8_t isBigEndian;
uint8_t charsetFamily;
uint8_t sizeofUChar;
uint8_t reservedByte;
uint8_t dataFormat[4];
uint8_t formatVersion[4];
uint8_t dataVersion[4];
} UDataInfo;
/* API for reading data -----------------------------------------------------*/
typedef struct UDataMemory UDataMemory;
typedef UBool U_CALLCONV
UDataMemoryIsAcceptable(void *context,
const char *type, const char *name,
const UDataInfo *pInfo);
U_CAPI UDataMemory * U_EXPORT2
udata_open(const char *path, const char *type, const char *name,
UErrorCode *pErrorCode);
U_CAPI UDataMemory * U_EXPORT2
udata_openChoice(const char *path, const char *type, const char *name,
UDataMemoryIsAcceptable *isAcceptable, void *context,
UErrorCode *pErrorCode);
U_CAPI void U_EXPORT2
udata_close(UDataMemory *pData);
U_CAPI const void * U_EXPORT2
udata_getMemory(UDataMemory *pData);
U_CAPI void U_EXPORT2
udata_getInfo(UDataMemory *pData, UDataInfo *pInfo);
U_CAPI void U_EXPORT2
udata_setCommonData(const void *data, UErrorCode *err);
U_CAPI void U_EXPORT2
udata_setAppData(const char *packageName, const void *data, UErrorCode *err);
typedef enum UDataFileAccess {
UDATA_FILES_FIRST,
UDATA_DEFAULT_ACCESS = UDATA_FILES_FIRST,
UDATA_ONLY_PACKAGES,
UDATA_PACKAGES_FIRST,
UDATA_NO_FILES,
#ifndef U_HIDE_DEPRECATED_API
UDATA_FILE_ACCESS_COUNT
#endif // U_HIDE_DEPRECATED_API
} UDataFileAccess;
U_CAPI void U_EXPORT2
udata_setFileAccess(UDataFileAccess access, UErrorCode *status);
U_CDECL_END
#if U_SHOW_CPLUSPLUS_API
U_NAMESPACE_BEGIN
U_DEFINE_LOCAL_OPEN_POINTER(LocalUDataMemoryPointer, UDataMemory, udata_close);
U_NAMESPACE_END
#endif // U_SHOW_CPLUSPLUS_API
#endif
LocalUDataMemoryPointer
"Smart pointer" class, closes a UDataMemory via udata_close().
localpointer.h
C++ API: "Smart pointers" for use with and in ICU4C C++ code.
U_DEFINE_LOCAL_OPEN_POINTER
#define U_DEFINE_LOCAL_OPEN_POINTER(LocalPointerClassName, Type, closeFunction)
"Smart pointer" definition macro, deletes objects via the closeFunction.
Definition: localpointer.h:550
U_CALLCONV
#define U_CALLCONV
Similar to U_CDECL_BEGIN/U_CDECL_END, this qualifier is necessary in callback function typedefs to ma...
Definition: platform.h:834
UDataInfo
UDataInfo contains the properties about the requested data.
Definition: udata.h:116
UDataInfo::sizeofUChar
uint8_t sizeofUChar
sizeof(UChar), one of { 1, 2, 4 }
Definition: udata.h:136
UDataInfo::charsetFamily
uint8_t charsetFamily
see U_CHARSET_FAMILY values in utypes.h
Definition: udata.h:132
UDataInfo::isBigEndian
uint8_t isBigEndian
0 for little-endian machine, 1 for big-endian
Definition: udata.h:128
UDataInfo::size
uint16_t size
sizeof(UDataInfo)
Definition: udata.h:119
UDataInfo::reservedByte
uint8_t reservedByte
unused, set to 0
Definition: udata.h:140
UDataInfo::reservedWord
uint16_t reservedWord
unused, set to 0
Definition: udata.h:123
udata_setAppData
U_CAPI void udata_setAppData(const char *packageName, const void *data, UErrorCode *err)
This function bypasses the normal ICU data loading process for application-specific data and allows y...
UDataFileAccess
UDataFileAccess
Possible settings for udata_setFileAccess()
Definition: udata.h:385
UDATA_FILE_ACCESS_COUNT
@ UDATA_FILE_ACCESS_COUNT
Number of real UDataFileAccess values.
Definition: udata.h:402
UDATA_ONLY_PACKAGES
@ UDATA_ONLY_PACKAGES
ICU only loads data from packages, not from single files.
Definition: udata.h:391
UDATA_DEFAULT_ACCESS
@ UDATA_DEFAULT_ACCESS
An alias for the default access mode.
Definition: udata.h:389
UDATA_FILES_FIRST
@ UDATA_FILES_FIRST
ICU looks for data in single files first, then in packages.
Definition: udata.h:387
UDATA_PACKAGES_FIRST
@ UDATA_PACKAGES_FIRST
ICU loads data from packages first, and only from single files if the data cannot be found in a packa...
Definition: udata.h:394
UDATA_NO_FILES
@ UDATA_NO_FILES
ICU does not access the file system for data loading.
Definition: udata.h:396
udata_openChoice
U_CAPI UDataMemory * udata_openChoice(const char *path, const char *type, const char *name, UDataMemoryIsAcceptable *isAcceptable, void *context, UErrorCode *pErrorCode)
Data loading function.
udata_getInfo
U_CAPI void udata_getInfo(UDataMemory *pData, UDataInfo *pInfo)
Get the information from the data memory header.
udata_setFileAccess
U_CAPI void udata_setFileAccess(UDataFileAccess access, UErrorCode *status)
This function may be called to control how ICU loads data.
udata_close
U_CAPI void udata_close(UDataMemory *pData)
Close the data memory.
udata_open
U_CAPI UDataMemory * udata_open(const char *path, const char *type, const char *name, UErrorCode *pErrorCode)
Convenience function.
udata_setCommonData
U_CAPI void udata_setCommonData(const void *data, UErrorCode *err)
This function bypasses the normal ICU data loading process and allows you to force ICU's system data ...
UDataMemoryIsAcceptable
UBool UDataMemoryIsAcceptable(void *context, const char *type, const char *name, const UDataInfo *pInfo)
Callback function for udata_openChoice().
Definition: udata.h:177
UDataMemory
struct UDataMemory UDataMemory
Forward declaration of the data memory type.
Definition: udata.h:161
udata_getMemory
U_CAPI const void * udata_getMemory(UDataMemory *pData)
Get the pointer to the actual data inside the data memory.
U_CDECL_END
#define U_CDECL_END
This is used to end a declaration of a library private ICU C API.
Definition: umachine.h:86
UBool
int8_t UBool
The ICU boolean type, a signed-byte integer.
Definition: umachine.h:247
U_CAPI
#define U_CAPI
This is used to declare a function as a public ICU C API.
Definition: umachine.h:110
U_CDECL_BEGIN
#define U_CDECL_BEGIN
This is used to begin a declaration of a library private ICU C API.
Definition: umachine.h:85
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition: utypes.h:415