Пример #1
0
	bool	resize(int new_size)
	// Return false if we couldn't resize.
	{
		if (m_read_only) return false;

		m_.resize(new_size);

		// Hm, does this make sense?  We're truncating the file, so clamping the cursor.
		// Alternative would be to disallow resize, but that doesn't seem good either.
		if (m_position > m_.size())
		{
			m_position = m_.size();
		}

		return true;
	}
Пример #2
0
bool	membuf::operator!=(const membuf& buf) const
{
	if (size() != buf.size())
	{
		return false;
	}
	return memcmp(m_data, buf.m_data, size()) == 0 ? false : true;
}
Пример #3
0
	bool	is_valid()
	{
		return
			m_position >= 0
			&& m_position <= m_.size();
	}
Пример #4
0
void membuf::operator=(const membuf& buf)
{
	resize(buf.size());
	memcpy(m_data, buf.m_data, size());
	m_read_only = buf.m_read_only;
}
Пример #5
0
void membuf::append(const membuf& buf)
{
	append(buf.data(), buf.size());
}