MCPcopy Create free account
hub / github.com/Nelarius/imnodes / SaveEditorStateToIniString

Function SaveEditorStateToIniString

imnodes.cpp:3042–3072  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3040}
3041
3042const char* SaveEditorStateToIniString(
3043 const ImNodesEditorContext* const editor_ptr,
3044 size_t* const data_size)
3045{
3046 assert(editor_ptr != NULL);
3047 const ImNodesEditorContext& editor = *editor_ptr;
3048
3049 GImNodes->TextBuffer.clear();
3050 // TODO: check to make sure that the estimate is the upper bound of element
3051 GImNodes->TextBuffer.reserve(64 * editor.Nodes.Pool.size());
3052
3053 GImNodes->TextBuffer.appendf(
3054 "[editor]\npanning=%i,%i\n", (int)editor.Panning.x, (int)editor.Panning.y);
3055
3056 for (int i = 0; i < editor.Nodes.Pool.size(); i++)
3057 {
3058 if (editor.Nodes.InUse[i])
3059 {
3060 const ImNodeData& node = editor.Nodes.Pool[i];
3061 GImNodes->TextBuffer.appendf("\n[node.%d]\n", node.Id);
3062 GImNodes->TextBuffer.appendf("origin=%i,%i\n", (int)node.Origin.x, (int)node.Origin.y);
3063 }
3064 }
3065
3066 if (data_size != NULL)
3067 {
3068 *data_size = GImNodes->TextBuffer.size();
3069 }
3070
3071 return GImNodes->TextBuffer.c_str();
3072}
3073
3074void LoadCurrentEditorStateFromIniString(const char* const data, const size_t data_size)
3075{

Callers 2

SaveEditorStateToIniFileFunction · 0.85

Calls 5

reserveMethod · 0.80
appendfMethod · 0.80
c_strMethod · 0.80
clearMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected