Class SharedStringProvider¶
Defined in File contentProvider.h
Inheritance Relationships¶
Base Type¶
public zim::writer::ContentProvider
(Class ContentProvider)
Class Documentation¶
-
class SharedStringProvider : public zim::writer::ContentProvider¶
SharedStringProvider provide the content stored in a shared string.
It is mostly the same thing that
StringProvider
but use a shared_ptr to avoid copy.Public Functions
-
inline explicit SharedStringProvider(std::shared_ptr<const std::string> content)¶
Create a provider using a string as content. The string content is not copied.
- 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.
-
inline explicit SharedStringProvider(std::shared_ptr<const std::string> content)¶