class static */
| 771 | // ------------------ |
| 772 | |
| 773 | /* class static */ void |
| 774 | XMPUtils::CatenateArrayItems ( const XMPMeta & xmpObj, |
| 775 | XMP_StringPtr schemaNS, |
| 776 | XMP_StringPtr arrayName, |
| 777 | XMP_StringPtr separator, |
| 778 | XMP_StringPtr quotes, |
| 779 | XMP_OptionBits options, |
| 780 | XMP_StringPtr * catedStr, |
| 781 | XMP_StringLen * catedLen ) |
| 782 | { |
| 783 | XMP_Assert ( (schemaNS != 0) && (arrayName != 0) ); // ! Enforced by wrapper. |
| 784 | XMP_Assert ( (separator != 0) && (quotes != 0) && (catedStr != 0) && (catedLen != 0) ); // ! Enforced by wrapper. |
| 785 | |
| 786 | size_t strLen=0, strPos=0, charLen=0; |
| 787 | UniCharKind charKind; |
| 788 | UniCodePoint currUCP, openQuote, closeQuote; |
| 789 | |
| 790 | const bool allowCommas = ((options & kXMPUtil_AllowCommas) != 0); |
| 791 | |
| 792 | const XMP_Node * arrayNode = 0; // ! Move up to avoid gcc complaints. |
| 793 | XMP_OptionBits arrayForm = 0; |
| 794 | const XMP_Node * currItem = 0; |
| 795 | |
| 796 | // Make sure the separator is OK. It must be one semicolon surrounded by zero or more spaces. |
| 797 | // Any of the recognized semicolons or spaces are allowed. |
| 798 | |
| 799 | strPos = 0; |
| 800 | strLen = strlen ( separator ); |
| 801 | bool haveSemicolon = false; |
| 802 | |
| 803 | while ( strPos < strLen ) { |
| 804 | ClassifyCharacter ( separator, strPos, &charKind, &charLen, &currUCP ); |
| 805 | strPos += charLen; |
| 806 | if ( charKind == UCK_semicolon ) { |
| 807 | if ( haveSemicolon ) XMP_Throw ( "Separator can have only one semicolon", kXMPErr_BadParam ); |
| 808 | haveSemicolon = true; |
| 809 | } else if ( charKind != UCK_space ) { |
| 810 | XMP_Throw ( "Separator can have only spaces and one semicolon", kXMPErr_BadParam ); |
| 811 | } |
| 812 | }; |
| 813 | if ( ! haveSemicolon ) XMP_Throw ( "Separator must have one semicolon", kXMPErr_BadParam ); |
| 814 | |
| 815 | // Make sure the open and close quotes are a legitimate pair. |
| 816 | |
| 817 | strLen = strlen ( quotes ); |
| 818 | ClassifyCharacter ( quotes, 0, &charKind, &charLen, &openQuote ); |
| 819 | if ( charKind != UCK_quote ) XMP_Throw ( "Invalid quoting character", kXMPErr_BadParam ); |
| 820 | |
| 821 | if ( charLen == strLen ) { |
| 822 | closeQuote = openQuote; |
| 823 | } else { |
| 824 | strPos = charLen; |
| 825 | ClassifyCharacter ( quotes, strPos, &charKind, &charLen, &closeQuote ); |
| 826 | if ( charKind != UCK_quote ) XMP_Throw ( "Invalid quoting character", kXMPErr_BadParam ); |
| 827 | if ( (strPos + charLen) != strLen ) XMP_Throw ( "Quoting string too long", kXMPErr_BadParam ); |
| 828 | } |
| 829 | if ( closeQuote != GetClosingQuote ( openQuote ) ) XMP_Throw ( "Mismatched quote pair", kXMPErr_BadParam ); |
| 830 |
nothing calls this directly
no test coverage detected