Tesseract 0.28.4
Loading...
Searching...
No Matches
tesseract::common::Resource Class Referenceabstract

Represents resource data available from a file or url. More...

#include <resource_locator.h>

Inheritance diagram for tesseract::common::Resource:

Public Types

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>

Public Member Functions

virtual bool isFile () const =0
 Returns true if the located resource is a local file.
virtual std::string getUrl () const =0
 Get the original URL used to locate the file.
virtual std::string getFilePath () const =0
 Get the file path of the resource. Only valid if isFile() is true.
virtual std::vector< uint8_t > getResourceContents () const =0
 Get the resource as bytes. This function may block.
virtual std::shared_ptr< std::istream > getResourceContentStream () const =0
 Get the resource as a std::istream. This function and the returned stream may block.
bool operator== (const Resource &rhs) const
bool operator!= (const Resource &rhs) const
Public Member Functions inherited from tesseract::common::ResourceLocator
virtual std::shared_ptr< Resource > locateResource (const std::string &url) const =0
 Locate a resource based on a URL.
bool operator== (const ResourceLocator &rhs) const
bool operator!= (const ResourceLocator &rhs) const

Friends

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

Detailed Description

Represents resource data available from a file or url.

Member Function Documentation

◆ isFile()

virtual bool tesseract::common::Resource::isFile ( ) const
pure virtual

Returns true if the located resource is a local file.

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

Implemented in tesseract::common::BytesResource, and tesseract::common::SimpleLocatedResource.

◆ getUrl()

virtual std::string tesseract::common::Resource::getUrl ( ) const
pure virtual

Get the original URL used to locate the file.

Returns
The URL of the resource

Implemented in tesseract::common::BytesResource, and tesseract::common::SimpleLocatedResource.

◆ getFilePath()

virtual std::string tesseract::common::Resource::getFilePath ( ) const
pure virtual

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

Returns
The file path to the resource

Implemented in tesseract::common::BytesResource, and tesseract::common::SimpleLocatedResource.

◆ getResourceContents()

virtual std::vector< uint8_t > tesseract::common::Resource::getResourceContents ( ) const
pure virtual

Get the resource as bytes. This function may block.

Returns
Resource bytes as a uint8_t vector

Implemented in tesseract::common::BytesResource, and tesseract::common::SimpleLocatedResource.

◆ getResourceContentStream()

virtual std::shared_ptr< std::istream > tesseract::common::Resource::getResourceContentStream ( ) const
pure virtual

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

Implemented in tesseract::common::BytesResource, and tesseract::common::SimpleLocatedResource.