18 #include "precompiled.h"
44 std::stringstream str;
45 str << std::setprecision(prec) << value;
46 std::string r = str.str();
47 size_t e = r.find(
'e');
50 if (e == r.length() - 5 && r[e + 2] ==
'0')
56 m_ScriptInterface(scriptInterface), m_Stream(stream), m_IsDebug(includeDebugInfo), m_Indent(0)
71 #define INDENT std::string(m_Indent, ' ')
130 m_Stream <<
INDENT << name <<
": " << (value ?
"true" :
"false") <<
"\n";
136 escaped.reserve(value.size());
137 for (
size_t i = 0; i < value.size(); ++i)
140 else if (value[i] ==
'\\')
142 else if (value[i] ==
'\n')
162 for (
size_t i = 0; i < len; ++i)
A simple fixed-point number class.
std::string utf8_from_wstring(const std::wstring &src, Status *err)
opposite of wstring_from_utf8
virtual std::ostream & GetStream()
Returns a stream which can be used to serialize data directly.
virtual void PutBool(const char *name, bool value)
int sprintf_s(char *buf, size_t max_chars, const char *fmt,...) PRINTF_ARGS(3)
std::string canonfloat(T value, int prec)
virtual void PutScriptVal(const char *name, jsval value)
virtual void PutNumber(const char *name, uint8_t value)
#define ENSURE(expr)
ensure the expression <expr> evaluates to non-zero.
virtual bool IsDebug() const
Returns true if the serializer is being used in debug mode.
virtual void PutRaw(const char *name, const u8 *data, size_t len)
#define T(string_literal)
void TextLine(const std::string &text)
void Comment(const std::string &comment)
virtual void PutString(const char *name, const std::string &value)
ScriptInterface & m_ScriptInterface
CStr8 ToString() const
Returns the shortest string such that FromString will parse to the correct value. ...
Abstraction around a SpiderMonkey JSContext.
std::wstring ToString(jsval obj, bool pretty=false)
CDebugSerializer(ScriptInterface &scriptInterface, std::ostream &stream, bool includeDebugInfo=true)