mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-11 12:42:31 +00:00
* Replaced most of the internal sigc++ slots and signals with a
lightweight version. This cut the size of the library w/debug by more than 300kb. All (almost) the signals the client connects to are now in DownloadWrapper. * Fixed off-by-one error in the month displayed. * Moved tracker url cleanup to src/parse and improved it. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@580 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
@@ -7,6 +7,7 @@ EXTRA_DIST= \
|
||||
rak/algorithm.h \
|
||||
rak/error_number.h \
|
||||
rak/functional.h \
|
||||
rak/string_manip.h \
|
||||
rak/unordered_vector.h \
|
||||
scripts/checks.m4 \
|
||||
scripts/common.m4
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
AC_INIT(rtorrent, 0.3.5, jaris@ifi.uio.no)
|
||||
AC_INIT(rtorrent, 0.3.6, jaris@ifi.uio.no)
|
||||
|
||||
AM_INIT_AUTOMAKE
|
||||
AM_CONFIG_HEADER(config.h)
|
||||
@@ -22,7 +22,7 @@ TORRENT_OTFD()
|
||||
|
||||
TORRENT_WITHOUT_VARIABLE_FDSET()
|
||||
|
||||
PKG_CHECK_MODULES(STUFF, sigc++-2.0 libtorrent >= 0.7.5,
|
||||
PKG_CHECK_MODULES(STUFF, sigc++-2.0 libtorrent >= 0.7.6,
|
||||
CXXFLAGS="$CXXFLAGS $STUFF_CFLAGS $CURL_CFLAGS";
|
||||
LIBS="$LIBS $STUFF_LIBS $CURL_LIBS")
|
||||
|
||||
|
||||
+72
-9
@@ -339,17 +339,11 @@ bind2nd(const Operation& op, const Type& val) {
|
||||
}
|
||||
|
||||
// Lightweight callback function including pointer to object. Should
|
||||
// be replaced by TR1 stuff later.
|
||||
|
||||
template <typename Ret>
|
||||
class function0 {
|
||||
public:
|
||||
virtual bool is_valid() const = 0;
|
||||
virtual Ret operator () () = 0;
|
||||
};
|
||||
// be replaced by TR1 stuff later. Requires an object to bind, instead
|
||||
// of using a seperate functor for that.
|
||||
|
||||
template <typename Object, typename Ret>
|
||||
class mem_fn0 : public function0<Ret> {
|
||||
class mem_fn0 {
|
||||
public:
|
||||
typedef Ret (Object::*Function)();
|
||||
|
||||
@@ -365,6 +359,23 @@ private:
|
||||
Function m_function;
|
||||
};
|
||||
|
||||
template <typename Object, typename Ret>
|
||||
class const_mem_fn0 {
|
||||
public:
|
||||
typedef Ret (Object::*Function)() const;
|
||||
|
||||
const_mem_fn0() : m_object(NULL) {}
|
||||
const_mem_fn0(Object* o, Function f) : m_object(o), m_function(f) {}
|
||||
|
||||
bool is_valid() const { return m_object; }
|
||||
|
||||
Ret operator () () { return (m_object->*m_function)(); }
|
||||
|
||||
private:
|
||||
Object* m_object;
|
||||
Function m_function;
|
||||
};
|
||||
|
||||
template <typename Object, typename Ret, typename Arg1>
|
||||
class mem_fn1 {
|
||||
public:
|
||||
@@ -382,18 +393,70 @@ private:
|
||||
Function m_function;
|
||||
};
|
||||
|
||||
template <typename Object, typename Ret, typename Arg1, typename Arg2>
|
||||
class mem_fn2 {
|
||||
public:
|
||||
typedef Ret (Object::*Function)(Arg1, Arg2);
|
||||
|
||||
mem_fn2() : m_object(NULL) {}
|
||||
mem_fn2(Object* o, Function f) : m_object(o), m_function(f) {}
|
||||
|
||||
bool is_valid() const { return m_object; }
|
||||
|
||||
Ret operator () (Arg1 a1, Arg2 a2) { return (m_object->*m_function)(a1, a2); }
|
||||
|
||||
private:
|
||||
Object* m_object;
|
||||
Function m_function;
|
||||
};
|
||||
|
||||
template <typename Object, typename Ret, typename Arg1, typename Arg2, typename Arg3>
|
||||
class mem_fn3 {
|
||||
public:
|
||||
typedef Ret (Object::*Function)(Arg1, Arg2, Arg3);
|
||||
|
||||
mem_fn3() : m_object(NULL) {}
|
||||
mem_fn3(Object* o, Function f) : m_object(o), m_function(f) {}
|
||||
|
||||
bool is_valid() const { return m_object; }
|
||||
|
||||
Ret operator () (Arg1 a1, Arg2 a2, Arg3 a3) { return (m_object->*m_function)(a1, a2, a3); }
|
||||
|
||||
private:
|
||||
Object* m_object;
|
||||
Function m_function;
|
||||
};
|
||||
|
||||
template <typename Object, typename Ret>
|
||||
inline mem_fn0<Object, Ret>
|
||||
make_mem_fn(Object* o, Ret (Object::*f)()) {
|
||||
return mem_fn0<Object, Ret>(o, f);
|
||||
}
|
||||
|
||||
template <typename Object, typename Ret>
|
||||
inline const_mem_fn0<Object, Ret>
|
||||
make_mem_fn(Object* o, Ret (Object::*f)() const) {
|
||||
return const_mem_fn0<Object, Ret>(o, f);
|
||||
}
|
||||
|
||||
template <typename Object, typename Ret, typename Arg1>
|
||||
inline mem_fn1<Object, Ret, Arg1>
|
||||
make_mem_fn(Object* o, Ret (Object::*f)(Arg1)) {
|
||||
return mem_fn1<Object, Ret, Arg1>(o, f);
|
||||
}
|
||||
|
||||
template <typename Object, typename Ret, typename Arg1, typename Arg2>
|
||||
inline mem_fn2<Object, Ret, Arg1, Arg2>
|
||||
make_mem_fn(Object* o, Ret (Object::*f)(Arg1, Arg2)) {
|
||||
return mem_fn2<Object, Ret, Arg1, Arg2>(o, f);
|
||||
}
|
||||
|
||||
template <typename Object, typename Ret, typename Arg1, typename Arg2, typename Arg3>
|
||||
inline mem_fn3<Object, Ret, Arg1, Arg2, Arg3>
|
||||
make_mem_fn(Object* o, Ret (Object::*f)(Arg1, Arg2, Arg3)) {
|
||||
return mem_fn3<Object, Ret, Arg1, Arg2, Arg3>(o, f);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
// rak - Rakshasa's toolbox
|
||||
// Copyright (C) 2005, Jari Sundell
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// In addition, as a special exception, the copyright holders give
|
||||
// permission to link the code of portions of this program with the
|
||||
// OpenSSL library under certain conditions as described in each
|
||||
// individual source file, and distribute linked combinations
|
||||
// including the two.
|
||||
//
|
||||
// You must obey the GNU General Public License in all respects for
|
||||
// all of the code used other than OpenSSL. If you modify file(s)
|
||||
// with this exception, you may extend this exception to your version
|
||||
// of the file(s), but you are not obligated to do so. If you do not
|
||||
// wish to do so, delete this exception statement from your version.
|
||||
// If you delete this exception statement from all source files in the
|
||||
// program, then also delete it here.
|
||||
//
|
||||
// Contact: Jari Sundell <jaris@ifi.uio.no>
|
||||
//
|
||||
// Skomakerveien 33
|
||||
// 3185 Skoppum, NORWAY
|
||||
|
||||
#ifndef RAK_STRING_MANIP_H
|
||||
#define RAK_STRING_MANIP_H
|
||||
|
||||
#include <cctype>
|
||||
|
||||
namespace rak {
|
||||
|
||||
// Use these trim functions until n1872 is widely supported.
|
||||
|
||||
template <typename Sequence>
|
||||
Sequence trim_begin(const Sequence& seq) {
|
||||
if (seq.empty() || !std::isspace(*seq.begin()))
|
||||
return seq;
|
||||
|
||||
typename Sequence::size_type pos = 0;
|
||||
|
||||
while (pos != seq.length() && std::isspace(seq[pos]))
|
||||
pos++;
|
||||
|
||||
return seq.substr(pos, seq.length() - pos);
|
||||
}
|
||||
|
||||
template <typename Sequence>
|
||||
Sequence trim_end(const Sequence& seq) {
|
||||
if (seq.empty() || !std::isspace(*(--seq.end())))
|
||||
return seq;
|
||||
|
||||
typename Sequence::size_type pos = seq.size();
|
||||
|
||||
while (pos != 0 && std::isspace(seq[pos - 1]))
|
||||
pos--;
|
||||
|
||||
return seq.substr(0, pos);
|
||||
}
|
||||
|
||||
template <typename Sequence>
|
||||
Sequence trim(const Sequence& seq) {
|
||||
return trim_begin(trim_end(seq));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -129,7 +129,7 @@ print_ddmmyyyy(time_t t) {
|
||||
str.fill('0');
|
||||
|
||||
str << std::setw(2) << u->tm_mday << '/'
|
||||
<< std::setw(2) << u->tm_mon << '/'
|
||||
<< std::setw(2) << (u->tm_mon + 1) << '/'
|
||||
<< std::setw(4) << (1900 + u->tm_year);
|
||||
|
||||
return str.str();
|
||||
|
||||
Reference in New Issue
Block a user