MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / getPrefixedDataField

Method getPrefixedDataField

Engine/source/console/simObject.cpp:1128–1161  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1126
1127
1128const char *SimObject::getPrefixedDataField(StringTableEntry fieldName, const char *array)
1129{
1130 // Sanity!
1131 AssertFatal(fieldName != NULL, "Cannot get field value with NULL field name.");
1132
1133 // Fetch field value.
1134 const char* pFieldValue = getDataField(fieldName, array);
1135
1136 // Sanity.
1137 //AssertFatal(pFieldValue != NULL, "Field value cannot be NULL.");
1138 if (!pFieldValue)
1139 return NULL;
1140
1141 // Return without the prefix if there's no value.
1142 if (*pFieldValue == 0)
1143 return StringTable->EmptyString();
1144
1145 // Fetch the field prefix.
1146 StringTableEntry fieldPrefix = getDataFieldPrefix(fieldName);
1147
1148 // Sanity!
1149 AssertFatal(fieldPrefix != NULL, "Field prefix cannot be NULL.");
1150
1151 // Calculate a buffer size including prefix.
1152 const U32 valueBufferSize = dStrlen(fieldPrefix) + dStrlen(pFieldValue) + 1;
1153
1154 // Fetch a buffer.
1155 char* pValueBuffer = Con::getReturnBuffer(valueBufferSize);
1156
1157 // Format the value buffer.
1158 dSprintf(pValueBuffer, valueBufferSize, "%s%s", fieldPrefix, pFieldValue);
1159
1160 return pValueBuffer;
1161}
1162
1163//-----------------------------------------------------------------------------
1164

Callers 1

compileStaticFieldsMethod · 0.80

Calls 4

getReturnBufferFunction · 0.85
dSprintfFunction · 0.85
EmptyStringMethod · 0.80
dStrlenFunction · 0.50

Tested by

no test coverage detected