From: Brian Aker Date: Tue, 2 Aug 2011 22:30:14 +0000 (-0700) Subject: Update util (fix dist issues) X-Git-Tag: 0.52~34 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=3e955aec34f06bf9c024a7d48091012b0e3c7398;p=m6w6%2Flibmemcached Update util (fix dist issues) --- diff --git a/util/instance.cc b/util/instance.cc index a5c289ef..23c8aec4 100644 --- a/util/instance.cc +++ b/util/instance.cc @@ -42,6 +42,7 @@ #include #include +#include #include #include #include diff --git a/util/instance.hpp b/util/instance.hpp index ff750f4f..bd9aeaa4 100644 --- a/util/instance.hpp +++ b/util/instance.hpp @@ -43,6 +43,7 @@ #include #include #include +#include #include "util/operation.hpp" diff --git a/util/operation.cc b/util/operation.cc new file mode 100644 index 00000000..ad19e2b7 --- /dev/null +++ b/util/operation.cc @@ -0,0 +1,72 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * DataDifferential Utility Library + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#include + +#include "util/operation.hpp" +#include + +namespace datadifferential { +namespace util { + +bool Operation::response(std::string &arg) +{ + if (_response.empty()) + return false; + + if (not memcmp("OK\r\n", &_response[0], 3)) + { } + else if (not memcmp("OK ", &_response[0], 3)) + { + arg.append(&_response[3], _response.size() -3); + } + else if (not memcmp("ERR ", &_response[0], 4)) + { + arg.append(&_response[4], _response.size() -4); + return false; + } + else + { + arg.append(&_response[0], _response.size()); + } + + return true; +} + +} /* namespace util */ +} /* namespace datadifferential */ diff --git a/util/operation.hpp b/util/operation.hpp index 5c8c26ed..13aeeb15 100644 --- a/util/operation.hpp +++ b/util/operation.hpp @@ -39,7 +39,7 @@ #include -#include +#include #include namespace datadifferential { @@ -86,29 +86,7 @@ public: } // Return false on error - bool response(std::string &arg) - { - if (_response.empty()) - return false; - - if (not memcmp("OK\r\n", &_response[0], 3)) - { } - else if (not memcmp("OK ", &_response[0], 3)) - { - arg.append(&_response[3], _response.size() -3); - } - else if (not memcmp("ERR ", &_response[0], 4)) - { - arg.append(&_response[4], _response.size() -4); - return false; - } - else - { - arg.append(&_response[0], _response.size()); - } - - return true; - } + bool response(std::string &); bool reconnect() const {