Ion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ion::base::MemoryZipStream Class Reference

A MemoryZipStream represents ZIP data in memory; the data may represent one or more files or directories in ZIP format. More...

#include "memoryzipstream.h"

Inheritance diagram for ion::base::MemoryZipStream:
Collaboration diagram for ion::base::MemoryZipStream:

Public Types

typedef AllocVector< uint8 > DataVector
 

Public Member Functions

 MemoryZipStream ()
 Constructs an empty MemoryZipStream. More...
 
 MemoryZipStream (const DataVector &data)
 Constructs a MemoryZipStream using pre-existing zip data. More...
 
 MemoryZipStream (DataVector *data)
 Constructs a MemoryZipStream using pre-existing zip data. More...
 
 ~MemoryZipStream () override
 
void AddFile (const std::string &filename, const DataVector &data)
 Compresses and adds a vector of data to this, associating it with the passed filename. More...
 
void AddFile (const std::string &filename, const std::string &data)
 Compresses and adds string data to this, associating it with the passed filename. More...
 
bool ContainsFile (const std::string &filename)
 Returns whether this contains filename. More...
 
const DataVector GetFileData (const std::string &filename)
 Returns the file data for filename. More...
 
const DataVectorGetData () const
 Gets the memory buffer backing this. More...
 
const AllocatorPtrGetAllocator () const
 Returns the Allocator that was used for the instance. More...
 
const AllocatorPtrGetNonNullAllocator () const
 Return our allocator, or the default allocator if the instance was declared on the stack. More...
 
const AllocatorPtrGetAllocatorForLifetime (AllocationLifetime lifetime) const
 Convenience function that returns the Allocator to use to allocate an object with a specific lifetime. More...
 
void * operator new (size_t size)
 The standard no-parameter new operator uses the default Allocator. More...
 
void * operator new (size_t size, AllocationLifetime lifetime)
 This overloaded version of the new operator uses the AllocationManager's default Allocator for the specified lifetime. More...
 
void * operator new (size_t size, const AllocatorPtr &allocator)
 This overloaded version of the new operator takes the Allocator to use directly as a parameter. More...
 
void * operator new (size_t size, const AllocatorPtr &allocator, void *ptr)
 Special operator new for using placement new with Allocatables. More...
 
void * operator new (size_t size, void *ptr)
 The placement new operator is defined conventionally. More...
 
void operator delete (void *ptr)
 Define the delete operator to use specialized functions dealing with an Allocator. More...
 
void operator delete (void *ptr, AllocationLifetime lifetime)
 Windows requires these (or it issues C4291 warnings). More...
 
void operator delete (void *ptr, const AllocatorPtr &allocator)
 
void operator delete (void *ptr, void *ptr2)
 The placement delete operator does nothing, as usual. More...
 

Detailed Description

A MemoryZipStream represents ZIP data in memory; the data may represent one or more files or directories in ZIP format.

Definition at line 33 of file memoryzipstream.h.

Member Typedef Documentation

Definition at line 35 of file memoryzipstream.h.

Constructor & Destructor Documentation

ion::base::MemoryZipStream::MemoryZipStream ( )

Constructs an empty MemoryZipStream.

Definition at line 167 of file memoryzipstream.cc.

ion::base::MemoryZipStream::MemoryZipStream ( const DataVector data)
explicit

Constructs a MemoryZipStream using pre-existing zip data.

This will make a copy of the data. If the data is not valid zip data then errors will occur when trying to decompress files. No additional validation is done.

Definition at line 172 of file memoryzipstream.cc.

ion::base::MemoryZipStream::MemoryZipStream ( DataVector data)
explicit

Constructs a MemoryZipStream using pre-existing zip data.

This will take ownership of the data via a vector swap(). If the data is not valid zip data then errors will occur when trying to decompress files. No additional validation is done.

Definition at line 178 of file memoryzipstream.cc.

ion::base::MemoryZipStream::~MemoryZipStream ( )
override

Definition at line 184 of file memoryzipstream.cc.

