So I just spent over a week or so building a mini string library for REs and I have integrated it in my re-common mini framework. It is mind boggling that such a concept is not part of the SDK, especially since it is such a basic need for a developer. It is like if you were building a house and the first thing you have to do is build your own hammer...
The main API implemented is fmt::printf which implements a very simplified version of the C api printf (only handles %d and %s with no other variants allowed at the moment).
With this basic API, I built a jbox namespace with convenient calls to replace JBox_GetMotherboardObjectRef and JBox_MakePropertyRef.
Example:
Code: Select all
// from VerySimpleSampler.cpp (example in RE SDK)
// code with new api
// N = 4
for(int i = 0; i < N; i++)
{
fSampleNativeObjectRefs[i] = jbox::get_property_ref(fMotherBoardCustomPropertiesRef, "sample_sound_native_object%d", i);
fSampleZoneObjectRefs[i] = jbox::get_object_ref("/user_samples/%d", i);
}
// vs original code
fSampleNativeObjectRefs[0] = JBox_MakePropertyRef(fMotherBoardCustomPropertiesRef, "sample_sound_native_object0");
fSampleNativeObjectRefs[1] = JBox_MakePropertyRef(fMotherBoardCustomPropertiesRef, "sample_sound_native_object1");
fSampleNativeObjectRefs[2] = JBox_MakePropertyRef(fMotherBoardCustomPropertiesRef, "sample_sound_native_object2");
fSampleNativeObjectRefs[3] = JBox_MakePropertyRef(fMotherBoardCustomPropertiesRef, "sample_sound_native_object3");
fSampleZoneObjectRefs[0] = JBox_GetMotherboardObjectRef("/user_samples/0");
fSampleZoneObjectRefs[1] = JBox_GetMotherboardObjectRef("/user_samples/1");
fSampleZoneObjectRefs[2] = JBox_GetMotherboardObjectRef("/user_samples/2");
fSampleZoneObjectRefs[3] = JBox_GetMotherboardObjectRef("/user_samples/3");
Code: Select all
using ObjectPath = StaticString<kJBox_MaxObjectNameLen + 1>;
using PropertyName = StaticString<kJBox_MaxPropertyNameLen + 1>;
using PropertyPath = StaticString<kMaxPropertyPathLen + 1>;
Code: Select all
JBox_GetMotherboardObjectRef(ObjectPath::printf("/user_samples/%d", 3));
// note that this is exactly what jbox::get_object_ref does ;)
Here is the commit that shows the simplification that it brings to re-cva-7 (which had to initialize 256 properties just for the display by hand...)
Yan