Tesseract 0.28.4
Loading...
Searching...
No Matches
tesseract::common::BytesResource Class Reference
Inheritance diagram for tesseract::common::BytesResource:

Public Member Functions

 BytesResource ()=default
 This is for serialization do not use directly.
 BytesResource (std::string url, std::vector< uint8_t > bytes, ResourceLocator::ConstPtr parent=nullptr)
 BytesResource (std::string url, const uint8_t *bytes, size_t bytes_len, ResourceLocator::ConstPtr parent=nullptr)
 BytesResource (const BytesResource &)=default
BytesResource & operator= (const BytesResource &)=default
 BytesResource (BytesResource &&)=default
BytesResource & operator= (BytesResource &&)=default
bool isFile () const override final
 Returns true if the located resource is a local file.
std::string getUrl () const override final
 Get the original URL used to locate the file.
std::string getFilePath () const override final
 Get the file path of the resource. Only valid if isFile() is true.
std::vector< uint8_t > getResourceContents () const override final
 Get the resource as bytes. This function may block.
std::shared_ptr< std::istream > getResourceContentStream () const override final
 Get the resource as a std::istream. This function and the returned stream may block.
Resource::Ptr locateResource (const std::string &url) const override final
 Locate a resource based on a URL.
bool operator== (const BytesResource &rhs) const
bool operator!= (const BytesResource &rhs) const
Public Member Functions inherited from tesseract::common::Resource
bool operator== (const Resource &rhs) const
bool operator!= (const Resource &rhs) const
Public Member Functions inherited from tesseract::common::ResourceLocator
bool operator== (const ResourceLocator &rhs) const
bool operator!= (const ResourceLocator &rhs) const

Friends

template<class Archive>
friend void::tesseract::common::serialize (Archive &ar, BytesResource &obj)

Additional Inherited Members

Public Types inherited from tesseract::common::Resource
using Ptr = std::shared_ptr<Resource>
using ConstPtr = std::shared_ptr<const Resource>
Public Types inherited from tesseract::common::ResourceLocator
using Ptr = std::shared_ptr<ResourceLocator>
using ConstPtr = std::shared_ptr<const ResourceLocator>

Member Function Documentation

◆ isFile()

bool tesseract::common::BytesResource::isFile ( ) const
finaloverridevirtual

Returns true if the located resource is a local file.

Returns
true if the resource is a local file, otherwise false

Implements tesseract::common::Resource.

◆ getUrl()

std::string tesseract::common::BytesResource::getUrl ( ) const
finaloverridevirtual

Get the original URL used to locate the file.

Returns
The URL of the resource

Implements tesseract::common::Resource.

◆ getFilePath()

std::string tesseract::common::BytesResource::getFilePath ( ) const
finaloverridevirtual

Get the file path of the resource. Only valid if isFile() is true.

Returns
The file path to the resource

Implements tesseract::common::Resource.

◆ getResourceContents()

std::vector< uint8_t > tesseract::common::BytesResource::getResourceContents ( ) const
finaloverridevirtual

Get the resource as bytes. This function may block.

Returns
Resource bytes as a uint8_t vector

Implements tesseract::common::Resource.

◆ getResourceContentStream()

std::shared_ptr< std::istream > tesseract::common::BytesResource::getResourceContentStream ( ) const
finaloverridevirtual

Get the resource as a std::istream. This function and the returned stream may block.

Returns
A std::istream shared pointer for the resource data

Implements tesseract::common::Resource.

◆ locateResource()

Resource::Ptr tesseract::common::BytesResource::locateResource ( const std::string & url) const
finaloverridevirtual

Locate a resource based on a URL.

Parameters
urlThe URL of the resource
Returns
A shared pointer to a Resource instance, or nullptr if not found

Implements tesseract::common::ResourceLocator.