Example #1
0
 /// <summary>
 /// Separate a single edit string into an array of strings.
 /// </summary>
 /// <param name="xmp">
 ///            The XMP object containing the array to be updated. </param>
 /// <param name="schemaNs">
 ///            The schema namespace URI for the array. Must not be null or
 ///            the empty string. </param>
 /// <param name="arrayName">
 ///            The name of the array. May be a general path expression, must
 ///            not be null or the empty string. Each item in the array must
 ///            be a simple string value. </param>
 /// <param name="catedStr">
 ///            The string to be separated into the array items. </param>
 /// <param name="arrayOptions"> Option flags to control the separation. </param>
 /// <param name="preserveCommas"> Flag if commas shall be preserved </param>
 /// <exception cref="XmpException"> Forwards the Exceptions from the metadata processing  </exception>
 public static void SeparateArrayItems(IXmpMeta xmp, string schemaNs, string arrayName, string catedStr,
                                       PropertyOptions arrayOptions, bool preserveCommas)
 {
     XmpUtilsImpl.SeparateArrayItems(xmp, schemaNs, arrayName, catedStr, arrayOptions, preserveCommas);
 }
Example #2
0
 /// <summary>
 /// <p>Append properties from one XMP object to another.
 ///
 /// <p>XMPUtils#appendProperties was created to support the File Info dialog's Append button, and
 /// has been been generalized somewhat from those specific needs. It appends information from one
 /// XMP object (source) to another (dest). The default operation is to append only external
 /// properties that do not already exist in the destination. The flag
 /// <code>doAllProperties</code> can be used to operate on all properties, external and internal.
 /// The flag <code>replaceOldValues</code> option can be used to replace the values
 /// of existing properties. The notion of external
 /// versus internal applies only to top level properties. The keep-or-replace-old notion applies
 /// within structs and arrays as described below.
 /// <ul>
 /// <li>If <code>replaceOldValues</code> is true then the processing is restricted to the top
 /// level properties. The processed properties from the source (according to
 /// <code>doAllProperties</code>) are propagated to the destination,
 /// replacing any existing values.Properties in the destination that are not in the source
 /// are left alone.
 ///
 /// <li>If <code>replaceOldValues</code> is not passed then the processing is more complicated.
 /// Top level properties are added to the destination if they do not already exist.
 /// If they do exist but differ in form (simple/struct/array) then the destination is left alone.
 /// If the forms match, simple properties are left unchanged while structs and arrays are merged.
 ///
 /// <li>If <code>deleteEmptyValues</code> is passed then an empty value in the source XMP causes
 /// the corresponding destination XMP property to be deleted. The default is to treat empty
 /// values the same as non-empty values. An empty value is any of a simple empty string, an array
 /// with no items, or a struct with no fields. Qualifiers are ignored.
 /// </ul>
 ///
 /// <p>The detailed behavior is defined by the following pseudo-code:
 /// <blockquote>
 /// <pre>
 ///    appendProperties ( sourceXMP, destXMP, doAllProperties,
 ///             replaceOldValues, deleteEmptyValues ):
 ///       for all source schema (top level namespaces):
 ///          for all top level properties in sourceSchema:
 ///             if doAllProperties or prop is external:
 ///                appendSubtree ( sourceNode, destSchema, replaceOldValues, deleteEmptyValues )
 ///
 ///    appendSubtree ( sourceNode, destParent, replaceOldValues, deleteEmptyValues ):
 ///        if deleteEmptyValues and source value is empty:
 ///            delete the corresponding child from destParent
 ///        else if sourceNode not in destParent (by name):
 ///           copy sourceNode's subtree to destParent
 ///        else if replaceOld:
 ///            delete subtree from destParent
 ///            copy sourceNode's subtree to destParent
 ///        else:
 ///            // Already exists in dest and not replacing, merge structs and arrays
 ///            if sourceNode and destNode forms differ:
 ///                return, leave the destNode alone
 ///            else if form is a struct:
 ///                for each field in sourceNode:
 ///                    AppendSubtree ( sourceNode.field, destNode, replaceOldValues )
 ///            else if form is an alt-text array:
 ///                copy new items by "xml:lang" value into the destination
 ///            else if form is an array:
 ///                copy new items by value into the destination, ignoring order and duplicates
 /// </pre>
 /// </blockquote>
 ///
 /// <p><em>Note:</em> appendProperties can be expensive if replaceOldValues is not passed and
 /// the XMP contains large arrays. The array item checking described above is n-squared.
 /// Each source item is checked to see if it already exists in the destination,
 /// without regard to order or duplicates.
 /// <p>Simple items are compared by value and "xml:lang" qualifier, other qualifiers are ignored.
 /// Structs are recursively compared by field names, without regard to field order. Arrays are
 /// compared by recursively comparing all items.
 /// </summary>
 /// <param name="source"> The source XMP object. </param>
 /// <param name="dest"> The destination XMP object. </param>
 /// <param name="doAllProperties"> Do internal properties in addition to external properties. </param>
 /// <param name="replaceOldValues"> Replace the values of existing properties. </param>
 /// <param name="deleteEmptyValues"> Delete destination values if source property is empty. </param>
 /// <exception cref="XmpException"> Forwards the Exceptions from the metadata processing  </exception>
 public static void AppendProperties(IXmpMeta source, IXmpMeta dest, bool doAllProperties, bool replaceOldValues,
                                     bool deleteEmptyValues)
 {
     XmpUtilsImpl.AppendProperties(source, dest, doAllProperties, replaceOldValues, deleteEmptyValues);
 }
