template<class T> void BasicArray<T>::truncate(std::size_t size)
{
    TIGHTDB_ASSERT(is_attached());
    TIGHTDB_ASSERT(size <= m_size);

    copy_on_write(); // Throws

    // Update size in accessor and in header. This leaves the capacity
    // unchanged.
    m_size = size;
    set_header_size(size);
}
Ejemplo n.º 2
0
bsaheadercfa& bsaheadercfa::operator =(const bsaheadercfa& other)
{
	if (this != &other) {
		set_width_uncompressed(other.get_width());
		set_height(other.get_height());
		set_width_compressed(other.width_compressed);
		set_u2(other.u2);
		set_u3(other.u3);
		set_bits_per_pixel(other.bits_per_pixel);
		set_frame_count(other.frame_count);
    set_header_size(other.header_size);
	}
	
	return *this;
}
void FileBundleWriter::SaveHeaderFile() {
  if (SegmentsEmpty()) {
    return;                             // already closed
  }

  // Build the header in a buffer in memory

  LittleEndianWriteBuffer buffer;
  BuildHeaderWriteBuffer(buffer);

  file_pool().WriteSimpleFileWithCRC(HeaderPath(),
                                     buffer,
                                     mode_ & ~kExecuteMode);
  set_header_size(buffer.size());
  set_hdr_orig_abs_path();
}
void BasicArray<T>::erase(std::size_t ndx)
{
    TIGHTDB_ASSERT(ndx < m_size);

    // Check if we need to copy before modifying
    copy_on_write(); // Throws

    // move data under deletion up
    if (ndx < m_size-1) {
        char* base = reinterpret_cast<char*>(m_data);
        char* dst_begin = base + ndx*m_width;
        const char* src_begin = dst_begin + m_width;
        const char* src_end   = base + m_size*m_width;
        std::copy(src_begin, src_end, dst_begin);
    }

    // Update size (also in header)
    --m_size;
    set_header_size(m_size);
}