39 #if !defined(TAWARA_FILE_CLUSTER_H_)
40 #define TAWARA_FILE_CLUSTER_H_
66 typedef boost::shared_ptr<FileCluster>
Ptr;
79 template <
typename BlockType>
81 :
public boost::iterator_facade<
82 IteratorBase<BlockType>, BlockType,
83 boost::forward_traversal_tag>
106 std::istream& stream, std::streampos pos)
107 : cluster_(cluster), stream_(&stream)
118 template <
typename OtherType>
120 : cluster_(other.cluster_), stream_(other.stream_),
127 friend class boost::iterator_core_access;
138 if (pos == cluster_->blocks_end_pos_)
146 std::streampos cur_read(stream_->tellg());
154 new_block->read(*stream_);
156 boost::shared_ptr<BlockType> new_const_block(new_block);
157 block_.swap(new_const_block);
162 new_block->read(*stream_);
164 boost::shared_ptr<BlockType> new_const_block(new_block);
165 block_.swap(new_const_block);
172 err_pos(static_cast<std::streamsize>(stream_->tellg()) -
176 stream_->seekg(cur_read);
187 load_block(block_->offset() + block_->size());
195 template <
typename OtherType>
204 return block_->offset() ==
257 virtual bool empty()
const;
265 virtual void clear();
274 virtual void erase(
Iterator position);
290 virtual void push_back(
value_type const& value);
293 std::streamsize
write(std::ostream& output);
296 std::streamsize finalise(std::ostream& output);
305 std::streamsize blocks_size()
const;
308 std::streamsize read_blocks(std::istream& input,
309 std::streamsize
size);
316 #endif // TAWARA_FILE_CLUSTER_H_
std::streampos blocks_end_pos_
std::streampos blocks_start_pos_
void load_block(std::streampos pos)
BlockType & dereference() const
Dereference the iterator to get a pointer to the block.
std::streamsize write(ID id, std::ostream &output)
Write an ID to an output stream.
boost::shared_ptr< BlockElement > Ptr
FileCluster const * cluster_
std::streamsize size(ID id)
Get the number of bytes required by an ID.
The in-file Cluster implementation.
BlockElement::Ptr value_type
The value type of this container.
bool equal(IteratorBase< OtherType > const &other) const
Test for equality with another iterator.
A child element was found where it doesn't belong.
void increment()
Increment the iterator to the next block.
boost::shared_ptr< BlockType > block_
ReadResult read(std::istream &input)
Read an ID from an input stream.
const ID BlockGroup(0xA0)
IteratorBase(FileCluster const *cluster, std::istream &stream, std::streampos pos)
Base constructor.
boost::shared_ptr< FileCluster > Ptr
Pointer to a file-based cluster.
const ID SimpleBlock(0xA3)
IteratorBase()
Base constructor.
boost::error_info< struct tag_par_id, uint32_t > err_par_id
A parent element ID.
The base Cluster, defining the common interface for Cluster element implementations.
IteratorBase< BlockElement > Iterator
File-based cluster iterator interface.
IteratorBase(IteratorBase< OtherType > const &other)
Templated base constructor.
boost::error_info< struct tag_id, ids::ID > err_id
An Element ID.
boost::error_info< struct tag_pos, std::streamsize > err_pos
Position in a Tawara file.
size_t size_type
The size type of this container.
std::pair< ID, std::streamsize > ReadResult
The result of a read operation is a pair of the ID read and the number of bytes read.