MCPcopy Create free account
hub / github.com/BespokeSynth/BespokeSynth / SavePrefab

Method SavePrefab

Source/Prefab.cpp:267–295  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

265}
266
267void Prefab::SavePrefab(std::string savePath)
268{
269 ofxJSONElement root;
270
271 root["modules"] = mModuleContainer.WriteModules();
272
273 std::stringstream ss(root.getRawString(true));
274 std::string line;
275 std::string lines;
276 while (getline(ss, line, '\n'))
277 {
278 const char* pos = strstr(line.c_str(), " : \"$");
279 if (pos != nullptr)
280 {
281 bool endsWithComma = line[line.length() - 1] == ',';
282 ofStringReplace(line, pos, " : \"\"");
283 if (endsWithComma)
284 line += ",";
285 }
286 lines += line + '\n';
287 }
288
289 UpdatePrefabName(savePath);
290
291 FileStreamOut out(ofToDataPath(savePath));
292
293 out << lines;
294 mModuleContainer.SaveState(out);
295}
296
297void Prefab::LoadPrefab(std::string loadPath)
298{

Callers

nothing calls this directly

Calls 6

ofStringReplaceFunction · 0.85
ofToDataPathFunction · 0.85
WriteModulesMethod · 0.80
getRawStringMethod · 0.80
lengthMethod · 0.80
SaveStateMethod · 0.45

Tested by

no test coverage detected