Loading...
Searching...
No Matches
AccelByte::DataStorageBinaryFile Class Reference
Inheritance diagram for AccelByte::DataStorageBinaryFile:

Public Member Functions

 DataStorageBinaryFile (FString DirectoryPath=TEXT(""))
void Reset (const THandler< bool > &Result, const FString &FileName=TEXT("DefaultFileName")) override
 Reset an existing Table in the Storage.
void DeleteItem (const FString &Key, const FVoidHandler OnDone, const FString &Filename=TEXT("DefaultFileName")) override
 Delete an Item in the file.
void SaveItemOverwiteEntireFile (FString Key, FString Item, const THandler< bool > &OnDone, const FString &Filename=TEXT("DefaultFileName")) override
 Insert Item to a file by overwrite operation.
void SaveItem (const FString &Key, const TArray< uint8 > &Item, const THandler< bool > &OnDone, const FString &Filename=TEXT("DefaultFileName")) override
 Insert Item to the Key Value file.
void SaveItem (const FString &Key, const FString &Item, const THandler< bool > &OnDone, const FString &Filename=TEXT("DefaultFileName")) override
 Insert Item to the Key Value file.
void SaveItem (const FString &Key, const FJsonObjectWrapper &Item, const THandler< bool > &OnDone, const FString &Filename=TEXT("DefaultFileName")) override
 Insert Item to the Key Value file.
void GetItem (const FString &Key, const THandler< TPair< FString, TArray< uint8 > > > &OnDone, const FString &Filename=TEXT("DefaultFileName")) override
 Get an Item from the Key Value file.
void GetItem (const FString &Key, const THandler< TPair< FString, FString > > &OnDone, const FString &Filename=TEXT("DefaultFileName")) override
 Get an Item from the Key Value file.
void GetItem (const FString &Key, const THandler< TPair< FString, FJsonObjectWrapper > > &OnDone, const FString &Filename=TEXT("DefaultFileName")) override
 Get an Item from the Key Value file.
FDirectoryPath GetAbsoluteFileDirectory ()
 Helper function.
void ConvertExistingCache (const FString &OldCacheFilename, const FString &NewCacheFilenameForTelemetry, const FString &NewCacheFilenameForGeneralPurpose) override
 Change the old JSON-Array structure into new-line (
) separated JSON. Telemetry will be extracted from the old cache into a Telemetry specific cache. DeviceID & refresh token will be extracted as well into a GeneralPurpose cache.

Protected Member Functions

virtual FString CompleteAbsoluteFilePath (const FString &FileName)
 Convert the filename within the storage directory into fullpath.
virtual TOptional< FString > LoadFromFile (const FString &FileName)
 Obtain the content of the specified file and return it.
virtual bool SaveToFile (const FString &FileName, const FString &Key, const TArray< uint8 > &Value)
 Load the targeted file, modify the specified key, and then save it again.
virtual FString FABBinaryFileStructureToString (FABBinaryFileStructure *Structure)
 Serialize an Array of Struct manually due to UE limitation Using Newline as delimiter.
virtual TSharedPtr< FABBinaryFileStructure > ParseStructureFromFile (const FString &FileName)
 Read file content and deserialize it.
virtual TSharedPtr< FABBinaryFileStructure > ParseStructureOnly (const FString &TargetedString)
 Deserialize string into an array string of FABBinaryFileStructure.
virtual bool IsFileExist (const FString &FileName)
 Check the existing file within the file storage directory.
virtual FABBinaryFileStructure ConvertOldCacheToNewFormat (const FString &Input)
 Convert the old cache format into new cache format.
virtual void MoveOldCacheToNewCacheFiles (const FABBinaryFileStructure &CacheContent, const FString &NewTelemetryCacheFilename, const FString &NewGenerelPurposeCacheFilename)
 Migrate the value from the converted old cache into each new files.
bool CopyFile (const FString &FileName, const FString &DestinationAbsoluteDirPath, const FString &SourceAbsoluteDirPath)
 Read file from Source directory then write to destination directory, effectively copying.
bool MigrateStorageFiles (const FDirectoryPath &SourceDirectory, const FDirectoryPath &DestinationDirectory)

Protected Attributes

FDirectoryPath RelativeFileDirectory
 The main storage directory.

Member Function Documentation

◆ CompleteAbsoluteFilePath()

FString AccelByte::DataStorageBinaryFile::CompleteAbsoluteFilePath ( const FString & FileName)
protectedvirtual

Convert the filename within the storage directory into fullpath.

Parameters
FileNameFile name only, without any prefix.
Returns
The complete absolute path of the file, appent by the storage directory.

◆ ConvertExistingCache()

void AccelByte::DataStorageBinaryFile::ConvertExistingCache ( const FString & OldCacheFilename,
const FString & NewCacheFilenameForTelemetry,
const FString & NewCacheFilenameForGeneralPurpose )
overridevirtual

Change the old JSON-Array structure into new-line (
) separated JSON. Telemetry will be extracted from the old cache into a Telemetry specific cache. DeviceID & refresh token will be extracted as well into a GeneralPurpose cache.

Parameters
OldCacheFilenameThe targeted file that will be extracted
NewCacheFilenameForTelemetry
NewCacheFilenameForGeneralPurpose

Implements AccelByte::IAccelByteDataStorage.

◆ ConvertOldCacheToNewFormat()

FABBinaryFileStructure AccelByte::DataStorageBinaryFile::ConvertOldCacheToNewFormat ( const FString & Input)
protectedvirtual

Convert the old cache format into new cache format.

Parameters
InputThe loaded old cache
Returns
The deserialized cache in a new format

◆ CopyFile()

bool AccelByte::DataStorageBinaryFile::CopyFile ( const FString & FileName,
const FString & DestinationAbsoluteDirPath,
const FString & SourceAbsoluteDirPath )
protected

Read file from Source directory then write to destination directory, effectively copying.

Parameters
FileName
DestinationAbsoluteDirPath
SourceAbsoluteDirPath
Returns
returns true if copy is successful

◆ DeleteItem()

void AccelByte::DataStorageBinaryFile::DeleteItem ( const FString & Key,
const FVoidHandler OnDone,
const FString & Filename = TEXT("DefaultFileName") )
overridevirtual

Delete an Item in the file.

Parameters
KeyThe Key of the Item.
OnDoneThis will be called when the operation done.
FileNameoptional. The name of the file. Default will drop the default storage file.

Implements AccelByte::IAccelByteDataStorage.

◆ FABBinaryFileStructureToString()

FString AccelByte::DataStorageBinaryFile::FABBinaryFileStructureToString ( FABBinaryFileStructure * Structure)
protectedvirtual

Serialize an Array of Struct manually due to UE limitation Using Newline as delimiter.

Parameters
Pointerto the structure that will be serialized

◆ GetItem() [1/3]

void AccelByte::DataStorageBinaryFile::GetItem ( const FString & Key,
const THandler< TPair< FString, FJsonObjectWrapper > > & OnDone,
const FString & Filename = TEXT("DefaultFileName") )
overridevirtual

Get an Item from the Key Value file.

Parameters
KeyThe Key of the Item to Get.
OnDoneThis will be called when the operation done. The result is Pair of a FString Key, and a FJsonObjectWrapper Value.
FileNameoptional. The name of the file. Default will get an item from the default storage file.

Implements AccelByte::IAccelByteDataStorage.

◆ GetItem() [2/3]

void AccelByte::DataStorageBinaryFile::GetItem ( const FString & Key,
const THandler< TPair< FString, FString > > & OnDone,
const FString & Filename = TEXT("DefaultFileName") )
overridevirtual

Get an Item from the Key Value file.

Parameters
KeyThe Key of the Item to Get.
OnDoneThis will be called when the operation done. The result is Pair of a FString Key, and a FString Value.
FileNameoptional. The name of the file. Default will get an item from the default storage file.

Implements AccelByte::IAccelByteDataStorage.

◆ GetItem() [3/3]

void AccelByte::DataStorageBinaryFile::GetItem ( const FString & Key,
const THandler< TPair< FString, TArray< uint8 > > > & OnDone,
const FString & Filename = TEXT("DefaultFileName") )
overridevirtual

Get an Item from the Key Value file.

Parameters
KeyThe Key of the Item to Get.
OnDoneThis will be called when the operation done. The result is Pair of a FString Key, and an array of uint8 Value.
FileNameoptional. The name of the file. Default will get an item from the default storage file.

Implements AccelByte::IAccelByteDataStorage.

◆ LoadFromFile()

TOptional< FString > AccelByte::DataStorageBinaryFile::LoadFromFile ( const FString & FileName)
protectedvirtual

Obtain the content of the specified file and return it.

Parameters
FileNameThe name of the file, not the absolute path.
Returns
The content of the file if the file exists. If value is not set, error did occur.

◆ MigrateStorageFiles()

bool AccelByte::DataStorageBinaryFile::MigrateStorageFiles ( const FDirectoryPath & SourceDirectory,
const FDirectoryPath & DestinationDirectory )
protected

Migrate AccelByte-related cache files from one directory to another directory. AccelByteGeneralCache & AccelByteTelemetryCache are the affected files.

