Example #1
0
	bool LoadDataFromFile(buffer& buff, const TCHAR* filename, bool text)
	{
		bool ret = false;
		FILE* file = nullptr;
		size_t size = 0;
		std::string fullpath;

		CHECK(filename);

		buff.clear();

		_tfopen_s(&file, filename, text ? _T("r") : _T("rb"));
		CHECK(file);

		fseek(file, 0L, SEEK_SET);
		fseek(file, 0L, SEEK_END);
		size = ftell(file);

		buff.resize(text ? size + sizeof(char) : size);

		fseek(file, 0L, SEEK_SET);
		size = fread(buff.ptr(), 1, size, file);

		if (text)
			buff.ptr()[size] = 0;

		ret = true;
	Exit0:
		if (file)
			fclose(file);
		return ret;
	}
Example #2
0
//get data for current record
void BucketIter::get_key(buffer &key)
{
    switch (m_riter.get_type())
    {
    case Record::RECORD_SMALL:
    case Record::RECORD_MEDIUM:
        key.resize(m_riter.get_keysize());
        memcpy(&key[0], m_riter.get_key(), m_riter.get_keysize());
        break;

    case Record::RECORD_LARGE:
        load_overflow();
        m_xtra->get_key(key);
        break;
    }
}
Example #3
0
void BucketIter::get_value(buffer &value)
{
    switch (m_riter.get_type())
    {
    case Record::RECORD_SMALL:
        value.resize(m_riter.get_valuesize());
        memcpy(&value[0], m_riter.get_value(), m_riter.get_valuesize());
        break;

    case Record::RECORD_MEDIUM:
        load_overflow();
        m_xtra->get_value(value);
        break;

    case Record::RECORD_LARGE:
        load_overflow();
        m_xtra->get_value(value);
        break;
    }

    assert (value.size() != 0);
}