MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / read

Method read

Engine/source/persistence/taml/json/tamlJSONReader.cpp:34–69  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32//-----------------------------------------------------------------------------
33
34SimObject* TamlJSONReader::read( FileStream& stream )
35{
36 // Debug Profiling.
37 PROFILE_SCOPE(TamlJSONReader_Read);
38
39 // Read JSON file.
40 const U32 streamSize = stream.getStreamSize();
41 FrameTemp<char> jsonText( streamSize + 1 );
42 if ( !stream.read( streamSize, jsonText ) )
43 {
44 // Warn!
45 Con::warnf("TamlJSONReader::read() - Could not load Taml JSON file from stream.");
46 return NULL;
47 }
48 jsonText[streamSize] = '\0';
49
50 // Create JSON document.
51 rapidjson::Document document;
52 document.Parse<0>( jsonText );
53
54 // Check the document is valid.
55 if ( document.GetType() != rapidjson::kObjectType )
56 {
57 // Warn!
58 Con::warnf("TamlJSONReader::read() - Load Taml JSON file from stream but was invalid.");
59 return NULL;
60 }
61
62 // Parse root value.
63 SimObject* pSimObject = parseType( document.MemberBegin() );
64
65 // Reset parse.
66 resetParse();
67
68 return pSimObject;
69}
70
71//-----------------------------------------------------------------------------
72

Callers 1

acceptMethod · 0.45

Calls 4

warnfFunction · 0.50
getStreamSizeMethod · 0.45
GetTypeMethod · 0.45
MemberBeginMethod · 0.45

Tested by

no test coverage detected