Member Function Documentation

void ion::base::MemoryZipStream::AddFile ( const std::string &  filename,
const DataVector data 
)

Compresses and adds a vector of data to this, associating it with the passed filename.

The filename may be any relative path, e.g., "foo/bar/bat.ext".

Definition at line 186 of file memoryzipstream.cc.

Referenced by AddFile().

void ion::base::MemoryZipStream::AddFile ( const std::string &  filename,
const std::string &  data 
)

Compresses and adds string data to this, associating it with the passed filename.

The filename may be any relative path, e.g., "foo/bar/bat.ext".

Definition at line 198 of file memoryzipstream.cc.

References AddFile().

bool ion::base::MemoryZipStream::ContainsFile ( const std::string &  filename)

Returns whether this contains filename.

Definition at line 204 of file memoryzipstream.cc.

const AllocatorPtr& ion::base::Allocatable::GetAllocator ( ) const
inlineinherited

Returns the Allocator that was used for the instance.

This will be NULL if the instance was declared on the stack or created with normal placement new.

Definition at line 68 of file allocatable.h.

References allocator_.

Referenced by ion::base::DataContainer::CreateAndCopy(), ion::text::DynamicFontImage::FindContainingImageDataIndex(), and ion::text::DynamicFontImage::FindImageDataIndex().

const MemoryZipStream::DataVector & ion::base::MemoryZipStream::GetData ( ) const

Gets the memory buffer backing this.

Definition at line 236 of file memoryzipstream.cc.

const MemoryZipStream::DataVector ion::base::MemoryZipStream::GetFileData ( const std::string &  filename)

Returns the file data for filename.

If the file does not exist, then the returned vector is empty.

Definition at line 211 of file memoryzipstream.cc.

const AllocatorPtr& ion::base::Allocatable::GetNonNullAllocator ( ) const
inlineinherited

Return our allocator, or the default allocator if the instance was declared on the stack.

Definition at line 72 of file allocatable.h.

References allocator_, and ion::base::AllocationManager::GetNonNullAllocator().

void ion::base::Allocatable::operator delete ( void *  ptr)
inlineinherited

Define the delete operator to use specialized functions dealing with an Allocator.

Definition at line 109 of file allocatable.h.

void ion::base::Allocatable::operator delete ( void *  ptr,
AllocationLifetime  lifetime 
)
inlineinherited

Windows requires these (or it issues C4291 warnings).

Definition at line 112 of file allocatable.h.

void ion::base::Allocatable::operator delete ( void *  ptr,
const AllocatorPtr allocator 
)
inlineinherited

Definition at line 113 of file allocatable.h.

void ion::base::Allocatable::operator delete ( void *  ptr,
void *  ptr2 
)
inlineinherited

The placement delete operator does nothing, as usual.

Definition at line 118 of file allocatable.h.

void* ion::base::Allocatable::operator new ( size_t  size)
inlineinherited

The standard no-parameter new operator uses the default Allocator.

Definition at line 84 of file allocatable.h.

void* ion::base::Allocatable::operator new ( size_t  size,
AllocationLifetime  lifetime 
)
inlineinherited

This overloaded version of the new operator uses the AllocationManager's default Allocator for the specified lifetime.

Definition at line 88 of file allocatable.h.

void* ion::base::Allocatable::operator new ( size_t  size,
const AllocatorPtr allocator 
)
inlineinherited

This overloaded version of the new operator takes the Allocator to use directly as a parameter.

If the Allocator pointer is NULL, this uses the default Allocator.

Definition at line 95 of file allocatable.h.

void* ion::base::Allocatable::operator new ( size_t  size,
const AllocatorPtr allocator,
void *  ptr 
)
inlineinherited

Special operator new for using placement new with Allocatables.

Definition at line 100 of file allocatable.h.

void* ion::base::Allocatable::operator new ( size_t  size,
void *  ptr 
)
inlineinherited

The placement new operator is defined conventionally.

Definition at line 105 of file allocatable.h.


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