michael@0: /* michael@0: ******************************************************************************* michael@0: * michael@0: * Copyright (C) 1999-2010, International Business Machines michael@0: * Corporation and others. All Rights Reserved. michael@0: * michael@0: ******************************************************************************* michael@0: * file name: unewdata.h michael@0: * encoding: US-ASCII michael@0: * tab size: 8 (not used) michael@0: * indentation:4 michael@0: * michael@0: * created on: 1999oct25 michael@0: * created by: Markus W. Scherer michael@0: */ michael@0: michael@0: #ifndef __UNEWDATA_H__ michael@0: #define __UNEWDATA_H__ michael@0: michael@0: #include "unicode/utypes.h" michael@0: #include "unicode/udata.h" michael@0: michael@0: /* API for writing data -----------------------------------------------------*/ michael@0: michael@0: /** @memo Forward declaration of the data memory creation type. */ michael@0: typedef struct UNewDataMemory UNewDataMemory; michael@0: michael@0: /** michael@0: * Create a new binary data file. michael@0: * The file-writing udata_ functions facilitate writing michael@0: * binary data files that can be read by ICU's udata API. michael@0: * This function opens a new file with a filename determined from its michael@0: * parameters - of the form "name.type". michael@0: * It then writes a short header, followed by the UDataInfo michael@0: * structure and, optionally, by the comment string. michael@0: * It then writes padding bytes to round up to a multiple of 16 bytes. michael@0: * Subsequent write operations will thus start at an offset in the file michael@0: * that is a multiple of 16. udata_getMemory() will return michael@0: * a pointer to this same starting offset. michael@0: * michael@0: * See udata.h . michael@0: * michael@0: * @param dir A string that specifies the directory where the data will be michael@0: * written. If NULL, then michael@0: * u_getDataDirectory is used. michael@0: * @param type A string that specifies the type of data to be written. michael@0: * For example, resource bundles are written with type "res", michael@0: * conversion tables with type "cnv". michael@0: * This may be NULL or empty. michael@0: * @param name A string that specifies the name of the data. michael@0: * @param pInfo A pointer to a correctly filled UDataInfo michael@0: * structure that will be copied into the file. michael@0: * @param comment A string (e.g., a copyright statement) that will be michael@0: * copied into the file if it is not NULL michael@0: * or empty. This string serves only as a comment in the binary michael@0: * file. It will not be accessible by any API. michael@0: * @param pErrorCode An ICU UErrorCode parameter. It must not be NULL. michael@0: */ michael@0: U_CAPI UNewDataMemory * U_EXPORT2 michael@0: udata_create(const char *dir, const char *type, const char *name, michael@0: const UDataInfo *pInfo, michael@0: const char *comment, michael@0: UErrorCode *pErrorCode); michael@0: michael@0: /** @memo Close a newly written binary file. */ michael@0: U_CAPI uint32_t U_EXPORT2 michael@0: udata_finish(UNewDataMemory *pData, UErrorCode *pErrorCode); michael@0: michael@0: /** @memo Write a dummy data file. */ michael@0: U_CAPI void U_EXPORT2 michael@0: udata_createDummy(const char *dir, const char *type, const char *name, UErrorCode *pErrorCode); michael@0: michael@0: /** @memo Write an 8-bit byte to the file. */ michael@0: U_CAPI void U_EXPORT2 michael@0: udata_write8(UNewDataMemory *pData, uint8_t byte); michael@0: michael@0: /** @memo Write a 16-bit word to the file. */ michael@0: U_CAPI void U_EXPORT2 michael@0: udata_write16(UNewDataMemory *pData, uint16_t word); michael@0: michael@0: /** @memo Write a 32-bit word to the file. */ michael@0: U_CAPI void U_EXPORT2 michael@0: udata_write32(UNewDataMemory *pData, uint32_t wyde); michael@0: michael@0: /** @memo Write a block of bytes to the file. */ michael@0: U_CAPI void U_EXPORT2 michael@0: udata_writeBlock(UNewDataMemory *pData, const void *s, int32_t length); michael@0: michael@0: /** @memo Write a block of arbitrary padding bytes to the file. */ michael@0: U_CAPI void U_EXPORT2 michael@0: udata_writePadding(UNewDataMemory *pData, int32_t length); michael@0: michael@0: /** @memo Write a char* string of platform "invariant characters" to the file. */ michael@0: U_CAPI void U_EXPORT2 michael@0: udata_writeString(UNewDataMemory *pData, const char *s, int32_t length); michael@0: michael@0: /** @memo Write a UChar* string of Unicode character code units to the file. */ michael@0: U_CAPI void U_EXPORT2 michael@0: udata_writeUString(UNewDataMemory *pData, const UChar *s, int32_t length); michael@0: michael@0: michael@0: /* michael@0: * Hey, Emacs, please set the following: michael@0: * michael@0: * Local Variables: michael@0: * indent-tabs-mode: nil michael@0: * End: michael@0: * michael@0: */ michael@0: michael@0: #endif