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

Method setPrefixedDataField

Engine/source/console/simObject.cpp:1057–1097  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1055//-----------------------------------------------------------------------------
1056
1057void SimObject::setPrefixedDataField(StringTableEntry fieldName, const char *array, const char *value)
1058{
1059 // Sanity!
1060 AssertFatal(fieldName != NULL, "Cannot set object field value with NULL field name.");
1061 AssertFatal(value != NULL, "Field value cannot be NULL.");
1062
1063 // Set value without prefix if there's no value.
1064 if (*value == 0)
1065 {
1066 setDataField(fieldName, NULL, value);
1067 return;
1068 }
1069
1070 // Fetch the field prefix.
1071 StringTableEntry fieldPrefix = getDataFieldPrefix(fieldName);
1072
1073 // Sanity.
1074 AssertFatal(fieldPrefix != NULL, "Field prefix cannot be NULL.");
1075
1076 // Do we have a field prefix?
1077 if (fieldPrefix == StringTable->EmptyString())
1078 {
1079 // No, so set the data field in the usual way.
1080 setDataField(fieldName, NULL, value);
1081 return;
1082 }
1083
1084 // Yes, so fetch the length of the field prefix.
1085 const U32 fieldPrefixLength = dStrlen(fieldPrefix);
1086
1087 // Yes, so does it start with the object field prefix?
1088 if (dStrnicmp(value, fieldPrefix, fieldPrefixLength) != 0)
1089 {
1090 // No, so set the data field in the usual way.
1091 setDataField(fieldName, NULL, value);
1092 return;
1093 }
1094
1095 // Yes, so set the data excluding the prefix.
1096 setDataField(fieldName, NULL, value + fieldPrefixLength);
1097}
1098
1099//-----------------------------------------------------------------------------
1100

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