本文整理汇总了C++中Reply类的典型用法代码示例。如果您正苦于以下问题:C++ Reply类的具体用法?C++ Reply怎么用?C++ Reply使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Reply类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RedisCommand
int CodisClient::incrby(string key, int incr, int tt)
{
Reply rep = RedisCommand(Command("INCRBY")(key)(int2string(incr)), tt);
return (rep.error()) ? 0 : rep.integer();
}
示例2: while
status_t
Server::_Listener()
{
status_t result;
uint32 size;
void* buffer = NULL;
while (!fThreadCancel) {
result = fConnection->Receive(&buffer, &size);
if (result == B_NO_MEMORY)
continue;
else if (result != B_OK) {
fThreadError = result;
return result;
}
ASSERT(buffer != NULL && size > 0);
Reply* reply = new(std::nothrow) Reply(buffer, size);
if (reply == NULL) {
free(buffer);
continue;
}
Request* req = fRequests.FindRequest(reply->GetXID());
if (req != NULL) {
*req->fReply = reply;
req->fDone = true;
req->fEvent.NotifyAll();
} else
delete reply;
}
return B_OK;
}
示例3: comm
vector<string> CodisClient::mget(vector<string>& keys, int tt)
{
vector<string> values;
Command comm("MGET");
for (size_t i=0; i<keys.size(); i++)
{
comm(keys[i]);
}
Reply rep = RedisCommand(comm, tt);
if (rep.error())
{
return values;
}
else
{
for (size_t i=0; i<rep.elements().size(); i++)
{
values.push_back(rep.elements()[i].str());
}
}
return values;
}
示例4: TEST_F
TEST_F(ReplyInterpreterTest, execute_calls_caller) {
// Register metatypes
qRegisterMetaType<Reply>();
qRegisterMetaType<types::QtGpsLocation>();
MetaTypeRegistrar& registrar = MetaTypeRegistrar::instance();
registrar.registerReplyMetaType<types::QtGpsLocation>();
// Create a mock callback
QSharedPointer<MockCallback<joynr::types::QtGpsLocation>> callback(new MockCallback<joynr::types::QtGpsLocation>());
int myAltitude = 13;
EXPECT_CALL(*callback, onSuccess(Property(&types::QtGpsLocation::getAltitude, myAltitude)))
.Times(1);
// Create a reply caller
QSharedPointer<IReplyCaller> icaller(new ReplyCaller<types::QtGpsLocation>(
[callback](const RequestStatus& status, const types::QtGpsLocation& location) {
callback->onSuccess(location);
},
[](const RequestStatus& status){
}));
// Create a reply
types::QtGpsLocation location;
location.setAltitude(myAltitude);
QList<QVariant> response;
response.append(QVariant::fromValue(location));
Reply reply;
reply.setResponse(response);
// Interpret the reply
IReplyInterpreter& interpreter = registrar.getReplyInterpreter(Util::getTypeId<types::QtGpsLocation>());
interpreter.execute(icaller, reply);
}
示例5: TEST
TEST(RedisClientTest, getRedisCommand)
{
vector<string> command;
command.push_back("get");
command.push_back("kk");
Reply ret = client.RedisCommand(command);
EXPECT_STREQ(ret.str().c_str(), "vv");
}
示例6: GetReply
Reply Reply::GetReply(Reply::StatusType status)
{
Reply reply;
reply.status = status;
const ConstBuffer& statusBuffer = Replies::ToBuffer(status);
reply.content.data.reset(const_cast<char*>(statusBuffer.data), [](const char*){} );
reply.content.size = statusBuffer.size;
reply.SetHeaders(reply.content.size, "text/html");
return reply;
}
示例7: StockReply
Reply Reply::StockReply(Reply::status_type status)
{
Reply reply;
reply.status = status;
reply.content.clear();
const std::string status_string = reply.ToString(status);
reply.content.insert(reply.content.end(), status_string.begin(), status_string.end());
reply.headers.emplace_back("Access-Control-Allow-Origin", "*");
reply.headers.emplace_back("Content-Length", cast::integral_to_string(reply.content.size()));
reply.headers.emplace_back("Content-Type", "text/html");
return reply;
}
示例8: HeaderScanner
Scanner::Scanner(std::istream* in, std::unique_ptr<Message>& message) {
if (!message) {
lexer_.reset(new HeaderScanner(in));
} else if (message->is_reply()) {
Reply* reply = static_cast<Reply*>(message.get());
if (reply->response_code() == STATUS_SeeOther)
lexer_.reset(new ErrorScanner(in));
else
lexer_.reset(new MessageScanner(in, true));
}
if (!lexer_)
lexer_.reset(new MessageScanner(in));
}
示例9: command
int CodisClient::del(vector<string>& keys, int tt)
{
Command command("DEL");
Reply rep;
for (size_t i=0; i<keys.size(); i++)
{
// rep = RedisCommand(command(keys[i]));
command(keys[i]);
}
rep = RedisCommand(command, tt);
return rep.integer();
}
示例10: HandlePortAssignmentResponse
/**
* Handle a PortAssignment response.
*/
void UsbProDevice::HandlePortAssignmentResponse(RpcController *controller,
string *response,
ConfigureCallback *done,
bool status,
uint8_t port1_assignment,
uint8_t port2_assignment) {
if (!status) {
controller->SetFailed("Get Port Assignments failed");
} else {
Reply reply;
reply.set_type(ola::plugin::usbpro::Reply::USBPRO_PORT_ASSIGNMENT_REPLY);
ola::plugin::usbpro::PortAssignmentReply *port_assignment_reply =
reply.mutable_port_assignment();
port_assignment_reply->set_port_assignment1(port1_assignment);
port_assignment_reply->set_port_assignment2(port2_assignment);
reply.SerializeToString(response);
}
done->Run();
}
示例11: StockReply
Reply Reply::StockReply(Reply::status_type status)
{
Reply rep;
rep.status = status;
rep.content.clear();
const std::string status_string = rep.ToString(status);
rep.content.insert(rep.content.end(), status_string.begin(), status_string.end());
rep.headers.resize(3);
rep.headers[0].name = "Access-Control-Allow-Origin";
rep.headers[0].value = "*";
rep.headers[1].name = "Content-Length";
std::string size_string = IntToString(rep.content.size());
rep.headers[1].value = size_string;
rep.headers[2].name = "Content-Type";
rep.headers[2].value = "text/html";
return rep;
}
示例12: ReplyToString
void ReplyToString(Reply& reply, std::string &rep)
{
stringstream stream;
stream << reply.type() << ";"
<< reply.str() << ";"
<< reply.error() << ";"
<< reply.integer() << ";";
std::vector<Reply> elements = reply.elements();
for (size_t i=0; i<elements.size(); i++)
{
stream << elements[i].type() << ";"
<< elements[i].str() << ";"
<< elements[i].error() << ";"
<< elements[i].integer() << ";";
}
rep = stream.str();
}