#include <Data.h>
Inheritance diagram for Arxx::Data:
This is the component underlying the Arxx::Item class. It delivers the ability to compress and decompress the data. Because of the public inhertitance from Arxx::Buffer it is still possible to call Buffer::stGetLength() but be aware that it will give you the state of the buffer which might not be what you want for two reasons:
Public Types | |
NONE = 0 | |
ZLIB_0 = 1 | |
ZLIB_1 = 2 | |
ZLIB_2 = 3 | |
ZLIB_3 = 4 | |
ZLIB_4 = 5 | |
ZLIB_5 = 6 | |
ZLIB_6 = 7 | |
ZLIB_7 = 8 | |
ZLIB_8 = 9 | |
ZLIB_9 = 10 | |
BZLIB = 11 | |
enum | Compression { NONE = 0, ZLIB_0 = 1, ZLIB_1 = 2, ZLIB_2 = 3, ZLIB_3 = 4, ZLIB_4 = 5, ZLIB_5 = 6, ZLIB_6 = 7, ZLIB_7 = 8, ZLIB_8 = 9, ZLIB_9 = 10, BZLIB = 11 } |
Public Member Functions | |
Data (void) | |
The default constructor for a Arxx::Data. | |
~Data (void) | |
The destructor of the Arxx::Data. | |
void | vDecompress (void) |
Decompresses the data of the buffer. | |
void | vCompress (const Arxx::Data::Compression &Compression=Arxx::Data::m_DefaultCompression) |
Compresses the data of the buffer. | |
bool | bIsCompressed (void) const |
Returns true if the data inside the buffer is compressed. | |
bool | bIsDecompressed (void) const |
Returns true if the data inside the buffer is decompressed. | |
Arxx::Data::Compression | GetCompression (void) const |
Returns the compression information, which will equal the compression rate of the zlib library. | |
Arxx::u4byte | u4GetDecompressedLength (void) const |
Gets the length of the decompressed data. | |
Arxx::u4byte | u4GetCompressedLength (void) const |
Gets the length of the compressed data. | |
const Arxx::URI & | GetURI (void) const |
Returns the internal locator used by the external data fetcher. | |
bool | bFetch (void) |
This function requests the item's data at the appropriate data channel. | |
void | vUnfetch (void) |
Unfetching the data generally means deleting the data thus releasing the memory in the buffer. | |
void | vReleaseDataChannel (void) |
Use this function to release the data source. | |
virtual void | vSetExternal (const Arxx::URI &URI="", const Arxx::Data::Compression &Compression=Arxx::Data::NONE, Arxx::u4byte u4DecompressedLength=0, Arxx::u4byte u4CompressedLength=0) |
Sets fake data to the buffer. | |
bool | bIsInternal (void) const |
Returns whether the data is meant to be stored internally. | |
bool | bIsExternal (void) const |
Returns whether the data is external and meant to be referenced by URI. | |
void | vInternalize (void) |
Use this function to change the data from external to internal. | |
Arxx::FetchStatus | GetFetchStatus (void) const |
Returns the fetch status of the data. | |
bool | bIsFetching (void) const |
Returns wether a fetching process is in progress. | |
bool | bIsFetched (void) const |
Returns wether the data is fetched. | |
Static Public Attributes | |
static Arxx::Data::Compression | m_DefaultCompression = BZLIB |
default compression | |
Private Attributes | |
Arxx::URI | m_URI |
A locator used to further describe the location to the fetcher. | |
Arxx::Data::Compression | m_Compression |
The compressed state the data is currently in. | |
Arxx::u4byte | m_u4DecompressedLength |
The length of the data if decompressed. | |
Arxx::u4byte | m_u4CompressedLength |
The length of the data if compressed or 0. | |
bool | m_bIsExternal |
A flag indicating whether the data is meant to be internal or external. | |
Arxx::FetchStatus | m_FetchStatus |
A status indicator showing the fetch status of the data. |
Arxx::Data::Data | ( | void | ) |
The default constructor for a Arxx::Data.
Arxx::Data::~Data | ( | void | ) |
The destructor of the Arxx::Data.
bool Arxx::Data::bFetch | ( | void | ) |
This function requests the item's data at the appropriate data channel.
In order to only try to fetch the data m_URI must be valid and bIsFetched() and bIsFetching() must be false. Otherwise the function will return false.
For asynchronous fetches the return value may be true because an Arxx::DataChannel could be found but the actuall fetching may fail. This information may be retrieved via Arxx::Data::GetFetchStatus().
bool Arxx::Data::bIsCompressed | ( | void | ) | const |
Returns true if the data inside the buffer is compressed.
bool Arxx::Data::bIsDecompressed | ( | void | ) | const |
Returns true if the data inside the buffer is decompressed.
bool Arxx::Data::bIsExternal | ( | void | ) | const |
Returns whether the data is external and meant to be referenced by URI.
Equals !bIsInternal().
bool Arxx::Data::bIsFetched | ( | void | ) | const |
Returns wether the data is fetched.
bool Arxx::Data::bIsFetching | ( | void | ) | const |
Returns wether a fetching process is in progress.
bool Arxx::Data::bIsInternal | ( | void | ) | const |
Returns whether the data is meant to be stored internally.
Equals !bIsExternal().
Arxx::Data::Compression Arxx::Data::GetCompression | ( | void | ) | const |
Returns the compression information, which will equal the compression rate of the zlib library.
Arxx::FetchStatus Arxx::Data::GetFetchStatus | ( | void | ) | const |
Returns the fetch status of the data.
For a normal data buffer this will be Arxx::FETCHED but generally every status in Arxx::FetchStatus is used.
const Arxx::URI & Arxx::Data::GetURI | ( | void | ) | const |
Returns the internal locator used by the external data fetcher.
Whether this URI is of importance or not is for the fetcher object to decide.
Arxx::u4byte Arxx::Data::u4GetCompressedLength | ( | void | ) | const |
Gets the length of the compressed data.
Arxx::u4byte Arxx::Data::u4GetDecompressedLength | ( | void | ) | const |
Gets the length of the decompressed data.
void Arxx::Data::vCompress | ( | const Arxx::Data::Compression & | Compression = Arxx::Data::m_DefaultCompression |
) |
Compresses the data of the buffer.
void Arxx::Data::vDecompress | ( | void | ) |
Decompresses the data of the buffer.
void Arxx::Data::vInternalize | ( | void | ) |
Use this function to change the data from external to internal.
This function will set the m_bIsExternal flag to false.
void Arxx::Data::vReleaseDataChannel | ( | void | ) |
Use this function to release the data source.
Using this function you can dereference the associated data fetcher thus making it impossible to fetch or refetch the item's data.
It will also set the m_URI to be invalid.
This function does NOT internalize the data, though. It's just meant to release the data channel to allow the releasing of resources associated with the data channel as the name quite plaily suggests.
void Arxx::Data::vSetExternal | ( | const Arxx::URI & | URI = "" , |
|
const Arxx::Data::Compression & | Compression = Arxx::Data::NONE , |
|||
Arxx::u4byte | u4DecompressedLength = 0 , |
|||
Arxx::u4byte | u4CompressedLength = 0 | |||
) | [virtual] |
Sets fake data to the buffer.
Compression | The state of the data. If this value if greater than 0 the fake data is considered compressed. | |
u4DecompressedLength | The length of the fake data if in decompressed state. Elsewise the value which Arxx::Buffer::u4GetDecompressedLength() will return and this data will serve no internal functionality, so you may use it as you like. | |
u4CompressedLength | The length of the fake data if in compressed state. Elsewise the value which Arxx::Buffer::u4GetCompressedDataLength() will return and this data will serve no internal functionality, so you may use it as you like. | |
URI | The URI of the external data. |
This function will set m_bIsExternal to true.
This function will set m_FetchStatus to Arxx::UNFETCHED.
void Arxx::Data::vUnfetch | ( | void | ) |
Unfetching the data generally means deleting the data thus releasing the memory in the buffer.
This function will empty the data buffer and release the memory associated with it. So why an extra function if this could be done with Buffers::Buffer::vDelete()?
Because if you vDelete the content of the buffer you change the data. Hence you don't change the flag whether the data is fetched and will not be able the refetch the data using vFetch() again.
This function requires the bIsFetched() to be true.
This function sets m_FetchStatus to Arxx::UNFETCHED.
bool Arxx::Data::m_bIsExternal [private] |
A flag indicating whether the data is meant to be internal or external.
This flag is changed by vSetExternalData(), vInternalize(). It can be queried using bIsExternal() or bIsInternal().
When saving an Arxx::Archive this flag decides whether the data or the URI reference is stored in the archive.
After creating an Item this value is intentionally false.
The compressed state the data is currently in.
Is set to either 0 for to indicate no compression or some value greater than 0 to indicate the compression level of the data as in the zlib library.
Arxx::Data::Compression Arxx::Data::m_DefaultCompression = BZLIB [static] |
default compression
libarxx - Advanced Resource files in C++ Copyright (C) 2005 Hagen Möbius
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Arxx::FetchStatus Arxx::Data::m_FetchStatus [private] |
A status indicator showing the fetch status of the data.
It can be queried using GetFetchStatus().
After creating an Item this value is intentionally Arxx::FETCHED.
Arxx::u4byte Arxx::Data::m_u4CompressedLength [mutable, private] |
The length of the data if compressed or 0.
Since the compressed size is not known as long as the data is decompressed this value is 0 whenever the data is decompressed.
Arxx::u4byte Arxx::Data::m_u4DecompressedLength [mutable, private] |
The length of the data if decompressed.
Arxx::URI Arxx::Data::m_URI [private] |
A locator used to further describe the location to the fetcher.
After creating an Item this value is intentionally invalid.