linuxdcpp-team team mailing list archive
-
linuxdcpp-team team
-
Mailing list archive
-
Message #05018
[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2745: GETSET with c++11
------------------------------------------------------------
revno: 2745
committer: Jacek Sieka <arnetheduck@xxxxxxxxx>
branch nick: dcplusplus
timestamp: Fri 2011-12-23 22:15:27 +0100
message:
GETSET with c++11
added:
dcpp/GetSet.h
modified:
dcpp/ADLSearch.h
dcpp/AdcCommand.cpp
dcpp/AdcCommand.h
dcpp/BundleItem.h
dcpp/ConnectionManager.h
dcpp/DirectoryListing.h
dcpp/Download.cpp
dcpp/Download.h
dcpp/FinishedItem.h
dcpp/HashBloom.h
dcpp/HashManager.h
dcpp/HubEntry.h
dcpp/OnlineUser.h
dcpp/QueueItem.h
dcpp/SSL.cpp
dcpp/SearchResult.h
dcpp/Socket.h
dcpp/Transfer.h
dcpp/Upload.h
dcpp/UploadManager.h
dcpp/UserCommand.cpp
dcpp/UserCommand.h
dcpp/Util.h
dcpp/WindowInfo.h
--
lp:dcplusplus
https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk
Your team Dcplusplus-team is subscribed to branch lp:dcplusplus.
To unsubscribe from this branch go to https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk/+edit-subscription
=== modified file 'dcpp/ADLSearch.h'
--- dcpp/ADLSearch.h 2011-12-15 17:08:18 +0000
+++ dcpp/ADLSearch.h 2011-12-23 21:15:27 +0000
@@ -28,7 +28,6 @@
#include "SettingsManager.h"
#include "Singleton.h"
#include "StringMatch.h"
-#include "Util.h"
namespace dcpp {
=== modified file 'dcpp/AdcCommand.cpp'
--- dcpp/AdcCommand.cpp 2011-12-22 22:14:45 +0000
+++ dcpp/AdcCommand.cpp 2011-12-23 21:15:27 +0000
@@ -237,6 +237,10 @@
return tmp;
}
+const string& AdcCommand::getParam(size_t n) const {
+ return getParameters().size() > n ? getParameters()[n] : Util::emptyString;
+}
+
bool AdcCommand::getParam(const char* name, size_t start, string& ret) const {
for(auto i = start; i < getParameters().size(); ++i) {
if(toCode(name) == toCode(getParameters()[i].c_str())) {
=== modified file 'dcpp/AdcCommand.h'
--- dcpp/AdcCommand.h 2011-10-15 14:59:13 +0000
+++ dcpp/AdcCommand.h 2011-12-23 21:15:27 +0000
@@ -22,7 +22,6 @@
#include "typedefs.h"
#include "Exception.h"
-#include "Util.h"
namespace dcpp {
@@ -147,9 +146,7 @@
parameters.push_back(str);
return *this;
}
- const string& getParam(size_t n) const {
- return getParameters().size() > n ? getParameters()[n] : Util::emptyString;
- }
+ const string& getParam(size_t n) const;
/** Return a named parameter where the name is a two-letter code */
bool getParam(const char* name, size_t start, string& ret) const;
bool hasFlag(const char* name, size_t start) const;
=== modified file 'dcpp/BundleItem.h'
--- dcpp/BundleItem.h 2011-05-28 15:31:50 +0000
+++ dcpp/BundleItem.h 2011-12-23 21:15:27 +0000
@@ -8,13 +8,15 @@
#ifndef BUNDLEITEM_H_
#define BUNDLEITEM_H_
+#include <string>
#include <map>
#include "Bundle.h"
-#include "Util.h"
+#include "GetSet.h"
namespace dcpp {
+using std::string;
using std::map;
class BundleItem {
=== modified file 'dcpp/ConnectionManager.h'
--- dcpp/ConnectionManager.h 2011-12-22 22:14:45 +0000
+++ dcpp/ConnectionManager.h 2011-12-23 21:15:27 +0000
@@ -20,11 +20,9 @@
#define DCPLUSPLUS_DCPP_CONNECTION_MANAGER_H
#include "TimerManager.h"
-
#include "UserConnectionListener.h"
#include "CriticalSection.h"
#include "Singleton.h"
-#include "Util.h"
#include "BufferedSocket.h"
#include "ConnectionManagerListener.h"
#include "HintedUser.h"
=== modified file 'dcpp/DirectoryListing.h'
--- dcpp/DirectoryListing.h 2011-12-22 22:14:45 +0000
+++ dcpp/DirectoryListing.h 2011-12-23 21:15:27 +0000
@@ -25,6 +25,7 @@
#include "HintedUser.h"
#include "FastAlloc.h"
#include "MerkleTree.h"
+#include "GetSet.h"
#include "Util.h"
namespace dcpp {
=== modified file 'dcpp/Download.cpp'
--- dcpp/Download.cpp 2011-12-18 17:34:49 +0000
+++ dcpp/Download.cpp 2011-12-23 21:15:27 +0000
@@ -91,4 +91,8 @@
params["target"] = getPath();
}
+string Download::getTargetFileName() {
+ return Util::getFileName(getPath());
+}
+
} // namespace dcpp
=== modified file 'dcpp/Download.h'
--- dcpp/Download.h 2011-09-30 11:33:12 +0000
+++ dcpp/Download.h 2011-12-23 21:15:27 +0000
@@ -6,7 +6,7 @@
#include "Transfer.h"
#include "MerkleTree.h"
#include "Flags.h"
-#include "Util.h"
+#include "GetSet.h"
namespace dcpp {
@@ -30,10 +30,7 @@
virtual ~Download();
/** @return Target filename without path. */
- string getTargetFileName() {
- return Util::getFileName(getPath());
- }
-
+ string getTargetFileName();
/** @internal */
const string& getDownloadTarget() {
return (getTempTarget().empty() ? getPath() : getTempTarget());
=== modified file 'dcpp/FinishedItem.h'
--- dcpp/FinishedItem.h 2011-04-13 19:16:51 +0000
+++ dcpp/FinishedItem.h 2011-12-23 21:15:27 +0000
@@ -22,9 +22,10 @@
#include <boost/noncopyable.hpp>
#include "forward.h"
+#include "typedefs.h"
#include "Pointer.h"
-#include "Util.h"
+#include "GetSet.h"
namespace dcpp {
=== added file 'dcpp/GetSet.h'
--- dcpp/GetSet.h 1970-01-01 00:00:00 +0000
+++ dcpp/GetSet.h 2011-12-23 21:15:27 +0000
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2001-2011 Jacek Sieka, arnetheduck on gmail point com
+ *
+ * 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.
+ */
+
+#ifndef DCPLUSPLUS_DCPP_GET_SET_H
+#define DCPLUSPLUS_DCPP_GET_SET_H
+
+#include <boost/mpl/eval_if.hpp>
+#include <boost/mpl/identity.hpp>
+#include <type_traits>
+
+#define REF_OR_COPY(t) boost::mpl::eval_if_c<std::is_class<t>::value, std::add_lvalue_reference<std::add_const<t>::type>, boost::mpl::identity<t>>::type
+
+#define GETSET(type, name, name2) \
+private: type name; \
+public: REF_OR_COPY(type) get##name2() const { return name; } \
+ void set##name2(REF_OR_COPY(type) name) { this->name = name; }
+
+#endif /* GETSET_H_ */
=== modified file 'dcpp/HashBloom.h'
--- dcpp/HashBloom.h 2011-04-13 19:16:51 +0000
+++ dcpp/HashBloom.h 2011-12-23 21:15:27 +0000
@@ -1,3 +1,21 @@
+/*
+ * Copyright (C) 2001-2011 Jacek Sieka, arnetheduck on gmail point com
+ *
+ * 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.
+ */
+
#ifndef HASHBLOOM_H_
#define HASHBLOOM_H_
=== modified file 'dcpp/HashManager.h'
--- dcpp/HashManager.h 2011-08-22 18:49:16 +0000
+++ dcpp/HashManager.h 2011-12-23 21:15:27 +0000
@@ -28,7 +28,7 @@
#include "Semaphore.h"
#include "TimerManager.h"
#include "HashManagerListener.h"
-#include "Util.h"
+#include "GetSet.h"
namespace dcpp {
=== modified file 'dcpp/HubEntry.h'
--- dcpp/HubEntry.h 2011-05-04 19:32:00 +0000
+++ dcpp/HubEntry.h 2011-12-23 21:15:27 +0000
@@ -22,7 +22,7 @@
#include <string>
#include "SettingsManager.h"
-#include "Util.h"
+#include "GetSet.h"
namespace dcpp {
=== modified file 'dcpp/OnlineUser.h'
--- dcpp/OnlineUser.h 2011-12-11 18:36:51 +0000
+++ dcpp/OnlineUser.h 2011-12-23 21:15:27 +0000
@@ -26,6 +26,7 @@
#include "forward.h"
#include "Flags.h"
#include "FastAlloc.h"
+#include "GetSet.h"
#include "Util.h"
#include "User.h"
#include "UserMatch.h"
=== modified file 'dcpp/QueueItem.h'
--- dcpp/QueueItem.h 2011-12-22 22:14:45 +0000
+++ dcpp/QueueItem.h 2011-12-23 21:15:27 +0000
@@ -29,6 +29,7 @@
#include "forward.h"
#include "Segment.h"
#include "Util.h"
+#include "GetSet.h"
#include "HintedUser.h"
namespace dcpp {
=== modified file 'dcpp/SSL.cpp'
--- dcpp/SSL.cpp 2011-04-13 19:16:51 +0000
+++ dcpp/SSL.cpp 2011-12-23 21:15:27 +0000
@@ -1,11 +1,14 @@
#include "stdinc.h"
+
#include "SSL.h"
-#include "Util.h"
+#include <vector>
namespace dcpp {
namespace ssl {
+using std::vector;
+
vector<uint8_t> X509_digest(::X509* x509, const ::EVP_MD* md) {
unsigned int n;
unsigned char buf[EVP_MAX_MD_SIZE];
=== modified file 'dcpp/SearchResult.h'
--- dcpp/SearchResult.h 2011-01-02 17:12:02 +0000
+++ dcpp/SearchResult.h 2011-12-23 21:15:27 +0000
@@ -24,6 +24,7 @@
#include "MerkleTree.h"
#include "AdcCommand.h"
#include "Pointer.h"
+#include "Util.h"
namespace dcpp {
=== modified file 'dcpp/Socket.h'
--- dcpp/Socket.h 2011-12-08 17:17:49 +0000
+++ dcpp/Socket.h 2011-12-23 21:15:27 +0000
@@ -41,6 +41,7 @@
#define SOCKET_ERROR -1
#endif
+#include "GetSet.h"
#include "Util.h"
#include "Exception.h"
=== modified file 'dcpp/Transfer.h'
--- dcpp/Transfer.h 2011-09-30 11:33:12 +0000
+++ dcpp/Transfer.h 2011-12-23 21:15:27 +0000
@@ -25,7 +25,7 @@
#include "MerkleTree.h"
#include "CriticalSection.h"
#include "Segment.h"
-#include "Util.h"
+#include "GetSet.h"
namespace dcpp {
=== modified file 'dcpp/Upload.h'
--- dcpp/Upload.h 2011-09-30 11:33:12 +0000
+++ dcpp/Upload.h 2011-12-23 21:15:27 +0000
@@ -4,6 +4,7 @@
#include "forward.h"
#include "Transfer.h"
#include "Flags.h"
+#include "GetSet.h"
namespace dcpp {
=== modified file 'dcpp/UploadManager.h'
--- dcpp/UploadManager.h 2011-04-13 19:16:51 +0000
+++ dcpp/UploadManager.h 2011-12-23 21:15:27 +0000
@@ -34,6 +34,7 @@
#include "Speaker.h"
#include "SettingsManager.h"
#include "HintedUser.h"
+#include "GetSet.h"
namespace dcpp {
=== modified file 'dcpp/UserCommand.cpp'
--- dcpp/UserCommand.cpp 2011-12-22 22:14:45 +0000
+++ dcpp/UserCommand.cpp 2011-12-23 21:15:27 +0000
@@ -20,6 +20,7 @@
#include "UserCommand.h"
#include "StringTokenizer.h"
+#include "Util.h"
namespace dcpp {
=== modified file 'dcpp/UserCommand.h'
--- dcpp/UserCommand.h 2011-04-13 19:16:51 +0000
+++ dcpp/UserCommand.h 2011-12-23 21:15:27 +0000
@@ -19,12 +19,19 @@
#ifndef DCPLUSPLUS_DCPP_USER_COMMAND_H
#define DCPLUSPLUS_DCPP_USER_COMMAND_H
+#include <vector>
+#include <string>
+
#include "Flags.h"
-#include "Util.h"
+#include "GetSet.h"
#include "noexcept.h"
+#include "typedefs.h"
namespace dcpp {
+using std::string;
+using std::vector;
+
class UserCommand : public Flags {
public:
typedef vector<UserCommand> List;
=== modified file 'dcpp/Util.h'
--- dcpp/Util.h 2011-12-22 22:14:45 +0000
+++ dcpp/Util.h 2011-12-23 21:15:27 +0000
@@ -51,32 +51,6 @@
using boost::find_if;
using std::map;
-template<typename T, bool flag> struct ReferenceSelector {
- typedef T ResultType;
-};
-template<typename T> struct ReferenceSelector<T,true> {
- typedef const T& ResultType;
-};
-
-template<typename T> class IsOfClassType {
-public:
- template<typename U> static char check(int U::*);
- template<typename U> static float check(...);
-public:
- enum { Result = sizeof(check<T>(0)) };
-};
-
-template<typename T> struct TypeTraits {
- typedef IsOfClassType<T> ClassType;
- typedef ReferenceSelector<T, ((ClassType::Result == 1) || (sizeof(T) > sizeof(char*)) ) > Selector;
- typedef typename Selector::ResultType ParameterType;
-};
-
-#define GETSET(type, name, name2) \
-private: type name; \
-public: TypeTraits<type>::ParameterType get##name2() const { return name; } \
- void set##name2(TypeTraits<type>::ParameterType a##name2) { name = a##name2; }
-
#define LIT(x) x, (sizeof(x)-1)
/** Evaluates op(pair<T1, T2>.first, compareTo) */
=== modified file 'dcpp/WindowInfo.h'
--- dcpp/WindowInfo.h 2011-03-18 15:40:31 +0000
+++ dcpp/WindowInfo.h 2011-12-23 21:15:27 +0000
@@ -19,12 +19,18 @@
#ifndef DCPLUSPLUS_DCPP_WINDOW_INFO_H
#define DCPLUSPLUS_DCPP_WINDOW_INFO_H
+#include <string>
+#include <unordered_map>
+
#include "forward.h"
#include "Flags.h"
-#include "Util.h"
+#include "GetSet.h"
namespace dcpp {
+using std::string;
+using std::unordered_map;
+
struct WindowParam : Flags {
WindowParam() : Flags() { }
WindowParam(const string& content, Flags::MaskType flags = 0) : Flags(flags), content(content) { }