Class: EventMachine::FastFileReader::Mapper
| Relationships & Source Files | |
| Inherits: | Object |
| Defined in: | ext/fastfilereader/rubymain.cpp |
Class Method Summary
- .new constructor mod_func
Instance Method Summary
-
#close
mapper_close.
-
#get_chunk
mapper_get_chunk.
-
#size
mapper_size.
Constructor Details
.new (mod_func)
[ GitHub ]# File 'ext/fastfilereader/rubymain.cpp', line 54
static VALUE mapper_new (VALUE self, VALUE filename)
{
Mapper_t *m = new Mapper_t (StringValueCStr (filename));
if (!m)
rb_raise (rb_eStandardError, "No Mapper Object");
VALUE v = TypedData_Wrap_Struct (Mapper, &mapper_type, (void*)m);
return v;
}
Instance Method Details
#close
mapper_close
# File 'ext/fastfilereader/rubymain.cpp', line 91
static VALUE mapper_close (VALUE self)
{
Mapper_t *m = NULL;
TypedData_Get_Struct (self, Mapper_t, &mapper_type, m);
if (!m)
rb_raise (rb_eStandardError, "No Mapper Object");
m->Close();
return Qnil;
}
#get_chunk
mapper_get_chunk
# File 'ext/fastfilereader/rubymain.cpp', line 68
static VALUE mapper_get_chunk (VALUE self, VALUE start, VALUE length)
{
Mapper_t *m = NULL;
TypedData_Get_Struct (self, Mapper_t, &mapper_type, m);
if (!m)
rb_raise (rb_eStandardError, "No Mapper Object");
// TODO, what if some moron sends us a negative start value?
unsigned _start = NUM2INT (start);
unsigned _length = NUM2INT (length);
if ((_start + _length) > m->GetFileSize())
rb_raise (rb_eStandardError, "Mapper Range Error");
const char *chunk = m->GetChunk (_start);
if (!chunk)
rb_raise (rb_eStandardError, "No Mapper Chunk");
return rb_str_new (chunk, _length);
}
#size
mapper_size
# File 'ext/fastfilereader/rubymain.cpp', line 105
static VALUE mapper_size (VALUE self)
{
Mapper_t *m = NULL;
TypedData_Get_Struct (self, Mapper_t, &mapper_type, m);
if (!m)
rb_raise (rb_eStandardError, "No Mapper Object");
return INT2NUM (m->GetFileSize());
}