Conscience Core
Public Member Functions | Static Public Member Functions | List of all members
conscience_core::core_objects::resources::CscResources Class Reference

#include <CscResources.h>

Public Member Functions

ifstream resolveAsStream (const CscResourceSpec &spec) noexcept(false)
 
vector< unsigned char > resolveAsBytes (const CscResourceSpec &spec) noexcept(false)
 
string resolveAsString (const CscResourceSpec &spec) noexcept(false)
 
void resolveAndExportToFile (const CscResourceSpec &spec, const fs::path &outPath) noexcept(false)
 
fs::path getInternalPath (const CscResourceSpec &spec) noexcept(false)
 
unsigned long long getLastModificationTime (const CscResourceSpec &spec) noexcept(false)
 
void publish (const CscResourceSpec &spec, const string &content) noexcept(false)
 
void remove (const CscResourceSpec &spec) noexcept(false)
 
bool checkIfPathExistOnDrive (const CscResourceSpec &spec)
 
 CscResources (CscResources &&)
 
virtual ~CscResources ()=default
 

Static Public Member Functions

static CscResourcesInstance ()
 

Constructor & Destructor Documentation

◆ CscResources()

conscience_core::core_objects::resources::CscResources::CscResources ( CscResources &&  )

◆ ~CscResources()

virtual conscience_core::core_objects::resources::CscResources::~CscResources ( )
virtualdefault

Member Function Documentation

◆ checkIfPathExistOnDrive()

bool conscience_core::core_objects::resources::CscResources::checkIfPathExistOnDrive ( const CscResourceSpec spec)

◆ getInternalPath()

fs::path conscience_core::core_objects::resources::CscResources::getInternalPath ( const CscResourceSpec spec)
noexcept

WARNING To be used very carefully - this returns / exposes resources internal cache directory, and should therefore be used with the greatest attention. This will return the direct path to the document. This provides a good way of optimizing (to avoid copy) but requires caution.

Parameters
specresource locator spec
Note
If spec supports & specifies protection unlock data, it will be used to grant this operation.
Returns
Internal resource path. File should not be deleted or modified, unless it's sure that there is absolutely no problem.
Exceptions
UnavailableResourceExceptionif resource cannot be retrieved

◆ getLastModificationTime()

unsigned long long conscience_core::core_objects::resources::CscResources::getLastModificationTime ( const CscResourceSpec spec)
noexcept
Parameters
specresource locator spec
Note
If spec supports & specifies protection unlock data, it will be used to grant this operation.
If remote resource, will be downloaded first
Returns
Last modification time of resource, timestamp millis
Exceptions
UnavailableResourceExceptionif resource cannot be retrieved

◆ Instance()

CscResources & conscience_core::core_objects::resources::CscResources::Instance ( )
static

◆ publish()

void conscience_core::core_objects::resources::CscResources::publish ( const CscResourceSpec spec,
const string &  content 
)
noexcept

Publishes new content for given resource spec.

Parameters
specresource locator spec
Note
If spec supports & specifies protection, it will be used to protect resources
Exceptions
UnavailableResourceExceptionif resource already exists and protection differs
UnsupportedSpecExceptionif spec does not support publication

◆ remove()

void conscience_core::core_objects::resources::CscResources::remove ( const CscResourceSpec spec)
noexcept

Removes resource denoted by given spec, if possible

Parameters
specresource locator spec
Note
If spec supports & specifies protection unlock data, it will be used to grant this operation.
Exceptions
UnavailableResourceExceptionif resource does not exists or
UnsupportedSpecExceptionif spec does not support publication

◆ resolveAndExportToFile()

void conscience_core::core_objects::resources::CscResources::resolveAndExportToFile ( const CscResourceSpec spec,
const fs::path &  outPath 
)
noexcept

Provide the requested resource to given path. Overwrites any existing file

Note
If spec supports & specifies protection unlock data, it will be used to grant this operation.
Parameters
specresource locator spec
outPathfs path to which write the file
Exceptions
UnavailableResourceExceptionif resource cannot be retrieved

◆ resolveAsBytes()

vector< unsigned char > conscience_core::core_objects::resources::CscResources::resolveAsBytes ( const CscResourceSpec spec)
noexcept

Returns resource's content as bytes vector

Parameters
specresource locator spec
Returns
content as bytes vector
Exceptions
UnavailableResourceExceptionif resource cannot be retrieved / open

◆ resolveAsStream()

ifstream conscience_core::core_objects::resources::CscResources::resolveAsStream ( const CscResourceSpec spec)
noexcept

WARNING: returned stream must be closed

Parameters
specresource locator spec
Returns
a stream to given resource
Exceptions
UnavailableResourceExceptionif resource cannot be retrieved

◆ resolveAsString()

string conscience_core::core_objects::resources::CscResources::resolveAsString ( const CscResourceSpec spec)
noexcept
Note
If spec supports & specifies protection unlock data, it will be used to grant this operation.
Parameters
specresource locator spec
Returns
the content of the resource as string
Exceptions
UnavailableResourceExceptionif resource cannot be retrieved

The documentation for this class was generated from the following files: