Polycode
Polycode::Data Class Reference

Stores, saves and loads data. More...

List of all members.

Public Member Functions

 Data ()
 Default constructor.
void loadFromFile (const String &fileName)
 Loads data from a file.
String getAsString (int encoding) const
 Retuns data as a string with the specified encoding.
void setFromString (const String &str, int encoding)
 Sets the data from a string with the specified encoding.
bool saveToFile (const String &fileName) const
 Saves the data to a file.
char * getData () const
 Returns pointer to the data.

Detailed Description

Stores, saves and loads data.

This class can save and load arbitrary data to and from disk and convert it to strings.


Member Function Documentation

String Data::getAsString ( int  encoding) const

Retuns data as a string with the specified encoding.

Parameters:
encodingThe encoding to use. Currently only supports String::ENCODING_UTF8
Returns:
String of the specified encoding.
char* Polycode::Data::getData ( ) const [inline]

Returns pointer to the data.

Returns:
Pointer to the data buffer.
void Data::loadFromFile ( const String fileName)

Loads data from a file.

Parameters:
fileNamePath to the file to load data from.
bool Data::saveToFile ( const String fileName) const

Saves the data to a file.

Parameters:
fileNamePath to the file to save data to.
Returns:
Returns true if successful or false if otherwise.
void Data::setFromString ( const String str,
int  encoding 
)

Sets the data from a string with the specified encoding.

Parameters:
strThe string to create the data from.
encodingThe encoding to use. Currently only supports String::ENCODING_UTF8