2001-03-21 20:44:20 +00:00
|
|
|
/*
|
|
|
|
**********************************************************************
|
2003-06-03 06:44:40 +00:00
|
|
|
* Copyright (C) 2000-2003, International Business Machines
|
2001-03-21 20:44:20 +00:00
|
|
|
* Corporation and others. All Rights Reserved.
|
|
|
|
**********************************************************************
|
|
|
|
*/
|
|
|
|
|
2000-05-15 18:39:17 +00:00
|
|
|
#ifndef URESIMP_H
|
|
|
|
#define URESIMP_H
|
|
|
|
|
|
|
|
#include "unicode/ures.h"
|
|
|
|
|
|
|
|
#include "uresdata.h"
|
|
|
|
|
|
|
|
#define kRootLocaleName "root"
|
|
|
|
|
|
|
|
/*
|
|
|
|
The default minor version and the version separator must be exactly one
|
|
|
|
character long.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define kDefaultMinorVersion "0"
|
|
|
|
#define kVersionSeparator "."
|
|
|
|
#define kVersionTag "Version"
|
|
|
|
|
2000-07-12 22:59:57 +00:00
|
|
|
#define MAGIC1 19700503
|
|
|
|
#define MAGIC2 19641227
|
|
|
|
|
2002-06-24 20:58:17 +00:00
|
|
|
#define URES_MAX_ALIAS_LEVEL 256
|
|
|
|
|
2001-10-10 18:05:10 +00:00
|
|
|
/*
|
2000-05-15 18:39:17 +00:00
|
|
|
enum UResEntryType {
|
|
|
|
ENTRY_OK = 0,
|
|
|
|
ENTRY_GOTO_ROOT = 1,
|
|
|
|
ENTRY_GOTO_DEFAULT = 2,
|
|
|
|
ENTRY_INVALID = 3
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef enum UResEntryType UResEntryType;
|
2001-10-10 18:05:10 +00:00
|
|
|
*/
|
2000-05-15 18:39:17 +00:00
|
|
|
|
|
|
|
struct UResourceDataEntry;
|
|
|
|
typedef struct UResourceDataEntry UResourceDataEntry;
|
|
|
|
|
|
|
|
struct UResourceDataEntry {
|
|
|
|
char *fName; /* name of the locale for bundle - still to decide whether it is original or fallback */
|
|
|
|
char *fPath; /* path to bundle - used for distinguishing between resources with the same name */
|
|
|
|
uint32_t fCountExisting; /* how much is this resource used */
|
|
|
|
ResourceData fData; /* data for low level access */
|
|
|
|
UResourceDataEntry *fParent; /*next resource in fallback chain*/
|
2001-10-10 18:05:10 +00:00
|
|
|
/* UResEntryType fStatus;*/
|
2000-05-15 18:39:17 +00:00
|
|
|
UErrorCode fBogus;
|
|
|
|
int32_t fHashKey; /* for faster access in the hashtable */
|
|
|
|
};
|
|
|
|
|
2002-06-24 20:58:17 +00:00
|
|
|
#define RES_BUFSIZE 256
|
|
|
|
#define RES_PATH_SEPARATOR '/'
|
|
|
|
#define RES_PATH_SEPARATOR_S "/"
|
|
|
|
|
2000-05-15 18:39:17 +00:00
|
|
|
struct UResourceBundle {
|
|
|
|
const char *fKey; /*tag*/
|
2003-02-28 05:59:24 +00:00
|
|
|
UResourceDataEntry *fData; /*for low-level access*/
|
|
|
|
char *fVersion;
|
2002-06-24 20:58:17 +00:00
|
|
|
char *fResPath; /* full path to the resource: "zh_TW/CollationElements/Sequence" */
|
|
|
|
char fResBuf[RES_BUFSIZE];
|
|
|
|
int32_t fResPathLen;
|
2000-05-18 22:08:39 +00:00
|
|
|
UBool fHasFallback;
|
|
|
|
UBool fIsTopLevel;
|
2003-02-28 05:59:24 +00:00
|
|
|
uint32_t fMagic1; /* For determining if it's a stack object */
|
|
|
|
uint32_t fMagic2; /* For determining if it's a stack object */
|
2000-05-15 18:39:17 +00:00
|
|
|
int32_t fIndex;
|
|
|
|
int32_t fSize;
|
|
|
|
ResourceData fResData;
|
|
|
|
Resource fRes;
|
2002-06-24 20:58:17 +00:00
|
|
|
|
|
|
|
/* parent of this resource -
|
|
|
|
* lives in the same data entry
|
|
|
|
*/
|
|
|
|
/* This cannot be done right now - need support in genrb */
|
|
|
|
/*Resource fParent; */
|
2000-05-15 18:39:17 +00:00
|
|
|
};
|
|
|
|
|
2003-08-13 20:52:53 +00:00
|
|
|
U_CAPI void U_EXPORT2 ures_initStackObject(UResourceBundle* resB);
|
2001-07-27 17:15:30 +00:00
|
|
|
U_CFUNC void ures_setIsStackObject( UResourceBundle* resB, UBool state);
|
|
|
|
U_CFUNC UBool ures_isStackObject( UResourceBundle* resB);
|
2000-05-15 18:39:17 +00:00
|
|
|
|
2001-07-27 17:15:30 +00:00
|
|
|
/* Some getters used by the copy constructor */
|
|
|
|
U_CFUNC const char* ures_getName(const UResourceBundle* resB);
|
|
|
|
U_CFUNC const char* ures_getPath(const UResourceBundle* resB);
|
2003-02-28 05:59:24 +00:00
|
|
|
U_CFUNC void ures_appendResPath(UResourceBundle *resB, const char* toAdd, int32_t lenToAdd);
|
2002-06-24 20:58:17 +00:00
|
|
|
/*U_CFUNC void ures_setResPath(UResourceBundle *resB, const char* toAdd);*/
|
|
|
|
U_CFUNC void ures_freeResPath(UResourceBundle *resB);
|
2001-07-27 17:15:30 +00:00
|
|
|
|
2000-05-15 18:39:17 +00:00
|
|
|
/* Candidates for export */
|
2001-10-04 00:12:19 +00:00
|
|
|
U_CFUNC UResourceBundle *ures_copyResb(UResourceBundle *r, const UResourceBundle *original, UErrorCode *status);
|
2002-07-13 05:36:27 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a resource that can be located using the pathToResource argument. One needs optional package, locale
|
|
|
|
* and path inside the locale, for example: "/myData/en/zoneStrings/3". Keys and indexes are supported. Keys
|
|
|
|
* need to reference data in named structures, while indexes can reference both named and anonymous resources.
|
|
|
|
* Features a fill-in parameter.
|
|
|
|
*
|
|
|
|
* @param pathToResource a path that will lead to the requested resource
|
|
|
|
* @param fillIn if NULL a new UResourceBundle struct is allocated and must be deleted by the caller.
|
|
|
|
* Alternatively, you can supply a struct to be filled by this function.
|
|
|
|
* @param status fills in the outgoing error code.
|
|
|
|
* @return a pointer to a UResourceBundle struct. If fill in param was NULL, caller must delete it
|
|
|
|
* @draft ICU 2.2
|
|
|
|
*/
|
|
|
|
U_CAPI UResourceBundle* U_EXPORT2
|
|
|
|
ures_findResource(const char* pathToResource,
|
|
|
|
UResourceBundle *fillIn, UErrorCode *status);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a sub resource that can be located using the pathToResource argument. One needs a path inside
|
|
|
|
* the supplied resource, for example, if you have "en_US" resource bundle opened, you might ask for
|
|
|
|
* "zoneStrings/3". Keys and indexes are supported. Keys
|
|
|
|
* need to reference data in named structures, while indexes can reference both
|
|
|
|
* named and anonymous resources.
|
|
|
|
* Features a fill-in parameter.
|
|
|
|
*
|
|
|
|
* @param resourceBundle a resource
|
|
|
|
* @param pathToResource a path that will lead to the requested resource
|
|
|
|
* @param fillIn if NULL a new UResourceBundle struct is allocated and must be deleted by the caller.
|
|
|
|
* Alternatively, you can supply a struct to be filled by this function.
|
|
|
|
* @param status fills in the outgoing error code.
|
|
|
|
* @return a pointer to a UResourceBundle struct. If fill in param was NULL, caller must delete it
|
|
|
|
* @draft ICU 2.2
|
|
|
|
*/
|
|
|
|
U_CAPI UResourceBundle* U_EXPORT2
|
|
|
|
ures_findSubResource(const UResourceBundle *resB,
|
|
|
|
const char* pathToResource,
|
|
|
|
UResourceBundle *fillIn, UErrorCode *status);
|
|
|
|
|
2000-05-15 18:39:17 +00:00
|
|
|
#endif /*URESIMP_H*/
|