Bond 0.9
C++ Bond Runtime Library API Documentation
Loading...
Searching...
No Matches
Bond::MemoryStreamFactory Class Reference

A concrete implementation of StreamFactory that instantiates MemoryInputStreams for a fixed collection of DataViews. More...

#include <bond/io/memorystreamfactory.h>

Inheritance diagram for Bond::MemoryStreamFactory:
Bond::StreamFactory

Public Member Functions

 MemoryStreamFactory (Allocator &allocator, const DataViewIndex &index, StreamFactory *delegateFactory=nullptr, bool throwOnFailure=true)
 Constructs a MemoryStreamFactory object.
virtual ~MemoryStreamFactory ()
 Destroys a MemoryStreamFactory object.
virtual InputStreamHandle CreateInputStream (const char *fileName) override
 Returns a MemoryInputStream over the DataView with the given name, or the stream created by the delegate factory if there is no such DataView.
virtual OutputStreamHandle CreateOutputStream (const char *fileName, bool append) override
 Returns the stream created by the delegate factory.
void SetDelegateFactory (StreamFactory *delegateFactory)
 Sets the fallback StreamFactory used when this factory cannot provide a stream.
Public Member Functions inherited from Bond::StreamFactory
virtual ~StreamFactory ()
 Destroys a StreamFactory object.

Detailed Description

A concrete implementation of StreamFactory that instantiates MemoryInputStreams for a fixed collection of DataViews.

A file name is looked up by exact match against the names in the DataViewIndex. The factory cannot create output streams itself, so it always forwards CreateOutputStream to its delegate factory.

Constructor & Destructor Documentation

◆ MemoryStreamFactory()

Bond::MemoryStreamFactory::MemoryStreamFactory ( Allocator & allocator,
const DataViewIndex & index,
StreamFactory * delegateFactory = nullptr,
bool throwOnFailure = true )
inline

Constructs a MemoryStreamFactory object.

Parameters
allocatorThe memory allocator from which MemoryInputStreams are allocated.
indexThe index of DataViews from which MemoryInputStreams are instantiated. The names in the index must be sorted in ascending order, since they are binary searched. The index is not copied and must remain valid for the lifetime of the factory.
delegateFactoryIf this factory cannot provide a stream, this factory is used as a fallback. May be null.
throwOnFailureIf true, stream creation failures are reported by throwing an Exception. Otherwise, stream creation failures return a null handle.

◆ ~MemoryStreamFactory()

virtual Bond::MemoryStreamFactory::~MemoryStreamFactory ( )
inlinevirtual

Destroys a MemoryStreamFactory object.

Member Function Documentation

◆ CreateInputStream()

virtual InputStreamHandle Bond::MemoryStreamFactory::CreateInputStream ( const char * fileName)
overridevirtual

Returns a MemoryInputStream over the DataView with the given name, or the stream created by the delegate factory if there is no such DataView.

Parameters
fileNameThe name of the DataView for which an input stream is created.

Implements Bond::StreamFactory.

◆ CreateOutputStream()

virtual OutputStreamHandle Bond::MemoryStreamFactory::CreateOutputStream ( const char * fileName,
bool append )
overridevirtual

Returns the stream created by the delegate factory.

Parameters
fileNameThe name of the file for which an output stream is created.
appendWhether bytes are written to the end of an existing file.

Implements Bond::StreamFactory.

◆ SetDelegateFactory()

void Bond::MemoryStreamFactory::SetDelegateFactory ( StreamFactory * delegateFactory)
inline

Sets the fallback StreamFactory used when this factory cannot provide a stream.

Parameters
delegateFactoryThe fallback StreamFactory, or null.

The documentation for this class was generated from the following file:
  • include/bond/io/memorystreamfactory.h