]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/common/uresimp.h
ICU-400.37.tar.gz
[apple/icu.git] / icuSources / common / uresimp.h
index 55f3eaeca9397f85184ac67ac6619734e62bafe6..4d9ed92da5048e6d9ddfd3c44921d43be4d60115 100644 (file)
@@ -1,6 +1,6 @@
 /*
 **********************************************************************
-*   Copyright (C) 2000-2003, International Business Machines
+*   Copyright (C) 2000-2008, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 **********************************************************************
 */
@@ -27,6 +27,7 @@
 #define MAGIC2 19641227
 
 #define URES_MAX_ALIAS_LEVEL 256
+#define URES_MAX_BUFFER_SIZE 256
 
 /*
 enum UResEntryType {
@@ -45,15 +46,15 @@ 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*/
-/*    UResEntryType fStatus;*/
+    ResourceData fData; /* data for low level access */
+    char fNameBuffer[3]; /* A small buffer of free space for fName. The free space is due to struct padding. */
+    uint32_t fCountExisting; /* how much is this resource used */
     UErrorCode fBogus;
-    int32_t fHashKey; /* for faster access in the hashtable */
+    /* int32_t fHashKey;*/ /* for faster access in the hashtable */
 };
 
-#define RES_BUFSIZE 256
+#define RES_BUFSIZE 64
 #define RES_PATH_SEPARATOR   '/'
 #define RES_PATH_SEPARATOR_S   "/"
 
@@ -61,35 +62,32 @@ struct UResourceBundle {
     const char *fKey; /*tag*/
     UResourceDataEntry *fData; /*for low-level access*/
     char *fVersion;
+    UResourceDataEntry *fTopLevelData; /* for getting the valid locale */
     char *fResPath; /* full path to the resource: "zh_TW/CollationElements/Sequence" */
+    ResourceData fResData;
     char fResBuf[RES_BUFSIZE];
     int32_t fResPathLen;
+    Resource fRes;
     UBool fHasFallback;
     UBool fIsTopLevel;
     uint32_t fMagic1;   /* For determining if it's a stack object */
     uint32_t fMagic2;   /* For determining if it's a stack object */
     int32_t fIndex;
     int32_t fSize;
-    ResourceData fResData;
-    Resource fRes;
 
-    /* parent of this resource - 
-     * lives in the same data entry 
-     */
-    /* This cannot be done right now - need support in genrb */
-    /*Resource fParent; */
+    /*const UResourceBundle *fParentRes;*/ /* needed to get the actual locale for a child resource */
 };
 
-U_CFUNC void ures_initStackObject(UResourceBundle* resB);
-U_CFUNC void ures_setIsStackObject( UResourceBundle* resB, UBool state);
-U_CFUNC UBool ures_isStackObject( UResourceBundle* resB);
+U_CAPI void U_EXPORT2 ures_initStackObject(UResourceBundle* resB);
 
 /* Some getters used by the copy constructor */
 U_CFUNC const char* ures_getName(const UResourceBundle* resB);
+#ifdef URES_DEBUG
 U_CFUNC const char* ures_getPath(const UResourceBundle* resB);
-U_CFUNC void ures_appendResPath(UResourceBundle *resB, const char* toAdd, int32_t lenToAdd);
+#endif
+/*U_CFUNC void ures_appendResPath(UResourceBundle *resB, const char* toAdd, int32_t lenToAdd);*/
 /*U_CFUNC void ures_setResPath(UResourceBundle *resB, const char* toAdd);*/
-U_CFUNC void ures_freeResPath(UResourceBundle *resB);
+/*U_CFUNC void ures_freeResPath(UResourceBundle *resB);*/
 
 /* Candidates for export */
 U_CFUNC UResourceBundle *ures_copyResb(UResourceBundle *r, const UResourceBundle *original, UErrorCode *status);
