Esempio n. 1
0
bool CECTag::ReadFromSocket(CECSocket& socket)
{
	ec_tagname_t tmp_tagName;
	if (!socket.ReadNumber(&tmp_tagName, sizeof(ec_tagname_t))) {
		return false;
	}
	m_tagName = tmp_tagName >> 1;
	bool hasChildren = (tmp_tagName & 0x01) != 0;

	if (!socket.ReadNumber(&m_dataType, sizeof(ec_tagtype_t))) {
		return false;
	}

	if (!socket.ReadNumber(&m_dataLen, sizeof(ec_taglen_t))) {
		return false;
	}

	if (hasChildren && !ReadChildren(socket)) {
		return false;
	}

	unsigned int tmp_len = m_dataLen;
	m_dataLen = 0;
	m_dataLen = tmp_len - GetTagLen();
	if (m_dataLen > 0) {
		NewData();
		if (!socket.ReadBuffer(m_tagData, m_dataLen)) {
			return false;
		}
	} else {
		m_tagData = NULL;
	}

	return true;
}
Esempio n. 2
0
bool CECTag::WriteChildren(CECSocket& socket) const
{
	uint16 tmp = (uint16)m_tagList.size();
	if (!socket.WriteNumber(&tmp, sizeof(tmp))) return false;
	for (const_iterator it = begin(); it != end(); ++it) {
		if (!it->WriteTag(socket)) return false;
	}
	return true;
}
Esempio n. 3
0
bool CECTag::WriteTag(CECSocket& socket) const
{
	ec_tagname_t tmp_tagName = (m_tagName << 1) | (m_tagList.empty() ? 0 : 1);
	ec_tagtype_t type = m_dataType;
	ec_taglen_t tagLen = GetTagLen();
	wxASSERT(type != EC_TAGTYPE_UNKNOWN);

	if (!socket.WriteNumber(&tmp_tagName, sizeof(ec_tagname_t))) return false;
	if (!socket.WriteNumber(&type, sizeof(ec_tagtype_t))) return false;
	if (!socket.WriteNumber(&tagLen, sizeof(ec_taglen_t))) return false;

	if (!m_tagList.empty()) {
		if (!WriteChildren(socket)) return false;
	}

	if (m_dataLen > 0) {
		if (m_tagData != NULL) {	// This is here only to make sure everything, it should not be NULL at this point
			if (!socket.WriteBuffer(m_tagData, m_dataLen)) return false;
		}
	}

	return true;
}
Esempio n. 4
0
bool CECTag::ReadChildren(CECSocket& socket)
{
	uint16 tmp_tagCount;
	if (!socket.ReadNumber(&tmp_tagCount, sizeof(uint16))) {
		return false;
	}
	m_tagList.clear();
	for (int i = 0; i < tmp_tagCount; i++) {
		m_tagList.push_back(CECTag());
		CECTag& tag = m_tagList.back();
		if (!tag.ReadFromSocket(socket)) {
			return false;
		}
	}
	return true;
}