Пример #1
0
void Environment::Deserialize(std::istream& in)
{
    uint16_t env_length = 0;
    Read(in, &env_length);

    while (env_length-- > 0) {
        std::string key, value;
        ReadShortString(in, &key);
        ReadShortString(in, &value);
        m_environment[key] = value;
    }
}
Пример #2
0
bool AMF0Serializer::ReadObject(IOBuffer &buffer, Variant &variant,
		bool readType) {
	if (readType) {
		AMF_CHECK_BOUNDARIES(buffer, 1);
		if (GETIBPOINTER(buffer)[0] != AMF0_OBJECT) {
			FATAL("AMF type not valid: want: %"PRIu8"; got: %"PRIu8,
					AMF0_OBJECT, GETIBPOINTER(buffer)[0]);
			return false;
		}

		if (!buffer.Ignore(1)) {
			FATAL("Unable to ignore 1 bytes");
			return false;
		}
	}

	AMF_CHECK_BOUNDARIES(buffer, 3);
	while (!((GETIBPOINTER(buffer)[0] == 0) && (GETIBPOINTER(buffer)[1] == 0) && (GETIBPOINTER(buffer)[2] == 9))) {
		Variant key;
		Variant value;
		if (!ReadShortString(buffer, key, false)) {
			FATAL("Unable to read key");
			return false;
		}
		if (!Read(buffer, value)) {
			FATAL("Unable to read value");
			return false;
		}
		variant[key] = value;
	}

	AMF_CHECK_BOUNDARIES(buffer, 3);
	if (!buffer.Ignore(3)) {
		FATAL("Unable to ignore 3 bytes");
		return false;
	}

	variant.IsArray(false);

	return true;
}