|
1 /* |
|
2 * Copyright (c) 2004-2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 using System; |
|
19 using System.Text; |
|
20 using System.Collections; |
|
21 using SymBuildParsingLib.Token; |
|
22 using SymbianTree; |
|
23 |
|
24 namespace SymBuildParsingLib.Common.Objects |
|
25 { |
|
26 public class SymDefineArgument : SymArgument |
|
27 { |
|
28 #region Constructors & destructor |
|
29 public SymDefineArgument( SymArgument aArgumentToCopyFrom ) |
|
30 { |
|
31 AppendChildrenFrom( aArgumentToCopyFrom ); |
|
32 } |
|
33 #endregion |
|
34 |
|
35 #region API |
|
36 #endregion |
|
37 |
|
38 #region Properties |
|
39 #endregion |
|
40 |
|
41 #region Data members |
|
42 #endregion |
|
43 } |
|
44 |
|
45 public class SymDefineDefinition |
|
46 { |
|
47 #region Enumerations |
|
48 #endregion |
|
49 |
|
50 #region Constructors & destructor |
|
51 public SymDefineDefinition() |
|
52 { |
|
53 } |
|
54 |
|
55 public SymDefineDefinition( string aName ) |
|
56 { |
|
57 iName = aName; |
|
58 } |
|
59 #endregion |
|
60 |
|
61 #region API |
|
62 public void AddArgument( SymDefineArgument aArgument ) |
|
63 { |
|
64 iArguments.Add( aArgument ); |
|
65 } |
|
66 #endregion |
|
67 |
|
68 #region Properties |
|
69 public bool IsValid |
|
70 { |
|
71 get |
|
72 { |
|
73 bool valid = ( Name.Length > 0 ); |
|
74 return valid; |
|
75 } |
|
76 } |
|
77 |
|
78 public string Name |
|
79 { |
|
80 get { return iName; } |
|
81 set { iName = value; } |
|
82 } |
|
83 |
|
84 public string CoalescedTokenValue |
|
85 { |
|
86 get |
|
87 { |
|
88 StringBuilder args = new StringBuilder(); |
|
89 // |
|
90 int count = iArguments.Count; |
|
91 for( int i=0; i<count; i++ ) |
|
92 { |
|
93 SymDefineArgument arg = (SymDefineArgument) iArguments[ i ]; |
|
94 // |
|
95 args.Append( arg.CoalescedTokenValue ); |
|
96 if ( i <count-1 ) |
|
97 { |
|
98 args.Append( ", " ); |
|
99 } |
|
100 } |
|
101 // |
|
102 if ( count > 0 ) |
|
103 { |
|
104 args.Insert( 0, "(" ); |
|
105 args.Append( ")" ); |
|
106 } |
|
107 return Name + args.ToString(); |
|
108 } |
|
109 } |
|
110 public SymTokenContainer Value |
|
111 { |
|
112 get { return iValue; } |
|
113 set { iValue = value; } |
|
114 } |
|
115 #endregion |
|
116 |
|
117 #region Properties - argument related |
|
118 public bool HasArguments |
|
119 { |
|
120 get { return ArgumentCount > 0; } |
|
121 } |
|
122 |
|
123 public int ArgumentCount |
|
124 { |
|
125 get { return iArguments.Count; } |
|
126 } |
|
127 |
|
128 public SymDefineArgument this[ int aIndex ] |
|
129 { |
|
130 get |
|
131 { |
|
132 SymDefineArgument arg = (SymDefineArgument) iArguments[ aIndex ]; |
|
133 return arg; |
|
134 } |
|
135 } |
|
136 #endregion |
|
137 |
|
138 #region From System.Object |
|
139 public override int GetHashCode() |
|
140 { |
|
141 int ret = iName.GetHashCode(); |
|
142 return ret; |
|
143 } |
|
144 #endregion |
|
145 |
|
146 #region Data members |
|
147 private string iName = string.Empty; |
|
148 private ArrayList iArguments = new ArrayList(); |
|
149 private SymTokenContainer iValue = new SymTokenContainer(); |
|
150 #endregion |
|
151 } |
|
152 } |