Example #3
0
 /// <summary>
 /// Create a single edit string from an array of strings.
 /// </summary>
 /// <param name="xmp">
 ///            The XMP object containing the array to be catenated. </param>
 /// <param name="schemaNs">
 ///            The schema namespace URI for the array. Must not be null or
 ///            the empty string. </param>
 /// <param name="arrayName">
 ///            The name of the array. May be a general path expression, must
 ///            not be null or the empty string. Each item in the array must
 ///            be a simple string value. </param>
 /// <param name="separator">
 ///            The string to be used to separate the items in the catenated
 ///            string. Defaults to &quot;; &quot;, ASCII semicolon and space
 ///            (U+003B, U+0020). </param>
 /// <param name="quotes">
 ///            The characters to be used as quotes around array items that
 ///            contain a separator. Defaults to &apos;&quot;&apos; </param>
 /// <param name="allowCommas">
 ///            Option flag to control the catenation. </param>
 /// <returns> Returns the string containing the catenated array items. </returns>
 /// <exception cref="XmpException"> Forwards the Exceptions from the metadata processing </exception>
 public static string CatenateArrayItems(IXmpMeta xmp, string schemaNs, string arrayName, string separator,
                                         string quotes, bool allowCommas)
 {
     return(XmpUtilsImpl.CatenateArrayItems(xmp, schemaNs, arrayName, separator, quotes, allowCommas));
 }
Example #4
0
 /// <summary>
 /// Remove multiple properties from an XMP object.
 ///
 /// RemoveProperties was created to support the File Info dialog's Delete
 /// button, and has been been generalized somewhat from those specific needs.
 /// It operates in one of three main modes depending on the schemaNs and
 /// propName parameters:
 ///
 /// <ul>
 /// <li> Non-empty <code>schemaNs</code> and <code>propName</code> - The named property is
 /// removed if it is an external property, or if the
 /// flag <code>doAllProperties</code> option is true. It does not matter whether the
 /// named property is an actual property or an alias.
 ///
 /// <li> Non-empty <code>schemaNs</code> and empty <code>propName</code> - The all external
 /// properties in the named schema are removed. Internal properties are also
 /// removed if the flag <code>doAllProperties</code> option is set. In addition,
 /// aliases from the named schema will be removed if the flag <code>includeAliases</code>
 /// option is set.
 ///
 /// <li> Empty <code>schemaNs</code> and empty <code>propName</code> - All external properties in
 /// all schema are removed. Internal properties are also removed if the
 /// flag <code>doAllProperties</code> option is passed. Aliases are implicitly handled
 /// because the associated actuals are internal if the alias is.
 /// </ul>
 ///
 /// It is an error to pass an empty <code>schemaNs</code> and non-empty <code>propName</code>.
 /// </summary>
 /// <param name="xmp">
 ///            The XMP object containing the properties to be removed.
 /// </param>
 /// <param name="schemaNs">
 ///            Optional schema namespace URI for the properties to be
 ///            removed.
 /// </param>
 /// <param name="propName">
 ///            Optional path expression for the property to be removed.
 /// </param>
 /// <param name="doAllProperties"> Option flag to control the deletion: do internal properties in
 ///          addition to external properties.
 /// </param>
 /// <param name="includeAliases"> Option flag to control the deletion:
 ///             Include aliases in the "named schema" case above.
 ///             <em>Note:</em> Currently not supported. </param>
 /// <exception cref="XmpException"> Forwards the Exceptions from the metadata processing  </exception>
 public static void RemoveProperties(IXmpMeta xmp, string schemaNs, string propName, bool doAllProperties,
                                     bool includeAliases)
 {
     XmpUtilsImpl.RemoveProperties(xmp, schemaNs, propName, doAllProperties, includeAliases);
 }