void BevelFrame::pick(Canvas* c, const Allocation& a, int depth, Hit& h) { Glyph* g = body(); if (g != nil) { if (hmargin_ || vmargin_) { Allocation interior(a); allocate_body(g, thickness(c), interior); g->pick(c, interior, depth, h); } else { g->pick(c, a, depth, h); } } }
void BevelFrame::allocate(Canvas* c, const Allocation& a, Extension& ext) { Glyph* g = body(); if (g != nil) { if (hmargin_ || vmargin_) { Allocation interior(a); allocate_body(g, thickness(c), interior); g->allocate(c, interior, ext); } else { g->allocate(c, a, ext); } } ext.merge(c, a); }
void BevelFrame::print(Printer* p, const Allocation& a) const { Coord t = thickness(p); draw_frame(p, a, t); Glyph* g = body(); if (g != nil) { if (hmargin_ || vmargin_) { Allocation interior(a); allocate_body(g, t, interior); g->print(p, interior); } else { g->print(p, a); } } }
void BevelFrame::draw(Canvas* c, const Allocation& a) const { Coord t = thickness(c); draw_frame(c, a, t); Glyph* g = body(); if (g != nil) { if (hmargin_ || vmargin_) { Allocation interior(a); allocate_body(g, t, interior); g->draw(c, interior); } else { g->draw(c, a); } } }
ssize_t ResponseMessage::decode(char* input, size_t size) { char* input_pos = input; received_ += size; if (!is_header_received_) { if (version_ == 0) { version_ = input[0] & 0x7F; // "input" will always have at least 1 bytes if (version_ >= 3) { header_size_ = CASS_HEADER_SIZE_V3; } else { header_size_ = CASS_HEADER_SIZE_V1_AND_V2; } } if (received_ >= header_size_) { // We may have received more data then we need, only copy what we need size_t overage = received_ - header_size_; size_t needed = size - overage; memcpy(header_buffer_pos_, input_pos, needed); header_buffer_pos_ += needed; input_pos += needed; assert(header_buffer_pos_ == header_buffer_ + header_size_); char* buffer = header_buffer_ + 1; // Skip over "version" byte flags_ = *(buffer++); if (version_ >= 3) { buffer = decode_int16(buffer, stream_); } else { stream_ = *(buffer++); } opcode_ = *(buffer++); decode_int32(buffer, length_); is_header_received_ = true; if (!allocate_body(opcode_) || !response_body_) { return -1; } response_body_->set_buffer(length_); body_buffer_pos_ = response_body_->data(); } else { // We haven't received all the data for the header. We consume the // entire buffer. memcpy(header_buffer_pos_, input_pos, size); header_buffer_pos_ += size; return size; } } const size_t remaining = size - (input_pos - input); const size_t frame_size = header_size_ + length_; if (received_ >= frame_size) { // We may have received more data then we need, only copy what we need size_t overage = received_ - frame_size; size_t needed = remaining - overage; memcpy(body_buffer_pos_, input_pos, needed); body_buffer_pos_ += needed; input_pos += needed; assert(body_buffer_pos_ == response_body_->data() + length_); char* pos = response_body()->data(); if (flags_ & CASS_FLAG_WARNING) { pos = response_body()->decode_warnings(pos, length_); } if (flags_ & CASS_FLAG_CUSTOM_PAYLOAD) { pos = response_body()->decode_custom_payload(pos, length_); } if (!response_body_->decode(version_, pos, length_)) { is_body_error_ = true; return -1; } is_body_ready_ = true; } else { // We haven't received all the data for the frame. We consume the entire // buffer. memcpy(body_buffer_pos_, input_pos, remaining); body_buffer_pos_ += remaining; return size; } return input_pos - input; }