Skip to content

Commit

Permalink
Implement Page
Browse files Browse the repository at this point in the history
  • Loading branch information
rshipp committed Apr 20, 2016
1 parent 0d660c1 commit 75d5c8d
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/page/page.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,30 @@ const size_t Page::PAGE_SIZE;


Page* Page::read_from_input(std::istream& in) {
// TODO: implement me
return nullptr;
char* buffer = new char[PAGE_SIZE];
in.read(buffer, PAGE_SIZE);
if (in.gcount() > 0) {
vector<char> bytes(buffer, buffer + in.gcount());
return new Page(bytes);
} else {
return nullptr;
}
}


size_t Page::size() const {
// TODO: implement me
return 0;
return bytes.size();
}


bool Page::is_valid_offset(size_t offset) const {
// TODO: implement me
if (offset < bytes.size()) {
return true;
}
return false;
}


char Page::get_byte_at_offset(size_t offset) {
// TODO: implement me
return 0;
return bytes[offset];
}

0 comments on commit 75d5c8d

Please sign in to comment.