#include "xscriptstringlist.h"
#include "xstring.h"

XScriptStringList::XScriptStringList()
    : XAsset()
    , mCount(0)
    , mStringPtrs()
    , mScriptStrings()
{

}

int XScriptStringList::Size()
{
    return mScriptStrings.size();
}

void XScriptStringList::Clear()
{
    mCount = 0;
    mStringPtrs.clear();
    mScriptStrings.clear();
}

void XScriptStringList::ParseData(QDataStream *aStream)
{
    if (GetPtr())
    {
        for (int i = 0; i < mCount; i++)
        {
            qint32 tempStringPtr;
            *aStream >> tempStringPtr;

            if (tempStringPtr == -1)
            {
                mScriptStrings << XString::ParseCustom(aStream);
            }
        }
    }
}

void XScriptStringList::ParsePtr(QDataStream *aStream, bool aDataFlag)
{
    qint32 stringsPtr;

    *aStream
        >> mCount
        >> stringsPtr;

    SetPtr(stringsPtr);
}
