Browse Source

2008-05-13 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>

	Replaced "" with static const variable A2STR::NIL.
	Replaced string comparison against "" with std::string::empty().
	Added PROTO_* to Request class and use them as a protocol string
	constant.
	Made "started", "stopped", "completed" static const variable in
	AnnounceList class.
Tatsuhiro Tsujikawa 17 years ago
parent
commit
386d19693b
59 changed files with 308 additions and 122 deletions
  1. 9 0
      ChangeLog
  2. 41 0
      src/A2STR.cc
  3. 51 0
      src/A2STR.h
  4. 13 6
      src/AnnounceList.cc
  5. 6 0
      src/AnnounceList.h
  6. 2 1
      src/AsyncNameResolver.cc
  7. 3 2
      src/AuthConfigFactory.cc
  8. 2 1
      src/ByteArrayDiskWriter.cc
  9. 2 1
      src/ChunkChecksum.h
  10. 2 1
      src/Cookie.cc
  11. 3 2
      src/CookieParser.cc
  12. 2 1
      src/DHTAbstractMessage.h
  13. 2 1
      src/DHTAnnouncePeerMessage.h
  14. 1 1
      src/DHTFindNodeMessage.h
  15. 2 1
      src/DHTGetPeersMessage.h
  16. 2 1
      src/DHTMessage.h
  17. 5 4
      src/DHTMessageFactory.h
  18. 5 4
      src/DHTMessageFactoryImpl.h
  19. 2 1
      src/DHTPingMessage.h
  20. 3 2
      src/DHTQueryMessage.h
  21. 2 1
      src/DHTResponseMessage.h
  22. 2 1
      src/DNSCache.h
  23. 2 1
      src/DefaultBtAnnounce.cc
  24. 4 3
      src/DefaultBtContext.cc
  25. 2 1
      src/DefaultBtContext.h
  26. 2 1
      src/ExtendedMessagingAware.h
  27. 4 3
      src/FeatureConfig.cc
  28. 3 2
      src/File.cc
  29. 2 1
      src/HelpItem.h
  30. 5 4
      src/HttpHeader.cc
  31. 2 1
      src/HttpHeaderProcessor.cc
  32. 2 2
      src/HttpRequest.cc
  33. 1 1
      src/HttpRequestCommand.cc
  34. 2 1
      src/HttpResponse.cc
  35. 3 3
      src/InitiateConnectionCommandFactory.cc
  36. 2 1
      src/Makefile.am
  37. 13 12
      src/Makefile.in
  38. 3 2
      src/Metalink2RequestGroup.cc
  39. 6 5
      src/MetalinkParserController.cc
  40. 8 0
      src/MetalinkResource.cc
  41. 9 0
      src/MetalinkResource.h
  42. 1 1
      src/Netrc.cc
  43. 2 1
      src/Netrc.h
  44. 2 1
      src/NullProgressInfoFile.h
  45. 5 4
      src/Option.cc
  46. 1 1
      src/ParameterizedStringParser.cc
  47. 2 1
      src/PeerSessionResource.cc
  48. 16 9
      src/Request.cc
  49. 6 0
      src/Request.h
  50. 3 2
      src/RequestGroup.cc
  51. 2 2
      src/SingleFileDownloadContext.cc
  52. 3 2
      src/SingleFileDownloadContext.h
  53. 2 1
      src/TaggedItem.cc
  54. 3 2
      src/TrackerWatcherCommand.cc
  55. 1 1
      src/UriListParser.cc
  56. 14 13
      src/Util.cc
  57. 2 1
      src/a2functional.h
  58. 3 2
      src/main.cc
  59. 3 2
      src/option_processing.cc

+ 9 - 0
ChangeLog

@@ -1,3 +1,12 @@
+2008-05-13  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
+
+	Replaced "" with static const variable A2STR::NIL.
+	Replaced string comparison against "" with std::string::empty().
+	Added PROTO_* to Request class and use them as a protocol string
+	constant.
+	Made "started", "stopped", "completed" static const variable in
+	AnnounceList class.
+	
 2008-05-13  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
 2008-05-13  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
 
 
 	Updated translations. Great thanks to translators.
 	Updated translations. Great thanks to translators.

+ 41 - 0
src/A2STR.cc

@@ -0,0 +1,41 @@
+/* <!-- copyright */
+/*
+ * aria2 - The high speed download utility
+ *
+ * Copyright (C) 2006 Tatsuhiro Tsujikawa
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  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.
+ */
+/* copyright --> */
+#include "A2STR.h"
+
+namespace aria2 {
+
+const std::string A2STR::NIL("");
+
+} // namespace aria2

+ 51 - 0
src/A2STR.h

@@ -0,0 +1,51 @@
+/* <!-- copyright */
+/*
+ * aria2 - The high speed download utility
+ *
+ * Copyright (C) 2006 Tatsuhiro Tsujikawa
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  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.
+ */
+/* copyright --> */
+#ifndef _D_A2_STR_H_
+#define _D_A2_STR_H_
+
+#include <string>
+
+namespace aria2 {
+
+class A2STR {
+private:
+  A2STR();
+public:
+  static const std::string NIL;
+
+};
+} // namespace aria2
+
+#endif // _D_A2_STR_H_

+ 13 - 6
src/AnnounceList.cc

@@ -35,10 +35,17 @@
 #include "AnnounceList.h"
 #include "AnnounceList.h"
 #include "List.h"
 #include "List.h"
 #include "Data.h"
 #include "Data.h"
+#include "A2STR.h"
 #include <algorithm>
 #include <algorithm>
 
 
 namespace aria2 {
 namespace aria2 {
 
 
+const std::string AnnounceList::STARTED("started");
+
+const std::string AnnounceList::STOPPED("stopped");
+
+const std::string AnnounceList::COMPLETED("completed");
+
 AnnounceList::AnnounceList(const MetaEntry* announceListEntry):
 AnnounceList::AnnounceList(const MetaEntry* announceListEntry):
   currentTrackerInitialized(false) {
   currentTrackerInitialized(false) {
   reconfigure(announceListEntry);
   reconfigure(announceListEntry);
@@ -96,7 +103,7 @@ std::string AnnounceList::getAnnounce() const {
   if(currentTrackerInitialized) {
   if(currentTrackerInitialized) {
     return *currentTracker;
     return *currentTracker;
   } else {
   } else {
-    return "";
+    return A2STR::NIL;
   }
   }
 }
 }
 
 
@@ -146,16 +153,16 @@ std::string AnnounceList::getEventString() const {
     switch((*currentTier)->event) {
     switch((*currentTier)->event) {
     case AnnounceTier::STARTED:
     case AnnounceTier::STARTED:
     case AnnounceTier::STARTED_AFTER_COMPLETION:
     case AnnounceTier::STARTED_AFTER_COMPLETION:
-      return "started";
+      return STARTED;
     case AnnounceTier::STOPPED:
     case AnnounceTier::STOPPED:
-      return "stopped";
+      return STOPPED;
     case AnnounceTier::COMPLETED:
     case AnnounceTier::COMPLETED:
-      return "completed";
+      return COMPLETED;
     default:
     default:
-      return "";
+      return A2STR::NIL;
     }
     }
   } else {
   } else {
-    return "";
+    return A2STR::NIL;
   }
   }
 }
 }
 
 

+ 6 - 0
src/AnnounceList.h

@@ -127,6 +127,12 @@ public:
   bool currentTierAcceptsStoppedEvent() const;
   bool currentTierAcceptsStoppedEvent() const;
 
 
   bool currentTierAcceptsCompletedEvent() const;
   bool currentTierAcceptsCompletedEvent() const;
+
+  static const std::string STARTED;
+
+  static const std::string STOPPED;
+
+  static const std::string COMPLETED;
 };
 };
 
 
 } // namespace aria2
 } // namespace aria2

+ 2 - 1
src/AsyncNameResolver.cc

@@ -34,6 +34,7 @@
 /* copyright --> */
 /* copyright --> */
 #include "AsyncNameResolver.h"
 #include "AsyncNameResolver.h"
 #include "Util.h"
 #include "Util.h"
