admin
2025-01-22 7e31442f0e9b07764e9c6a9680d3d4aeba5fe1de
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
Quintiq file version 2.0
#parent: #root
Method SynchronizeAttributes (JSON jsondata)
{
  TextBody:
  [*
    new := construct( Lib3DS_Attributes );
    
    attrnamedata := guard( jsondata.Get( 'attribute' ), null( JSON, owning ) );
    attrtypedata := guard( jsondata.Get( 'attribute.type' ), null( JSON, owning ) );
    attrvaluedata := guard( jsondata.Get( 'attribute.value' ), null( JSON, owning ) );
    
    if( guard( attrnamedata.IsArray(), false )
        and guard( attrtypedata.IsArray(), false )
        and guard( attrvaluedata.IsArray(), false ) )
    {
      for( i := 0; i < attrnamedata.Size(); i++ )
      {
        attr := Lib3DS_Attribute::FindOrCreate( this, attrnamedata.Get( i ).GetString() );
        attr.Type( guard( attrtypedata.Get( i ).GetString(), '' ) );
        attr.Value( guard( attrvaluedata.Get( i ).GetString(), '' ) );
        new.Add( attr );
      }
    }
    else // Read individual attributes
    {
      // Traverse all properties
      for( i := 0; i < jsondata.Size(); i++ )
      {
        key := jsondata.GetProperty( i );
    
        // Find attribute properties (type or value)
        if( key.Wildcard( 'attribute[*].type' ) or key.Wildcard( 'attribute[*].value' ) )
        {
          // Extract property name
          start := key.FindString( '[', 0 ) + 1;
          end := key.FindString( ']', 0 );
          count := end - start;
          attrname := key.SubString( start, count );
          
          // Find or create attribute object
          attr := Lib3DS_Attribute::FindOrCreate( this, attrname );
          if( key.EndsWith( 'type' ) )
          {
            attr.Type( guard( jsondata.Get( key ).GetString(), '' ) );
          }
          else if( key.EndsWith( 'value' ) )
          {
            attr.Value( guard( jsondata.Get( key ).GetString(), '' ) );
          }
          new.Add( attr );
        }
      }
    }
  *]
  InterfaceProperties { Accessibility: 'Module' }
}