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

Method setPrefixedDataField

Engine/source/console/simObject.cpp:1165–1205  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1163//-----------------------------------------------------------------------------
1164
1165void SimObject::setPrefixedDataField(StringTableEntry fieldName, const char *_array, const char *value)
1166{
1167 // Sanity!
1168 AssertFatal(fieldName != NULL, "Cannot set object field value with NULL field name.");
1169 AssertFatal(value != NULL, "Field value cannot be NULL.");
1170
1171 // Set value without prefix if there's no value.
1172 if (*value == 0)
1173 {
1174 setDataField(fieldName, _array, value);
1175 return;
1176 }
1177
1178 // Fetch the field prefix.
1179 StringTableEntry fieldPrefix = getDataFieldPrefix(fieldName);
1180
1181 // Sanity.
1182 AssertFatal(fieldPrefix != NULL, "Field prefix cannot be NULL.");
1183
1184 // Do we have a field prefix?
1185 if (fieldPrefix == StringTable->EmptyString())
1186 {
1187 // No, so set the data field in the usual way.
1188 setDataField(fieldName, _array, value);
1189 return;
1190 }
1191
1192 // Yes, so fetch the length of the field prefix.
1193 const U32 fieldPrefixLength = dStrlen(fieldPrefix);
1194
1195 // Yes, so does it start with the object field prefix?
1196 if (dStrnicmp(value, fieldPrefix, fieldPrefixLength) != 0)
1197 {
1198 // No, so set the data field in the usual way.
1199 setDataField(fieldName, _array, value);
1200 return;
1201 }
1202
1203 // Yes, so set the data excluding the prefix.
1204 setDataField(fieldName, _array, value + fieldPrefixLength);
1205}
1206
1207//-----------------------------------------------------------------------------
1208

Callers 3

parseAttributesMethod · 0.80
parseFieldMethod · 0.80
parseAttributesMethod · 0.80

Calls 3

dStrnicmpFunction · 0.85
EmptyStringMethod · 0.80
dStrlenFunction · 0.50

Tested by

no test coverage detected