Introduce some more civilized ways to copy properties.
authordezeroex <dezeroex@d19143bc-622f-0410-bfdd-b5b2a6649095>
Sun, 21 Aug 2005 20:46:01 +0000 (20:46 +0000)
committerdezeroex <dezeroex@d19143bc-622f-0410-bfdd-b5b2a6649095>
Sun, 21 Aug 2005 20:46:01 +0000 (20:46 +0000)
See code comments for usage.

git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt@806 d19143bc-622f-0410-bfdd-b5b2a6649095

src/framework/mlt_properties.c
src/framework/mlt_properties.h
src/framework/mlt_property.c
src/framework/mlt_property.h

index b42d02a..18452dd 100644 (file)
@@ -215,7 +215,7 @@ int mlt_properties_ref_count( mlt_properties this )
        return 0;
 }
 
-/** Allow the specification of a mirror.
+/** Mirror properties set on 'this' to 'that'.
 */
 
 void mlt_properties_mirror( mlt_properties this, mlt_properties that )
@@ -264,6 +264,7 @@ int mlt_properties_pass( mlt_properties this, mlt_properties that, const char *p
        return 0;
 }
 
+
 /** Locate a property by name
 */
 
@@ -335,6 +336,52 @@ static mlt_property mlt_properties_fetch( mlt_properties this, const char *name
        return property;
 }
 
+/** Pass property 'name' from 'that' to 'this' 
+* Who to blame: Zach <zachary.drew@gmail.com>
+*/
+
+void mlt_properties_pass_property( mlt_properties this, mlt_properties that, const char *name )
+{
+       // Make sure the source property isn't null.
+       mlt_property that_prop = mlt_properties_find( that, name );
+       if( that_prop == NULL )
+               return;
+
+       mlt_property_pass( mlt_properties_fetch( this, name ), that_prop );
+}
+
+/** Pass all properties from 'that' to 'this' as found in comma seperated 'list'.
+* Who to blame: Zach <zachary.drew@gmail.com>
+*/
+
+int mlt_properties_pass_list( mlt_properties this, mlt_properties that, const char *list )
+{
+       char *props = strdup( list );
+       char *ptr = props;
+       char *delim = " ,\t\n"; // Any combination of spaces, commas, tabs, and newlines
+       int count, done = 0;
+
+       while( !done )
+       {
+               count = strcspn( ptr, delim );
+
+               if( ptr[count] == '\0' )
+                       done = 1;
+               else
+                       ptr[count] = '\0';      // Make it a real string
+
+               mlt_properties_pass_property( this, that, ptr );
+
+               ptr += count + 1;
+               ptr += strspn( ptr, delim );
+       }
+
+       free( props );
+
+       return 0;
+}
+
+
 /** Set the property.
 */
 
index c2cbebc..12edfca 100644 (file)
@@ -49,6 +49,8 @@ extern int mlt_properties_ref_count( mlt_properties self );
 extern void mlt_properties_mirror( mlt_properties self, mlt_properties that );
 extern int mlt_properties_inherit( mlt_properties self, mlt_properties that );
 extern int mlt_properties_pass( mlt_properties self, mlt_properties that, const char *prefix );
+extern void mlt_properties_pass_property( mlt_properties this, mlt_properties that, const char *name );
+extern int mlt_properties_pass_list( mlt_properties this, mlt_properties that, const char *list );
 extern int mlt_properties_set( mlt_properties self, const char *name, const char *value );
 extern int mlt_properties_set_or_default( mlt_properties self, const char *name, const char *value, const char *def );
 extern int mlt_properties_parse( mlt_properties self, const char *namevalue );
index 016ea91..d057f0c 100644 (file)
@@ -310,4 +310,31 @@ void mlt_property_close( mlt_property this )
        free( this );
 }
 
+/** Pass the property 'that' to 'this'.
+* Who to blame: Zach <zachary.drew@gmail.com>
+*/
+void mlt_property_pass( mlt_property this, mlt_property that )
+{
+       mlt_property_clear( this );
+
+       this->types = that->types;
 
+       if ( this->types & mlt_prop_int64 )
+               this->prop_int64 = that->prop_int64;
+       else if ( this->types & mlt_prop_int )
+               this->prop_int = that->prop_int;
+       else if ( this->types & mlt_prop_double )
+               this->prop_double = that->prop_double;
+       else if ( this->types & mlt_prop_position )
+               this->prop_position = that->prop_position;
+       else if ( this->types & mlt_prop_string )
+       {
+               if ( that->prop_string != NULL )
+                       this->prop_string = strdup( that->prop_string );
+       }
+       else if ( this->types & mlt_prop_data && this->serialiser != NULL )
+       {
+               this->types = mlt_prop_string;
+               this->prop_string = this->serialiser( this->data, this->length );       
+       }
+}
index 51a8f41..493839d 100644 (file)
@@ -81,5 +81,7 @@ extern char *mlt_property_get_string( mlt_property self );
 extern void *mlt_property_get_data( mlt_property self, int *length );
 extern void mlt_property_close( mlt_property self );
 
+extern void mlt_property_pass( mlt_property this, mlt_property that );
+
 #endif