pluto-src 0.1.1+0.10.4

Sources of Pluto (Lua 5.4 dialect) and logic to build it.
Documentation
#include "JsonInt.hpp"

#include "Writer.hpp"

NAMESPACE_SOUP
{
	JsonInt::JsonInt(int64_t value) noexcept
		: JsonNode(JSON_INT), value(value)
	{
	}

	bool JsonInt::operator==(const JsonNode& b) const noexcept
	{
		return JSON_INT == b.type
			&& value == b.reinterpretAsInt().value
			;
	}

	void JsonInt::encodeAndAppendTo(std::string& str) const SOUP_EXCAL
	{
		str.append(std::to_string(value));
	}

	bool JsonInt::binaryEncode(Writer& w) const
	{
		uint8_t b = JSON_INT;
		if (value >= 0 && value < 0b11111)
		{
			b |= (value << 3);
			return w.u8(b);
		}
		b |= (0b11111 << 3);
		return w.u8(b)
			&& w.i64_dyn(value)
			;
	}
}