MCPcopy Create free account
hub / github.com/GarageGames/Torque3D / parseObjectFormat

Function parseObjectFormat

Engine/source/gui/worldEditor/worldEditor.cpp:166–229  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

164
165 //
166 const char * parseObjectFormat(SimObject * obj, const char * format)
167 {
168 static char buf[1024];
169
170 U32 curPos = 0;
171 U32 len = dStrlen(format);
172
173 for(U32 i = 0; i < len; i++)
174 {
175 if(format[i] == '$')
176 {
177 U32 j;
178 for(j = i+1; j < len; j++)
179 if(format[j] == '$')
180 break;
181
182 if(j == len)
183 break;
184
185 char token[80];
186
187 AssertFatal((j - i) < (sizeof(token) - 1), "token too long");
188 dStrncpy(token, &format[i+1], (j - i - 1));
189 token[j-i-1] = 0;
190
191 U32 remaining = sizeof(buf) - curPos - 1;
192
193 // look at the token
194 if(!dStricmp(token, "id"))
195 curPos += dSprintf(buf + curPos, remaining, "%d", obj->getId());
196 else if( dStricmp( token, "name|class" ) == 0 )
197 {
198 const char* str;
199 if( obj->getName() && obj->getName()[ 0 ] )
200 str = obj->getName();
201 else
202 str = obj->getClassName();
203
204 curPos += dSprintf( buf + curPos, remaining, "%s", str );
205 }
206 else if(!dStricmp(token, "name|internal"))
207 {
208 if( obj->getName() || !obj->getInternalName() )
209 curPos += dSprintf(buf + curPos, remaining, "%s", obj->getName());
210 else
211 curPos += dSprintf(buf + curPos, remaining, "[%s]", obj->getInternalName());
212 }
213 else if(!dStricmp(token, "name"))
214 curPos += dSprintf(buf + curPos, remaining, "%s", obj->getName());
215 else if(!dStricmp(token, "class"))
216 curPos += dSprintf(buf + curPos, remaining, "%s", obj->getClassName());
217 else if(!dStricmp(token, "namespace") && obj->getNamespace())
218 curPos += dSprintf(buf + curPos, remaining, "%s", obj->getNamespace()->mName);
219
220 //
221 i = j;
222 }
223 else

Callers 1

renderScreenObjMethod · 0.85

Calls 9

dStrncpyFunction · 0.85
dStricmpFunction · 0.85
dSprintfFunction · 0.85
getInternalNameMethod · 0.80
getNamespaceMethod · 0.80
dStrlenFunction · 0.50
getIdMethod · 0.45
getNameMethod · 0.45
getClassNameMethod · 0.45

Tested by

no test coverage detected