5 #define DebugValidate(str) Property_Validate( str )
7 #define DebugValidate(str) true
15 string() Property_Create =
17 return String_Create();
20 string( string pString ) Property_Zone =
22 return String_Zone( pString );
25 string( string pString ) Propery_Free =
27 return String_Free( pString );
35 bool( string pString ) Property_Validate =
39 lCount = Util_GetAltStringCount( pString );
40 // check whether this is a valid property string
41 if( rint( lCount / 2 ) != lCount / 2 )
43 error( __FUNC__, "Invalid property string \"", pString , "\"!\n" );
46 dprint( __FUNC__, "Invalid property string \"", pString, "\"!\n" );
58 bool( string pString, string pName ) Property_Exists =
63 if( !DebugValidate( pString ) )
66 lCount = Util_GetAltStringCount( pString );
67 for( lCounter = 0 ; lCounter < lCount ; lCounter += 2 )
68 if( String_Normal( Util_GetAltStringItem( pString, lCounter ) ) == pName )
78 string( string pString, string pName, string pInitValue ) Property_Register =
83 if( !DebugValidate( pString ) )
86 // If the entry already exists, do nothing (thus exit the function)
87 lCount = Util_GetAltStringCount( pString );
88 for( lCounter = 0 ; lCounter < lCount ; lCounter += 2 )
89 if( String_Normal( Util_GetAltStringItem( pString, lCounter ) ) == pName )
92 // If it hasnt been added yet, create it
93 pString = Util_AltStringPush( pString, pInitValue );
94 pString = Util_AltStringPush( pString, pName );
104 string( string pString, string pName, string pValue ) Property_Set =
107 local float lCounter;
109 if( !DebugValidate( pString ) )
112 // Found the entry and set it to the new value
113 lCount = Util_GetAltStringCount( pString );
114 for( lCounter = 0 ; lCounter < lCount ; lCounter += 2 )
115 if( String_Normal( Util_GetAltStringItem( pString, lCounter ) ) == pName )
116 return Util_SetAltStringItem( pString, lCounter + 1, pValue );
118 // If the property isnt found, it depends on DEBUG and STRICT
120 error( __FUNC__, "The property \"", pName, "\" hasn't been declared!\npString = \"", pString, "\"" );
122 dprint( __FUNC__, "The property \"", pName, "\" hasn't been declared!\npString = \"", pString, "\"" );
128 string( string pString, string pOldName, string pNewName ) Property_Rename =
131 local float lCounter;
133 if( !DebugValidate( pString ) )
136 // Found the entry if it already exists
137 lCount = Util_GetAltStringCount( pString );
138 for( lCounter = 0 ; lCounter < lCount ; lCounter += 2 )
139 if( String_Normal( Util_GetAltStringItem( pString, lCounter ) ) == pOldName )
140 return Util_SetAltStringItem( pString, lCounter, pNewName );
142 // If the property isnt found, it depends on DEBUG and STRICT
144 error( __FUNC__, "The property \"", pOldName, "\" hasn't been declared!\npString = \"", pString, "\"" );
146 dprint( __FUNC__, "The property \"", pOldName, "\" hasn't been declared!\npString = \"", pString, "\"" );
151 string( string pString, string pName ) Property_Delete =
154 local float lCounter;
156 if( !DebugValidate( pString ) )
159 // Found the entry if it already exists
160 lCount = Util_GetAltStringCount( pString );
161 for( lCounter = 0 ; lCounter < lCount ; lCounter += 2 )
162 if( String_Normal( Util_GetAltStringItem( pString, lCounter ) ) == pName ) {
163 pString = Util_DelAltStringItem( pString, lCounter );
164 pString = Util_DelAltStringItem( pString, lCounter );
168 // If the property isnt found, it depends on DEBUG and STRICT
170 error( __FUNC__, "The property \"", pName, "\" hasn't been declared!\npString = \"", pString, "\"" );
172 dprint( __FUNC__, "The property \"", pName, "\" hasn't been declared!\npString = \"", pString, "\"" );
183 string( string pString, string pName, string pValue ) Property_Set =
186 local float lCounter;
190 pValue = strzone( pValue );
192 if( !DebugValidate( pString ) )
195 // Found the entry if it already exists
196 lCount = Util_GetAltStringCount( pString );
198 for( lCounter = 0 ; lCounter < lCount ; lCounter += 2 )
199 if( Util_GetAltStringItem( pString, lCounter ) == pName ) {
204 // If it hasnt been added yet, create it
206 pString = Util_AltStringPush( pString, pValue );
207 pString = Util_AltStringPush( pString, pName );
209 pString = Util_SetAltStringItem( pString, lProp + 1, pValue );
221 string( string pString, string pName ) Property_Get =
224 local float lCounter;
226 if( !DebugValidate( pString ) )
229 // Found the entry and return its value
230 lCount = Util_GetAltStringCount( pString );
231 for( lCounter = 0 ; lCounter < lCount ; lCounter += 2 )
232 if( String_Normal( Util_GetAltStringItem( pString, lCounter ) ) == pName )
233 return Util_GetAltStringItem( pString, lCounter + 1);
235 // If the property isnt found, it depends on DEBUG and STRICT
237 error( "The property \"", pName, "\" hasn't been declared!\npString = \"", pString, "\"" );
239 dprint( "The property \"", pName, "\" hasn't been declared!\npString = \"", pString, "\"" );
242 return String_Zone( "" );
250 string( string pString, string pName ) Property_GetString =
252 return Property_Get( pString, pName );
257 Property_GetFloatProperty
260 float( string pString, string pName ) Property_GetFloat =
262 return stof( String_Normal( Property_Get( pString, pName ) ) );
265 vector( string pString, string pName ) Property_GetVector =
267 return stov( String_Normal( Property_Get( pString, pName ) ) );
270 entity( string pString, string pName ) Property_GetEntity =
272 return ftoe( Property_GetFloat( pString, pName ) );
275 #undef DebugValidate()