MCPcopy Create free account
hub / github.com/Jaysmito101/TerraForge3D / LoadEditorStateFromIniString

Function LoadEditorStateFromIniString

include/imnodes/imnodes.cpp:3067–3124  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3065}
3066
3067void LoadEditorStateFromIniString(
3068 ImNodesEditorContext* const editor_ptr,
3069 const char* const data,
3070 const size_t data_size)
3071{
3072 if (data_size == 0u)
3073 {
3074 return;
3075 }
3076
3077 ImNodesEditorContext& editor = editor_ptr == NULL ? EditorContextGet() : *editor_ptr;
3078
3079 char* buf = (char*)ImGui::MemAlloc(data_size + 1);
3080 const char* buf_end = buf + data_size;
3081 memcpy(buf, data, data_size);
3082 buf[data_size] = 0;
3083
3084 void (*line_handler)(ImNodesEditorContext&, const char*);
3085 line_handler = NULL;
3086 char* line_end = NULL;
3087 for (char* line = buf; line < buf_end; line = line_end + 1)
3088 {
3089 while (*line == '\n' || *line == '\r')
3090 {
3091 line++;
3092 }
3093 line_end = line;
3094 while (line_end < buf_end && *line_end != '\n' && *line_end != '\r')
3095 {
3096 line_end++;
3097 }
3098 line_end[0] = 0;
3099
3100 if (*line == ';' || *line == '\0')
3101 {
3102 continue;
3103 }
3104
3105 if (line[0] == '[' && line_end[-1] == ']')
3106 {
3107 line_end[-1] = 0;
3108 if (strncmp(line + 1, "node", 4) == 0)
3109 {
3110 line_handler = NodeLineHandler;
3111 }
3112 else if (strcmp(line + 1, "editor") == 0)
3113 {
3114 line_handler = EditorLineHandler;
3115 }
3116 }
3117
3118 if (line_handler != NULL)
3119 {
3120 line_handler(editor, line);
3121 }
3122 }
3123 ImGui::MemFree(buf);
3124}

Callers 3

LoadEditorDataFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected