ICU-157 add definitions for the udata API

X-SVN-Rev: 202
This commit is contained in:
Markus Scherer 1999-11-20 01:15:55 +00:00
parent f4c7ecf008
commit d834f7cd2d
6 changed files with 225 additions and 0 deletions

View file

@ -46,6 +46,7 @@
#define icu_strrchr(s, c) strrchr(s, c)
#define icu_toupper(c) toupper(c)
#define icu_tolower(c) tolower(c)
#define icu_strtoul(str, end, base) strtoul(str, end, base)
/*===========================================================================*/
/* Wide-character functions */

View file

@ -91,6 +91,14 @@ typedef unsigned long uint32_t;
#include <limits.h>
#define T_INT32_MAX (LONG_MAX)
/*===========================================================================*/
/* Character data types */
/*===========================================================================*/
#ifdef OS390
# define U_CHARSET_FAMILY 1
#endif
/*===========================================================================*/
/* Symbol import-export control */
/*===========================================================================*/

View file

@ -80,6 +80,12 @@ typedef unsigned long uint32_t;
#include <limits.h>
#define T_INT32_MAX (LONG_MAX)
/*===========================================================================*/
/* Character data types */
/*===========================================================================*/
#define U_CHARSET_FAMILY 1
/*===========================================================================*/
/* Symbol import-export control */
/*===========================================================================*/

View file

@ -79,6 +79,12 @@ typedef unsigned long uint32_t;
#include <limits.h>
#define T_INT32_MAX (LONG_MAX)
/*===========================================================================*/
/* Character data types */
/*===========================================================================*/
#define U_SIZEOF_WCHAR_T 2
/*===========================================================================*/
/* Symbol import-export control */
/*===========================================================================*/

148
icu4c/source/common/udata.h Normal file
View file

@ -0,0 +1,148 @@
/*
*******************************************************************************
* *
* COPYRIGHT: *
* (C) Copyright International Business Machines Corporation, 1999 *
* Licensed Material - Program-Property of IBM - All Rights Reserved. *
* US Government Users Restricted Rights - Use, duplication, or disclosure *
* restricted by GSA ADP Schedule Contract with IBM Corp. *
* *
*******************************************************************************
* file name: udata.h
* encoding: US-ASCII
* tab size: 8 (not used)
* indentation:4
*
* created on: 1999oct25
* created by: Markus W. Scherer
*/
#ifndef __UDATA_H__
#define __UDATA_H__
#include "utypes.h"
/**
* Information about data memory.
* This structure may grow in the future, indicated by the
* <code>size</code> field.
*
* <p>The platform data property fields help determine if a data
* file can be efficiently used on a given machine.
* The particular fields are of importance only if the data
* is affected by the properties - if there is integer data
* with word sizes > 1 byte, char* text, or UChar* text.</p>
*
* <p>The <code>dataFormat</code> may be used to identify
* the kind of data, e.g. a converter table.</p>
*
* <p>The <code>formatVersion</code> field should be used to
* make sure that the format can be interpreted.
* I may be a good idea to check only for the one or two highest
* of the version elements to allow the data memory to
* get more or somewhat rearranged contents, for as long
* as the using code can still interpret the older contents.</p>
*
* <p>The <code>dataVersion</code> field is intended to be a
* common place to store the source version of the data;
* for data from the Unicode character database, this could
* reflect the Unicode version.</p>
*/
typedef struct {
/** @memo sizeof(UDataInfo) */
uint16_t size;
/** @memo unused, set to 0 */
uint16_t reservedWord;
/* platform data properties */
/** @memo 0 for little-endian machine, 1 for big-endian */
uint8_t isBigEndian;
/** @memo see U_CHARSET_FAMILY values in utypes.h */
uint8_t charsetFamily;
/** @memo sizeof(UChar), one of { 1, 2, 4 } */
uint8_t sizeofUChar;
/** @memo unused, set to 0 */
uint8_t reservedByte;
/** @memo data format identifier */
uint8_t dataFormat[4];
/** @memo versions: [0] major [1] minor [2] milli [3] micro */
uint8_t formatVersion[4];
uint8_t dataVersion[4];
} UDataInfo;
/* API for reading data -----------------------------------------------------*/
/**
* Forward declaration of the data memory type.
*/
typedef struct UDataMemory UDataMemory;
/**
* Callback function for udata_openChoice().
* @return TRUE if the current data memory is acceptable
*/
typedef bool_t
UDataMemoryIsAcceptable(void *context,
const char *type, const char *name,
UDataInfo *pInfo);
/**
* Convenience function.
* This function works the same as <code>udata_openChoice</code>
* except that any data that matches the type and name
* is assumed to be acceptable.
*/
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);
/**
* Close the data memory.
* This function must be called to allow the system to
* release resources associated with this data memory.
*/
U_CAPI void U_EXPORT2
udata_close(UDataMemory *pData);
/**
* Get the pointer to the actual data inside the data memory.
*/
U_CAPI const void * U_EXPORT2
udata_getMemory(UDataMemory *pData);
/**
* Get the information from the data memory header.
* This allows to get access to the header containing
* platform data properties etc. which is not part of
* the data itself and can therefore not be accessed
* via the pointer that <code>udata_getMemory()</code> returns.
*
* @param pData pointer to the data memory object
* @param pInfo pointer to a UDataInfo object;
* its <code>size</code> field must be set correctly,
* typically to <code>sizeof(UDataInfo)</code>.
*
* <code>*pInfo</code> will be filled with the UDataInfo structure
* in the data memory object. If this structure is smaller than
* <code>pInfo->size</code>, then the <code>size</code> will be
* adjusted and only part of the structure will be filled.
*/
U_CAPI void U_EXPORT2
udata_getInfo(UDataMemory *pData, UDataInfo *pInfo);
#endif

View file

@ -81,6 +81,59 @@ typedef int8_t bool_t;
# define FALSE 0
#endif
/*===========================================================================*/
/* char Character set family */
/*===========================================================================*/
/*
* These definitions allow to specify the encoding of text
* in the char data type as defined by the platform and the compiler.
* It is enough to determine the code point values of "invariant characters",
* which are the ones shared by all encodings that are in use
* on a given platform.
*
* Those "invariant characters" should be all the uppercase and lowercase
* latin letters, the digits, the space, and "basic punctuation".
* Also, '\n', '\r', '\t' should be available.
*
* The list of "invariant characters" is:
* A-Z a-z 0-9 SPACE " % & ' ( ) * + , - . / : ; < = > ? _
* (52 letters + 10 numbers + 20 punc/sym = 82 total)
*
* In other words, all the graphic characters in 7-bit ASCII should
* be safely accessible except the following:
*
* '\' <backslash>
* '[' <left bracket>
* ']' <right bracket>
* '{' <left brace>
* '}' <right brace>
* '^' <circumflex>
* '~' <tilde>
* '!' <exclamation mark>
* '#' <number sign>
* '|' <vertical line>
* '$' <dollar sign>
* '@' <commercial at>
* '`' <grave accent>
*/
#define U_ASCII_FAMILY 0
#define U_EBCDIC_FAMILY 1
#ifndef U_CHARSET_FAMILY
# define U_CHARSET_FAMILY 0
#endif
/*===========================================================================*/
/* sizeof(whar_t) */
/*===========================================================================*/
/* U_SIZEOF_WCHAR_T==sizeof(wchar_t) */
#ifndef U_SIZEOF_WCHAR_T
# define U_SIZEOF_WCHAR_T 4
#endif
/*===========================================================================*/
/* Unicode string offset */
/*===========================================================================*/
@ -91,6 +144,9 @@ typedef int32_t UTextOffset;
/*===========================================================================*/
typedef uint16_t UChar;
/* U_SIZEOF_UCHAR==sizeof(UChar) */
#define U_SIZEOF_UCHAR 2
/*===========================================================================*/
/* ICU version number */
/*===========================================================================*/