Parameters
SourceDirectory
DestinationDirectory
Returns
returns true when there is no need to migrate or migrate success
returns false failed to migrate & need to fallback and use the old cache

◆ MoveOldCacheToNewCacheFiles()

void AccelByte::DataStorageBinaryFile::MoveOldCacheToNewCacheFiles ( const FABBinaryFileStructure & CacheContent,
const FString & NewTelemetryCacheFilename,
const FString & NewGenerelPurposeCacheFilename )
protectedvirtual

Migrate the value from the converted old cache into each new files.

Parameters
CacheContentCache that will be stored into new files.
NewTelemetryCacheFilename
NewGenerelPurposeCacheFilename

◆ ParseStructureFromFile()

TSharedPtr< FABBinaryFileStructure > AccelByte::DataStorageBinaryFile::ParseStructureFromFile ( const FString & FileName)
protectedvirtual

Read file content and deserialize it.

Parameters
FileNameThe name of the file, not the absolute path.
Returns
The deserialization result.

◆ ParseStructureOnly()

TSharedPtr< FABBinaryFileStructure > AccelByte::DataStorageBinaryFile::ParseStructureOnly ( const FString & TargetedString)
protectedvirtual

Deserialize string into an array string of FABBinaryFileStructure.

Parameters
TargetedStringThe string that will be deserialized.
Returns
The deserialization result.

◆ Reset()

void AccelByte::DataStorageBinaryFile::Reset ( const THandler< bool > & Result,
const FString & FileName = TEXT("DefaultFileName") )
overridevirtual

Reset an existing Table in the Storage.

Parameters
ResultThis will be called when the operation done. The result is bool.
FileNameoptional. The name of the file. Default will drop the default storage file.

Implements AccelByte::IAccelByteDataStorage.

◆ SaveItem() [1/3]

void AccelByte::DataStorageBinaryFile::SaveItem ( const FString & Key,
const FJsonObjectWrapper & Item,
const THandler< bool > & OnDone,
const FString & Filename = TEXT("DefaultFileName") )
overridevirtual

Insert Item to the Key Value file.

Parameters
KeyThe Key of the Item.
ItemThe Data to be inserted to the file. The Data would be a FJsonObjectWrapper.
OnDoneThis will be called when the operation done. The result is bool.
FileNameoptional. The name of the file. Default will insert an item to the default storage file.

Implements AccelByte::IAccelByteDataStorage.

◆ SaveItem() [2/3]

void AccelByte::DataStorageBinaryFile::SaveItem ( const FString & Key,
const FString & Item,
const THandler< bool > & OnDone,
const FString & Filename = TEXT("DefaultFileName") )
overridevirtual

Insert Item to the Key Value file.

Parameters
KeyThe Key of the Item.
ItemThe Data to be inserted to the file. The Data would be a FString.
OnDoneThis will be called when the operation done. The result is bool.
FileNameoptional. The name of the file. Default will insert an item to the default storage file.

Implements AccelByte::IAccelByteDataStorage.

◆ SaveItem() [3/3]

void AccelByte::DataStorageBinaryFile::SaveItem ( const FString & Key,
const TArray< uint8 > & Item,
const THandler< bool > & OnDone,
const FString & Filename = TEXT("DefaultFileName") )
overridevirtual

Insert Item to the Key Value file.

Parameters
KeyThe Key of the Item.
ItemThe Data to be inserted to the file. The Data would be an array of uint8.
OnDoneThis will be called when the operation done. The result is bool.
FileNameoptional. The name of the file. Default will insert an item to the default storage file.

Implements AccelByte::IAccelByteDataStorage.

◆ SaveItemOverwiteEntireFile()

void AccelByte::DataStorageBinaryFile::SaveItemOverwiteEntireFile ( FString Key,
FString Item,
const THandler< bool > & OnDone,
const FString & Filename = TEXT("DefaultFileName") )
overridevirtual

Insert Item to a file by overwrite operation.

Parameters
KeyThe Key of the Item.
ItemThe Data to be inserted to the Table. The Data would be a FString.
OnDoneThis will be called when the operation done. The result is bool.
Filenameoptional. The name of the table. Default will insert an item to the default KeyValue table.

Implements AccelByte::IAccelByteDataStorage.

◆ SaveToFile()

bool AccelByte::DataStorageBinaryFile::SaveToFile ( const FString & FileName,
const FString & Key,
const TArray< uint8 > & Value )
protectedvirtual

Load the targeted file, modify the specified key, and then save it again.

Parameters
FileNameThe name of the file, not the absolute path.
KeyThe key to store the specified value.
ValueThe array of byte that will be written based on the key.
Returns
Is the save operation success.