+#include "A2STR.h"
 #include <cstring>
 #include <cstring>
 
 
 namespace aria2 {
 namespace aria2 {
@@ -121,7 +122,7 @@ bool AsyncNameResolver::operator==(const AsyncNameResolver& resolver) const
 
 
 void AsyncNameResolver::reset()
 void AsyncNameResolver::reset()
 {
 {
-  _hostname = "";
+  _hostname = A2STR::NIL;
   _resolvedAddresses.clear();
   _resolvedAddresses.clear();
   status = STATUS_READY;
   status = STATUS_READY;
   ares_destroy(channel);
   ares_destroy(channel);

+ 3 - 2
src/AuthConfigFactory.cc

@@ -51,9 +51,10 @@ AuthConfigFactory::~AuthConfigFactory() {}
 AuthConfigHandle
 AuthConfigHandle
 AuthConfigFactory::createAuthConfig(const RequestHandle& request) const
 AuthConfigFactory::createAuthConfig(const RequestHandle& request) const
 {
 {
-  if(request->getProtocol() == "http" || request->getProtocol() == "https") {
+  if(request->getProtocol() == Request::PROTO_HTTP ||
+     request->getProtocol() == Request::PROTO_HTTPS) {
     return createHttpAuthResolver()->resolveAuthConfig(request->getHost());
     return createHttpAuthResolver()->resolveAuthConfig(request->getHost());
-  } else if(request->getProtocol() == "ftp") {
+  } else if(request->getProtocol() == Request::PROTO_FTP) {
     if(!request->getUsername().empty()) {
     if(!request->getUsername().empty()) {
       return createAuthConfig(request->getUsername(), request->getPassword());
       return createAuthConfig(request->getUsername(), request->getPassword());
     } else {
     } else {

+ 2 - 1
src/ByteArrayDiskWriter.cc

@@ -34,6 +34,7 @@
 /* copyright --> */
 /* copyright --> */
 #include "ByteArrayDiskWriter.h"
 #include "ByteArrayDiskWriter.h"
 #include "Util.h"
 #include "Util.h"
+#include "A2STR.h"
 
 
 namespace aria2 {
 namespace aria2 {
 
 
@@ -43,7 +44,7 @@ ByteArrayDiskWriter::~ByteArrayDiskWriter() {}
 
 
 void ByteArrayDiskWriter::clear()
 void ByteArrayDiskWriter::clear()
 {
 {
-  buf.str("");
+  buf.str(A2STR::NIL);
 }
 }
 
 
 void ByteArrayDiskWriter::initAndOpenFile(const std::string& filename,
 void ByteArrayDiskWriter::initAndOpenFile(const std::string& filename,

+ 2 - 1
src/ChunkChecksum.h

@@ -37,6 +37,7 @@
 
 
 #include "common.h"
 #include "common.h"
 #include "SharedHandle.h"
 #include "SharedHandle.h"
+#include "A2STR.h"
 #include <string>
 #include <string>
 #include <deque>
 #include <deque>
 
 
@@ -82,7 +83,7 @@ public:
     if(index < _checksums.size()) {
     if(index < _checksums.size()) {
       return _checksums[index];
       return _checksums[index];
     } else {
     } else {
-      return "";
+      return A2STR::NIL;
     }
     }
   }
   }
   
   

+ 2 - 1
src/Cookie.cc

@@ -34,6 +34,7 @@
 /* copyright --> */
 /* copyright --> */
 #include "Cookie.h"
 #include "Cookie.h"
 #include "Util.h"
 #include "Util.h"
+#include "A2STR.h"
 
 
 namespace aria2 {
 namespace aria2 {
 
 
@@ -74,7 +75,7 @@ std::string Cookie::toString() const
 
 
 void Cookie::clear()
 void Cookie::clear()
 {
 {
-  name = value = path = domain = "";
+  name = value = path = domain = A2STR::NIL;
   expires = 0;
   expires = 0;
   secure = false;
   secure = false;
 }
 }

+ 3 - 2
src/CookieParser.cc

@@ -34,6 +34,7 @@
 /* copyright --> */
 /* copyright --> */
 #include "CookieParser.h"
 #include "CookieParser.h"
 #include "Util.h"
 #include "Util.h"
+#include "A2STR.h"
 #include <strings.h>
 #include <strings.h>
 #include <utility>
 #include <utility>
 #include <istream>
 #include <istream>
@@ -60,7 +61,7 @@ void CookieParser::setField(Cookie& cookie, const std::string& name, const std::
 
 
 Cookie CookieParser::parse(const std::string& cookieStr) const
 Cookie CookieParser::parse(const std::string& cookieStr) const
 {
 {
-  return parse(cookieStr, "", "");
+  return parse(cookieStr, A2STR::NIL, A2STR::NIL);
 }
 }
 
 
 Cookie CookieParser::parse(const std::string& cookieStr, const std::string& defaultDomain, const std::string& defaultPath) const
 Cookie CookieParser::parse(const std::string& cookieStr, const std::string& defaultDomain, const std::string& defaultPath) const
@@ -84,7 +85,7 @@ Cookies CookieParser::parse(std::istream& s) const
   Cookies cookies;
   Cookies cookies;
   std::string line;
   std::string line;
   while(getline(s, line)) {
   while(getline(s, line)) {
-    if(Util::trim(line) == "" || Util::startsWith(line, "#")) {
+    if(Util::trim(line).empty() || Util::startsWith(line, "#")) {
       continue;
       continue;
     }
     }
     Cookie cookie = parse(line);
     Cookie cookie = parse(line);

+ 2 - 1
src/DHTAbstractMessage.h

@@ -36,6 +36,7 @@
 #define _D_DHT_ABSTRACT_MESSAGE_H_
 #define _D_DHT_ABSTRACT_MESSAGE_H_
 
 
 #include "DHTMessage.h"
 #include "DHTMessage.h"
+#include "A2STR.h"
 
 
 namespace aria2 {
 namespace aria2 {
 
 
@@ -57,7 +58,7 @@ protected:
 public:
 public:
   DHTAbstractMessage(const SharedHandle<DHTNode>& localNode,
   DHTAbstractMessage(const SharedHandle<DHTNode>& localNode,
 		     const SharedHandle<DHTNode>& remoteNode,
 		     const SharedHandle<DHTNode>& remoteNode,
-		     const std::string& transactionID = "");
+		     const std::string& transactionID = A2STR::NIL);
 
 
   virtual ~DHTAbstractMessage();
   virtual ~DHTAbstractMessage();
 
 

+ 2 - 1
src/DHTAnnouncePeerMessage.h

@@ -37,6 +37,7 @@
 
 
 #include "DHTQueryMessage.h"
 #include "DHTQueryMessage.h"
 #include "DHTConstants.h"
 #include "DHTConstants.h"
+#include "A2STR.h"
 
 
 namespace aria2 {
 namespace aria2 {
 
 
@@ -62,7 +63,7 @@ public:
 			 const unsigned char* infoHash,
 			 const unsigned char* infoHash,
 			 uint16_t tcpPort,
 			 uint16_t tcpPort,
 			 const std::string& token,
 			 const std::string& token,
-			 const std::string& transactionID = "");
+			 const std::string& transactionID = A2STR::NIL);
 
 
   virtual ~DHTAnnouncePeerMessage();
   virtual ~DHTAnnouncePeerMessage();
 
 

+ 1 - 1
src/DHTFindNodeMessage.h

@@ -49,7 +49,7 @@ public:
   DHTFindNodeMessage(const SharedHandle<DHTNode>& localNode,
   DHTFindNodeMessage(const SharedHandle<DHTNode>& localNode,
 		     const SharedHandle<DHTNode>& remoteNode,
 		     const SharedHandle<DHTNode>& remoteNode,
 		     const unsigned char* targetNodeID,
 		     const unsigned char* targetNodeID,
-		     const std::string& transactionID = "");
+		     const std::string& transactionID = A2STR::NIL);
 
 
   virtual ~DHTFindNodeMessage();
   virtual ~DHTFindNodeMessage();
 
 

+ 2 - 1
src/DHTGetPeersMessage.h

@@ -37,6 +37,7 @@
 
 
 #include "DHTQueryMessage.h"
 #include "DHTQueryMessage.h"
 #include "DHTConstants.h"
 #include "DHTConstants.h"
+#include "A2STR.h"
 
 
 namespace aria2 {
 namespace aria2 {
 
 
@@ -56,7 +57,7 @@ public:
   DHTGetPeersMessage(const SharedHandle<DHTNode>& localNode,
   DHTGetPeersMessage(const SharedHandle<DHTNode>& localNode,
 		     const SharedHandle<DHTNode>& remoteNode,
 		     const SharedHandle<DHTNode>& remoteNode,
 		     const unsigned char* infoHash,
 		     const unsigned char* infoHash,
-		     const std::string& transactionID = "");
+		     const std::string& transactionID = A2STR::NIL);
 
 
   virtual ~DHTGetPeersMessage();
   virtual ~DHTGetPeersMessage();
 
 

+ 2 - 1
src/DHTMessage.h

@@ -37,6 +37,7 @@
 
 
 #include "common.h"
 #include "common.h"
 #include "SharedHandle.h"
 #include "SharedHandle.h"
+#include "A2STR.h"
 #include <string>
 #include <string>
 
 
 namespace aria2 {
 namespace aria2 {
@@ -55,7 +56,7 @@ protected:
 public:
 public:
   DHTMessage(const SharedHandle<DHTNode>& localNode,
   DHTMessage(const SharedHandle<DHTNode>& localNode,
 	     const SharedHandle<DHTNode>& remoteNode,
 	     const SharedHandle<DHTNode>& remoteNode,
-	     const std::string& transactionID = "");
+	     const std::string& transactionID = A2STR::NIL);
 
 
   virtual ~DHTMessage();
   virtual ~DHTMessage();
 
 

+ 5 - 4
src/DHTMessageFactory.h

@@ -37,6 +37,7 @@
 
 
 #include "common.h"
 #include "common.h"
 #include "SharedHandle.h"
 #include "SharedHandle.h"
+#include "A2STR.h"
 #include <string>
 #include <string>
 #include <deque>
 #include <deque>
 
 
@@ -62,7 +63,7 @@ public:
 
 
   virtual SharedHandle<DHTMessage>
   virtual SharedHandle<DHTMessage>
   createPingMessage(const SharedHandle<DHTNode>& remoteNode,
   createPingMessage(const SharedHandle<DHTNode>& remoteNode,
-		    const std::string& transactionID = "") = 0;
+		    const std::string& transactionID = A2STR::NIL) = 0;
 
 
   virtual SharedHandle<DHTMessage>
   virtual SharedHandle<DHTMessage>
   createPingReplyMessage(const SharedHandle<DHTNode>& remoteNode,
   createPingReplyMessage(const SharedHandle<DHTNode>& remoteNode,
@@ -72,7 +73,7 @@ public:
   virtual SharedHandle<DHTMessage>
   virtual SharedHandle<DHTMessage>
   createFindNodeMessage(const SharedHandle<DHTNode>& remoteNode,
   createFindNodeMessage(const SharedHandle<DHTNode>& remoteNode,
 			const unsigned char* targetNodeID,
 			const unsigned char* targetNodeID,
-			const std::string& transactionID = "") = 0;
+			const std::string& transactionID = A2STR::NIL) = 0;
 
 
   virtual SharedHandle<DHTMessage>
   virtual SharedHandle<DHTMessage>
   createFindNodeReplyMessage(const SharedHandle<DHTNode>& remoteNode,
   createFindNodeReplyMessage(const SharedHandle<DHTNode>& remoteNode,
@@ -82,7 +83,7 @@ public:
   virtual SharedHandle<DHTMessage>
   virtual SharedHandle<DHTMessage>
   createGetPeersMessage(const SharedHandle<DHTNode>& remoteNode,
   createGetPeersMessage(const SharedHandle<DHTNode>& remoteNode,
 			const unsigned char* infoHash,
 			const unsigned char* infoHash,
-			const std::string& transactionID = "") = 0;
+			const std::string& transactionID = A2STR::NIL) = 0;
 
 
   virtual SharedHandle<DHTMessage>
   virtual SharedHandle<DHTMessage>
   createGetPeersReplyMessage(const SharedHandle<DHTNode>& remoteNode,
   createGetPeersReplyMessage(const SharedHandle<DHTNode>& remoteNode,
@@ -101,7 +102,7 @@ public:
 			    const unsigned char* infoHash,
 			    const unsigned char* infoHash,
 			    uint16_t tcpPort,
 			    uint16_t tcpPort,
 			    const std::string& token,
 			    const std::string& token,
-			    const std::string& transactionID = "") = 0;
+			    const std::string& transactionID = A2STR::NIL) = 0;
 
 
   virtual SharedHandle<DHTMessage>
   virtual SharedHandle<DHTMessage>
   createAnnouncePeerReplyMessage(const SharedHandle<DHTNode>& remoteNode,
   createAnnouncePeerReplyMessage(const SharedHandle<DHTNode>& remoteNode,

+ 5 - 4
src/DHTMessageFactoryImpl.h

@@ -36,6 +36,7 @@
 #define _D_DHT_MESSAGE_FACTORY_IMPL_H_
 #define _D_DHT_MESSAGE_FACTORY_IMPL_H_
 
 
 #include "DHTMessageFactory.h"
 #include "DHTMessageFactory.h"
+#include "A2STR.h"
 
 
 namespace aria2 {
 namespace aria2 {
 
 
@@ -94,7 +95,7 @@ public:
 
 
   virtual SharedHandle<DHTMessage>
   virtual SharedHandle<DHTMessage>
   createPingMessage(const SharedHandle<DHTNode>& remoteNode,
   createPingMessage(const SharedHandle<DHTNode>& remoteNode,
-		    const std::string& transactionID = "");
+		    const std::string& transactionID = A2STR::NIL);
 
 
   virtual SharedHandle<DHTMessage>
   virtual SharedHandle<DHTMessage>
   createPingReplyMessage(const SharedHandle<DHTNode>& remoteNode,
   createPingReplyMessage(const SharedHandle<DHTNode>& remoteNode,
@@ -104,7 +105,7 @@ public:
   virtual SharedHandle<DHTMessage>
   virtual SharedHandle<DHTMessage>
   createFindNodeMessage(const SharedHandle<DHTNode>& remoteNode,
   createFindNodeMessage(const SharedHandle<DHTNode>& remoteNode,
 			const unsigned char* targetNodeID,
 			const unsigned char* targetNodeID,
-			const std::string& transactionID = "");
+			const std::string& transactionID = A2STR::NIL);
 
 
   SharedHandle<DHTMessage>
   SharedHandle<DHTMessage>
   createFindNodeReplyMessage(const SharedHandle<DHTNode>& remoteNode,
   createFindNodeReplyMessage(const SharedHandle<DHTNode>& remoteNode,
@@ -120,7 +121,7 @@ public:
   virtual SharedHandle<DHTMessage>
   virtual SharedHandle<DHTMessage>
   createGetPeersMessage(const SharedHandle<DHTNode>& remoteNode,
   createGetPeersMessage(const SharedHandle<DHTNode>& remoteNode,
 			const unsigned char* infoHash,
 			const unsigned char* infoHash,
-			const std::string& transactionID = "");
+			const std::string& transactionID = A2STR::NIL);
 
 
   virtual SharedHandle<DHTMessage>
   virtual SharedHandle<DHTMessage>
   createGetPeersReplyMessage(const SharedHandle<DHTNode>& remoteNode,
   createGetPeersReplyMessage(const SharedHandle<DHTNode>& remoteNode,
@@ -149,7 +150,7 @@ public:
 			    const unsigned char* infoHash,
 			    const unsigned char* infoHash,
 			    uint16_t tcpPort,
 			    uint16_t tcpPort,
 			    const std::string& token,
 			    const std::string& token,
-			    const std::string& transactionID = "");
+			    const std::string& transactionID = A2STR::NIL);
 
 
   virtual SharedHandle<DHTMessage>
   virtual SharedHandle<DHTMessage>
   createAnnouncePeerReplyMessage(const SharedHandle<DHTNode>& remoteNode,
   createAnnouncePeerReplyMessage(const SharedHandle<DHTNode>& remoteNode,

+ 2 - 1
src/DHTPingMessage.h

@@ -36,6 +36,7 @@
 #define _D_DHT_PING_MESSAGE_H_
 #define _D_DHT_PING_MESSAGE_H_
 
 
 #include "DHTQueryMessage.h"
 #include "DHTQueryMessage.h"
+#include "A2STR.h"
 
 
 namespace aria2 {
 namespace aria2 {
 
 
@@ -43,7 +44,7 @@ class DHTPingMessage:public DHTQueryMessage {
 public:
 public:
   DHTPingMessage(const SharedHandle<DHTNode>& localNode,
   DHTPingMessage(const SharedHandle<DHTNode>& localNode,
 		 const SharedHandle<DHTNode>& remoteNode,
 		 const SharedHandle<DHTNode>& remoteNode,
-		 const std::string& transactionID = "");
+		 const std::string& transactionID = A2STR::NIL);
 
 
   virtual ~DHTPingMessage();
   virtual ~DHTPingMessage();
 
 

+ 3 - 2
src/DHTQueryMessage.h

@@ -36,16 +36,17 @@
 #define _D_DHT_QUERY_MESSAGE_H_
 #define _D_DHT_QUERY_MESSAGE_H_
 
 
 #include "DHTAbstractMessage.h"
 #include "DHTAbstractMessage.h"
+#include "A2STR.h"
 
 
 namespace aria2 {
 namespace aria2 {
 
 
 class DHTQueryMessage:public DHTAbstractMessage {
 class DHTQueryMessage:public DHTAbstractMessage {
 protected:
 protected:
-  virtual std::string toStringOptional() const { return ""; }
+  virtual std::string toStringOptional() const { return A2STR::NIL; }
 public:
 public:
   DHTQueryMessage(const SharedHandle<DHTNode>& localNode,
   DHTQueryMessage(const SharedHandle<DHTNode>& localNode,
 		  const SharedHandle<DHTNode>& remoteNode,
 		  const SharedHandle<DHTNode>& remoteNode,
-		  const std::string& transactionID = "");
+		  const std::string& transactionID = A2STR::NIL);
 
 
   virtual ~DHTQueryMessage();
   virtual ~DHTQueryMessage();
 
 

+ 2 - 1
src/DHTResponseMessage.h

@@ -36,12 +36,13 @@
 #define _D_DHT_RESPONSE_MESSAGE_H_
 #define _D_DHT_RESPONSE_MESSAGE_H_
 
 
 #include "DHTAbstractMessage.h"
 #include "DHTAbstractMessage.h"
+#include "A2STR.h"
 
 
 namespace aria2 {
 namespace aria2 {
 
 
 class DHTResponseMessage:public DHTAbstractMessage {
 class DHTResponseMessage:public DHTAbstractMessage {
 protected:
 protected:
-  virtual std::string toStringOptional() const { return ""; }
+  virtual std::string toStringOptional() const { return A2STR::NIL; }
 public:
 public:
   DHTResponseMessage(const SharedHandle<DHTNode>& localNode,
   DHTResponseMessage(const SharedHandle<DHTNode>& localNode,
 		     const SharedHandle<DHTNode>& remoteNode,
 		     const SharedHandle<DHTNode>& remoteNode,

+ 2 - 1
src/DNSCache.h

@@ -38,6 +38,7 @@
 #include "common.h"
 #include "common.h"
 #include "SharedHandle.h"
 #include "SharedHandle.h"
 #include "SingletonHolder.h"
 #include "SingletonHolder.h"
+#include "A2STR.h"
 #include <string>
 #include <string>
 #include <map>
 #include <map>
 
 
@@ -79,7 +80,7 @@ class NullDNSCache : public DNSCache {
 public:
 public:
   virtual ~NullDNSCache() {}
   virtual ~NullDNSCache() {}
 
 
-  virtual std::string find(const std::string& hostname) { return ""; }
+  virtual std::string find(const std::string& hostname) { return A2STR::NIL; }
 
 
   virtual void put(const std::string& hostname, const std::string& ipaddr) {}
   virtual void put(const std::string& hostname, const std::string& ipaddr) {}
 };
 };

+ 2 - 1
src/DefaultBtAnnounce.cc

@@ -53,6 +53,7 @@
 #include "Peer.h"
 #include "Peer.h"
 #include "Option.h"
 #include "Option.h"
 #include "StringFormat.h"
 #include "StringFormat.h"
+#include "A2STR.h"
 
 
 namespace aria2 {
 namespace aria2 {
 
 
@@ -128,7 +129,7 @@ std::string DefaultBtAnnounce::getAnnounceUrl() {
       announceList.setEvent(AnnounceTier::STARTED_AFTER_COMPLETION);
       announceList.setEvent(AnnounceTier::STARTED_AFTER_COMPLETION);
     }
     }
   } else {
   } else {
-    return "";
+    return A2STR::NIL;
   }
   }
   unsigned int numWant = 50;
   unsigned int numWant = 50;
   if(!btRuntime->lessThanEqMinPeer() || btRuntime->isHalt()) {
   if(!btRuntime->lessThanEqMinPeer() || btRuntime->isHalt()) {

+ 4 - 3
src/DefaultBtContext.cc

@@ -50,6 +50,7 @@
 #include "message.h"
 #include "message.h"
 #include "PeerMessageUtil.h"
 #include "PeerMessageUtil.h"
 #include "StringFormat.h"
 #include "StringFormat.h"
+#include "A2STR.h"
 #include <cstring>
 #include <cstring>
 #include <ostream>
 #include <ostream>
 #include <functional>
 #include <functional>
@@ -87,14 +88,14 @@ std::string DefaultBtContext::getInfoHashAsString() const {
 
 
 void DefaultBtContext::clear() {
 void DefaultBtContext::clear() {
   memset(infoHash, 0, INFO_HASH_LENGTH);
   memset(infoHash, 0, INFO_HASH_LENGTH);
-  infoHashString = "";
+  infoHashString = A2STR::NIL;
   pieceHashes.clear();
   pieceHashes.clear();
   fileEntries.clear();
   fileEntries.clear();
   totalLength = 0;
   totalLength = 0;
   pieceLength = 0;
   pieceLength = 0;
   fileMode = BtContext::SINGLE;
   fileMode = BtContext::SINGLE;
   numPieces = 0;
   numPieces = 0;
-  name = "";
+  name = A2STR::NIL;
   announceTiers.clear();
   announceTiers.clear();
   _private = false;
   _private = false;
 }
 }
@@ -359,7 +360,7 @@ std::string DefaultBtContext::getPieceHash(size_t index) const {
   if(index < numPieces) {
   if(index < numPieces) {
     return pieceHashes[index];
     return pieceHashes[index];
   } else {
   } else {
-    return "";
+    return A2STR::NIL;
   }
   }
 }
 }
 
 

+ 2 - 1
src/DefaultBtContext.h

@@ -36,6 +36,7 @@
 #define _D_DEFAULT_BT_CONTEXT_H_
 #define _D_DEFAULT_BT_CONTEXT_H_
 
 
 #include "BtContext.h"
 #include "BtContext.h"
+#include "A2STR.h"
 #include <iosfwd>
 #include <iosfwd>
 
 
 namespace aria2 {
 namespace aria2 {
@@ -137,7 +138,7 @@ private:
   virtual std::string getActualBasePath() const;
   virtual std::string getActualBasePath() const;
 
 
   virtual const unsigned char* getPeerId() {
   virtual const unsigned char* getPeerId() {
-    if(peerId == "") {
+    if(peerId.empty()) {
       peerId = generatePeerId();
       peerId = generatePeerId();
     }
     }
     return reinterpret_cast<const unsigned char*>(peerId.c_str());
     return reinterpret_cast<const unsigned char*>(peerId.c_str());

+ 2 - 1
src/ExtendedMessagingAware.h

@@ -37,6 +37,7 @@
 
 
 #include "common.h"
 #include "common.h"
 #include "BtConstants.h"
 #include "BtConstants.h"
+#include "A2STR.h"
 #include <string>
 #include <string>
 
 
 namespace aria2 {
 namespace aria2 {
@@ -76,7 +77,7 @@ public:
 	return p.first;
 	return p.first;
       }
       }
     }
     }
-    return "";
+    return A2STR::NIL;
   }
   }
 
 
   void removeExtension(const std::string& name)
   void removeExtension(const std::string& name)

+ 4 - 3
src/FeatureConfig.cc

@@ -35,6 +35,7 @@
 #include "FeatureConfig.h"
 #include "FeatureConfig.h"
 #include "array_fun.h"
 #include "array_fun.h"
 #include "Util.h"
 #include "Util.h"
+#include "Request.h"
 #include <numeric>
 #include <numeric>
 
 
 namespace aria2 {
 namespace aria2 {
@@ -78,9 +79,9 @@ const std::string FeatureConfig::FEATURE_ASYNC_DNS("Async DNS");
 #endif // ENABLE_ASYNC_DNS
 #endif // ENABLE_ASYNC_DNS
 
 
 FeatureConfig::FeatureConfig() {
 FeatureConfig::FeatureConfig() {
-  _defaultPorts.insert(PortMap::value_type("http", 80));
-  _defaultPorts.insert(PortMap::value_type("https", 443));
-  _defaultPorts.insert(PortMap::value_type("ftp", 21));
+  _defaultPorts.insert(PortMap::value_type(Request::PROTO_HTTP, 80));
+  _defaultPorts.insert(PortMap::value_type(Request::PROTO_HTTPS, 443));
+  _defaultPorts.insert(PortMap::value_type(Request::PROTO_FTP, 21));
 
 
   FeatureMap::value_type featureArray[] = {
   FeatureMap::value_type featureArray[] = {
     FeatureMap::value_type(FEATURE_HTTPS, HTTPS_ENABLED),
     FeatureMap::value_type(FEATURE_HTTPS, HTTPS_ENABLED),

+ 3 - 2
src/File.cc

@@ -34,6 +34,7 @@
 /* copyright --> */
 /* copyright --> */
 #include "File.h"
 #include "File.h"
 #include "Util.h"
 #include "Util.h"
+#include "A2STR.h"
 #include <cstring>
 #include <cstring>
 #include <stdlib.h>
 #include <stdlib.h>
 #include <deque>
 #include <deque>
@@ -142,8 +143,8 @@ std::string File::getDirname() const
 {
 {
   std::string::size_type lastSlashIndex = name.find_last_of("/");
   std::string::size_type lastSlashIndex = name.find_last_of("/");
   if(lastSlashIndex == std::string::npos) {
   if(lastSlashIndex == std::string::npos) {
-    if(name == "") {
-      return "";
+    if(name.empty()) {
+      return A2STR::NIL;
     } else {
     } else {
       return ".";
       return ".";
     }
     }

+ 2 - 1
src/HelpItem.h

@@ -36,6 +36,7 @@
 #define _D_HELP_ITEM_H_
 #define _D_HELP_ITEM_H_
 
 
 #include "TaggedItem.h"
 #include "TaggedItem.h"
+#include "A2STR.h"
 
 
 namespace aria2 {
 namespace aria2 {
 
 
@@ -48,7 +49,7 @@ private:
   std::string _defaultValue;
   std::string _defaultValue;
 
 
 public:
 public:
-  HelpItem(const std::string& name, const std::string& usageText, const std::string& defaultValue = ""):
+  HelpItem(const std::string& name, const std::string& usageText, const std::string& defaultValue = A2STR::NIL):
     TaggedItem(name),
     TaggedItem(name),
     _usageText(usageText),
     _usageText(usageText),
     _defaultValue(defaultValue) {}
     _defaultValue(defaultValue) {}

+ 5 - 4
src/HttpHeader.cc

@@ -35,6 +35,7 @@
 #include "HttpHeader.h"
 #include "HttpHeader.h"
 #include "Range.h"
 #include "Range.h"
 #include "Util.h"
 #include "Util.h"
+#include "A2STR.h"
 #include <istream>
 #include <istream>
 
 
 namespace aria2 {
 namespace aria2 {
@@ -51,7 +52,7 @@ bool HttpHeader::defined(const std::string& name) const {
 std::string HttpHeader::getFirst(const std::string& name) const {
 std::string HttpHeader::getFirst(const std::string& name) const {
   std::multimap<std::string, std::string>::const_iterator itr = table.find(Util::toLower(name));
   std::multimap<std::string, std::string>::const_iterator itr = table.find(Util::toLower(name));
   if(itr == table.end()) {
   if(itr == table.end()) {
-    return "";
+    return A2STR::NIL;
   } else {
   } else {
     return (*itr).second;
     return (*itr).second;
   }
   }
@@ -73,7 +74,7 @@ unsigned int HttpHeader::getFirstAsUInt(const std::string& name) const {
 
 
 uint64_t HttpHeader::getFirstAsULLInt(const std::string& name) const {
 uint64_t HttpHeader::getFirstAsULLInt(const std::string& name) const {
   std::string value = getFirst(name);
   std::string value = getFirst(name);
-  if(value == "") {
+  if(value.empty()) {
     return 0;
     return 0;
   } else {
   } else {
     return Util::parseULLInt(value);
     return Util::parseULLInt(value);
@@ -83,9 +84,9 @@ uint64_t HttpHeader::getFirstAsULLInt(const std::string& name) const {
 RangeHandle HttpHeader::getRange() const
 RangeHandle HttpHeader::getRange() const
 {
 {
   std::string rangeStr = getFirst("Content-Range");
   std::string rangeStr = getFirst("Content-Range");
-  if(rangeStr == "") {
+  if(rangeStr.empty()) {
     std::string contentLengthStr = getFirst("Content-Length");
     std::string contentLengthStr = getFirst("Content-Length");
-    if(contentLengthStr == "") {
+    if(contentLengthStr.empty()) {
       return SharedHandle<Range>(new Range());
       return SharedHandle<Range>(new Range());
     } else {
     } else {
       uint64_t contentLength = Util::parseULLInt(contentLengthStr);
       uint64_t contentLength = Util::parseULLInt(contentLengthStr);

+ 2 - 1
src/HttpHeaderProcessor.cc

@@ -38,6 +38,7 @@
 #include "Util.h"
 #include "Util.h"
 #include "DlRetryEx.h"
 #include "DlRetryEx.h"
 #include "DlAbortEx.h"
 #include "DlAbortEx.h"
+#include "A2STR.h"
 
 
 namespace aria2 {
 namespace aria2 {
 
 
@@ -90,7 +91,7 @@ size_t HttpHeaderProcessor::getPutBackDataLength() const
 
 
 void HttpHeaderProcessor::clear()
 void HttpHeaderProcessor::clear()
 {
 {
-  strm.str("");
+  strm.str(A2STR::NIL);
 }
 }
 
 
 SharedHandle<HttpHeader> HttpHeaderProcessor::getHttpResponseHeader()
 SharedHandle<HttpHeader> HttpHeaderProcessor::getHttpResponseHeader()

+ 2 - 2
src/HttpRequest.cc

@@ -134,7 +134,7 @@ std::string HttpRequest::getHostText(const std::string& host, uint16_t port) con
 std::string HttpRequest::createRequest() const
 std::string HttpRequest::createRequest() const
 {
 {
   std::string requestLine = "GET ";
   std::string requestLine = "GET ";
-  if(getProtocol() == "ftp" || proxyEnabled) {
+  if(getProtocol() == Request::PROTO_FTP || proxyEnabled) {
     requestLine += getCurrentURI();
     requestLine += getCurrentURI();
   } else {
   } else {
     if(getDir() == "/") {
     if(getDir() == "/") {
@@ -193,7 +193,7 @@ std::string HttpRequest::createRequest() const
   Cookies cookies = request->cookieBox->criteriaFind(getHost(),
   Cookies cookies = request->cookieBox->criteriaFind(getHost(),
 						     getDir(),
 						     getDir(),
 						     time(0),
 						     time(0),
-						     getProtocol() == "https" ?
+						     getProtocol() == Request::PROTO_HTTPS ?
 						     true : false);
 						     true : false);
   for(Cookies::const_iterator itr = cookies.begin(); itr != cookies.end(); itr++) {
   for(Cookies::const_iterator itr = cookies.begin(); itr != cookies.end(); itr++) {
     cookiesValue += (*itr).toString()+";";
     cookiesValue += (*itr).toString()+";";

+ 1 - 1
src/HttpRequestCommand.cc

@@ -95,7 +95,7 @@ createHttpRequest(const SharedHandle<Request>& req,
 
 
 bool HttpRequestCommand::executeInternal() {
 bool HttpRequestCommand::executeInternal() {
   socket->setBlockingMode();
   socket->setBlockingMode();
-  if(req->getProtocol() == "https") {
+  if(req->getProtocol() == Request::PROTO_HTTPS) {
     socket->initiateSecureConnection();
     socket->initiateSecureConnection();
   }
   }
 
 

+ 2 - 1
src/HttpResponse.cc

@@ -46,6 +46,7 @@
 #include "message.h"
 #include "message.h"
 #include "DlAbortEx.h"
 #include "DlAbortEx.h"
 #include "StringFormat.h"
 #include "StringFormat.h"
+#include "A2STR.h"
 #include <deque>
 #include <deque>
 
 
 namespace aria2 {
 namespace aria2 {
@@ -168,7 +169,7 @@ uint64_t HttpResponse::getEntityLength() const
 std::string HttpResponse::getContentType() const
 std::string HttpResponse::getContentType() const
 {
 {
   if(httpHeader.isNull()) {
   if(httpHeader.isNull()) {
-    return "";
+    return A2STR::NIL;
   } else {
   } else {
     return httpHeader->getFirst("Content-Type");
     return httpHeader->getFirst("Content-Type");
   }
   }

+ 3 - 3
src/InitiateConnectionCommandFactory.cc

@@ -47,10 +47,10 @@ namespace aria2 {
 
 
 Command*
 Command*
 InitiateConnectionCommandFactory::createInitiateConnectionCommand(int32_t cuid, const RequestHandle& req, RequestGroup* requestGroup, DownloadEngine* e) {
 InitiateConnectionCommandFactory::createInitiateConnectionCommand(int32_t cuid, const RequestHandle& req, RequestGroup* requestGroup, DownloadEngine* e) {
-  if(req->getProtocol() == "http"
+  if(req->getProtocol() == Request::PROTO_HTTP
 #ifdef ENABLE_SSL
 #ifdef ENABLE_SSL
      // for SSL
      // for SSL
-     || req->getProtocol() == "https"
+     || req->getProtocol() == Request::PROTO_HTTPS
 #endif // ENABLE_SSL
 #endif // ENABLE_SSL
      ) {
      ) {
     
     
@@ -62,7 +62,7 @@ InitiateConnectionCommandFactory::createInitiateConnectionCommand(int32_t cuid,
     }
     }
 
 
     return new HttpInitiateConnectionCommand(cuid, req, requestGroup, e);
     return new HttpInitiateConnectionCommand(cuid, req, requestGroup, e);
-  } else if(req->getProtocol() == "ftp") {
+  } else if(req->getProtocol() == Request::PROTO_FTP) {
     return new FtpInitiateConnectionCommand(cuid, req, requestGroup, e);
     return new FtpInitiateConnectionCommand(cuid, req, requestGroup, e);
   } else {
   } else {
     // these protocols are not supported yet
     // these protocols are not supported yet

+ 2 - 1
src/Makefile.am

@@ -186,7 +186,8 @@ SRCS =  Socket.h\
 	StringFormat.cc StringFormat.h\
 	StringFormat.cc StringFormat.h\
 	HttpSkipResponseCommand.cc HttpSkipResponseCommand.h\
 	HttpSkipResponseCommand.cc HttpSkipResponseCommand.h\
 	InitiateConnectionCommand.cc InitiateConnectionCommand.h\
 	InitiateConnectionCommand.cc InitiateConnectionCommand.h\
-	FtpFinishDownloadCommand.cc FtpFinishDownloadCommand.h
+	FtpFinishDownloadCommand.cc FtpFinishDownloadCommand.h\
+	A2STR.cc A2STR.h
 
 
 if ENABLE_ASYNC_DNS
 if ENABLE_ASYNC_DNS
 SRCS += AsyncNameResolver.cc AsyncNameResolver.h
 SRCS += AsyncNameResolver.cc AsyncNameResolver.h

+ 13 - 12
src/Makefile.in

@@ -409,7 +409,7 @@ am__libaria2c_a_SOURCES_DIST = Socket.h SocketCore.cc SocketCore.h \
 	HttpSkipResponseCommand.cc HttpSkipResponseCommand.h \
 	HttpSkipResponseCommand.cc HttpSkipResponseCommand.h \
 	InitiateConnectionCommand.cc InitiateConnectionCommand.h \
 	InitiateConnectionCommand.cc InitiateConnectionCommand.h \
 	FtpFinishDownloadCommand.cc FtpFinishDownloadCommand.h \
 	FtpFinishDownloadCommand.cc FtpFinishDownloadCommand.h \
-	AsyncNameResolver.cc AsyncNameResolver.h \
+	A2STR.cc A2STR.h AsyncNameResolver.cc AsyncNameResolver.h \
 	IteratableChunkChecksumValidator.cc \
 	IteratableChunkChecksumValidator.cc \
 	IteratableChunkChecksumValidator.h \
 	IteratableChunkChecksumValidator.h \
 	IteratableChecksumValidator.cc IteratableChecksumValidator.h \
 	IteratableChecksumValidator.cc IteratableChecksumValidator.h \
@@ -789,12 +789,12 @@ am__objects_15 = SocketCore.$(OBJEXT) Command.$(OBJEXT) \
 	TimedHaltCommand.$(OBJEXT) ProtocolDetector.$(OBJEXT) \
 	TimedHaltCommand.$(OBJEXT) ProtocolDetector.$(OBJEXT) \
 	StringFormat.$(OBJEXT) HttpSkipResponseCommand.$(OBJEXT) \
 	StringFormat.$(OBJEXT) HttpSkipResponseCommand.$(OBJEXT) \
 	InitiateConnectionCommand.$(OBJEXT) \
 	InitiateConnectionCommand.$(OBJEXT) \
-	FtpFinishDownloadCommand.$(OBJEXT) $(am__objects_1) \
-	$(am__objects_2) $(am__objects_3) $(am__objects_4) \
-	$(am__objects_5) $(am__objects_6) $(am__objects_7) \
-	$(am__objects_8) $(am__objects_9) $(am__objects_10) \
-	$(am__objects_11) $(am__objects_12) $(am__objects_13) \
-	$(am__objects_14)
+	FtpFinishDownloadCommand.$(OBJEXT) A2STR.$(OBJEXT) \
+	$(am__objects_1) $(am__objects_2) $(am__objects_3) \
+	$(am__objects_4) $(am__objects_5) $(am__objects_6) \
+	$(am__objects_7) $(am__objects_8) $(am__objects_9) \
+	$(am__objects_10) $(am__objects_11) $(am__objects_12) \
+	$(am__objects_13) $(am__objects_14)
 am_libaria2c_a_OBJECTS = $(am__objects_15)
 am_libaria2c_a_OBJECTS = $(am__objects_15)
 libaria2c_a_OBJECTS = $(am_libaria2c_a_OBJECTS)
 libaria2c_a_OBJECTS = $(am_libaria2c_a_OBJECTS)
 am__installdirs = "$(DESTDIR)$(bindir)"
 am__installdirs = "$(DESTDIR)$(bindir)"
@@ -1133,11 +1133,11 @@ SRCS = Socket.h SocketCore.cc SocketCore.h BinaryStream.h Command.cc \
 	HttpSkipResponseCommand.cc HttpSkipResponseCommand.h \
 	HttpSkipResponseCommand.cc HttpSkipResponseCommand.h \
 	InitiateConnectionCommand.cc InitiateConnectionCommand.h \
 	InitiateConnectionCommand.cc InitiateConnectionCommand.h \
 	FtpFinishDownloadCommand.cc FtpFinishDownloadCommand.h \
 	FtpFinishDownloadCommand.cc FtpFinishDownloadCommand.h \
-	$(am__append_1) $(am__append_2) $(am__append_3) \
-	$(am__append_4) $(am__append_5) $(am__append_6) \
-	$(am__append_7) $(am__append_8) $(am__append_9) \
-	$(am__append_10) $(am__append_11) $(am__append_12) \
-	$(am__append_13) $(am__append_14)
+	A2STR.cc A2STR.h $(am__append_1) $(am__append_2) \
+	$(am__append_3) $(am__append_4) $(am__append_5) \
+	$(am__append_6) $(am__append_7) $(am__append_8) \
+	$(am__append_9) $(am__append_10) $(am__append_11) \
+	$(am__append_12) $(am__append_13) $(am__append_14)
 noinst_LIBRARIES = libaria2c.a
 noinst_LIBRARIES = libaria2c.a
 libaria2c_a_SOURCES = $(SRCS)
 libaria2c_a_SOURCES = $(SRCS)
 aria2c_LDADD = libaria2c.a @LIBINTL@ @ALLOCA@ @LIBGNUTLS_LIBS@\
 aria2c_LDADD = libaria2c.a @LIBINTL@ @ALLOCA@ @LIBGNUTLS_LIBS@\
@@ -1225,6 +1225,7 @@ distclean-compile:
 	-rm -f *.tab.c
 	-rm -f *.tab.c
 
 
 @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/alloca.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/alloca.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/A2STR.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/AbstractAuthResolver.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/AbstractAuthResolver.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/AbstractBtMessage.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/AbstractBtMessage.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/AbstractCommand.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/AbstractCommand.Po@am__quote@

+ 3 - 2
src/Metalink2RequestGroup.cc

@@ -48,6 +48,7 @@
 #include "MetalinkEntry.h"
 #include "MetalinkEntry.h"
 #include "MetalinkResource.h"
 #include "MetalinkResource.h"
 #include "FileEntry.h"
 #include "FileEntry.h"
+#include "A2STR.h"
 #ifdef ENABLE_BITTORRENT
 #ifdef ENABLE_BITTORRENT
 # include "BtDependency.h"
 # include "BtDependency.h"
 #endif // ENABLE_BITTORRENT
 #endif // ENABLE_BITTORRENT
@@ -167,7 +168,7 @@ Metalink2RequestGroup::createRequestGroup
       SharedHandle<SingleFileDownloadContext> dctx
       SharedHandle<SingleFileDownloadContext> dctx
 	(new SingleFileDownloadContext(_option->getAsInt(PREF_SEGMENT_SIZE),
 	(new SingleFileDownloadContext(_option->getAsInt(PREF_SEGMENT_SIZE),
 				       0,
 				       0,
-				       ""));
+				       A2STR::NIL));
       //dctx->setDir(_option->get(PREF_DIR));
       //dctx->setDir(_option->get(PREF_DIR));
       torrentRg->setDownloadContext(dctx);
       torrentRg->setDownloadContext(dctx);
       torrentRg->clearPreDowloadHandler();
       torrentRg->clearPreDowloadHandler();
@@ -205,7 +206,7 @@ Metalink2RequestGroup::createRequestGroup
     SharedHandle<SingleFileDownloadContext> dctx
     SharedHandle<SingleFileDownloadContext> dctx
       (new SingleFileDownloadContext(pieceLength,
       (new SingleFileDownloadContext(pieceLength,
 				     entry->getLength(),
 				     entry->getLength(),
-				     "",
+				     A2STR::NIL,
 				     entry->file->getPath()));
 				     entry->file->getPath()));
     dctx->setDir(_option->get(PREF_DIR));
     dctx->setDir(_option->get(PREF_DIR));
 #ifdef ENABLE_MESSAGE_DIGEST
 #ifdef ENABLE_MESSAGE_DIGEST

+ 6 - 5
src/MetalinkParserController.cc

@@ -38,6 +38,7 @@
 #include "MetalinkResource.h"
 #include "MetalinkResource.h"
 #include "FileEntry.h"
 #include "FileEntry.h"
 #include "a2functional.h"
 #include "a2functional.h"
+#include "A2STR.h"
 #ifdef ENABLE_MESSAGE_DIGEST
 #ifdef ENABLE_MESSAGE_DIGEST
 # include "Checksum.h"
 # include "Checksum.h"
 # include "ChunkChecksum.h"
 # include "ChunkChecksum.h"
@@ -86,7 +87,7 @@ void MetalinkParserController::setFileLengthOfEntry(uint64_t length)
     return;
     return;
   }
   }
   if(_tEntry->file.isNull()) {
   if(_tEntry->file.isNull()) {
-    _tEntry->file.reset(new FileEntry("", length, 0));
+    _tEntry->file.reset(new FileEntry(A2STR::NIL, length, 0));
   } else {
   } else {
     _tEntry->file->setLength(length);
     _tEntry->file->setLength(length);
   }
   }
@@ -165,13 +166,13 @@ void MetalinkParserController::setTypeOfResource(const std::string& type)
   if(_tResource.isNull()) {
   if(_tResource.isNull()) {
     return;
     return;
   }
   }
-  if(type == "ftp") {
+  if(type == MetalinkResource::FTP) {
     _tResource->type = MetalinkResource::TYPE_FTP;
     _tResource->type = MetalinkResource::TYPE_FTP;
-  } else if(type == "http") {
+  } else if(type == MetalinkResource::HTTP) {
     _tResource->type = MetalinkResource::TYPE_HTTP;
     _tResource->type = MetalinkResource::TYPE_HTTP;
-  } else if(type == "https") {
+  } else if(type == MetalinkResource::HTTPS) {
     _tResource->type = MetalinkResource::TYPE_HTTPS;
     _tResource->type = MetalinkResource::TYPE_HTTPS;
-  } else if(type == "bittorrent") {
+  } else if(type == MetalinkResource::BITTORRENT) {
     _tResource->type = MetalinkResource::TYPE_BITTORRENT;
     _tResource->type = MetalinkResource::TYPE_BITTORRENT;
   } else {
   } else {
     _tResource->type = MetalinkResource::TYPE_NOT_SUPPORTED;
     _tResource->type = MetalinkResource::TYPE_NOT_SUPPORTED;

+ 8 - 0
src/MetalinkResource.cc

@@ -40,6 +40,14 @@ std::string MetalinkResource::type2String[] = {
   "ftp", "http", "https", "bittorrent", "not_supported"
   "ftp", "http", "https", "bittorrent", "not_supported"
 };
 };
 
 
+const std::string MetalinkResource::HTTP("http");
+
+const std::string MetalinkResource::HTTPS("https");
+
+const std::string MetalinkResource::FTP("ftp");
+
+const std::string MetalinkResource::BITTORRENT("bittorrent");
+
 MetalinkResource::MetalinkResource():
 MetalinkResource::MetalinkResource():
   maxConnections(-1)
   maxConnections(-1)
 {}
 {}

+ 9 - 0
src/MetalinkResource.h

@@ -51,6 +51,15 @@ public:
   };
   };
 
 
   static std::string type2String[];
   static std::string type2String[];
+
+  static const std::string HTTP;
+
+  static const std::string HTTPS;
+
+  static const std::string FTP;
+
+  static const std::string BITTORRENT;
+
 public:
 public:
   std::string url;
   std::string url;
   TYPE type;
   TYPE type;

+ 1 - 1
src/Netrc.cc

@@ -56,7 +56,7 @@ void Netrc::skipMacdef(std::ifstream& f) const
   std::string line;
   std::string line;
   getline(f, line);
   getline(f, line);
   while(getline(f, line)) {
   while(getline(f, line)) {
-    if(line == "\r" || line == "") {
+    if(line == "\r" || line.empty()) {
       break;
       break;
     }
     }
   }
   }

+ 2 - 1
src/Netrc.h

@@ -37,6 +37,7 @@
 
 
 #include "common.h"
 #include "common.h"
 #include "SharedHandle.h"
 #include "SharedHandle.h"
+#include "A2STR.h"
 #include <string>
 #include <string>
 #include <deque>
 #include <deque>
 #include <iosfwd>
 #include <iosfwd>
@@ -116,7 +117,7 @@ public:
   DefaultAuthenticator(const std::string& login,
   DefaultAuthenticator(const std::string& login,
 		       const std::string& password,
 		       const std::string& password,
 		       const std::string& account)
 		       const std::string& account)
-    :Authenticator("", login, password, account) {}
+    :Authenticator(A2STR::NIL, login, password, account) {}
 
 
   virtual ~DefaultAuthenticator() {}
   virtual ~DefaultAuthenticator() {}
 
 

+ 2 - 1
src/NullProgressInfoFile.h

@@ -36,6 +36,7 @@
 #define _D_NULL_PROGRESS_INFO_FILE_H_
 #define _D_NULL_PROGRESS_INFO_FILE_H_
 
 
 #include "BtProgressInfoFile.h"
 #include "BtProgressInfoFile.h"
+#include "A2STR.h"
 
 
 namespace aria2 {
 namespace aria2 {
 
 
@@ -45,7 +46,7 @@ public:
 
 
   virtual std::string getFilename()
   virtual std::string getFilename()
   {
   {
-    return "";
+    return A2STR::NIL;
   }
   }
 
 
   virtual bool exists() { return false; }
   virtual bool exists() { return false; }

+ 5 - 4
src/Option.cc

@@ -34,6 +34,7 @@
 /* copyright --> */
 /* copyright --> */
 #include "Option.h"
 #include "Option.h"
 #include "prefs.h"
 #include "prefs.h"
+#include "A2STR.h"
 #include <cstdlib>
 #include <cstdlib>
 
 
 namespace aria2 {
 namespace aria2 {
@@ -53,7 +54,7 @@ bool Option::defined(const std::string& name) const {
 std::string Option::get(const std::string& name) const {
 std::string Option::get(const std::string& name) const {
   std::map<std::string, std::string>::const_iterator itr = table.find(name);
   std::map<std::string, std::string>::const_iterator itr = table.find(name);
   if(itr == table.end()) {
   if(itr == table.end()) {
-    return "";
+    return A2STR::NIL;
   } else {
   } else {
     return (*itr).second;
     return (*itr).second;
   }
   }
@@ -61,7 +62,7 @@ std::string Option::get(const std::string& name) const {
 
 
 int32_t Option::getAsInt(const std::string& name) const {
 int32_t Option::getAsInt(const std::string& name) const {
   std::string value = get(name);
   std::string value = get(name);
-  if(value == "") {
+  if(value.empty()) {
     return 0;
     return 0;
   } else {
   } else {
     return strtol(value.c_str(), NULL, 10);
     return strtol(value.c_str(), NULL, 10);
@@ -70,7 +71,7 @@ int32_t Option::getAsInt(const std::string& name) const {
 
 
 int64_t Option::getAsLLInt(const std::string& name) const {
 int64_t Option::getAsLLInt(const std::string& name) const {
   std::string value = get(name);
   std::string value = get(name);
-  if(value == "") {
+  if(value.empty()) {
     return 0;
     return 0;
   } else {
   } else {
     return strtoll(value.c_str(), NULL, 10);
     return strtoll(value.c_str(), NULL, 10);
@@ -88,7 +89,7 @@ bool Option::getAsBool(const std::string& name) const {
 
 
 double Option::getAsDouble(const std::string& name) const {
 double Option::getAsDouble(const std::string& name) const {
   std::string value = get(name);
   std::string value = get(name);
-  if(value == "") {
+  if(value.empty()) {
     return 0.0;
     return 0.0;
   } else {
   } else {
     return strtod(value.c_str(), 0);
     return strtod(value.c_str(), 0);

+ 1 - 1
src/ParameterizedStringParser.cc

@@ -121,7 +121,7 @@ PStringDatumHandle ParameterizedStringParser::createLoop(const std::string& src,
     loopStr.erase(colonIndex);
     loopStr.erase(colonIndex);
   }
   }
   std::pair<std::string, std::string> range = Util::split(loopStr, "-");
   std::pair<std::string, std::string> range = Util::split(loopStr, "-");
-  if(range.first == "" || range.second == "") {
+  if(range.first.empty() || range.second.empty()) {
     throw FatalException("Loop range missing.");
     throw FatalException("Loop range missing.");
   }
   }
   NumberDecoratorHandle nd;
   NumberDecoratorHandle nd;

+ 2 - 1
src/PeerSessionResource.cc

@@ -35,6 +35,7 @@
 #include "PeerSessionResource.h"
 #include "PeerSessionResource.h"
 #include "BitfieldManFactory.h"
 #include "BitfieldManFactory.h"
 #include "BitfieldMan.h"
 #include "BitfieldMan.h"
+#include "A2STR.h"
 #include <algorithm>
 #include <algorithm>
 
 
 namespace aria2 {
 namespace aria2 {
@@ -267,7 +268,7 @@ std::string PeerSessionResource::getExtensionName(uint8_t id) const
       return p.first;
       return p.first;
     }
     }
   }
   }
-  return "";
+  return A2STR::NIL;
 }
 }
 
 
 void PeerSessionResource::addExtension(const std::string& name, uint8_t id)
 void PeerSessionResource::addExtension(const std::string& name, uint8_t id)

+ 16 - 9
src/Request.cc

@@ -39,6 +39,7 @@
 #include "CookieBox.h"
 #include "CookieBox.h"
 #include "RecoverableException.h"
 #include "RecoverableException.h"
 #include "StringFormat.h"
 #include "StringFormat.h"
+#include "A2STR.h"
 #include <utility>
 #include <utility>
 
 
 namespace aria2 {
 namespace aria2 {
@@ -47,6 +48,12 @@ const std::string Request::METHOD_GET = "GET";
 
 
 const std::string Request::METHOD_HEAD = "HEAD";
 const std::string Request::METHOD_HEAD = "HEAD";
 
 
+const std::string Request::PROTO_HTTP("http");
+
+const std::string Request::PROTO_HTTPS("https");
+
+const std::string Request::PROTO_FTP("ftp");
+
 Request::Request():
 Request::Request():
   port(0), tryCount(0),
   port(0), tryCount(0),
   _supportsPersistentConnection(true),
   _supportsPersistentConnection(true),
@@ -69,7 +76,7 @@ bool Request::resetUrl() {
 }
 }
 
 
 bool Request::redirectUrl(const std::string& url) {
 bool Request::redirectUrl(const std::string& url) {
-  previousUrl = "";
+  previousUrl = A2STR::NIL;
   _supportsPersistentConnection = true;
   _supportsPersistentConnection = true;
   return parseUrl(url);
   return parseUrl(url);
 }
 }
@@ -84,13 +91,13 @@ bool Request::parseUrl(const std::string& url) {
   }
   }
   currentUrl = tempUrl;
   currentUrl = tempUrl;
   std::string query;
   std::string query;
-  host = "";
+  host = A2STR::NIL;
   port = 0;
   port = 0;
-  dir = "";
-  file = "";
-  _query = "";
-  _username = "";
-  _password = "";
+  dir = A2STR::NIL;
+  file = A2STR::NIL;
+  _query = A2STR::NIL;
+  _username = A2STR::NIL;
+  _password = A2STR::NIL;
   // find query part
   // find query part
   std::string queryTemp;
   std::string queryTemp;
   std::string::size_type startQueryIndex = tempUrl.find("?");
   std::string::size_type startQueryIndex = tempUrl.find("?");
@@ -126,7 +133,7 @@ bool Request::parseUrl(const std::string& url) {
   std::pair<std::string, std::string> hostAndPort;
   std::pair<std::string, std::string> hostAndPort;
   Util::split(hostAndPort, hostPart, ':');
   Util::split(hostAndPort, hostPart, ':');
   host = hostAndPort.first;
   host = hostAndPort.first;
-  if(hostAndPort.second != "") {
+  if(hostAndPort.second != A2STR::NIL) {
     try {
     try {
       port = Util::parseInt(hostAndPort.second);
       port = Util::parseInt(hostAndPort.second);
     } catch(RecoverableException& e) {
     } catch(RecoverableException& e) {
@@ -168,7 +175,7 @@ bool Request::isHexNumber(const char c) const
 std::string Request::urlencode(const std::string& src) const
 std::string Request::urlencode(const std::string& src) const
 {
 {
   if(src.empty()) {
   if(src.empty()) {
-    return "";
+    return A2STR::NIL;
   }
   }
   size_t lastIndex = src.size()-1;
   size_t lastIndex = src.size()-1;
   std::string result = src+"  ";
   std::string result = src+"  ";

+ 6 - 0
src/Request.h

@@ -174,6 +174,12 @@ public:
   static const std::string METHOD_GET;
   static const std::string METHOD_GET;
   static const std::string METHOD_HEAD;
   static const std::string METHOD_HEAD;
 
 
+  static const std::string PROTO_HTTP;
+
+  static const std::string PROTO_HTTPS;
+
+  static const std::string PROTO_FTP;
+
 };
 };
 
 
 typedef SharedHandle<Request> RequestHandle;
 typedef SharedHandle<Request> RequestHandle;

+ 3 - 2
src/RequestGroup.cc

@@ -71,6 +71,7 @@
 #include "Request.h"
 #include "Request.h"
 #include "FileAllocationIterator.h"
 #include "FileAllocationIterator.h"
 #include "StringFormat.h"
 #include "StringFormat.h"
+#include "A2STR.h"
 #ifdef ENABLE_MESSAGE_DIGEST
 #ifdef ENABLE_MESSAGE_DIGEST
 # include "CheckIntegrityCommand.h"
 # include "CheckIntegrityCommand.h"
 #endif // ENABLE_MESSAGE_DIGEST
 #endif // ENABLE_MESSAGE_DIGEST
@@ -517,7 +518,7 @@ std::string RequestGroup::getFilePath() const
 {
 {
   assert(!_downloadContext.isNull());
   assert(!_downloadContext.isNull());
   if(_downloadContext.isNull()) {
   if(_downloadContext.isNull()) {
-    return "";
+    return A2STR::NIL;
   } else {
   } else {
     return _downloadContext->getActualBasePath();
     return _downloadContext->getActualBasePath();
   }
   }
@@ -858,7 +859,7 @@ DownloadResultHandle RequestGroup::createDownloadResult() const
     SharedHandle<DownloadResult>(new DownloadResult(_gid,
     SharedHandle<DownloadResult>(new DownloadResult(_gid,
 						    getFilePath(),
 						    getFilePath(),
 						    getTotalLength(),
 						    getTotalLength(),
-						    uris.empty() ? "":uris.front(),
+						    uris.empty() ? A2STR::NIL:uris.front(),
 						    uris.size(),
 						    uris.size(),
 						    downloadFinished()?
 						    downloadFinished()?
 						    DownloadResult::FINISHED :
 						    DownloadResult::FINISHED :

+ 2 - 2
src/SingleFileDownloadContext.cc

@@ -51,9 +51,9 @@ SingleFileDownloadContext::SingleFileDownloadContext(size_t pieceLength,
 
 
 void SingleFileDownloadContext::updateFileEntry()
 void SingleFileDownloadContext::updateFileEntry()
 {
 {
-  if(_ufilename != "") {
+  if(!_ufilename.empty()) {
     _fileEntry->setPath(_ufilename);
     _fileEntry->setPath(_ufilename);
-  } else if(_filename != "") {
+  } else if(!_filename.empty()) {
     _fileEntry->setPath(_filename);
     _fileEntry->setPath(_filename);
   } else {
   } else {
     _fileEntry->setPath("index.html");
     _fileEntry->setPath("index.html");

+ 3 - 2
src/SingleFileDownloadContext.h

@@ -36,6 +36,7 @@
 #define _D_SINGLE_FILE_DOWNLOAD_CONTEXT_H_
 #define _D_SINGLE_FILE_DOWNLOAD_CONTEXT_H_
 
 
 #include "DownloadContext.h"
 #include "DownloadContext.h"
+#include "A2STR.h"
 #include <string>
 #include <string>
 #include <deque>
 #include <deque>
 
 
@@ -70,7 +71,7 @@ public:
   SingleFileDownloadContext(size_t pieceLength,
   SingleFileDownloadContext(size_t pieceLength,
 			    uint64_t totalLength,
 			    uint64_t totalLength,
 			    const std::string& filename,
 			    const std::string& filename,
-			    const std::string& ufilename = "");
+			    const std::string& ufilename = A2STR::NIL);
 
 
   virtual ~SingleFileDownloadContext() {}
   virtual ~SingleFileDownloadContext() {}
 
 
@@ -79,7 +80,7 @@ public:
     if(index < _pieceHashes.size()) {
     if(index < _pieceHashes.size()) {
       return _pieceHashes[index];
       return _pieceHashes[index];
     } else {
     } else {
-      return "";
+      return A2STR::NIL;
     }
     }
   }
   }
   
   

+ 2 - 1
src/TaggedItem.cc

@@ -34,6 +34,7 @@
 /* copyright --> */
 /* copyright --> */
 #include "TaggedItem.h"
 #include "TaggedItem.h"
 #include "a2functional.h"
 #include "a2functional.h"
+#include "A2STR.h"
 #include <algorithm>
 #include <algorithm>
 
 
 namespace aria2 {
 namespace aria2 {
@@ -48,7 +49,7 @@ std::string TaggedItem::toTagString() const
     }
     }
     return s;
     return s;
   } else {
   } else {
-    return "";
+    return A2STR::NIL;
   }
   }
 }
 }
 
 

+ 3 - 2
src/TrackerWatcherCommand.cc

@@ -53,6 +53,7 @@
 #include "Option.h"
 #include "Option.h"
 #include "DlAbortEx.h"
 #include "DlAbortEx.h"
 #include "Logger.h"
 #include "Logger.h"
+#include "A2STR.h"
 #include <sstream>
 #include <sstream>
 
 
 namespace aria2 {
 namespace aria2 {
@@ -176,9 +177,9 @@ TrackerWatcherCommand::createRequestGroup(const std::string& uri)
   SingleFileDownloadContextHandle dctx
   SingleFileDownloadContextHandle dctx
     (new SingleFileDownloadContext(e->option->getAsInt(PREF_SEGMENT_SIZE),
     (new SingleFileDownloadContext(e->option->getAsInt(PREF_SEGMENT_SIZE),
 				   0,
 				   0,
-				   "",
+				   A2STR::NIL,
 				   "[tracker.announce]"));
 				   "[tracker.announce]"));
-  dctx->setDir("");
+  dctx->setDir(A2STR::NIL);
   rg->setDownloadContext(dctx);
   rg->setDownloadContext(dctx);
   SharedHandle<DiskWriterFactory> dwf(new ByteArrayDiskWriterFactory());
   SharedHandle<DiskWriterFactory> dwf(new ByteArrayDiskWriterFactory());
   rg->setDiskWriterFactory(dwf);
   rg->setDiskWriterFactory(dwf);

+ 1 - 1
src/UriListParser.cc

@@ -47,7 +47,7 @@ std::deque<std::string> UriListParser::parseNext(std::istream& in)
   std::deque<std::string> uris;
   std::deque<std::string> uris;
   std::string line;
   std::string line;
   while(getline(in, line)) {
   while(getline(in, line)) {
-    if(Util::trim(line) != "") {
+    if(!Util::trim(line).empty()) {
       Util::slice(uris, line, '\t', true);
       Util::slice(uris, line, '\t', true);
       return uris;
       return uris;
     }
     }

+ 14 - 13
src/Util.cc

@@ -43,6 +43,7 @@
 #include "FatalException.h"
 #include "FatalException.h"
 #include "FileEntry.h"
 #include "FileEntry.h"
 #include "StringFormat.h"
 #include "StringFormat.h"
+#include "A2STR.h"
 #include <signal.h>
 #include <signal.h>
 #include <cerrno>
 #include <cerrno>
 #include <cassert>
 #include <cassert>
@@ -64,7 +65,7 @@ std::string Util::trim(const std::string& src, const std::string& trimCharset)
   std::string::size_type sp = src.find_first_not_of(trimCharset);
   std::string::size_type sp = src.find_first_not_of(trimCharset);
   std::string::size_type ep = src.find_last_not_of(trimCharset);
   std::string::size_type ep = src.find_last_not_of(trimCharset);
   if(sp == std::string::npos || ep == std::string::npos) {
   if(sp == std::string::npos || ep == std::string::npos) {
-    return "";
+    return A2STR::NIL;
   } else {
   } else {
     return src.substr(sp, ep-sp+1);
     return src.substr(sp, ep-sp+1);
   }
   }
@@ -72,12 +73,12 @@ std::string Util::trim(const std::string& src, const std::string& trimCharset)
 
 
 void Util::split(std::pair<std::string, std::string>& hp, const std::string& src, char delim)
 void Util::split(std::pair<std::string, std::string>& hp, const std::string& src, char delim)
 {
 {
-  hp.first = "";
-  hp.second = "";
+  hp.first = A2STR::NIL;
+  hp.second = A2STR::NIL;
   std::string::size_type p = src.find(delim);
   std::string::size_type p = src.find(delim);
   if(p == std::string::npos) {
   if(p == std::string::npos) {
     hp.first = src;
     hp.first = src;
-    hp.second = "";
+    hp.second = A2STR::NIL;
   } else {
   } else {
     hp.first = trim(src.substr(0, p));
     hp.first = trim(src.substr(0, p));
     hp.second = trim(src.substr(p+1));
     hp.second = trim(src.substr(p+1));
@@ -87,12 +88,12 @@ void Util::split(std::pair<std::string, std::string>& hp, const std::string& src
 std::pair<std::string, std::string> Util::split(const std::string& src, const std::string& delims)
 std::pair<std::string, std::string> Util::split(const std::string& src, const std::string& delims)
 {
 {
   std::pair<std::string, std::string> hp;
   std::pair<std::string, std::string> hp;
-  hp.first = "";
-  hp.second = "";
+  hp.first = A2STR::NIL;
+  hp.second = A2STR::NIL;
   std::string::size_type p = src.find_first_of(delims);
   std::string::size_type p = src.find_first_of(delims);
   if(p == std::string::npos) {
   if(p == std::string::npos) {
     hp.first = src;
     hp.first = src;
-    hp.second = "";
+    hp.second = A2STR::NIL;
   } else {
   } else {
     hp.first = trim(src.substr(0, p));
     hp.first = trim(src.substr(0, p));
     hp.second = trim(src.substr(p+1));
     hp.second = trim(src.substr(p+1));
@@ -145,7 +146,7 @@ bool Util::startsWith(const std::string& target, const std::string& part) {
   if(target.size() < part.size()) {
   if(target.size() < part.size()) {
     return false;
     return false;
   }
   }
-  if(part == "") {
+  if(part.empty()) {
     return true;
     return true;
   }
   }
   if(target.find(part) == 0) {
   if(target.find(part) == 0) {
@@ -159,7 +160,7 @@ bool Util::endsWith(const std::string& target, const std::string& part) {
   if(target.size() < part.size()) {
   if(target.size() < part.size()) {
     return false;
     return false;
   }
   }
-  if(part == "") {
+  if(part.empty()) {
     return true;
     return true;
   }
   }
   if(target.rfind(part) == target.size()-part.size()) {
   if(target.rfind(part) == target.size()-part.size()) {
@@ -170,7 +171,7 @@ bool Util::endsWith(const std::string& target, const std::string& part) {
 }
 }
 
 
 std::string Util::replace(const std::string& target, const std::string& oldstr, const std::string& newstr) {
 std::string Util::replace(const std::string& target, const std::string& oldstr, const std::string& newstr) {
-  if(target == "" || oldstr == "" ) {
+  if(target.empty() || oldstr.empty()) {
     return target;
     return target;
   }
   }
   std::string result;
   std::string result;
@@ -515,12 +516,12 @@ std::string Util::getContentDispositionFilename(const std::string& header) {
   std::string keyName = "filename=";
   std::string keyName = "filename=";
   std::string::size_type attributesp = header.find(keyName);
   std::string::size_type attributesp = header.find(keyName);
   if(attributesp == std::string::npos) {
   if(attributesp == std::string::npos) {
-    return "";
+    return A2STR::NIL;
   }
   }
   std::string::size_type filenamesp = attributesp+strlen(keyName.c_str());
   std::string::size_type filenamesp = attributesp+strlen(keyName.c_str());
   std::string::size_type filenameep;
   std::string::size_type filenameep;
   if(filenamesp == header.size()) {
   if(filenamesp == header.size()) {
-    return "";
+    return A2STR::NIL;
   }
   }
   
   
   if(header[filenamesp] == '\'' || header[filenamesp] == '"') {
   if(header[filenamesp] == '\'' || header[filenamesp] == '"') {
@@ -622,7 +623,7 @@ std::string Util::getHomeDir()
   if(p) {
   if(p) {
     return p;
     return p;
   } else {
   } else {
-    return "";
+    return A2STR::NIL;
   }
   }
 }
 }
 
 

+ 2 - 1
src/a2functional.h

@@ -37,6 +37,7 @@
 
 
 #include <functional>
 #include <functional>
 #include "SharedHandle.h"
 #include "SharedHandle.h"
+#include "A2STR.h"
 #include <string>
 #include <string>
 
 
 namespace aria2 {
 namespace aria2 {
@@ -143,7 +144,7 @@ class Concat {
 private:
 private:
   std::string _delim;
   std::string _delim;
 public:
 public:
-  Concat(const std::string& delim = ""):_delim(delim) {}
+  Concat(const std::string& delim = A2STR::NIL):_delim(delim) {}
 
 
   std::string operator()(const std::string& s1, const std::string& s2) const
   std::string operator()(const std::string& s1, const std::string& s2) const
   {
   {

+ 3 - 2
src/main.cc

@@ -65,6 +65,7 @@
 #include "ConsoleStatCalc.h"
 #include "ConsoleStatCalc.h"
 #include "NullStatCalc.h"
 #include "NullStatCalc.h"
 #include "StringFormat.h"
 #include "StringFormat.h"
+#include "A2STR.h"
 #ifdef ENABLE_METALINK
 #ifdef ENABLE_METALINK
 # include "MetalinkHelper.h"
 # include "MetalinkHelper.h"
 # include "Metalink2RequestGroup.h"
 # include "Metalink2RequestGroup.h"
@@ -112,13 +113,13 @@ std::deque<std::string> unfoldURI(const std::deque<std::string>& args)
 }
 }
 
 
 RequestGroupHandle createRequestGroup(const Option* op, const std::deque<std::string>& uris,
 RequestGroupHandle createRequestGroup(const Option* op, const std::deque<std::string>& uris,
-				      const std::string& ufilename = "")
+				      const std::string& ufilename = A2STR::NIL)
 {
 {
   RequestGroupHandle rg(new RequestGroup(op, uris));
   RequestGroupHandle rg(new RequestGroup(op, uris));
   SingleFileDownloadContextHandle dctx
   SingleFileDownloadContextHandle dctx
     (new SingleFileDownloadContext(op->getAsInt(PREF_SEGMENT_SIZE),
     (new SingleFileDownloadContext(op->getAsInt(PREF_SEGMENT_SIZE),
 				  0,
 				  0,
-				  "",
+				  A2STR::NIL,
 				  ufilename));
 				  ufilename));
   dctx->setDir(op->get(PREF_DIR));
   dctx->setDir(op->get(PREF_DIR));
   rg->setDownloadContext(dctx);
   rg->setDownloadContext(dctx);

+ 3 - 2
src/option_processing.cc

@@ -46,6 +46,7 @@
 #include "File.h"
 #include "File.h"
 #include "StringFormat.h"
 #include "StringFormat.h"
 #include <cstdlib>
 #include <cstdlib>
+#include <cstring>
 #include <fstream>
 #include <fstream>
 #include <sstream>
 #include <sstream>
 #include <iostream>
 #include <iostream>
@@ -62,7 +63,7 @@ extern void showUsage(const std::string& category, const Option* option);
 static std::string toBoolArg(const char* optarg)
 static std::string toBoolArg(const char* optarg)
 {
 {
   std::string arg;
   std::string arg;
-  if(!optarg || std::string(optarg) == "") {
+  if(!optarg || strlen(optarg) == 0) {
     arg = V_TRUE;
     arg = V_TRUE;
   } else {
   } else {
     arg = optarg;
     arg = optarg;
@@ -508,7 +509,7 @@ Option* option_processing(int argc, char* const argv[])
     case 'h':
     case 'h':
       {
       {
 	std::string category;
 	std::string category;
-	if(optarg == 0 || std::string(optarg) == "") {
+	if(optarg == 0 || strlen(optarg) == 0) {
 	  category = TAG_BASIC;
 	  category = TAG_BASIC;
 	} else {
 	} else {
 	  category = optarg;
 	  category = optarg;