Exemplo n.º 1
0
ITextBufferSP VKTS_APIENTRY fileLoadText(const char* filename)
{
    auto buffer = fileLoadBinary(filename);

    if (!buffer.get())
    {
        return ITextBufferSP();
    }

    if (!buffer->getData() || buffer->getSize() == 0)
    {
        return ITextBufferSP();
    }

    auto data = new char[buffer->getSize() + 1];

    if (!data)
    {
        return ITextBufferSP();
    }

    memset(data, 0, buffer->getSize() + 1);

    memcpy(data, buffer->getData(), buffer->getSize());

    auto text = ITextBufferSP(new TextBuffer(data));

    delete[] data;

    return text;
}
Exemplo n.º 2
0
ITextBufferSP TextBuffer::clone() const
{
    return ITextBufferSP(new TextBuffer(text));
}