mirror of
https://github.com/aria2/aria2.git
synced 2024-12-29 14:14:53 +00:00
Made ExtensionMessage's NAME const char[]
This commit is contained in:
parent
c522d79d89
commit
f0000a8754
@ -49,8 +49,8 @@ public:
|
||||
virtual std::string getPayload() = 0;
|
||||
|
||||
virtual uint8_t getExtensionMessageID() = 0;
|
||||
|
||||
virtual const std::string& getExtensionName() const = 0;
|
||||
|
||||
virtual const char* getExtensionName() const = 0;
|
||||
|
||||
virtual std::string toString() const = 0;
|
||||
|
||||
|
@ -49,7 +49,7 @@
|
||||
|
||||
namespace aria2 {
|
||||
|
||||
const std::string HandshakeExtensionMessage::EXTENSION_NAME = "handshake";
|
||||
const char HandshakeExtensionMessage::EXTENSION_NAME[] = "handshake";
|
||||
|
||||
HandshakeExtensionMessage::HandshakeExtensionMessage()
|
||||
: tcpPort_(0),
|
||||
@ -83,7 +83,7 @@ std::string HandshakeExtensionMessage::getPayload()
|
||||
std::string HandshakeExtensionMessage::toString() const
|
||||
{
|
||||
std::string s(fmt("%s client=%s, tcpPort=%u, metadataSize=%lu",
|
||||
getExtensionName().c_str(),
|
||||
getExtensionName(),
|
||||
util::percentEncode(clientVersion_).c_str(),
|
||||
tcpPort_,
|
||||
static_cast<unsigned long>(metadataSize_)));
|
||||
@ -162,8 +162,7 @@ HandshakeExtensionMessage::create(const unsigned char* data, size_t length)
|
||||
if(length < 1) {
|
||||
throw DL_ABORT_EX
|
||||
(fmt(MSG_TOO_SMALL_PAYLOAD_SIZE,
|
||||
EXTENSION_NAME.c_str(),
|
||||
static_cast<unsigned long>(length)));
|
||||
EXTENSION_NAME, static_cast<unsigned long>(length)));
|
||||
}
|
||||
HandshakeExtensionMessageHandle msg(new HandshakeExtensionMessage());
|
||||
A2_LOG_DEBUG(fmt("Creating HandshakeExtensionMessage from %s",
|
||||
|
@ -71,12 +71,12 @@ public:
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual const std::string& getExtensionName() const
|
||||
virtual const char* getExtensionName() const
|
||||
{
|
||||
return EXTENSION_NAME;
|
||||
}
|
||||
|
||||
static const std::string EXTENSION_NAME;
|
||||
static const char EXTENSION_NAME[];
|
||||
|
||||
virtual std::string toString() const;
|
||||
|
||||
|
@ -36,7 +36,7 @@
|
||||
|
||||
namespace aria2 {
|
||||
|
||||
const std::string UTMetadataExtensionMessage::EXTENSION_NAME = "ut_metadata";
|
||||
const char UTMetadataExtensionMessage::EXTENSION_NAME[] = "ut_metadata";
|
||||
|
||||
UTMetadataExtensionMessage::UTMetadataExtensionMessage
|
||||
(uint8_t extensionMessageID):
|
||||
|
@ -52,12 +52,12 @@ public:
|
||||
return extensionMessageID_;
|
||||
}
|
||||
|
||||
virtual const std::string& getExtensionName() const
|
||||
virtual const char* getExtensionName() const
|
||||
{
|
||||
return EXTENSION_NAME;
|
||||
}
|
||||
|
||||
static const std::string EXTENSION_NAME;
|
||||
static const char EXTENSION_NAME[];
|
||||
|
||||
void setIndex(size_t index)
|
||||
{
|
||||
|
@ -55,7 +55,7 @@ const size_t DEFAULT_MAX_DROPPED_PEER = 50;
|
||||
|
||||
} // namespace
|
||||
|
||||
const std::string UTPexExtensionMessage::EXTENSION_NAME = "ut_pex";
|
||||
const char UTPexExtensionMessage::EXTENSION_NAME[] = "ut_pex";
|
||||
|
||||
UTPexExtensionMessage::UTPexExtensionMessage(uint8_t extensionMessageID):
|
||||
extensionMessageID_(extensionMessageID),
|
||||
@ -186,7 +186,7 @@ UTPexExtensionMessage::create(const unsigned char* data, size_t len)
|
||||
{
|
||||
if(len < 1) {
|
||||
throw DL_ABORT_EX(fmt(MSG_TOO_SMALL_PAYLOAD_SIZE,
|
||||
EXTENSION_NAME.c_str(),
|
||||
EXTENSION_NAME,
|
||||
static_cast<unsigned long>(len)));
|
||||
}
|
||||
UTPexExtensionMessageHandle msg(new UTPexExtensionMessage(*data));
|
||||
|
@ -81,12 +81,12 @@ public:
|
||||
return extensionMessageID_;
|
||||
}
|
||||
|
||||
virtual const std::string& getExtensionName() const
|
||||
virtual const char* getExtensionName() const
|
||||
{
|
||||
return EXTENSION_NAME;
|
||||
}
|
||||
|
||||
static const std::string EXTENSION_NAME;
|
||||
static const char EXTENSION_NAME[];
|
||||
|
||||
virtual std::string toString() const;
|
||||
|
||||
|
@ -51,7 +51,8 @@ void HandshakeExtensionMessageTest::testGetExtensionMessageID()
|
||||
void HandshakeExtensionMessageTest::testGetExtensionName()
|
||||
{
|
||||
HandshakeExtensionMessage msg;
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("handshake"), msg.getExtensionName());
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("handshake"),
|
||||
std::string(msg.getExtensionName()));
|
||||
}
|
||||
|
||||
void HandshakeExtensionMessageTest::testGetBencodedData()
|
||||
|
@ -40,9 +40,9 @@ public:
|
||||
return extensionMessageID_;
|
||||
}
|
||||
|
||||
virtual const std::string& getExtensionName() const
|
||||
virtual const char* getExtensionName() const
|
||||
{
|
||||
return extensionName_;
|
||||
return extensionName_.c_str();
|
||||
}
|
||||
|
||||
virtual std::string toString() const
|
||||
|
@ -78,7 +78,8 @@ void UTMetadataRequestExtensionMessageTest::testGetExtensionMessageID()
|
||||
void UTMetadataRequestExtensionMessageTest::testGetExtensionName()
|
||||
{
|
||||
UTMetadataRequestExtensionMessage msg(1);
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("ut_metadata"), msg.getExtensionName());
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("ut_metadata"),
|
||||
std::string(msg.getExtensionName()));
|
||||
}
|
||||
|
||||
void UTMetadataRequestExtensionMessageTest::testGetBencodedData()
|
||||
|
@ -63,7 +63,8 @@ void UTPexExtensionMessageTest::testGetExtensionMessageID()
|
||||
void UTPexExtensionMessageTest::testGetExtensionName()
|
||||
{
|
||||
UTPexExtensionMessage msg(1);
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("ut_pex"), msg.getExtensionName());
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("ut_pex"),
|
||||
std::string(msg.getExtensionName()));
|
||||
}
|
||||
|
||||
void UTPexExtensionMessageTest::testGetBencodedData()
|
||||
|
Loading…
Reference in New Issue
Block a user