예제 #1
0
bool BinTreeNodeReader::nextTreeInternal(ProtocolTreeNode& node, QDataStream &in)
{
    quint8 b;

    in >> b;
    int size = readListSize(b,in);
    in >> b;
    if (b == 2)
        return false;

    QByteArray tag;
    readString(b, tag, in);

    int attribCount = (size - 2 + size % 2) / 2;
    AttributeList attribs;
    readAttributes(attribs,attribCount,in);

    node.setTag(tag);
    node.setAttributes(attribs);

    if ((size % 2) == 1)
        return true;

    in >> b;
    if (isListTag(b))
    {
        readList(b,node,in);
        return true;
    }

    QByteArray data;
    readString(b,data,in);
    node.setData(data);
    return true;
}
예제 #2
0
bool BinTreeNodeReader::nextTree(ProtocolTreeNode& node)
{
    bool result;

    node.setSize(getOneToplevelStream());
    QDataStream in(readBuffer);

    result = nextTreeInternal(node, in);
    qDebug() << "read" << node.toString();
    return result;
}
예제 #3
0
bool BinTreeNodeReader::nextTree(ProtocolTreeNode& node)
{
    bool result;

    node.setSize(getOneToplevelStream());
    QDataStream in(readBuffer);

    result = nextTreeInternal(node, in);
    Utilities::logData(QDateTime::currentDateTime().toString());
    Utilities::logData(node.toString());
    return result;
}
예제 #4
0
bool BinTreeNodeReader::nextTreeInternal(ProtocolTreeNode& node)
{
    quint8 b;

    if (!readInt8(b))
        return false;

    int size = -1;
    if (!readListSize(b, size))
        return false;
    if (size < 0)
        return false;

    if (!readInt8(b))
        return false;

    if (b == 2)
        return false;

    QByteArray tag;
    if (!readString(b, tag))
        return false;

    int attribCount = (size - 2 + size % 2) / 2;

    AttributeList attribs;
    if (!readAttributes(attribs,attribCount))
        return false;

    node.setTag(tag);
    node.setAttributes(attribs);

    if ((size % 2) == 1)
        return true;

    if (!readInt8(b))
        return false;

    if (isListTag(b))
    {
        return readList(b,node);
    }

    QByteArray data;
    if (!readString(b,data))
        return false;

    node.setData(data);
    return true;
}
예제 #5
0
bool BinTreeNodeReader::nextTree(ProtocolTreeNode& node)
{
    bool result;

    if (!getOneToplevelStream()) {
        return false;
    }

    node.setSize(getOneToplevelStreamSize());

    result = nextTreeInternal(node);
    Utilities::logData("INCOMING:\n" + node.toString());
    return result;
}
예제 #6
0
void BinTreeNodeReader::readList(qint32 token,ProtocolTreeNode& node,QDataStream& in)
{
    int size = readListSize(token,in);
    for (int i=0; i<size; i++)
    {
        ProtocolTreeNode child;
        nextTreeInternal(child,in);
        node.addChild(child);
    }
}
예제 #7
0
bool BinTreeNodeReader::readList(qint32 token,ProtocolTreeNode& node)
{
    int size = 0;
    if (!readListSize(token, size)) {
        qDebug() << "failed to read listSize";
        return false;
    }
    for (int i=0; i<size; i++)
    {
        ProtocolTreeNode child;
        //TODO: check results
        nextTreeInternal(child);
        node.addChild(child);
    }
    return true;
}