| 114 | } |
| 115 | |
| 116 | void save() |
| 117 | { |
| 118 | // Save the internal imnodes state |
| 119 | ImNodes::SaveCurrentEditorStateToIniFile("save_load.ini"); |
| 120 | |
| 121 | // Dump our editor state as bytes into a file |
| 122 | |
| 123 | std::fstream fout( |
| 124 | "save_load.bytes", std::ios_base::out | std::ios_base::binary | std::ios_base::trunc); |
| 125 | |
| 126 | // copy the node vector to file |
| 127 | const size_t num_nodes = nodes_.size(); |
| 128 | fout.write( |
| 129 | reinterpret_cast<const char*>(&num_nodes), |
| 130 | static_cast<std::streamsize>(sizeof(size_t))); |
| 131 | fout.write( |
| 132 | reinterpret_cast<const char*>(nodes_.data()), |
| 133 | static_cast<std::streamsize>(sizeof(Node) * num_nodes)); |
| 134 | |
| 135 | // copy the link vector to file |
| 136 | const size_t num_links = links_.size(); |
| 137 | fout.write( |
| 138 | reinterpret_cast<const char*>(&num_links), |
| 139 | static_cast<std::streamsize>(sizeof(size_t))); |
| 140 | fout.write( |
| 141 | reinterpret_cast<const char*>(links_.data()), |
| 142 | static_cast<std::streamsize>(sizeof(Link) * num_links)); |
| 143 | |
| 144 | // copy the current_id to file |
| 145 | fout.write( |
| 146 | reinterpret_cast<const char*>(¤t_id_), static_cast<std::streamsize>(sizeof(int))); |
| 147 | } |
| 148 | |
| 149 | void load() |
| 150 | { |
no test coverage detected