Otter  0.9.8.91
2d Game Development Framework based on SFML.Net
 All Classes Namespaces Functions Variables Enumerations Properties
Otter.DataSaver Class Reference

Class that is used for storing strings, ints, floats, or bools with keys of enum or string. The saver can output data in an semi-encrypted format, and also an editable config file format. More...

Public Types

enum  DataExportMode { Data, Config }
 The export modes for the data. More...
 

Public Member Functions

 DataSaver (string defaultPath="")
 Initializes a new instance of the DataSaver class. More...
 
bool Verify (string stringData)
 Verifies the specified string data. Only applies to DataExportMode.Data. More...
 
void ClearFile (string filename="")
 Deletes the exported file for this save data. More...
 
void Clear ()
 Clears the data. More...
 
bool FileExists (string filename="")
 Check if an exported file exists for this data. More...
 
void Import (string filename="", bool verify=true)
 Imports the data in the specified file. More...
 
void Export (string filename="")
 Exports the data to the specified file. More...
 
float GetFloat (string key)
 Gets a float from the data. More...
 
float GetFloat (Enum key)
 Gets a float from the data. More...
 
float GetFloatOrDefault (string key, float defaultIfNotFound=default(float))
 Gets a float or a default float value. More...
 
float GetFloatOrDefault (Enum key, float defaultIfNotFound=default(float))
 Gets a float or a default float value. More...
 
int GetInt (string key)
 Gets an int from the data. More...
 
int GetInt (Enum key)
 Gets an int from the data. More...
 
int GetIntOrDefault (string key, int defaultIfNotFound=default(int))
 Gets an int or a default int value. More...
 
int GetIntOrDefault (Enum key, int defaultIfNotFound=default(int))
 Gets an int or a default int value. More...
 
string GetString (string key)
 Gets a string from the data. More...
 
string GetString (Enum key)
 Gets a string from the data. More...
 
string GetStringOrDefault (string key, string defaultIfNotFound=default(string))
 Gets a string or a default string value. More...
 
string GetStringOrDefault (Enum key, string defaultIfNotFound=default(string))
 Gets a string or a default string value. More...
 
bool GetBool (string key)
 Gets a bool from the data. More...
 
bool GetBool (Enum key)
 Gets a bool from the data. More...
 
bool GetBoolOrDefault (string key, bool defaultIfNotFound=default(bool))
 Gets a bool or a default bool value. More...
 
bool GetBoolOrDefault (Enum key, bool defaultIfNotFound=default(bool))
 Gets a bool or a default bool value. More...
 
void SetData (string key, object obj)
 Sets the data. More...
 
void SetData (Enum key, object obj)
 Sets the data. More...
 

Public Attributes

string KeyDelim = "::OTTERK::"
 The string to use when delimiting key data in data exports. More...
 
string ValueDelim = "::OTTERV::"
 The string to use when delimiting value data in data exports. More...
 
string EncryptionSalt = "otter"
 The phrase to use as a salt when encrypting the data exports. More...
 
string SaltGuide = "{S}{D}{S}"
 The guide to salt the data string. {S} is the salt, {D} is the data. It is recommended to change this from the default for your game, but only if you really care about hacking save data. More...
 
string DefaultPath = ""
 The default path that the files will be imported from and exported to. More...
 
string DefaultFilename = "data"
 The default file name that the data will export as. More...
 
DataExportMode ExportMode = DataExportMode.Data
 The export mode for the data. Data: Semi-encrypted uneditable data. Config: Easy to hand edit unencrypted data. More...
 

Properties

string this[string key] [get]
 Gets the string with the specified key. More...
 
string this[Enum key] [get]
 Gets the string with the specified key. More...
 

Detailed Description

Class that is used for storing strings, ints, floats, or bools with keys of enum or string. The saver can output data in an semi-encrypted format, and also an editable config file format.

Member Enumeration Documentation

The export modes for the data.

Constructor & Destructor Documentation

Otter.DataSaver.DataSaver ( string  defaultPath = "")

Initializes a new instance of the DataSaver class.

Parameters
defaultPathThe default path.

Member Function Documentation

void Otter.DataSaver.Clear ( )

Clears the data.

void Otter.DataSaver.ClearFile ( string  filename = "")

Deletes the exported file for this save data.

