TerraForge3D  2.3.1
3D Terrain And Landscape Generator

◆ LoadFile()

void Serializer::LoadFile ( std::string  path)

Definition at line 247 of file Serializer.cpp.

248{
249 if (path.size() <= 3)
250 {
251 return;
252 }
253
254 if (path.find(".terr3d") == std::string::npos)
255 {
256 path = path + ".terr3d";
257 }
258
259 bool flagRd = true;
260 std::string sdata = ReadShaderSourceFile(path, &flagRd);
261
262 if (!flagRd)
263 {
264 Log("Could not read file : " + path);
265 return;
266 }
267
268 if (sdata.size() == 0)
269 {
270 Log("Empty file.");
271 return;
272 }
273
274 nlohmann::json tmp;
275
276 try
277 {
278 tmp = nlohmann::json::parse(sdata);
279 }
280
281 catch (...)
282 {
283 Log("Failed to Parse file : " + path);
284 }
285
286 if (path != appState->globals.currentOpenFilePath)
287 {
288 appState->globals.currentOpenFilePath = path;
289 }
290
291 Deserialize(tmp);
292}
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json parse(InputType &&i, const parser_callback_t cb=nullptr, const bool allow_exceptions=true, const bool ignore_comments=false)
deserialize from a compatible input
Definition: json.hpp:24605
a class to store JSON values
Definition: json.hpp:17860