forked from dcariola/XCodeEditor-for-Unity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PBXGroup.cs
166 lines (144 loc) · 3.44 KB
/
PBXGroup.cs
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
namespace UnityEditor.XCodeEditor
{
public class PBXGroup : PBXObject
{
protected const string NAME_KEY = "name";
protected const string CHILDREN_KEY = "children";
protected const string PATH_KEY = "path";
protected const string SOURCETREE_KEY = "sourceTree";
#region Constructor
public PBXGroup( string name, string path = null, string tree = "SOURCE_ROOT" ) : base()
{
this.Add( NAME_KEY, name );
this.Add( CHILDREN_KEY, new PBXList() );
if( path != null ) {
this.Add( PATH_KEY, path );
this.Add( SOURCETREE_KEY, tree );
}
else {
this.Add( SOURCETREE_KEY, "<group>" );
}
}
public PBXGroup( string guid, PBXDictionary dictionary ) : base( guid, dictionary )
{
}
#endregion
#region Properties
public string name {
get {
if( !ContainsKey( NAME_KEY ) ) {
return null;
}
return (string)_data[NAME_KEY];
}
}
public PBXList children {
get {
if( !ContainsKey( CHILDREN_KEY ) ) {
this.Add( CHILDREN_KEY, new PBXList() );
}
return (PBXList)_data[CHILDREN_KEY];
}
}
public string path {
get {
if( !ContainsKey( PATH_KEY ) ) {
return null;
}
return (string)_data[PATH_KEY];
}
}
public string sourceTree {
get {
return (string)_data[SOURCETREE_KEY];
}
}
#endregion
public string AddChild( PBXObject child )
{
if( child is PBXFileReference || child is PBXGroup ) {
children.Add( child.guid );
return child.guid;
}
return null;
}
public void RemoveChild( string id )
{
if( !IsGuid( id ) )
return;
children.Remove( id );
}
public bool HasChild( string id )
{
if( !ContainsKey( CHILDREN_KEY ) ) {
this.Add( CHILDREN_KEY, new PBXList() );
return false;
}
if( !IsGuid( id ) )
return false;
return ((PBXList)_data[ CHILDREN_KEY ]).Contains( id );
}
public string GetName()
{
return (string)_data[ NAME_KEY ];
}
// class PBXGroup(PBXObject):
// def add_child(self, ref):
// if not isinstance(ref, PBXDict):
// return None
//
// isa = ref.get('isa')
//
// if isa != 'PBXFileReference' and isa != 'PBXGroup':
// return None
//
// if not self.has_key('children'):
// self['children'] = PBXList()
//
// self['children'].add(ref.id)
//
// return ref.id
//
// def remove_child(self, id):
// if not self.has_key('children'):
// self['children'] = PBXList()
// return
//
// if not PBXObject.IsGuid(id):
// id = id.id
//
// self['children'].remove(id)
//
// def has_child(self, id):
// if not self.has_key('children'):
// self['children'] = PBXList()
// return False
//
// if not PBXObject.IsGuid(id):
// id = id.id
//
// return id in self['children']
//
// def get_name(self):
// path_name = os.path.split(self.get('path',''))[1]
// return self.get('name', path_name)
//
// @classmethod
// def Create(cls, name, path=None, tree='SOURCE_ROOT'):
// grp = cls()
// grp.id = cls.GenerateId()
// grp['name'] = name
// grp['children'] = PBXList()
//
// if path:
// grp['path'] = path
// grp['sourceTree'] = tree
// else:
// grp['sourceTree'] = '<group>'
//
// return grp
}
}