Parameters
filenameThe filename to delete (usually you don't have to set this.)
void Otter.DataSaver.Export ( string  filename = "")

Exports the data to the specified file.

Parameters
filenameThe filename.
bool Otter.DataSaver.FileExists ( string  filename = "")

Check if an exported file exists for this data.

Parameters
filenameThe filename to check.
Returns
True if the exported file exists, and is verified for encrypted files.
bool Otter.DataSaver.GetBool ( string  key)

Gets a bool from the data.

Parameters
keyThe key.
Returns
An int from the specified key.
bool Otter.DataSaver.GetBool ( Enum  key)

Gets a bool from the data.

Parameters
keyThe key.
Returns
An int from the specified key.
bool Otter.DataSaver.GetBoolOrDefault ( string  key,
bool  defaultIfNotFound = default(bool) 
)

Gets a bool or a default bool value.

Parameters
keyThe key.
defaultIfNotFoundThe default if not found.
Returns
The value or the default if the key is not found.
bool Otter.DataSaver.GetBoolOrDefault ( Enum  key,
bool  defaultIfNotFound = default(bool) 
)

Gets a bool or a default bool value.

Parameters
keyThe key.
defaultIfNotFoundThe default if not found.
Returns
The value or the default if the key is not found.
float Otter.DataSaver.GetFloat ( string  key)

Gets a float from the data.

Parameters
keyThe key.
Returns
A float from the specified key.
float Otter.DataSaver.GetFloat ( Enum  key)

Gets a float from the data.

Parameters
keyThe key.
Returns
A float from the specified key.
float Otter.DataSaver.GetFloatOrDefault ( string  key,
float  defaultIfNotFound = default(float) 
)

Gets a float or a default float value.

Parameters
keyThe key.
defaultIfNotFoundThe default if not found.
Returns
The value or the default if a value is not found.
float Otter.DataSaver.GetFloatOrDefault ( Enum  key,
float  defaultIfNotFound = default(float) 
)

Gets a float or a default float value.

Parameters
keyThe key.
defaultIfNotFoundThe default if not found.
Returns
The value or the default if the key is not found.
int Otter.DataSaver.GetInt ( string  key)

Gets an int from the data.

Parameters
keyThe key.
Returns
An int from the specified key.
int Otter.DataSaver.GetInt ( Enum  key)

Gets an int from the data.

Parameters
keyThe key.
Returns
An int from the specified key.
int Otter.DataSaver.GetIntOrDefault ( string  key,
int  defaultIfNotFound = default(int) 
)

Gets an int or a default int value.

Parameters
keyThe key.
defaultIfNotFoundThe default if not found.
Returns
The value or the default if the key is not found.
int Otter.DataSaver.GetIntOrDefault ( Enum  key,
int  defaultIfNotFound = default(int) 
)

Gets an int or a default int value.

Parameters
keyThe key.
defaultIfNotFoundThe default if not found.
Returns
The value or the default if the key is not found.
string Otter.DataSaver.GetString ( string  key)

Gets a string from the data.

Parameters
keyThe key.
Returns
An int from the specified key.
string Otter.DataSaver.GetString ( Enum  key)

Gets a string from the data.

Parameters
keyThe key.
Returns
An int from the specified key.
string Otter.DataSaver.GetStringOrDefault ( string  key,
string  defaultIfNotFound = default(string) 
)

Gets a string or a default string value.

Parameters
keyThe key.
defaultIfNotFoundThe default if not found.
Returns
The value or the default if the key is not found.
string Otter.DataSaver.GetStringOrDefault ( Enum  key,
string  defaultIfNotFound = default(string) 
)

Gets a string or a default string value.

Parameters
keyThe key.
defaultIfNotFoundThe default if not found.
Returns
The value or the default if the key is not found.
void Otter.DataSaver.Import ( string  filename = "",
bool  verify = true 
)

Imports the data in the specified file.

Parameters
filenameThe filename.
verifyif set to true verify the data before importing.
void Otter.DataSaver.SetData ( string  key,
object  obj 
)

Sets the data.

Parameters
keyThe key.
objThe object.
void Otter.DataSaver.SetData ( Enum  key,
object  obj 
)

Sets the data.

Parameters
keyThe key.
objThe object.
bool Otter.DataSaver.Verify ( string  stringData)

Verifies the specified string data. Only applies to DataExportMode.Data.

Parameters
stringDataThe string data.
Returns
True if the data is successfully verified.

Member Data Documentation

string Otter.DataSaver.DefaultFilename = "data"

The default file name that the data will export as.

string Otter.DataSaver.DefaultPath = ""

The default path that the files will be imported from and exported to.

string Otter.DataSaver.EncryptionSalt = "otter"

The phrase to use as a salt when encrypting the data exports.

DataExportMode Otter.DataSaver.ExportMode = DataExportMode.Data

The export mode for the data. Data: Semi-encrypted uneditable data. Config: Easy to hand edit unencrypted data.

string Otter.DataSaver.KeyDelim = "::OTTERK::"

The string to use when delimiting key data in data exports.

string Otter.DataSaver.SaltGuide = "{S}{D}{S}"

The guide to salt the data string. {S} is the salt, {D} is the data. It is recommended to change this from the default for your game, but only if you really care about hacking save data.

string Otter.DataSaver.ValueDelim = "::OTTERV::"

The string to use when delimiting value data in data exports.

Property Documentation

string Otter.DataSaver.this[Enum key]
get

Gets the string with the specified key.

Parameters
keyThe key.
Returns
The string data or null.
string Otter.DataSaver.this[string key]
get

Gets the string with the specified key.

Parameters
keyThe key.
Returns
The string data or null.

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