@@ -99,6 +97,9 @@ U_CFUNC UResourceBundle *ures_copyResb(UResourceBundle *r, const UResourceBundle
  * 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. 
+ * 
+ * Note, this function does NOT have a syntax for specifying items within a tree.  May want to consider a
+ * syntax that delineates between package/tree and 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.
@@ -129,7 +130,86 @@ ures_findResource(const char* pathToResource,
  */
 U_CAPI UResourceBundle* U_EXPORT2
 ures_findSubResource(const UResourceBundle *resB, 
-                     const char* pathToResource, 
+                     char* pathToResource, 
                      UResourceBundle *fillIn, UErrorCode *status);
 
+/**
+ * Returns a functionally equivalent locale (considering keywords) for the specified keyword.
+ * @param result fillin for the equivalent locale
+ * @param resultCapacity capacity of the fillin buffer
+ * @param path path to the tree, or NULL for ICU data
+ * @param resName top level resource. Example: "collations"
+ * @param keyword locale keyword. Example: "collation"
+ * @param locid The requested locale
+ * @param isAvailable If non-null, pointer to fillin parameter that indicates whether the 
+ * requested locale was available. The locale is defined as 'available' if it physically 
+ * exists within the specified tree.
+ * @param omitDefault if TRUE, omit keyword and value if default. 'de_DE\@collation=standard' -> 'de_DE'
+ * @param status error code
+ * @return  the actual buffer size needed for the full locale.  If it's greater 
+ * than resultCapacity, the returned full name will be truncated and an error code will be returned.
+ * @internal ICU 3.0
+ */
+U_INTERNAL int32_t U_EXPORT2
+ures_getFunctionalEquivalent(char *result, int32_t resultCapacity, 
+                             const char *path, const char *resName, const char *keyword, const char *locid,
+                             UBool *isAvailable, UBool omitDefault, UErrorCode *status);
+
+/**
+ * Given a tree path and keyword, return a string enumeration of all possible values for that keyword.
+ * @param path path to the tree, or NULL for ICU data
+ * @param keyword a particular keyword to consider, must match a top level resource name 
+ * within the tree.
+ * @param status error code
+ * @internal ICU 3.0
+ */
+U_INTERNAL UEnumeration* U_EXPORT2
+ures_getKeywordValues(const char *path, const char *keyword, UErrorCode *status);
+
+
+/**
+ * Get a resource with multi-level fallback. Normally only the top level resources will
+ * fallback to its parent. This performs fallback on subresources. For example, when a table
+ * is defined in a resource bundle and a parent resource bundle, normally no fallback occurs
+ * on the sub-resources because the table is defined in the current resource bundle, but this
+ * function can perform fallback on the sub-resources of the table.
+ * @param resB              a resource
+ * @param inKey             a key associated with 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
+ *                could be <TT>U_MISSING_RESOURCE_ERROR</TT> if the key is not found
+ *                could be a non-failing error 
+ *                e.g.: <TT>U_USING_FALLBACK_WARNING</TT>,<TT>U_USING_DEFAULT_WARNING </TT>
+ * @return                  a pointer to a UResourceBundle struct. If fill in param was NULL, caller must delete it
+ * @internal ICU 3.0
+ */
+U_INTERNAL UResourceBundle* U_EXPORT2 
+ures_getByKeyWithFallback(const UResourceBundle *resB, 
+                          const char* inKey, 
+                          UResourceBundle *fillIn, 
+                          UErrorCode *status);
+
+
+/**
+ * Get a String with multi-level fallback. Normally only the top level resources will
+ * fallback to its parent. This performs fallback on subresources. For example, when a table
+ * is defined in a resource bundle and a parent resource bundle, normally no fallback occurs
+ * on the sub-resources because the table is defined in the current resource bundle, but this
+ * function can perform fallback on the sub-resources of the table.
+ * @param resB              a resource
+ * @param inKey             a key associated with the requested resource
+ * @param status: fills in the outgoing error code
+ *                could be <TT>U_MISSING_RESOURCE_ERROR</TT> if the key is not found
+ *                could be a non-failing error 
+ *                e.g.: <TT>U_USING_FALLBACK_WARNING</TT>,<TT>U_USING_DEFAULT_WARNING </TT>
+ * @return                  a pointer to a UResourceBundle struct. If fill in param was NULL, caller must delete it
+ * @internal ICU 3.4
+ * @draft ICU 3.4
+ */
+U_INTERNAL const UChar* U_EXPORT2 
+ures_getStringByKeyWithFallback(const UResourceBundle *resB, 
+                          const char* inKey,  
+                          int32_t* len,
+                          UErrorCode *status);
 #endif /*URESIMP_H*/