MCPcopy Create free account
hub / github.com/Illation/ETEngine / WriteNumber

Method WriteNumber

Engine/source/EtCore/FileSystem/Json/JsonWriter.cpp:166–194  ·  view source on GitHub ↗

--------------------------------- Writer::WriteNumber Write a number

Source from the content-addressed store, hash-verified

164// Write a number
165//
166bool Writer::WriteNumber(Number const* const jNum)
167{
168 if (jNum == nullptr)
169 {
170 LOG("JSON::Writer::WriteNumber > Failed to write json number to string, number object was null", LogLevel::Warning);
171 return false;
172 }
173
174 // use either the double or int val. if its a double the ostream should automatically convert to scientific notation if necessary
175 if (jNum->isInt)
176 {
177 m_JsonString += std::to_string(jNum->valueInt);
178 }
179 else
180 {
181 std::ostringstream streamObj;
182 streamObj << jNum->value;
183
184 std::string numString = streamObj.str();
185 if (numString.find('.') == std::string::npos)
186 {
187 numString += ".0";
188 }
189
190 m_JsonString += numString;
191 }
192
193 return true;
194}
195
196//---------------------------------
197// Writer::WriteString

Callers

nothing calls this directly

Calls 1

strMethod · 0.80

Tested by

no test coverage detected