OLD | NEW |
1 /* | 1 /* |
2 ******************************************************************************* | 2 ******************************************************************************* |
3 * | 3 * |
4 * Copyright (C) 2002-2014, International Business Machines | 4 * Copyright (C) 2002-2015, International Business Machines |
5 * Corporation and others. All Rights Reserved. | 5 * Corporation and others. All Rights Reserved. |
6 * | 6 * |
7 ******************************************************************************* | 7 ******************************************************************************* |
8 * | 8 * |
9 * File wrtxml.cpp | 9 * File wrtxml.cpp |
10 * | 10 * |
11 * Modification History: | 11 * Modification History: |
12 * | 12 * |
13 * Date Name Description | 13 * Date Name Description |
14 * 10/01/02 Ram Creation. | 14 * 10/01/02 Ram Creation. |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 * | 129 * |
130 * @author Michael Lecuyer (mjl@theorem.com) | 130 * @author Michael Lecuyer (mjl@theorem.com) |
131 * @version 1.1 August 11, 1998 | 131 * @version 1.1 August 11, 1998 |
132 */ | 132 */ |
133 | 133 |
134 /* ICU is not endian portable, because ICU data generated on big endian machines
can be | 134 /* ICU is not endian portable, because ICU data generated on big endian machines
can be |
135 * ported to big endian machines but not to little endian machines and vice vers
a. The | 135 * ported to big endian machines but not to little endian machines and vice vers
a. The |
136 * conversion is not portable across platforms with different endianess. | 136 * conversion is not portable across platforms with different endianess. |
137 */ | 137 */ |
138 | 138 |
139 uint32_t computeCRC(char *ptr, uint32_t len, uint32_t lastcrc){ | 139 uint32_t computeCRC(const char *ptr, uint32_t len, uint32_t lastcrc){ |
140 int32_t crc; | 140 int32_t crc; |
141 uint32_t temp1; | 141 uint32_t temp1; |
142 uint32_t temp2; | 142 uint32_t temp2; |
143 | 143 |
144 int32_t crc_ta[256]; | 144 int32_t crc_ta[256]; |
145 int i = 0; | 145 int i = 0; |
146 int j = 0; | 146 int j = 0; |
147 uint32_t crc2 = 0; | 147 uint32_t crc2 = 0; |
148 | 148 |
149 #define CRC32_POLYNOMIAL 0xEDB88320 | 149 #define CRC32_POLYNOMIAL 0xEDB88320 |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 if(U_SUCCESS(*status)){ | 412 if(U_SUCCESS(*status)){ |
413 trim(&buf,&bufLen); | 413 trim(&buf,&bufLen); |
414 write_utf8_file(out,UnicodeString(tagStart)); | 414 write_utf8_file(out,UnicodeString(tagStart)); |
415 write_utf8_file(out,UnicodeString(buf, bufLen, "UTF-8")); | 415 write_utf8_file(out,UnicodeString(buf, bufLen, "UTF-8")); |
416 write_utf8_file(out,UnicodeString(tagEnd)); | 416 write_utf8_file(out,UnicodeString(tagEnd)); |
417 write_utf8_file(out,UnicodeString("\n")); | 417 write_utf8_file(out,UnicodeString("\n")); |
418 | 418 |
419 } | 419 } |
420 } | 420 } |
421 static void | 421 static void |
422 printNoteElements(struct UString *src, UErrorCode *status){ | 422 printNoteElements(const UString *src, UErrorCode *status){ |
423 | 423 |
424 #if UCONFIG_NO_REGULAR_EXPRESSIONS==0 /* donot compile when no RegularExpression
s are available */ | 424 #if UCONFIG_NO_REGULAR_EXPRESSIONS==0 /* donot compile when no RegularExpression
s are available */ |
425 | 425 |
426 int32_t capacity = 0; | 426 int32_t capacity = 0; |
427 UChar* note = NULL; | 427 UChar* note = NULL; |
428 int32_t noteLen = 0; | 428 int32_t noteLen = 0; |
429 int32_t count = 0,i; | 429 int32_t count = 0,i; |
430 | 430 |
431 if(src == NULL){ | 431 if(src == NULL){ |
432 return; | 432 return; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 UChar* desc = (UChar*) uprv_malloc(U_SIZEOF_UCHAR * capacity); | 493 UChar* desc = (UChar*) uprv_malloc(U_SIZEOF_UCHAR * capacity); |
494 UChar* trans = (UChar*) uprv_malloc(U_SIZEOF_UCHAR * capacity); | 494 UChar* trans = (UChar*) uprv_malloc(U_SIZEOF_UCHAR * capacity); |
495 | 495 |
496 int32_t descLen = 0, transLen=0; | 496 int32_t descLen = 0, transLen=0; |
497 if(desc==NULL || trans==NULL){ | 497 if(desc==NULL || trans==NULL){ |
498 *status = U_MEMORY_ALLOCATION_ERROR; | 498 *status = U_MEMORY_ALLOCATION_ERROR; |
499 uprv_free(desc); | 499 uprv_free(desc); |
500 uprv_free(trans); | 500 uprv_free(trans); |
501 return; | 501 return; |
502 } | 502 } |
| 503 // TODO: make src const, stop modifying it in-place, make printContainer() t
ake const resource, etc. |
503 src->fLength = removeCmtText(src->fChars, src->fLength, status); | 504 src->fLength = removeCmtText(src->fChars, src->fLength, status); |
504 descLen = getDescription(src->fChars,src->fLength, &desc, capacity, status)
; | 505 descLen = getDescription(src->fChars,src->fLength, &desc, capacity, status)
; |
505 transLen = getTranslate(src->fChars,src->fLength, &trans, capacity, status); | 506 transLen = getTranslate(src->fChars,src->fLength, &trans, capacity, status); |
506 | 507 |
507 /* first print translate attribute */ | 508 /* first print translate attribute */ |
508 if(transLen > 0){ | 509 if(transLen > 0){ |
509 if(printTranslate){ | 510 if(printTranslate){ |
510 /* print translate attribute */ | 511 /* print translate attribute */ |
511 buf = convertAndEscape(&buf, 0, &bufLen, trans, transLen, status); | 512 buf = convertAndEscape(&buf, 0, &bufLen, trans, transLen, status); |
512 if(U_SUCCESS(*status)){ | 513 if(U_SUCCESS(*status)){ |
(...skipping 23 matching lines...) Expand all Loading... |
536 | 537 |
537 #endif /* UCONFIG_NO_REGULAR_EXPRESSIONS */ | 538 #endif /* UCONFIG_NO_REGULAR_EXPRESSIONS */ |
538 | 539 |
539 } | 540 } |
540 | 541 |
541 /* | 542 /* |
542 * Print out a containing element, like: | 543 * Print out a containing element, like: |
543 * <trans-unit id = "blah" resname = "blah" restype = "x-id-alias" translate = "
no"> | 544 * <trans-unit id = "blah" resname = "blah" restype = "x-id-alias" translate = "
no"> |
544 * <group id "calendar_gregorian" resname = "gregorian" restype = "x-icu-array"> | 545 * <group id "calendar_gregorian" resname = "gregorian" restype = "x-icu-array"> |
545 */ | 546 */ |
546 static char *printContainer(struct SResource *res, const char *container, const
char *restype, const char *mimetype, const char *id, UErrorCode *status) | 547 static char *printContainer(SResource *res, const char *container, const char *r
estype, const char *mimetype, const char *id, UErrorCode *status) |
547 { | 548 { |
548 char resKeyBuffer[8]; | |
549 const char *resname = NULL; | 549 const char *resname = NULL; |
550 char *sid = NULL; | 550 char *sid = NULL; |
551 | 551 |
552 write_tabs(out); | 552 write_tabs(out); |
553 | 553 |
554 resname = res_getKeyString(srBundle, res, resKeyBuffer); | 554 resname = res->getKeyString(srBundle); |
555 if (resname != NULL && *resname != 0) { | 555 if (resname != NULL && *resname != 0) { |
556 sid = getID(id, resname, sid); | 556 sid = getID(id, resname, sid); |
557 } else { | 557 } else { |
558 sid = getID(id, NULL, sid); | 558 sid = getID(id, NULL, sid); |
559 } | 559 } |
560 | 560 |
561 write_utf8_file(out, UnicodeString("<")); | 561 write_utf8_file(out, UnicodeString("<")); |
562 write_utf8_file(out, UnicodeString(container)); | 562 write_utf8_file(out, UnicodeString(container)); |
563 printAttribute("id", sid, (int32_t) uprv_strlen(sid)); | 563 printAttribute("id", sid, (int32_t) uprv_strlen(sid)); |
564 | 564 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
606 static const char *application_mimetype = "application"; /* add "/octet-stream"?
*/ | 606 static const char *application_mimetype = "application"; /* add "/octet-stream"?
*/ |
607 | 607 |
608 static const char *alias_restype = "x-icu-alias"; | 608 static const char *alias_restype = "x-icu-alias"; |
609 static const char *array_restype = "x-icu-array"; | 609 static const char *array_restype = "x-icu-array"; |
610 static const char *binary_restype = "x-icu-binary"; | 610 static const char *binary_restype = "x-icu-binary"; |
611 static const char *integer_restype = "x-icu-integer"; | 611 static const char *integer_restype = "x-icu-integer"; |
612 static const char *intvector_restype = "x-icu-intvector"; | 612 static const char *intvector_restype = "x-icu-intvector"; |
613 static const char *table_restype = "x-icu-table"; | 613 static const char *table_restype = "x-icu-table"; |
614 | 614 |
615 static void | 615 static void |
616 string_write_xml(struct SResource *res, const char* id, const char* /*language*/
, UErrorCode *status) { | 616 string_write_xml(StringResource *res, const char* id, const char* /*language*/,
UErrorCode *status) { |
617 | 617 |
618 char *sid = NULL; | 618 char *sid = NULL; |
619 char* buf = NULL; | 619 char* buf = NULL; |
620 int32_t bufLen = 0; | 620 int32_t bufLen = 0; |
621 | 621 |
622 if(status==NULL || U_FAILURE(*status)){ | 622 if(status==NULL || U_FAILURE(*status)){ |
623 return; | 623 return; |
624 } | 624 } |
625 | 625 |
626 sid = printContainer(res, trans_unit, NULL, NULL, id, status); | 626 sid = printContainer(res, trans_unit, NULL, NULL, id, status); |
627 | 627 |
628 write_tabs(out); | 628 write_tabs(out); |
629 | 629 |
630 write_utf8_file(out, UnicodeString(source)); | 630 write_utf8_file(out, UnicodeString(source)); |
631 | 631 |
632 buf = convertAndEscape(&buf, 0, &bufLen, res->u.fString.fChars, res->u.fStri
ng.fLength, status); | 632 buf = convertAndEscape(&buf, 0, &bufLen, res->getBuffer(), res->length(), st
atus); |
633 | 633 |
634 if (U_FAILURE(*status)) { | 634 if (U_FAILURE(*status)) { |
635 return; | 635 return; |
636 } | 636 } |
637 | 637 |
638 write_utf8_file(out, UnicodeString(buf, bufLen, "UTF-8")); | 638 write_utf8_file(out, UnicodeString(buf, bufLen, "UTF-8")); |
639 write_utf8_file(out, UnicodeString(close_source)); | 639 write_utf8_file(out, UnicodeString(close_source)); |
640 | 640 |
641 printNoteElements(&res->fComment, status); | 641 printNoteElements(&res->fComment, status); |
642 | 642 |
643 tabCount -= 1; | 643 tabCount -= 1; |
644 write_tabs(out); | 644 write_tabs(out); |
645 | 645 |
646 write_utf8_file(out, UnicodeString(close_trans_unit)); | 646 write_utf8_file(out, UnicodeString(close_trans_unit)); |
647 | 647 |
648 uprv_free(buf); | 648 uprv_free(buf); |
649 uprv_free(sid); | 649 uprv_free(sid); |
650 } | 650 } |
651 | 651 |
652 static void | 652 static void |
653 alias_write_xml(struct SResource *res, const char* id, const char* /*language*/,
UErrorCode *status) { | 653 alias_write_xml(AliasResource *res, const char* id, const char* /*language*/, UE
rrorCode *status) { |
654 char *sid = NULL; | 654 char *sid = NULL; |
655 char* buf = NULL; | 655 char* buf = NULL; |
656 int32_t bufLen=0; | 656 int32_t bufLen=0; |
657 | 657 |
658 sid = printContainer(res, trans_unit, alias_restype, NULL, id, status); | 658 sid = printContainer(res, trans_unit, alias_restype, NULL, id, status); |
659 | 659 |
660 write_tabs(out); | 660 write_tabs(out); |
661 | 661 |
662 write_utf8_file(out, UnicodeString(source)); | 662 write_utf8_file(out, UnicodeString(source)); |
663 | 663 |
664 buf = convertAndEscape(&buf, 0, &bufLen, res->u.fString.fChars, res->u.fStri
ng.fLength, status); | 664 buf = convertAndEscape(&buf, 0, &bufLen, res->getBuffer(), res->length(), st
atus); |
665 | 665 |
666 if(U_FAILURE(*status)){ | 666 if(U_FAILURE(*status)){ |
667 return; | 667 return; |
668 } | 668 } |
669 write_utf8_file(out, UnicodeString(buf, bufLen, "UTF-8")); | 669 write_utf8_file(out, UnicodeString(buf, bufLen, "UTF-8")); |
670 write_utf8_file(out, UnicodeString(close_source)); | 670 write_utf8_file(out, UnicodeString(close_source)); |
671 | 671 |
672 printNoteElements(&res->fComment, status); | 672 printNoteElements(&res->fComment, status); |
673 | 673 |
674 tabCount -= 1; | 674 tabCount -= 1; |
675 write_tabs(out); | 675 write_tabs(out); |
676 | 676 |
677 write_utf8_file(out, UnicodeString(close_trans_unit)); | 677 write_utf8_file(out, UnicodeString(close_trans_unit)); |
678 | 678 |
679 uprv_free(buf); | 679 uprv_free(buf); |
680 uprv_free(sid); | 680 uprv_free(sid); |
681 } | 681 } |
682 | 682 |
683 static void | 683 static void |
684 array_write_xml(struct SResource *res, const char* id, const char* language, UEr
rorCode *status) { | 684 array_write_xml(ArrayResource *res, const char* id, const char* language, UError
Code *status) { |
685 char* sid = NULL; | 685 char* sid = NULL; |
686 int index = 0; | 686 int index = 0; |
687 | 687 |
688 struct SResource *current = NULL; | 688 struct SResource *current = NULL; |
689 | 689 |
690 sid = printContainer(res, group, array_restype, NULL, id, status); | 690 sid = printContainer(res, group, array_restype, NULL, id, status); |
691 | 691 |
692 current = res->u.fArray.fFirst; | 692 current = res->fFirst; |
693 | 693 |
694 while (current != NULL) { | 694 while (current != NULL) { |
695 char c[256] = {0}; | 695 char c[256] = {0}; |
696 char* subId = NULL; | 696 char* subId = NULL; |
697 | 697 |
698 itostr(c, index, 10, 0); | 698 itostr(c, index, 10, 0); |
699 index += 1; | 699 index += 1; |
700 subId = getID(sid, c, subId); | 700 subId = getID(sid, c, subId); |
701 | 701 |
702 res_write_xml(current, subId, language, FALSE, status); | 702 res_write_xml(current, subId, language, FALSE, status); |
703 uprv_free(subId); | 703 uprv_free(subId); |
704 subId = NULL; | 704 subId = NULL; |
705 | 705 |
706 if(U_FAILURE(*status)){ | 706 if(U_FAILURE(*status)){ |
707 return; | 707 return; |
708 } | 708 } |
709 | 709 |
710 current = current->fNext; | 710 current = current->fNext; |
711 } | 711 } |
712 | 712 |
713 tabCount -= 1; | 713 tabCount -= 1; |
714 write_tabs(out); | 714 write_tabs(out); |
715 write_utf8_file(out, UnicodeString(close_group)); | 715 write_utf8_file(out, UnicodeString(close_group)); |
716 | 716 |
717 uprv_free(sid); | 717 uprv_free(sid); |
718 } | 718 } |
719 | 719 |
720 static void | 720 static void |
721 intvector_write_xml(struct SResource *res, const char* id, const char* /*languag
e*/, UErrorCode *status) { | 721 intvector_write_xml(IntVectorResource *res, const char* id, const char* /*langua
ge*/, UErrorCode *status) { |
722 char* sid = NULL; | 722 char* sid = NULL; |
723 char* ivd = NULL; | 723 char* ivd = NULL; |
724 uint32_t i=0; | 724 uint32_t i=0; |
725 uint32_t len=0; | 725 uint32_t len=0; |
726 char buf[256] = {'0'}; | 726 char buf[256] = {'0'}; |
727 | 727 |
728 sid = printContainer(res, group, intvector_restype, NULL, id, status); | 728 sid = printContainer(res, group, intvector_restype, NULL, id, status); |
729 | 729 |
730 for(i = 0; i < res->u.fIntVector.fCount; i += 1) { | 730 for(i = 0; i < res->fCount; i += 1) { |
731 char c[256] = {0}; | 731 char c[256] = {0}; |
732 | 732 |
733 itostr(c, i, 10, 0); | 733 itostr(c, i, 10, 0); |
734 ivd = getID(sid, c, ivd); | 734 ivd = getID(sid, c, ivd); |
735 len = itostr(buf, res->u.fIntVector.fArray[i], 10, 0); | 735 len = itostr(buf, res->fArray[i], 10, 0); |
736 | 736 |
737 write_tabs(out); | 737 write_tabs(out); |
738 write_utf8_file(out, UnicodeString("<")); | 738 write_utf8_file(out, UnicodeString("<")); |
739 write_utf8_file(out, UnicodeString(trans_unit)); | 739 write_utf8_file(out, UnicodeString(trans_unit)); |
740 | 740 |
741 printAttribute("id", ivd, (int32_t)uprv_strlen(ivd)); | 741 printAttribute("id", ivd, (int32_t)uprv_strlen(ivd)); |
742 printAttribute("restype", integer_restype, (int32_t) strlen(integer_rest
ype)); | 742 printAttribute("restype", integer_restype, (int32_t) strlen(integer_rest
ype)); |
743 | 743 |
744 write_utf8_file(out, UnicodeString(">\n")); | 744 write_utf8_file(out, UnicodeString(">\n")); |
745 | 745 |
(...skipping 14 matching lines...) Expand all Loading... |
760 | 760 |
761 tabCount -= 1; | 761 tabCount -= 1; |
762 write_tabs(out); | 762 write_tabs(out); |
763 | 763 |
764 write_utf8_file(out, UnicodeString(close_group)); | 764 write_utf8_file(out, UnicodeString(close_group)); |
765 uprv_free(sid); | 765 uprv_free(sid); |
766 sid = NULL; | 766 sid = NULL; |
767 } | 767 } |
768 | 768 |
769 static void | 769 static void |
770 int_write_xml(struct SResource *res, const char* id, const char* /*language*/, U
ErrorCode *status) { | 770 int_write_xml(IntResource *res, const char* id, const char* /*language*/, UError
Code *status) { |
771 char* sid = NULL; | 771 char* sid = NULL; |
772 char buf[256] = {0}; | 772 char buf[256] = {0}; |
773 uint32_t len = 0; | 773 uint32_t len = 0; |
774 | 774 |
775 sid = printContainer(res, trans_unit, integer_restype, NULL, id, status); | 775 sid = printContainer(res, trans_unit, integer_restype, NULL, id, status); |
776 | 776 |
777 write_tabs(out); | 777 write_tabs(out); |
778 | 778 |
779 write_utf8_file(out, UnicodeString(source)); | 779 write_utf8_file(out, UnicodeString(source)); |
780 | 780 |
781 len = itostr(buf, res->u.fIntValue.fValue, 10, 0); | 781 len = itostr(buf, res->fValue, 10, 0); |
782 write_utf8_file(out, UnicodeString(buf, len)); | 782 write_utf8_file(out, UnicodeString(buf, len)); |
783 | 783 |
784 write_utf8_file(out, UnicodeString(close_source)); | 784 write_utf8_file(out, UnicodeString(close_source)); |
785 | 785 |
786 printNoteElements(&res->fComment, status); | 786 printNoteElements(&res->fComment, status); |
787 | 787 |
788 tabCount -= 1; | 788 tabCount -= 1; |
789 write_tabs(out); | 789 write_tabs(out); |
790 | 790 |
791 write_utf8_file(out, UnicodeString(close_trans_unit)); | 791 write_utf8_file(out, UnicodeString(close_trans_unit)); |
792 | 792 |
793 uprv_free(sid); | 793 uprv_free(sid); |
794 sid = NULL; | 794 sid = NULL; |
795 } | 795 } |
796 | 796 |
797 static void | 797 static void |
798 bin_write_xml(struct SResource *res, const char* id, const char* /*language*/, U
ErrorCode *status) { | 798 bin_write_xml(BinaryResource *res, const char* id, const char* /*language*/, UEr
rorCode *status) { |
799 const char* m_type = application_mimetype; | 799 const char* m_type = application_mimetype; |
800 char* sid = NULL; | 800 char* sid = NULL; |
801 uint32_t crc = 0xFFFFFFFF; | 801 uint32_t crc = 0xFFFFFFFF; |
802 | 802 |
803 char fileName[1024] ={0}; | 803 char fileName[1024] ={0}; |
804 int32_t tLen = ( outDir == NULL) ? 0 :(int32_t)uprv_strlen(outDir); | 804 int32_t tLen = ( outDir == NULL) ? 0 :(int32_t)uprv_strlen(outDir); |
805 char* fn = (char*) uprv_malloc(sizeof(char) * (tLen+1024 + | 805 char* fn = (char*) uprv_malloc(sizeof(char) * (tLen+1024 + |
806 (res->u.fBinaryValue.fFileNa
me !=NULL ? | 806 (res->fFileName !=NULL ? |
807 uprv_strlen(res->u.fBinaryVa
lue.fFileName) :0))); | 807 uprv_strlen(res->fFileName)
:0))); |
808 const char* ext = NULL; | 808 const char* ext = NULL; |
809 | 809 |
810 char* f = NULL; | 810 char* f = NULL; |
811 | 811 |
812 fn[0]=0; | 812 fn[0]=0; |
813 | 813 |
814 if(res->u.fBinaryValue.fFileName != NULL){ | 814 if(res->fFileName != NULL){ |
815 uprv_strcpy(fileName, res->u.fBinaryValue.fFileName); | 815 uprv_strcpy(fileName, res->fFileName); |
816 f = uprv_strrchr(fileName, '\\'); | 816 f = uprv_strrchr(fileName, '\\'); |
817 | 817 |
818 if (f != NULL) { | 818 if (f != NULL) { |
819 f++; | 819 f++; |
820 } else { | 820 } else { |
821 f = fileName; | 821 f = fileName; |
822 } | 822 } |
823 | 823 |
824 ext = uprv_strrchr(fileName, '.'); | 824 ext = uprv_strrchr(fileName, '.'); |
825 | 825 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
868 | 868 |
869 write_tabs(out); | 869 write_tabs(out); |
870 write_utf8_file(out, UnicodeString(bin_source)); | 870 write_utf8_file(out, UnicodeString(bin_source)); |
871 | 871 |
872 tabCount += 1; | 872 tabCount += 1; |
873 write_tabs(out); | 873 write_tabs(out); |
874 | 874 |
875 write_utf8_file(out, UnicodeString(internal_file)); | 875 write_utf8_file(out, UnicodeString(internal_file)); |
876 printAttribute("form", application_mimetype, (int32_t) uprv_strlen(appli
cation_mimetype)); | 876 printAttribute("form", application_mimetype, (int32_t) uprv_strlen(appli
cation_mimetype)); |
877 | 877 |
878 while(i <res->u.fBinaryValue.fLength){ | 878 while(i <res->fLength){ |
879 len = itostr(temp, res->u.fBinaryValue.fData[i], 16, 2); | 879 len = itostr(temp, res->fData[i], 16, 2); |
880 crc = computeCRC(temp, len, crc); | 880 crc = computeCRC(temp, len, crc); |
881 i++; | 881 i++; |
882 } | 882 } |
883 | 883 |
884 len = itostr(temp, crc, 10, 0); | 884 len = itostr(temp, crc, 10, 0); |
885 printAttribute("crc", temp, len); | 885 printAttribute("crc", temp, len); |
886 | 886 |
887 write_utf8_file(out, UnicodeString(">")); | 887 write_utf8_file(out, UnicodeString(">")); |
888 | 888 |
889 i = 0; | 889 i = 0; |
890 while(i <res->u.fBinaryValue.fLength){ | 890 while(i <res->fLength){ |
891 len = itostr(temp, res->u.fBinaryValue.fData[i], 16, 2); | 891 len = itostr(temp, res->fData[i], 16, 2); |
892 write_utf8_file(out, UnicodeString(temp)); | 892 write_utf8_file(out, UnicodeString(temp)); |
893 i += 1; | 893 i += 1; |
894 } | 894 } |
895 | 895 |
896 write_utf8_file(out, UnicodeString(close_internal_file)); | 896 write_utf8_file(out, UnicodeString(close_internal_file)); |
897 | 897 |
898 tabCount -= 2; | 898 tabCount -= 2; |
899 write_tabs(out); | 899 write_tabs(out); |
900 | 900 |
901 write_utf8_file(out, UnicodeString(close_bin_source)); | 901 write_utf8_file(out, UnicodeString(close_bin_source)); |
902 printNoteElements(&res->fComment, status); | 902 printNoteElements(&res->fComment, status); |
903 | 903 |
904 tabCount -= 1; | 904 tabCount -= 1; |
905 write_tabs(out); | 905 write_tabs(out); |
906 write_utf8_file(out, UnicodeString(close_bin_unit)); | 906 write_utf8_file(out, UnicodeString(close_bin_unit)); |
907 | 907 |
908 uprv_free(sid); | 908 uprv_free(sid); |
909 sid = NULL; | 909 sid = NULL; |
910 } | 910 } |
911 | 911 |
912 uprv_free(fn); | 912 uprv_free(fn); |
913 } | 913 } |
914 | 914 |
915 | 915 |
916 | 916 |
917 static void | 917 static void |
918 table_write_xml(struct SResource *res, const char* id, const char* language, UBo
ol isTopLevel, UErrorCode *status) { | 918 table_write_xml(TableResource *res, const char* id, const char* language, UBool
isTopLevel, UErrorCode *status) { |
919 | 919 |
920 uint32_t i = 0; | 920 uint32_t i = 0; |
921 | 921 |
922 struct SResource *current = NULL; | 922 struct SResource *current = NULL; |
923 char* sid = NULL; | 923 char* sid = NULL; |
924 | 924 |
925 if (U_FAILURE(*status)) { | 925 if (U_FAILURE(*status)) { |
926 return ; | 926 return ; |
927 } | 927 } |
928 | 928 |
929 sid = printContainer(res, group, table_restype, NULL, id, status); | 929 sid = printContainer(res, group, table_restype, NULL, id, status); |
930 | 930 |
931 if(isTopLevel) { | 931 if(isTopLevel) { |
932 sid[0] = '\0'; | 932 sid[0] = '\0'; |
933 } | 933 } |
934 | 934 |
935 current = res->u.fTable.fFirst; | 935 current = res->fFirst; |
936 i = 0; | 936 i = 0; |
937 | 937 |
938 while (current != NULL) { | 938 while (current != NULL) { |
939 res_write_xml(current, sid, language, FALSE, status); | 939 res_write_xml(current, sid, language, FALSE, status); |
940 | 940 |
941 if(U_FAILURE(*status)){ | 941 if(U_FAILURE(*status)){ |
942 return; | 942 return; |
943 } | 943 } |
944 | 944 |
945 i += 1; | 945 i += 1; |
(...skipping 12 matching lines...) Expand all Loading... |
958 void | 958 void |
959 res_write_xml(struct SResource *res, const char* id, const char* language, UBoo
l isTopLevel, UErrorCode *status) { | 959 res_write_xml(struct SResource *res, const char* id, const char* language, UBoo
l isTopLevel, UErrorCode *status) { |
960 | 960 |
961 if (U_FAILURE(*status)) { | 961 if (U_FAILURE(*status)) { |
962 return ; | 962 return ; |
963 } | 963 } |
964 | 964 |
965 if (res != NULL) { | 965 if (res != NULL) { |
966 switch (res->fType) { | 966 switch (res->fType) { |
967 case URES_STRING: | 967 case URES_STRING: |
968 string_write_xml (res, id, language, status); | 968 string_write_xml (static_cast<StringResource *>(res), id, langua
ge, status); |
969 return; | 969 return; |
970 | 970 |
971 case URES_ALIAS: | 971 case URES_ALIAS: |
972 alias_write_xml (res, id, language, status); | 972 alias_write_xml (static_cast<AliasResource *>(res), id, languag
e, status); |
973 return; | 973 return; |
974 | 974 |
975 case URES_INT_VECTOR: | 975 case URES_INT_VECTOR: |
976 intvector_write_xml (res, id, language, status); | 976 intvector_write_xml (static_cast<IntVectorResource *>(res), id, lan
guage, status); |
977 return; | 977 return; |
978 | 978 |
979 case URES_BINARY: | 979 case URES_BINARY: |
980 bin_write_xml (res, id, language, status); | 980 bin_write_xml (static_cast<BinaryResource *>(res), id, langua
ge, status); |
981 return; | 981 return; |
982 | 982 |
983 case URES_INT: | 983 case URES_INT: |
984 int_write_xml (res, id, language, status); | 984 int_write_xml (static_cast<IntResource *>(res), id, language,
status); |
985 return; | 985 return; |
986 | 986 |
987 case URES_ARRAY: | 987 case URES_ARRAY: |
988 array_write_xml (res, id, language, status); | 988 array_write_xml (static_cast<ArrayResource *>(res), id, languag
e, status); |
989 return; | 989 return; |
990 | 990 |
991 case URES_TABLE: | 991 case URES_TABLE: |
992 table_write_xml (res, id, language, isTopLevel, status); | 992 table_write_xml (static_cast<TableResource *>(res), id, languag
e, isTopLevel, status); |
993 return; | 993 return; |
994 | 994 |
995 default: | 995 default: |
996 break; | 996 break; |
997 } | 997 } |
998 } | 998 } |
999 | 999 |
1000 *status = U_INTERNAL_PROGRAM_ERROR; | 1000 *status = U_INTERNAL_PROGRAM_ERROR; |
1001 } | 1001 } |
1002 | 1002 |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1201 cleanup_bundle_write_xml: | 1201 cleanup_bundle_write_xml: |
1202 uprv_free(originalFileName); | 1202 uprv_free(originalFileName); |
1203 uprv_free(lang); | 1203 uprv_free(lang); |
1204 if(xmlfileName != NULL) { | 1204 if(xmlfileName != NULL) { |
1205 uprv_free(xmlfileName); | 1205 uprv_free(xmlfileName); |
1206 } | 1206 } |
1207 if(outputFileName != NULL){ | 1207 if(outputFileName != NULL){ |
1208 uprv_free(outputFileName); | 1208 uprv_free(outputFileName); |
1209 } | 1209 } |
1210 } | 1210 } |
OLD | NEW |