mirror of https://github.com/aria2/aria2
Made BtMessage's NAME const char[]
parent
9a510ddac0
commit
c63af24c63
|
@ -39,7 +39,7 @@
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
AbstractBtMessage::AbstractBtMessage(uint8_t id, const std::string& name)
|
AbstractBtMessage::AbstractBtMessage(uint8_t id, const char* name)
|
||||||
: BtMessage(id),
|
: BtMessage(id),
|
||||||
sendingInProgress_(false),
|
sendingInProgress_(false),
|
||||||
invalidate_(false),
|
invalidate_(false),
|
||||||
|
|
|
@ -55,7 +55,7 @@ private:
|
||||||
bool uploading_;
|
bool uploading_;
|
||||||
cuid_t cuid_;
|
cuid_t cuid_;
|
||||||
|
|
||||||
std::string name_;
|
const char* name_;
|
||||||
|
|
||||||
SharedHandle<PieceStorage> pieceStorage_;
|
SharedHandle<PieceStorage> pieceStorage_;
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ protected:
|
||||||
return metadataGetMode_;
|
return metadataGetMode_;
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
AbstractBtMessage(uint8_t id, const std::string& name);
|
AbstractBtMessage(uint8_t id, const char* name);
|
||||||
|
|
||||||
virtual ~AbstractBtMessage();
|
virtual ~AbstractBtMessage();
|
||||||
|
|
||||||
|
@ -172,7 +172,7 @@ public:
|
||||||
|
|
||||||
void setBtRequestFactory(BtRequestFactory* factory);
|
void setBtRequestFactory(BtRequestFactory* factory);
|
||||||
|
|
||||||
const std::string& getName() const
|
const char* getName() const
|
||||||
{
|
{
|
||||||
return name_;
|
return name_;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
const std::string BtAllowedFastMessage::NAME("allowed fast");
|
const char BtAllowedFastMessage::NAME[] = "allowed fast";
|
||||||
|
|
||||||
BtAllowedFastMessage::BtAllowedFastMessage(size_t index):
|
BtAllowedFastMessage::BtAllowedFastMessage(size_t index):
|
||||||
IndexBtMessage(ID, NAME, index) {}
|
IndexBtMessage(ID, NAME, index) {}
|
||||||
|
|
|
@ -49,7 +49,7 @@ public:
|
||||||
|
|
||||||
static const uint8_t ID = 17;
|
static const uint8_t ID = 17;
|
||||||
|
|
||||||
static const std::string NAME;
|
static const char NAME[];
|
||||||
|
|
||||||
static SharedHandle<BtAllowedFastMessage> create
|
static SharedHandle<BtAllowedFastMessage> create
|
||||||
(const unsigned char* data, size_t dataLength);
|
(const unsigned char* data, size_t dataLength);
|
||||||
|
|
|
@ -46,7 +46,7 @@
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
const std::string BtBitfieldMessage::NAME("bitfield");
|
const char BtBitfieldMessage::NAME[] = "bitfield";
|
||||||
|
|
||||||
BtBitfieldMessage::BtBitfieldMessage():SimpleBtMessage(ID, NAME),
|
BtBitfieldMessage::BtBitfieldMessage():SimpleBtMessage(ID, NAME),
|
||||||
bitfield_(0),
|
bitfield_(0),
|
||||||
|
|
|
@ -56,7 +56,7 @@ public:
|
||||||
|
|
||||||
static const uint8_t ID = 5;
|
static const uint8_t ID = 5;
|
||||||
|
|
||||||
static const std::string NAME;
|
static const char NAME[];
|
||||||
|
|
||||||
void setBitfield(const unsigned char* bitfield, size_t bitfieldLength);
|
void setBitfield(const unsigned char* bitfield, size_t bitfieldLength);
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
const std::string BtCancelMessage::NAME("cancel");
|
const char BtCancelMessage::NAME[] = "cancel";
|
||||||
|
|
||||||
BtCancelMessage::BtCancelMessage
|
BtCancelMessage::BtCancelMessage
|
||||||
(size_t index, int32_t begin, int32_t length)
|
(size_t index, int32_t begin, int32_t length)
|
||||||
|
|
|
@ -49,7 +49,7 @@ public:
|
||||||
|
|
||||||
static const int8_t ID = 8;
|
static const int8_t ID = 8;
|
||||||
|
|
||||||
static const std::string NAME;
|
static const char NAME[];
|
||||||
|
|
||||||
static BtCancelMessageHandle create
|
static BtCancelMessageHandle create
|
||||||
(const unsigned char* data, size_t dataLength);
|
(const unsigned char* data, size_t dataLength);
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
const std::string BtChokeMessage::NAME("choke");
|
const char BtChokeMessage::NAME[] = "choke";
|
||||||
|
|
||||||
BtChokeMessage::BtChokeMessage():ZeroBtMessage(ID, NAME) {}
|
BtChokeMessage::BtChokeMessage():ZeroBtMessage(ID, NAME) {}
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ public:
|
||||||
|
|
||||||
static const uint8_t ID = 0;
|
static const uint8_t ID = 0;
|
||||||
|
|
||||||
static const std::string NAME;
|
static const char NAME[];
|
||||||
|
|
||||||
virtual void doReceivedAction();
|
virtual void doReceivedAction();
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
const std::string BtExtendedMessage::NAME("extended");
|
const char BtExtendedMessage::NAME[] = "extended";
|
||||||
|
|
||||||
BtExtendedMessage::BtExtendedMessage
|
BtExtendedMessage::BtExtendedMessage
|
||||||
(const ExtensionMessageHandle& extensionMessage):
|
(const ExtensionMessageHandle& extensionMessage):
|
||||||
|
|
|
@ -57,7 +57,7 @@ public:
|
||||||
|
|
||||||
static const uint8_t ID = 20;
|
static const uint8_t ID = 20;
|
||||||
|
|
||||||
static const std::string NAME;
|
static const char NAME[];
|
||||||
|
|
||||||
static BtExtendedMessageHandle create
|
static BtExtendedMessageHandle create
|
||||||
(const SharedHandle<ExtensionMessageFactory>& factory,
|
(const SharedHandle<ExtensionMessageFactory>& factory,
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
const std::string BtHandshakeMessage::NAME("handshake");
|
const char BtHandshakeMessage::NAME[] = "handshake";
|
||||||
|
|
||||||
const unsigned char* BtHandshakeMessage::BT_PSTR =
|
const unsigned char* BtHandshakeMessage::BT_PSTR =
|
||||||
reinterpret_cast<const unsigned char*>("BitTorrent protocol");
|
reinterpret_cast<const unsigned char*>("BitTorrent protocol");
|
||||||
|
@ -104,7 +104,7 @@ size_t BtHandshakeMessage::getMessageLength() {
|
||||||
|
|
||||||
std::string BtHandshakeMessage::toString() const {
|
std::string BtHandshakeMessage::toString() const {
|
||||||
return fmt("%s peerId=%s, reserved=%s",
|
return fmt("%s peerId=%s, reserved=%s",
|
||||||
NAME.c_str(),
|
NAME,
|
||||||
util::percentEncode(peerId_, PEER_ID_LENGTH).c_str(),
|
util::percentEncode(peerId_, PEER_ID_LENGTH).c_str(),
|
||||||
util::toHex(reserved_, RESERVED_LENGTH).c_str());
|
util::toHex(reserved_, RESERVED_LENGTH).c_str());
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,7 @@ public:
|
||||||
|
|
||||||
static const uint8_t ID = INT8_MAX;
|
static const uint8_t ID = INT8_MAX;
|
||||||
|
|
||||||
static const std::string NAME;
|
static const char NAME[];
|
||||||
|
|
||||||
virtual void doReceivedAction() {};
|
virtual void doReceivedAction() {};
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
const std::string BtHaveAllMessage::NAME("have all");
|
const char BtHaveAllMessage::NAME[] = "have all";
|
||||||
|
|
||||||
BtHaveAllMessage::BtHaveAllMessage():ZeroBtMessage(ID, NAME) {}
|
BtHaveAllMessage::BtHaveAllMessage():ZeroBtMessage(ID, NAME) {}
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ public:
|
||||||
|
|
||||||
static const uint8_t ID = 14;
|
static const uint8_t ID = 14;
|
||||||
|
|
||||||
static const std::string NAME;
|
static const char NAME[];
|
||||||
|
|
||||||
static SharedHandle<BtHaveAllMessage> create
|
static SharedHandle<BtHaveAllMessage> create
|
||||||
(const unsigned char* data, size_t dataLength);
|
(const unsigned char* data, size_t dataLength);
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
const std::string BtHaveMessage::NAME("have");
|
const char BtHaveMessage::NAME[] = "have";
|
||||||
|
|
||||||
BtHaveMessage::BtHaveMessage(size_t index):IndexBtMessage(ID, NAME, index) {}
|
BtHaveMessage::BtHaveMessage(size_t index):IndexBtMessage(ID, NAME, index) {}
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ public:
|
||||||
|
|
||||||
static const uint8_t ID = 4;
|
static const uint8_t ID = 4;
|
||||||
|
|
||||||
static const std::string NAME;
|
static const char NAME[];
|
||||||
|
|
||||||
static SharedHandle<BtHaveMessage> create
|
static SharedHandle<BtHaveMessage> create
|
||||||
(const unsigned char* data, size_t dataLength);
|
(const unsigned char* data, size_t dataLength);
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
const std::string BtHaveNoneMessage::NAME("have none");
|
const char BtHaveNoneMessage::NAME[] = "have none";
|
||||||
|
|
||||||
BtHaveNoneMessage::BtHaveNoneMessage():ZeroBtMessage(ID, NAME) {}
|
BtHaveNoneMessage::BtHaveNoneMessage():ZeroBtMessage(ID, NAME) {}
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ public:
|
||||||
|
|
||||||
static const uint8_t ID = 15;
|
static const uint8_t ID = 15;
|
||||||
|
|
||||||
static const std::string NAME;
|
static const char NAME[];
|
||||||
|
|
||||||
static SharedHandle<BtHaveNoneMessage> create
|
static SharedHandle<BtHaveNoneMessage> create
|
||||||
(const unsigned char* data, size_t dataLength);
|
(const unsigned char* data, size_t dataLength);
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
const std::string BtInterestedMessage::NAME("interested");
|
const char BtInterestedMessage::NAME[] = "interested";
|
||||||
|
|
||||||
BtInterestedMessage::BtInterestedMessage():ZeroBtMessage(ID, NAME) {}
|
BtInterestedMessage::BtInterestedMessage():ZeroBtMessage(ID, NAME) {}
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ public:
|
||||||
|
|
||||||
static const uint8_t ID = 2;
|
static const uint8_t ID = 2;
|
||||||
|
|
||||||
static const std::string NAME;
|
static const char NAME[];
|
||||||
|
|
||||||
static SharedHandle<BtInterestedMessage> create
|
static SharedHandle<BtInterestedMessage> create
|
||||||
(const unsigned char* data, size_t dataLength);
|
(const unsigned char* data, size_t dataLength);
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
const std::string BtKeepAliveMessage::NAME("keep alive");
|
const char BtKeepAliveMessage::NAME[] = "keep alive";
|
||||||
|
|
||||||
unsigned char* BtKeepAliveMessage::createMessage()
|
unsigned char* BtKeepAliveMessage::createMessage()
|
||||||
{
|
{
|
||||||
|
|
|
@ -51,7 +51,7 @@ public:
|
||||||
|
|
||||||
static const uint8_t ID = 99;
|
static const uint8_t ID = 99;
|
||||||
|
|
||||||
static const std::string NAME;
|
static const char NAME[];
|
||||||
|
|
||||||
virtual void doReceivedAction() {}
|
virtual void doReceivedAction() {}
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
const std::string BtNotInterestedMessage::NAME("not interested");
|
const char BtNotInterestedMessage::NAME[] = "not interested";
|
||||||
|
|
||||||
BtNotInterestedMessage::BtNotInterestedMessage():ZeroBtMessage(ID, NAME) {}
|
BtNotInterestedMessage::BtNotInterestedMessage():ZeroBtMessage(ID, NAME) {}
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ public:
|
||||||
|
|
||||||
static const uint8_t ID = 3;
|
static const uint8_t ID = 3;
|
||||||
|
|
||||||
static const std::string NAME;
|
static const char NAME[];
|
||||||
|
|
||||||
static SharedHandle<BtNotInterestedMessage> create
|
static SharedHandle<BtNotInterestedMessage> create
|
||||||
(const unsigned char* data, size_t dataLength);
|
(const unsigned char* data, size_t dataLength);
|
||||||
|
|
|
@ -59,7 +59,7 @@
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
const std::string BtPieceMessage::NAME("piece");
|
const char BtPieceMessage::NAME[] = "piece";
|
||||||
|
|
||||||
BtPieceMessage::BtPieceMessage
|
BtPieceMessage::BtPieceMessage
|
||||||
(size_t index, int32_t begin, int32_t blockLength)
|
(size_t index, int32_t begin, int32_t blockLength)
|
||||||
|
@ -212,7 +212,7 @@ void BtPieceMessage::pushPieceData(int64_t offset, int32_t length) const
|
||||||
std::string BtPieceMessage::toString() const
|
std::string BtPieceMessage::toString() const
|
||||||
{
|
{
|
||||||
return fmt("%s index=%lu, begin=%d, length=%d",
|
return fmt("%s index=%lu, begin=%d, length=%d",
|
||||||
NAME.c_str(),
|
NAME,
|
||||||
static_cast<unsigned long>(index_),
|
static_cast<unsigned long>(index_),
|
||||||
begin_, blockLength_);
|
begin_, blockLength_);
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,7 @@ public:
|
||||||
|
|
||||||
static const uint8_t ID = 7;
|
static const uint8_t ID = 7;
|
||||||
|
|
||||||
static const std::string NAME;
|
static const char NAME[];
|
||||||
|
|
||||||
size_t getIndex() const { return index_; }
|
size_t getIndex() const { return index_; }
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
const std::string BtPortMessage::NAME("port");
|
const char BtPortMessage::NAME[] = "port";
|
||||||
|
|
||||||
BtPortMessage::BtPortMessage(uint16_t port)
|
BtPortMessage::BtPortMessage(uint16_t port)
|
||||||
: SimpleBtMessage(ID, NAME),
|
: SimpleBtMessage(ID, NAME),
|
||||||
|
@ -118,7 +118,7 @@ size_t BtPortMessage::getMessageLength() {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string BtPortMessage::toString() const {
|
std::string BtPortMessage::toString() const {
|
||||||
return fmt("%s port=%u", NAME.c_str(), port_);
|
return fmt("%s port=%u", NAME, port_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BtPortMessage::setLocalNode(DHTNode* localNode)
|
void BtPortMessage::setLocalNode(DHTNode* localNode)
|
||||||
|
|
|
@ -61,7 +61,7 @@ public:
|
||||||
|
|
||||||
static const uint8_t ID = 9;
|
static const uint8_t ID = 9;
|
||||||
|
|
||||||
static const std::string NAME;
|
static const char NAME[];
|
||||||
|
|
||||||
uint16_t getPort() const { return port_; }
|
uint16_t getPort() const { return port_; }
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
const std::string BtRejectMessage::NAME("reject");
|
const char BtRejectMessage::NAME[] = "reject";
|
||||||
|
|
||||||
BtRejectMessage::BtRejectMessage
|
BtRejectMessage::BtRejectMessage
|
||||||
(size_t index, int32_t begin, int32_t length):
|
(size_t index, int32_t begin, int32_t length):
|
||||||
|
|
|
@ -49,7 +49,7 @@ public:
|
||||||
|
|
||||||
static const uint8_t ID = 16;
|
static const uint8_t ID = 16;
|
||||||
|
|
||||||
static const std::string NAME;
|
static const char NAME[];
|
||||||
|
|
||||||
static SharedHandle<BtRejectMessage> create
|
static SharedHandle<BtRejectMessage> create
|
||||||
(const unsigned char* data, size_t dataLength);
|
(const unsigned char* data, size_t dataLength);
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
const std::string BtRequestMessage::NAME("request");
|
const char BtRequestMessage::NAME[] = "request";
|
||||||
|
|
||||||
BtRequestMessage::BtRequestMessage
|
BtRequestMessage::BtRequestMessage
|
||||||
(size_t index, int32_t begin, int32_t length, size_t blockIndex):
|
(size_t index, int32_t begin, int32_t length, size_t blockIndex):
|
||||||
|
|
|
@ -54,7 +54,7 @@ public:
|
||||||
|
|
||||||
static const uint8_t ID = 6;
|
static const uint8_t ID = 6;
|
||||||
|
|
||||||
static const std::string NAME;
|
static const char NAME[];
|
||||||
|
|
||||||
size_t getBlockIndex() const { return blockIndex_; }
|
size_t getBlockIndex() const { return blockIndex_; }
|
||||||
void setBlockIndex(size_t blockIndex) { blockIndex_ = blockIndex; }
|
void setBlockIndex(size_t blockIndex) { blockIndex_ = blockIndex; }
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
const std::string BtSuggestPieceMessage::NAME("suggest piece");
|
const char BtSuggestPieceMessage::NAME[] = "suggest piece";
|
||||||
|
|
||||||
SharedHandle<BtSuggestPieceMessage> BtSuggestPieceMessage::create
|
SharedHandle<BtSuggestPieceMessage> BtSuggestPieceMessage::create
|
||||||
(const unsigned char* data, size_t dataLength)
|
(const unsigned char* data, size_t dataLength)
|
||||||
|
|
|
@ -49,7 +49,7 @@ public:
|
||||||
|
|
||||||
static const uint8_t ID = 13;
|
static const uint8_t ID = 13;
|
||||||
|
|
||||||
static const std::string NAME;
|
static const char NAME[];
|
||||||
|
|
||||||
static SharedHandle<BtSuggestPieceMessage> create
|
static SharedHandle<BtSuggestPieceMessage> create
|
||||||
(const unsigned char* data, size_t dataLength);
|
(const unsigned char* data, size_t dataLength);
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
const std::string BtUnchokeMessage::NAME("unchoke");
|
const char BtUnchokeMessage::NAME[] = "unchoke";
|
||||||
|
|
||||||
BtUnchokeMessage::BtUnchokeMessage():ZeroBtMessage(ID, NAME) {}
|
BtUnchokeMessage::BtUnchokeMessage():ZeroBtMessage(ID, NAME) {}
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ public:
|
||||||
|
|
||||||
static const uint8_t ID = 1;
|
static const uint8_t ID = 1;
|
||||||
|
|
||||||
static const std::string NAME;
|
static const char NAME[];
|
||||||
|
|
||||||
static SharedHandle<BtUnchokeMessage> create
|
static SharedHandle<BtUnchokeMessage> create
|
||||||
(const unsigned char* data, size_t dataLength);
|
(const unsigned char* data, size_t dataLength);
|
||||||
|
|
|
@ -60,9 +60,7 @@ size_t IndexBtMessage::getMessageLength()
|
||||||
|
|
||||||
std::string IndexBtMessage::toString() const
|
std::string IndexBtMessage::toString() const
|
||||||
{
|
{
|
||||||
return fmt("%s index=%lu",
|
return fmt("%s index=%lu", getName(), static_cast<unsigned long>(index_));
|
||||||
getName().c_str(),
|
|
||||||
static_cast<unsigned long>(index_));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
|
@ -56,7 +56,7 @@ protected:
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
IndexBtMessage(uint8_t id, const std::string& name, size_t index)
|
IndexBtMessage(uint8_t id, const char* name, size_t index)
|
||||||
:SimpleBtMessage(id, name),
|
:SimpleBtMessage(id, name),
|
||||||
index_(index) {}
|
index_(index) {}
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
RangeBtMessage::RangeBtMessage(uint8_t id,
|
RangeBtMessage::RangeBtMessage(uint8_t id,
|
||||||
const std::string& name,
|
const char* name,
|
||||||
size_t index, int32_t begin, int32_t length)
|
size_t index, int32_t begin, int32_t length)
|
||||||
:SimpleBtMessage(id, name),
|
:SimpleBtMessage(id, name),
|
||||||
index_(index),
|
index_(index),
|
||||||
|
@ -73,7 +73,7 @@ size_t RangeBtMessage::getMessageLength()
|
||||||
std::string RangeBtMessage::toString() const
|
std::string RangeBtMessage::toString() const
|
||||||
{
|
{
|
||||||
return fmt("%s index=%lu, begin=%d, length=%d",
|
return fmt("%s index=%lu, begin=%d, length=%d",
|
||||||
getName().c_str(),
|
getName(),
|
||||||
static_cast<unsigned long>(index_),
|
static_cast<unsigned long>(index_),
|
||||||
begin_, length_);
|
begin_, length_);
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,7 +61,7 @@ protected:
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
RangeBtMessage(uint8_t id, const std::string& name,
|
RangeBtMessage(uint8_t id, const char* name,
|
||||||
size_t index, int32_t begin, int32_t length);
|
size_t index, int32_t begin, int32_t length);
|
||||||
|
|
||||||
size_t getIndex() const { return index_; }
|
size_t getIndex() const { return index_; }
|
||||||
|
|
|
@ -43,7 +43,7 @@
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
SimpleBtMessage::SimpleBtMessage(uint8_t id, const std::string& name)
|
SimpleBtMessage::SimpleBtMessage(uint8_t id, const char* name)
|
||||||
: AbstractBtMessage(id, name)
|
: AbstractBtMessage(id, name)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ namespace aria2 {
|
||||||
|
|
||||||
class SimpleBtMessage : public AbstractBtMessage {
|
class SimpleBtMessage : public AbstractBtMessage {
|
||||||
public:
|
public:
|
||||||
SimpleBtMessage(uint8_t id, const std::string& name);
|
SimpleBtMessage(uint8_t id, const char* name);
|
||||||
|
|
||||||
virtual void send();
|
virtual void send();
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ protected:
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ZeroBtMessage(uint8_t id, const std::string& name):
|
ZeroBtMessage(uint8_t id, const char* name):
|
||||||
SimpleBtMessage(id, name) {}
|
SimpleBtMessage(id, name) {}
|
||||||
|
|
||||||
virtual unsigned char* createMessage();
|
virtual unsigned char* createMessage();
|
||||||
|
|
|
@ -847,34 +847,33 @@ std::pair<std::string, uint16_t> unpackcompact
|
||||||
}
|
}
|
||||||
|
|
||||||
void assertPayloadLengthGreater
|
void assertPayloadLengthGreater
|
||||||
(size_t threshold, size_t actual, const std::string& msgName)
|
(size_t threshold, size_t actual, const char* msgName)
|
||||||
{
|
{
|
||||||
if(actual <= threshold) {
|
if(actual <= threshold) {
|
||||||
throw DL_ABORT_EX
|
throw DL_ABORT_EX
|
||||||
(fmt(MSG_TOO_SMALL_PAYLOAD_SIZE, msgName.c_str(),
|
(fmt(MSG_TOO_SMALL_PAYLOAD_SIZE, msgName,
|
||||||
static_cast<unsigned long>(actual)));
|
static_cast<unsigned long>(actual)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void assertPayloadLengthEqual
|
void assertPayloadLengthEqual
|
||||||
(size_t expected, size_t actual, const std::string& msgName)
|
(size_t expected, size_t actual, const char* msgName)
|
||||||
{
|
{
|
||||||
if(expected != actual) {
|
if(expected != actual) {
|
||||||
throw DL_ABORT_EX
|
throw DL_ABORT_EX
|
||||||
(fmt(EX_INVALID_PAYLOAD_SIZE, msgName.c_str(),
|
(fmt(EX_INVALID_PAYLOAD_SIZE, msgName,
|
||||||
static_cast<unsigned long>(actual),
|
static_cast<unsigned long>(actual),
|
||||||
static_cast<unsigned long>(expected)));
|
static_cast<unsigned long>(expected)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void assertID
|
void assertID
|
||||||
(uint8_t expected, const unsigned char* data, const std::string& msgName)
|
(uint8_t expected, const unsigned char* data, const char* msgName)
|
||||||
{
|
{
|
||||||
uint8_t id = getId(data);
|
uint8_t id = getId(data);
|
||||||
if(expected != id) {
|
if(expected != id) {
|
||||||
throw DL_ABORT_EX
|
throw DL_ABORT_EX
|
||||||
(fmt(EX_INVALID_BT_MESSAGE_ID, id, msgName.c_str(),
|
(fmt(EX_INVALID_BT_MESSAGE_ID, id, msgName, expected));
|
||||||
expected));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -215,15 +215,15 @@ unpackcompact(const unsigned char* compact, int family);
|
||||||
|
|
||||||
// Throws exception if threshold >= actual
|
// Throws exception if threshold >= actual
|
||||||
void assertPayloadLengthGreater
|
void assertPayloadLengthGreater
|
||||||
(size_t threshold, size_t actual, const std::string& msgName);
|
(size_t threshold, size_t actual, const char* msgName);
|
||||||
|
|
||||||
// Throws exception if expected != actual
|
// Throws exception if expected != actual
|
||||||
void assertPayloadLengthEqual
|
void assertPayloadLengthEqual
|
||||||
(size_t expected, size_t actual, const std::string& msgName);
|
(size_t expected, size_t actual, const char* msgName);
|
||||||
|
|
||||||
// Throws exception if expected is not equal to id from data.
|
// Throws exception if expected is not equal to id from data.
|
||||||
void assertID
|
void assertID
|
||||||
(uint8_t expected, const unsigned char* data, const std::string& msgName);
|
(uint8_t expected, const unsigned char* data, const char* msgName);
|
||||||
|
|
||||||
// Converts attrs into torrent data. This function does not guarantee
|
// Converts attrs into torrent data. This function does not guarantee
|
||||||
// the returned string is valid torrent data.
|
// the returned string is valid torrent data.
|
||||||
|
|
Loading…
Reference in New Issue