




#include "xpathnodetreenodes.h"

XPathNodeTreeNodes::XPathNodeTreeNodes()
    : XAsset() {
}

void XPathNodeTreeNodes::ParseData(QDataStream *aStream) {
    if (GetPtr() == -1) {
        aStream->read((char*)&mNodeCount, sizeof(int));

        // Allocate and parse nodes
        if (mNodes != nullptr) {
            delete[] mNodes;
            mNodes = nullptr;
        }

        if (mNodeCount > 0) {
            mNodes = new unsigned short[mNodeCount];
            aStream->read((char*)mNodes, mNodeCount * sizeof(unsigned short));
        }
    }
}

int XPathNodeTreeNodes::GetNodeCount() const {
    return mNodeCount;
}

void XPathNodeTreeNodes::SetNodeCount(int count) {
    mNodeCount = count;
}

unsigned short* XPathNodeTreeNodes::GetNodes() const {
    return mNodes;
}

void XPathNodeTreeNodes::SetNodes(unsigned short* nodes, int count) {
    if (mNodes != nullptr) {
        delete[] mNodes;
    }

    mNodeCount = count;
    mNodes = new unsigned short[count];
    memcpy(mNodes, nodes, count * sizeof(unsigned short));
}




