class static */
| 874 | // ------------------ |
| 875 | |
| 876 | /* class static */ void |
| 877 | XMPUtils::SeparateArrayItems ( XMPMeta * xmpObj, |
| 878 | XMP_StringPtr schemaNS, |
| 879 | XMP_StringPtr arrayName, |
| 880 | XMP_OptionBits options, |
| 881 | XMP_StringPtr catedStr ) |
| 882 | { |
| 883 | XMP_Assert ( (schemaNS != 0) && (arrayName != 0) && (catedStr != 0) ); // ! Enforced by wrapper. |
| 884 | |
| 885 | XMP_VarString itemValue; |
| 886 | size_t itemStart, itemEnd; |
| 887 | size_t nextSize, charSize = 0; // Avoid VS uninit var warnings. |
| 888 | UniCharKind nextKind, charKind = UCK_normal; |
| 889 | UniCodePoint nextChar, uniChar = 0; |
| 890 | |
| 891 | // Extract "special" option bits, verify and normalize the others. |
| 892 | |
| 893 | bool preserveCommas = false; |
| 894 | if ( options & kXMPUtil_AllowCommas ) { |
| 895 | preserveCommas = true; |
| 896 | options ^= kXMPUtil_AllowCommas; |
| 897 | } |
| 898 | |
| 899 | options = VerifySetOptions ( options, 0 ); // Keep a zero value, has special meaning below. |
| 900 | if ( options & ~kXMP_PropArrayFormMask ) XMP_Throw ( "Options can only provide array form", kXMPErr_BadOptions ); |
| 901 | |
| 902 | // Find the array node, make sure it is OK. Move the current children aside, to be readded later if kept. |
| 903 | |
| 904 | XMP_ExpandedXPath arrayPath; |
| 905 | ExpandXPath ( schemaNS, arrayName, &arrayPath ); |
| 906 | XMP_Node * arrayNode = FindNode ( &xmpObj->tree, arrayPath, kXMP_ExistingOnly ); |
| 907 | |
| 908 | if ( arrayNode != 0 ) { |
| 909 | // The array exists, make sure the form is compatible. Zero arrayForm means take what exists. |
| 910 | XMP_OptionBits arrayForm = arrayNode->options & kXMP_PropArrayFormMask; |
| 911 | if ( (arrayForm == 0) || (arrayForm & kXMP_PropArrayIsAlternate) ) { |
| 912 | XMP_Throw ( "Named property must be non-alternate array", kXMPErr_BadXPath ); |
| 913 | } |
| 914 | if ( (options != 0) && (options != arrayForm) ) XMP_Throw ( "Mismatch of specified and existing array form", kXMPErr_BadXPath ); // *** Right error? |
| 915 | } else { |
| 916 | // The array does not exist, try to create it. |
| 917 | arrayNode = FindNode ( &xmpObj->tree, arrayPath, kXMP_CreateNodes, (options | kXMP_PropValueIsArray) ); |
| 918 | if ( arrayNode == 0 ) XMP_Throw ( "Failed to create named array", kXMPErr_BadXPath ); |
| 919 | } |
| 920 | |
| 921 | XMP_NodeOffspring oldChildren ( arrayNode->children ); |
| 922 | size_t oldChildCount = oldChildren.size(); |
| 923 | arrayNode->children.clear(); |
| 924 | |
| 925 | // Extract the item values one at a time, until the whole input string is done. Be very careful |
| 926 | // in the extraction about the string positions. They are essentially byte pointers, while the |
| 927 | // contents are UTF-8. Adding or subtracting 1 does not necessarily move 1 Unicode character! |
| 928 | |
| 929 | size_t endPos = strlen ( catedStr ); |
| 930 | |
| 931 | itemEnd = 0; |
| 932 | while ( itemEnd < endPos ) { |
| 933 |
nothing calls this directly
no test coverage detected