bool McRequest::setKeyFrom(const folly::IOBuf& source, const uint8_t* keyBegin, size_t keySize) { if (keySize && cloneInto(keyData_, source, keyBegin, keySize)) { keys_ = Keys(getRange(keyData_)); return true; } return false; }
Board* Board::clone() { Board* b = new Board(); for (unsigned char row = 0; row < BOARD_SIZE; row++) { for (unsigned char column = 0; column < BOARD_SIZE; column++) { b->positions[row*BOARD_SIZE + column].row = row; b->positions[row*BOARD_SIZE + column].column = column; } } cloneInto(b); return b; }
TileSet* TileSet::clone(NodeCloneContext &context) { TileSet* copy = new TileSet(); cloneInto(copy, context); return copy; }
unique_ptr<IOBuf> IOBuf::clone() const { unique_ptr<IOBuf> ret = make_unique<IOBuf>(); cloneInto(*ret); return ret; }
bool McRequest::setValueFrom(const folly::IOBuf& source, const uint8_t* valueBegin, size_t valueSize) { return valueSize && cloneInto(valueData_, source, valueBegin, valueSize); }
MemoImpl * MemoImpl::clone() const { auto result = std::make_unique<MemoImpl>(getParentHandle(),getControlData()); cloneInto(*result); return result.release(); }
bool McParser::umMessageReady( const uint8_t* header, const uint8_t* body, const folly::IOBuf& bodyBuffer) { switch (type_) { case ParserType::SERVER: { try { mc_op_t op; uint64_t reqid; auto req = umbrellaParseRequest(bodyBuffer, header, umMsgInfo_.header_size, body, umMsgInfo_.body_size, op, reqid); /* Umbrella requests never include a result and are never 'noreply' */ requestReadyHelper(std::move(req), op, reqid, /* result= */ mc_res_unknown, /* noreply= */ false); } catch (const std::runtime_error& e) { errorHelper( McReply(mc_res_remote_error, std::string("Error parsing Umbrella message: ") + e.what())); return false; } } break; case ParserType::CLIENT: { auto mutMsg = createMcMsgRef(); uint64_t reqid; auto st = um_consume_no_copy(header, umMsgInfo_.header_size, body, umMsgInfo_.body_size, &reqid, mutMsg.get()); if (st != um_ok) { errorHelper(McReply(mc_res_remote_error, "Error parsing Umbrella message")); return false; } folly::IOBuf value; if (mutMsg->value.len != 0) { if (!cloneInto(value, bodyBuffer, reinterpret_cast<uint8_t*>(mutMsg->value.str), mutMsg->value.len)) { errorHelper(McReply(mc_res_remote_error, "Error parsing Umbrella value")); return false; } // Reset msg->value, or it will confuse McReply::releasedMsg mutMsg->value.str = nullptr; mutMsg->value.len = 0; } McMsgRef msg(std::move(mutMsg)); auto reply = McReply(msg->result, msg.clone()); if (value.length() != 0) { reply.setValue(std::move(value)); } replyReadyHelper(std::move(reply), msg->op, reqid); } break; } return true; }