JX Application Framework
|
#include <JFileArrayIndex.h>
Public Types | |
enum | ItemType { kData = 0 , kEmbeddedFile = 1 } |
Public Member Functions | |
JFileArrayIndex () | |
~JFileArrayIndex () override | |
void | InsertItemAtIndex (const JFAIndex &index, const JUnsignedOffset offset, const JFAID &id) |
void | RemoveItem (const JFAIndex &index, const JSize itemSize) |
void | MoveItemToIndex (const JFAIndex ¤tIndex, const JFAIndex &newIndex) |
void | SwapItems (const JFAIndex &index1, const JFAIndex &index2) |
JUnsignedOffset | GetItemOffset (const JFAIndex &index) const |
void | ItemSizeChanged (const JFAIndex &index, const JInteger changeInItemSize) |
JFAID | GetItemID (const JFAIndex &index) const |
void | SetItemID (const JFAIndex &index, const JFAID &id) |
bool | GetItemIndexFromID (const JFAID &id, JFAIndex *index) const |
JFAID | GetUniqueID () const |
void | SetToEmbeddedFile (const JFAIndex &index) |
bool | IsEmbeddedFile (const JFAIndex &index) const |
void | EmbeddedFileOpened (const JFAIndex &index, JFileArray *theEmbeddedFile) |
void | EmbeddedFileClosed (const JFAIndex &index) |
bool | EmbeddedFileIsClosed (const JFAIndex &index) const |
bool | AllEmbeddedFilesAreClosed () const |
void | ReplaceEmbeddedFileStreams (std::fstream *newStream) |
void | ReadIndex (const JSize itemCount, std::istream &input) |
void | WriteIndex (std::ostream &output) |
JSize | GetIndexLength () const |
![]() | |
JContainer () | |
JContainer (const JContainer &source) | |
JContainer & | operator= (const JContainer &source) |
![]() | |
JCollection () | |
JCollection (const JCollection &source) | |
~JCollection () override | |
JCollection & | operator= (const JCollection &source) |
JSize | GetItemCount () const |
bool | IsEmpty () const |
bool | IndexValid (const JIndex index) const |
JIndex | GetIndexFromEnd (const JIndex index) const |
JString | ToString () const override |
![]() | |
JBroadcaster () | |
virtual | ~JBroadcaster () |
JBroadcaster & | operator= (const JBroadcaster &source) |
bool | HasSenders () const |
JSize | GetSenderCount () const |
bool | HasRecipients () const |
JSize | GetRecipientCount () const |
template<class T > | |
void | ListenTo (const JBroadcaster *sender, const std::function< void(const T &)> &f) |
Additional Inherited Members | |
![]() | |
void | InstallCollection (JCollection *list) |
const JCollection * | GetList () const |
void | Receive (JBroadcaster *sender, const Message &message) override |
![]() | |
void | ItemAdded () |
void | ItemRemoved () |
void | SetItemCount (const JSize newItemCount) |
![]() | |
JBroadcaster (const JBroadcaster &source) | |
void | ListenTo (const JBroadcaster *sender) |
void | StopListening (const JBroadcaster *sender) |
void | ClearWhenGoingAway (const JBroadcaster *sender, void *pointerToMember) |
void | StopListening (const JBroadcaster *sender, const std::type_info &messageType) |
template<class T > | |
void | Send (JBroadcaster *recipient, const T &message) |
template<class T > | |
void | Broadcast (const T &message) |
void | SendWithFeedback (JBroadcaster *recipient, Message *message) |
void | BroadcastWithFeedback (Message *message) |
virtual void | ReceiveWithFeedback (JBroadcaster *sender, Message *message) |
virtual void | ReceiveGoingAway (JBroadcaster *sender) |
The Index-of-Items for a JFileArray Class This class stores and index of the items in a JFileArray.
JFileArrayIndex::JFileArrayIndex | ( | ) |
|
override |
bool JFileArrayIndex::AllEmbeddedFilesAreClosed | ( | ) | const |
Returns true if all embedded files are closed.
void JFileArrayIndex::EmbeddedFileClosed | ( | const JFAIndex & | index | ) |
Tell us that the specified item (an embedded file) has been closed. We scream if the item isn't an embedded file or if the item isn't open.
Returns TRUE if the specified item is not an embedded file or if it is a closed embedded file.
void JFileArrayIndex::EmbeddedFileOpened | ( | const JFAIndex & | index, |
JFileArray * | theEmbeddedFile | ||
) |
Notify us that an embedded file has been opened. We scream if the item isn't an embedded file or if the item is already open.
JSize JFileArrayIndex::GetIndexLength | ( | ) | const |
Return the amount of space required to store the index. Not inline because constants shouldn't be part of class declaration.
Return the index of the item with the specified ID. Returns false if there is no item with the specified ID.
JUnsignedOffset JFileArrayIndex::GetItemOffset | ( | const JFAIndex & | index | ) | const |
JFAID JFileArrayIndex::GetUniqueID | ( | ) | const |
Return an unused ID. Return zero if all ID's have been used.
void JFileArrayIndex::InsertItemAtIndex | ( | const JFAIndex & | index, |
const JUnsignedOffset | offset, | ||
const JFAID & | id | ||
) |
Insert a new item into the index. Since the storage is appended to the file, we don't have to adjust any item offsets.
If the item will be an embedded file, the caller must set it separately.
Returns TRUE if the specified item contains an embedded file.
Adjust the offsets of the other items. This is the only way item offsets change.
|
inline |
void JFileArrayIndex::ReadIndex | ( | const JSize | itemCount, |
std::istream & | input | ||
) |
Read the file's index.
Caller must position read mark before calling.
Remove the specified item and adjust the offsets of the other items.
void JFileArrayIndex::ReplaceEmbeddedFileStreams | ( | std::fstream * | newStream | ) |
Notify all embedded files that their enclosing file has a new std::fstream.
Set the id of the specified item. We scream if the id has already been used.
void JFileArrayIndex::SetToEmbeddedFile | ( | const JFAIndex & | index | ) |
Specify that the specified item contains an embedded file. This is irreversible because the data (an entire JFileArray) is not usable by anyone else. They should remove the item instead.
void JFileArrayIndex::WriteIndex | ( | std::ostream & | output | ) |
Write the file's index.
Caller must position write mark before calling.