+// © 2016 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
*
-* Copyright (C) 2002-2014, International Business Machines
+* Copyright (C) 2002-2015, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
u_strToUTF8(NULL,
0,
&len,
- outString.getBuffer(),
+ toUCharPtr(outString.getBuffer()),
outString.length(),
&status);
u_strToUTF8(dest,
len,
&len,
- outString.getBuffer(),
+ toUCharPtr(outString.getBuffer()),
outString.length(),
&status);
* conversion is not portable across platforms with different endianess.
*/
-uint32_t computeCRC(char *ptr, uint32_t len, uint32_t lastcrc){
+uint32_t computeCRC(const char *ptr, uint32_t len, uint32_t lastcrc){
int32_t crc;
uint32_t temp1;
uint32_t temp2;
#define LF 0x000D
#define AT_SIGN 0x0040
+#if UCONFIG_NO_REGULAR_EXPRESSIONS==0
static void
trim(char **src, int32_t *len){
}
}
+#endif
+
static void
-printNoteElements(struct UString *src, UErrorCode *status){
+printNoteElements(const UString *src, UErrorCode *status){
#if UCONFIG_NO_REGULAR_EXPRESSIONS==0 /* donot compile when no RegularExpressions are available */
write_utf8_file(out, UnicodeString("\""));
}
+#if UCONFIG_NO_REGULAR_EXPRESSIONS==0 /* donot compile when no RegularExpressions are available */
static void printAttribute(const char *name, const UnicodeString value, int32_t /*len*/)
{
write_utf8_file(out, UnicodeString(" "));
write_utf8_file(out, value);
write_utf8_file(out, UnicodeString("\""));
}
+#endif
static void
printComments(struct UString *src, const char *resName, UBool printTranslate, UErrorCode *status){
uprv_free(trans);
return;
}
+ // TODO: make src const, stop modifying it in-place, make printContainer() take const resource, etc.
src->fLength = removeCmtText(src->fChars, src->fLength, status);
descLen = getDescription(src->fChars,src->fLength, &desc, capacity, status);
transLen = getTranslate(src->fChars,src->fLength, &trans, capacity, status);
* <trans-unit id = "blah" resname = "blah" restype = "x-id-alias" translate = "no">
* <group id "calendar_gregorian" resname = "gregorian" restype = "x-icu-array">
*/
-static char *printContainer(struct SResource *res, const char *container, const char *restype, const char *mimetype, const char *id, UErrorCode *status)
+static char *printContainer(SResource *res, const char *container, const char *restype, const char *mimetype, const char *id, UErrorCode *status)
{
- char resKeyBuffer[8];
const char *resname = NULL;
char *sid = NULL;
write_tabs(out);
- resname = res_getKeyString(srBundle, res, resKeyBuffer);
+ resname = res->getKeyString(srBundle);
if (resname != NULL && *resname != 0) {
sid = getID(id, resname, sid);
} else {
static const char *table_restype = "x-icu-table";
static void
-string_write_xml(struct SResource *res, const char* id, const char* /*language*/, UErrorCode *status) {
+string_write_xml(StringResource *res, const char* id, const char* /*language*/, UErrorCode *status) {
char *sid = NULL;
char* buf = NULL;
write_utf8_file(out, UnicodeString(source));
- buf = convertAndEscape(&buf, 0, &bufLen, res->u.fString.fChars, res->u.fString.fLength, status);
+ buf = convertAndEscape(&buf, 0, &bufLen, res->getBuffer(), res->length(), status);
if (U_FAILURE(*status)) {
return;
}
static void
-alias_write_xml(struct SResource *res, const char* id, const char* /*language*/, UErrorCode *status) {
+alias_write_xml(AliasResource *res, const char* id, const char* /*language*/, UErrorCode *status) {
char *sid = NULL;
char* buf = NULL;
int32_t bufLen=0;
write_utf8_file(out, UnicodeString(source));
- buf = convertAndEscape(&buf, 0, &bufLen, res->u.fString.fChars, res->u.fString.fLength, status);
+ buf = convertAndEscape(&buf, 0, &bufLen, res->getBuffer(), res->length(), status);
if(U_FAILURE(*status)){
return;
}
static void
-array_write_xml(struct SResource *res, const char* id, const char* language, UErrorCode *status) {
+array_write_xml(ArrayResource *res, const char* id, const char* language, UErrorCode *status) {
char* sid = NULL;
int index = 0;
sid = printContainer(res, group, array_restype, NULL, id, status);
- current = res->u.fArray.fFirst;
+ current = res->fFirst;
while (current != NULL) {
char c[256] = {0};
}
static void
-intvector_write_xml(struct SResource *res, const char* id, const char* /*language*/, UErrorCode *status) {
+intvector_write_xml(IntVectorResource *res, const char* id, const char* /*language*/, UErrorCode *status) {
char* sid = NULL;
char* ivd = NULL;
uint32_t i=0;
sid = printContainer(res, group, intvector_restype, NULL, id, status);
- for(i = 0; i < res->u.fIntVector.fCount; i += 1) {
+ for(i = 0; i < res->fCount; i += 1) {
char c[256] = {0};
itostr(c, i, 10, 0);
ivd = getID(sid, c, ivd);
- len = itostr(buf, res->u.fIntVector.fArray[i], 10, 0);
+ len = itostr(buf, res->fArray[i], 10, 0);
write_tabs(out);
write_utf8_file(out, UnicodeString("<"));
}
static void
-int_write_xml(struct SResource *res, const char* id, const char* /*language*/, UErrorCode *status) {
+int_write_xml(IntResource *res, const char* id, const char* /*language*/, UErrorCode *status) {
char* sid = NULL;
char buf[256] = {0};
uint32_t len = 0;
write_utf8_file(out, UnicodeString(source));
- len = itostr(buf, res->u.fIntValue.fValue, 10, 0);
+ len = itostr(buf, res->fValue, 10, 0);
write_utf8_file(out, UnicodeString(buf, len));
write_utf8_file(out, UnicodeString(close_source));
}
static void
-bin_write_xml(struct SResource *res, const char* id, const char* /*language*/, UErrorCode *status) {
+bin_write_xml(BinaryResource *res, const char* id, const char* /*language*/, UErrorCode *status) {
const char* m_type = application_mimetype;
char* sid = NULL;
uint32_t crc = 0xFFFFFFFF;
char fileName[1024] ={0};
int32_t tLen = ( outDir == NULL) ? 0 :(int32_t)uprv_strlen(outDir);
char* fn = (char*) uprv_malloc(sizeof(char) * (tLen+1024 +
- (res->u.fBinaryValue.fFileName !=NULL ?
- uprv_strlen(res->u.fBinaryValue.fFileName) :0)));
+ (res->fFileName !=NULL ?
+ uprv_strlen(res->fFileName) :0)));
const char* ext = NULL;
char* f = NULL;
fn[0]=0;
- if(res->u.fBinaryValue.fFileName != NULL){
- uprv_strcpy(fileName, res->u.fBinaryValue.fFileName);
+ if(res->fFileName != NULL){
+ uprv_strcpy(fileName, res->fFileName);
f = uprv_strrchr(fileName, '\\');
if (f != NULL) {
write_utf8_file(out, UnicodeString(internal_file));
printAttribute("form", application_mimetype, (int32_t) uprv_strlen(application_mimetype));
- while(i <res->u.fBinaryValue.fLength){
- len = itostr(temp, res->u.fBinaryValue.fData[i], 16, 2);
+ while(i <res->fLength){
+ len = itostr(temp, res->fData[i], 16, 2);
crc = computeCRC(temp, len, crc);
i++;
}
write_utf8_file(out, UnicodeString(">"));
i = 0;
- while(i <res->u.fBinaryValue.fLength){
- len = itostr(temp, res->u.fBinaryValue.fData[i], 16, 2);
+ while(i <res->fLength){
+ len = itostr(temp, res->fData[i], 16, 2);
write_utf8_file(out, UnicodeString(temp));
i += 1;
}
static void
-table_write_xml(struct SResource *res, const char* id, const char* language, UBool isTopLevel, UErrorCode *status) {
+table_write_xml(TableResource *res, const char* id, const char* language, UBool isTopLevel, UErrorCode *status) {
uint32_t i = 0;
sid[0] = '\0';
}
- current = res->u.fTable.fFirst;
+ current = res->fFirst;
i = 0;
while (current != NULL) {
if (res != NULL) {
switch (res->fType) {
case URES_STRING:
- string_write_xml (res, id, language, status);
+ string_write_xml (static_cast<StringResource *>(res), id, language, status);
return;
case URES_ALIAS:
- alias_write_xml (res, id, language, status);
+ alias_write_xml (static_cast<AliasResource *>(res), id, language, status);
return;
case URES_INT_VECTOR:
- intvector_write_xml (res, id, language, status);
+ intvector_write_xml (static_cast<IntVectorResource *>(res), id, language, status);
return;
case URES_BINARY:
- bin_write_xml (res, id, language, status);
+ bin_write_xml (static_cast<BinaryResource *>(res), id, language, status);
return;
case URES_INT:
- int_write_xml (res, id, language, status);
+ int_write_xml (static_cast<IntResource *>(res), id, language, status);
return;
case URES_ARRAY:
- array_write_xml (res, id, language, status);
+ array_write_xml (static_cast<ArrayResource *>(res), id, language, status);
return;
case URES_TABLE:
- table_write_xml (res, id, language, isTopLevel, status);
+ table_write_xml (static_cast<TableResource *>(res), id, language, isTopLevel, status);
return;
default: