libASPL
Loading...
Searching...
No Matches
aspl::Storage Class Reference

Plugin persistent storage. More...

#include <aspl/Storage.hpp>

Public Member Functions

 Storage (std::shared_ptr< Context > context)
 Construct storage.
 
 Storage (const Storage &)=delete
 
Storageoperator= (const Storage &)=delete
 
std::shared_ptr< const ContextGetContext () const
 Get context.
 
std::pair< std::vector< UInt8 >, boolReadBytes (std::string key) const
 Read CFData value from storage and decode it into byte array.
 
std::pair< std::string, boolReadString (std::string key) const
 Read CFString value from storage and decode it into UTF-8 string.
 
std::pair< bool, boolReadBoolean (std::string key) const
 Read CFBoolean value from storage and decode it into bool.
 
std::pair< SInt64, boolReadInt (std::string key) const
 Read CFNumber value from storage and decode it into SInt64.
 
std::pair< Float64, boolReadFloat (std::string key) const
 Read CFNumber value from storage and decode it into Float64.
 
std::pair< CFPropertyListRef, boolReadCustom (std::string key) const
 Read CFPropertyList value from storage and return it.
 
bool WriteBytes (std::string key, std::vector< UInt8 > value)
 Encode byte array into CFData value and write it to storage.
 
bool WriteString (std::string key, std::string value)
 Encode C++ string into CFString value and write it to storage.
 
bool WriteBoolean (std::string key, bool value)
 Encode bool into CFBoolean value and write it to storage.
 
bool WriteInt (std::string key, SInt64 value)
 Encode SInt64 into CFNumber value and write it to storage.
 
bool WriteFloat (std::string key, Float64 value)
 Encode Float64 into CFNumber value and write it to storage.
 
bool WriteCustom (std::string key, CFPropertyListRef value)
 Write CFPropertyList value to storage.
 
bool Delete (std::string key)
 Delete value from storage.
 

Detailed Description

Plugin persistent storage.

Storage data persists across audio server restart and rebooting. Storage keys for one plug-in do not collide with the keys for other plug-ins.

This class is a wrapper for "Storage Operations" API in AudioServerPlugInHostInterface, which is stored in Context.Host. It becomes available during driver initialization; until that, attempt to use Storage methods will lead to errors.

Definition at line 29 of file Storage.hpp.

Constructor & Destructor Documentation

◆ Storage()

aspl::Storage::Storage ( std::shared_ptr< Context > context)
explicit

Construct storage.

Member Function Documentation

◆ Delete()

bool aspl::Storage::Delete ( std::string key)

Delete value from storage.

Remarks
Returns error if value does not exist or can not be deleted.
Note
Uses Context.Host.DeleteFromStorage.

◆ GetContext()

std::shared_ptr< const Context > aspl::Storage::GetContext ( ) const

Get context.

◆ ReadBoolean()

std::pair< bool, bool > aspl::Storage::ReadBoolean ( std::string key) const

Read CFBoolean value from storage and decode it into bool.

Remarks
Returns error if value does not exist or has wrong type.
Note
Uses Context.Host.CopyFromStorage.

◆ ReadBytes()

std::pair< std::vector< UInt8 >, bool > aspl::Storage::ReadBytes ( std::string key) const

Read CFData value from storage and decode it into byte array.

Remarks
Returns error if value does not exist or has wrong type.
Note
Uses Context.Host.CopyFromStorage.

◆ ReadCustom()

std::pair< CFPropertyListRef, bool > aspl::Storage::ReadCustom ( std::string key) const

Read CFPropertyList value from storage and return it.

Remarks
Returns error if value does not exist. Caller is responsible to release returned value.
Note
Uses Context.Host.CopyFromStorage.

◆ ReadFloat()

std::pair< Float64, bool > aspl::Storage::ReadFloat ( std::string key) const

Read CFNumber value from storage and decode it into Float64.

Remarks
Returns error if value does not exist, has wrong type, or can not be represented as Float64 without loss.
Note
Uses Context.Host.CopyFromStorage.

◆ ReadInt()

std::pair< SInt64, bool > aspl::Storage::ReadInt ( std::string key) const

Read CFNumber value from storage and decode it into SInt64.

Remarks
Returns error if value does not exist, has wrong type, or can not be represented as SInt64 without loss.
Note
Uses Context.Host.CopyFromStorage.

◆ ReadString()

std::pair< std::string, bool > aspl::Storage::ReadString ( std::string key) const

Read CFString value from storage and decode it into UTF-8 string.

Remarks
Returns error if value does not exist or has wrong type.
Note
Uses Context.Host.CopyFromStorage.

◆ WriteBoolean()

bool aspl::Storage::WriteBoolean ( std::string key,
bool value )

Encode bool into CFBoolean value and write it to storage.

Remarks
Returns error if value can not be encoded or written.
Note
Uses Context.Host.WriteToStorage.

◆ WriteBytes()

bool aspl::Storage::WriteBytes ( std::string key,
std::vector< UInt8 > value )

Encode byte array into CFData value and write it to storage.

Remarks
Returns error if value can not be encoded or written.
Note
Uses Context.Host.WriteToStorage.

◆ WriteCustom()

bool aspl::Storage::WriteCustom ( std::string key,
CFPropertyListRef value )

Write CFPropertyList value to storage.

Remarks
Returns error if value can not be encoded or written. Does not take ownership of the value.
Note
Uses Context.Host.WriteToStorage.

◆ WriteFloat()

bool aspl::Storage::WriteFloat ( std::string key,
Float64 value )

Encode Float64 into CFNumber value and write it to storage.

Remarks
Returns error if value can not be encoded or written.
Note
Uses Context.Host.WriteToStorage.

◆ WriteInt()

bool aspl::Storage::WriteInt ( std::string key,
SInt64 value )

Encode SInt64 into CFNumber value and write it to storage.

Remarks
Returns error if value can not be encoded or written.
Note
Uses Context.Host.WriteToStorage.

◆ WriteString()

bool aspl::Storage::WriteString ( std::string key,
std::string value )

Encode C++ string into CFString value and write it to storage.

Remarks
Returns error if value can not be encoded or written.
Note
Uses Context.Host.WriteToStorage.

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