Class StringProvider

Inheritance Relationships

Base Type

Class Documentation

class StringProvider : public zim::writer::ContentProvider

StringProvider provide the content stored in a string.

Public Functions

inline explicit StringProvider(const std::string &content)

Create a provider using a string as content. The string content is copied and the reference don’t have to be “keep” alive.

Parameters:

content – the content to serve.

inline virtual zim::size_type getSize() const

The size of the content to add into the archive.

Returns:

the total size of the content.

virtual Blob feed()

Return a blob to add to the archive.

The returned blob doesn’t have to represent the whole content. The feed method can return the whole content chunk by chunk or in one step. When the whole content has been returned, feed must return an empty blob (size == 0).

This method will be called several times (at least twice) for each content to add.

It is up to the implementation to manage correctly the data pointed by the returned blob. It may (re)use the same buffer between calls (rewriting its content), create a new buffer each time or make the blob point to a new region of a big buffer. It is up to the implementation to free any allocated memory.

The data pointed by the blob must stay valid until the next call to feed. A call to feed ensure that the data returned by a previous call will not be used anymore.

Protected Attributes

std::string content
bool feeded