mirror of https://github.com/aria2/aria2
2008-05-14 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Made string literals used in SAX parser static const std::string. * src/FileMetalinkParserState.cc * src/FileMetalinkParserState.h * src/FilesMetalinkParserState.cc * src/FilesMetalinkParserState.h * src/InitialMetalinkParserState.cc * src/InitialMetalinkParserState.h * src/MetalinkMetalinkParserState.cc * src/MetalinkMetalinkParserState.h * src/PiecesMetalinkParserState.cc * src/PiecesMetalinkParserState.h * src/ResourcesMetalinkParserState.cc * src/ResourcesMetalinkParserState.h * src/VerificationMetalinkParserState.cc * src/VerificationMetalinkParserState.hpull/1/head
parent
1b874503cf
commit
48c96ac441
18
ChangeLog
18
ChangeLog
|
@ -1,3 +1,21 @@
|
|||
2008-05-14 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||
|
||||
Made string literals used in SAX parser static const std::string.
|
||||
* src/FileMetalinkParserState.cc
|
||||
* src/FileMetalinkParserState.h
|
||||
* src/FilesMetalinkParserState.cc
|
||||
* src/FilesMetalinkParserState.h
|
||||
* src/InitialMetalinkParserState.cc
|
||||
* src/InitialMetalinkParserState.h
|
||||
* src/MetalinkMetalinkParserState.cc
|
||||
* src/MetalinkMetalinkParserState.h
|
||||
* src/PiecesMetalinkParserState.cc
|
||||
* src/PiecesMetalinkParserState.h
|
||||
* src/ResourcesMetalinkParserState.cc
|
||||
* src/ResourcesMetalinkParserState.h
|
||||
* src/VerificationMetalinkParserState.cc
|
||||
* src/VerificationMetalinkParserState.h
|
||||
|
||||
2008-05-14 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||
|
||||
Use A2STR::SLASH_C, A2STR::DOT_C instead of "/", "." respectively.
|
||||
|
|
|
@ -39,27 +39,42 @@
|
|||
|
||||
namespace aria2 {
|
||||
|
||||
const std::string FileMetalinkParserState::SIZE("size");
|
||||
|
||||
const std::string FileMetalinkParserState::METALINK_VERSION("version");
|
||||
|
||||
const std::string FileMetalinkParserState::LANGUAGE("language");
|
||||
|
||||
const std::string FileMetalinkParserState::OS("os");
|
||||
|
||||
const std::string FileMetalinkParserState::VERIFICATION("verification");
|
||||
|
||||
const std::string FileMetalinkParserState::RESOURCES("resources");
|
||||
|
||||
const std::string FileMetalinkParserState::MAXCONNECTIONS("maxconnections");
|
||||
|
||||
void FileMetalinkParserState::beginElement(MetalinkParserStateMachine* stm,
|
||||
const std::string& name,
|
||||
const std::map<std::string, std::string>& attrs)
|
||||
{
|
||||
if(name == "size") {
|
||||
if(name == FileMetalinkParserState::SIZE) {
|
||||
stm->setSizeState();
|
||||
} else if(name == "version") {
|
||||
} else if(name == FileMetalinkParserState::METALINK_VERSION) {
|
||||
stm->setVersionState();
|
||||
} else if(name == "language") {
|
||||
} else if(name == FileMetalinkParserState::LANGUAGE) {
|
||||
stm->setLanguageState();
|
||||
} else if(name == "os") {
|
||||
} else if(name == FileMetalinkParserState::OS) {
|
||||
stm->setOSState();
|
||||
#ifdef ENABLE_MESSAGE_DIGEST
|
||||
} else if(name == "verification") {
|
||||
} else if(name == FileMetalinkParserState::VERIFICATION) {
|
||||
stm->setVerificationState();
|
||||
#endif // ENABLE_MESSAGE_DIGEST
|
||||
} else if(name == "resources") {
|
||||
} else if(name == FileMetalinkParserState::RESOURCES) {
|
||||
stm->setResourcesState();
|
||||
int maxConnections;
|
||||
{
|
||||
std::map<std::string, std::string>::const_iterator itr = attrs.find("maxconnections");
|
||||
std::map<std::string, std::string>::const_iterator itr =
|
||||
attrs.find(FileMetalinkParserState::MAXCONNECTIONS);
|
||||
if(itr == attrs.end()) {
|
||||
maxConnections = -1;
|
||||
} else {
|
||||
|
|
|
@ -41,6 +41,21 @@ namespace aria2 {
|
|||
|
||||
class FileMetalinkParserState:public MetalinkParserState
|
||||
{
|
||||
private:
|
||||
static const std::string SIZE;
|
||||
|
||||
// VERSION is not allowed here because it is defined in macro.
|
||||
static const std::string METALINK_VERSION;
|
||||
|
||||
static const std::string LANGUAGE;
|
||||
|
||||
static const std::string OS;
|
||||
|
||||
static const std::string VERIFICATION;
|
||||
|
||||
static const std::string RESOURCES;
|
||||
|
||||
static const std::string MAXCONNECTIONS;
|
||||
public:
|
||||
void beginElement(MetalinkParserStateMachine* stm,
|
||||
const std::string& name, const std::map<std::string, std::string>& attrs);
|
||||
|
|
|
@ -37,13 +37,18 @@
|
|||
|
||||
namespace aria2 {
|
||||
|
||||
const std::string FilesMetalinkParserState::FILE("file");
|
||||
|
||||
const std::string FilesMetalinkParserState::NAME("name");
|
||||
|
||||
void FilesMetalinkParserState::beginElement(MetalinkParserStateMachine* stm,
|
||||
const std::string& name,
|
||||
const std::map<std::string, std::string>& attrs)
|
||||
{
|
||||
if(name == "file") {
|
||||
if(name == FilesMetalinkParserState::FILE) {
|
||||
stm->setFileState();
|
||||
std::map<std::string, std::string>::const_iterator itr = attrs.find("name");
|
||||
std::map<std::string, std::string>::const_iterator itr =
|
||||
attrs.find(FilesMetalinkParserState::NAME);
|
||||
if(itr != attrs.end()) {
|
||||
stm->newEntryTransaction();
|
||||
stm->setFileNameOfEntry((*itr).second);
|
||||
|
|
|
@ -41,6 +41,10 @@ namespace aria2 {
|
|||
|
||||
class FilesMetalinkParserState:public MetalinkParserState
|
||||
{
|
||||
private:
|
||||
static const std::string FILE;
|
||||
|
||||
static const std::string NAME;
|
||||
public:
|
||||
void beginElement(MetalinkParserStateMachine* stm,
|
||||
const std::string& name, const std::map<std::string, std::string>& attrs);
|
||||
|
|
|
@ -37,11 +37,13 @@
|
|||
|
||||
namespace aria2 {
|
||||
|
||||
const std::string InitialMetalinkParserState::METALINK("metalink");
|
||||
|
||||
void InitialMetalinkParserState::beginElement(MetalinkParserStateMachine* stm,
|
||||
const std::string& name,
|
||||
const std::map<std::string, std::string>& attrs)
|
||||
{
|
||||
if(name == "metalink") {
|
||||
if(name == InitialMetalinkParserState::METALINK) {
|
||||
stm->setMetalinkState();
|
||||
} else {
|
||||
stm->setSkipTagState(this);
|
||||
|
|
|
@ -41,6 +41,8 @@ namespace aria2 {
|
|||
|
||||
class InitialMetalinkParserState:public MetalinkParserState
|
||||
{
|
||||
private:
|
||||
static const std::string METALINK;
|
||||
public:
|
||||
void beginElement(MetalinkParserStateMachine* stm,
|
||||
const std::string& name, const std::map<std::string, std::string>& attrs);
|
||||
|
|
|
@ -37,11 +37,13 @@
|
|||
|
||||
namespace aria2 {
|
||||
|
||||
const std::string MetalinkMetalinkParserState::FILES("files");
|
||||
|
||||
void MetalinkMetalinkParserState::beginElement(MetalinkParserStateMachine* stm,
|
||||
const std::string& name,
|
||||
const std::map<std::string, std::string>& attrs)
|
||||
{
|
||||
if(name == "files") {
|
||||
if(name == MetalinkMetalinkParserState::FILES) {
|
||||
stm->setFilesState();
|
||||
} else {
|
||||
stm->setSkipTagState(this);
|
||||
|
|
|
@ -41,6 +41,8 @@ namespace aria2 {
|
|||
|
||||
class MetalinkMetalinkParserState:public MetalinkParserState
|
||||
{
|
||||
private:
|
||||
static const std::string FILES;
|
||||
public:
|
||||
void beginElement(MetalinkParserStateMachine* stm,
|
||||
const std::string& name, const std::map<std::string, std::string>& attrs);
|
||||
|
|
|
@ -39,13 +39,18 @@
|
|||
|
||||
namespace aria2 {
|
||||
|
||||
const std::string PiecesMetalinkParserState::HASH("hash");
|
||||
|
||||
const std::string PiecesMetalinkParserState::PIECE("piece");
|
||||
|
||||
void PiecesMetalinkParserState::beginElement(MetalinkParserStateMachine* stm,
|
||||
const std::string& name,
|
||||
const std::map<std::string, std::string>& attrs)
|
||||
{
|
||||
if(name == "hash") {
|
||||
if(name == PiecesMetalinkParserState::HASH) {
|
||||
stm->setPieceHashState();
|
||||
std::map<std::string, std::string>::const_iterator itr = attrs.find("piece");
|
||||
std::map<std::string, std::string>::const_iterator itr =
|
||||
attrs.find(PiecesMetalinkParserState::PIECE);
|
||||
if(itr == attrs.end()) {
|
||||
stm->cancelChunkChecksumTransaction();
|
||||
} else {
|
||||
|
|
|
@ -41,6 +41,10 @@ namespace aria2 {
|
|||
|
||||
class PiecesMetalinkParserState:public MetalinkParserState
|
||||
{
|
||||
private:
|
||||
static const std::string HASH;
|
||||
|
||||
static const std::string PIECE;
|
||||
public:
|
||||
void beginElement(MetalinkParserStateMachine* stm,
|
||||
const std::string& name, const std::map<std::string, std::string>& attrs);
|
||||
|
|
|
@ -39,15 +39,26 @@
|
|||
|
||||
namespace aria2 {
|
||||
|
||||
const std::string ResourcesMetalinkParserState::URL("url");
|
||||
|
||||
const std::string ResourcesMetalinkParserState::TYPE("type");
|
||||
|
||||
const std::string ResourcesMetalinkParserState::LOCATION("location");
|
||||
|
||||
const std::string ResourcesMetalinkParserState::PREFERENCE("preference");
|
||||
|
||||
const std::string ResourcesMetalinkParserState::MAXCONNECTIONS("maxconnections");
|
||||
|
||||
void ResourcesMetalinkParserState::beginElement(MetalinkParserStateMachine* stm,
|
||||
const std::string& name,
|
||||
const std::map<std::string, std::string>& attrs)
|
||||
{
|
||||
if(name == "url") {
|
||||
if(name == ResourcesMetalinkParserState::URL) {
|
||||
stm->setURLState();
|
||||
std::string type;
|
||||
{
|
||||
std::map<std::string, std::string>::const_iterator itr = attrs.find("type");
|
||||
std::map<std::string, std::string>::const_iterator itr =
|
||||
attrs.find(ResourcesMetalinkParserState::TYPE);
|
||||
if(itr == attrs.end()) {
|
||||
return;
|
||||
} else {
|
||||
|
@ -56,14 +67,16 @@ void ResourcesMetalinkParserState::beginElement(MetalinkParserStateMachine* stm,
|
|||
}
|
||||
std::string location;
|
||||
{
|
||||
std::map<std::string, std::string>::const_iterator itr = attrs.find("location");
|
||||
std::map<std::string, std::string>::const_iterator itr =
|
||||
attrs.find(ResourcesMetalinkParserState::LOCATION);
|
||||
if(itr != attrs.end()) {
|
||||
location = Util::toUpper((*itr).second);
|
||||
}
|
||||
}
|
||||
int preference;
|
||||
{
|
||||
std::map<std::string, std::string>::const_iterator itr = attrs.find("preference");
|
||||
std::map<std::string, std::string>::const_iterator itr =
|
||||
attrs.find(ResourcesMetalinkParserState::PREFERENCE);
|
||||
if(itr == attrs.end()) {
|
||||
preference = 0;
|
||||
} else {
|
||||
|
@ -76,7 +89,8 @@ void ResourcesMetalinkParserState::beginElement(MetalinkParserStateMachine* stm,
|
|||
}
|
||||
int maxConnections;
|
||||
{
|
||||
std::map<std::string, std::string>::const_iterator itr = attrs.find("maxconnections");
|
||||
std::map<std::string, std::string>::const_iterator itr =
|
||||
attrs.find(ResourcesMetalinkParserState::MAXCONNECTIONS);
|
||||
if(itr == attrs.end()) {
|
||||
maxConnections = -1;
|
||||
} else {
|
||||
|
|
|
@ -41,6 +41,16 @@ namespace aria2 {
|
|||
|
||||
class ResourcesMetalinkParserState:public MetalinkParserState
|
||||
{
|
||||
private:
|
||||
static const std::string URL;
|
||||
|
||||
static const std::string TYPE;
|
||||
|
||||
static const std::string LOCATION;
|
||||
|
||||
static const std::string PREFERENCE;
|
||||
|
||||
static const std::string MAXCONNECTIONS;
|
||||
public:
|
||||
void beginElement(MetalinkParserStateMachine* stm,
|
||||
const std::string& name, const std::map<std::string, std::string>& attrs);
|
||||
|
|
|
@ -39,13 +39,22 @@
|
|||
|
||||
namespace aria2 {
|
||||
|
||||
const std::string VerificationMetalinkParserState::HASH("hash");
|
||||
|
||||
const std::string VerificationMetalinkParserState::TYPE("type");
|
||||
|
||||
const std::string VerificationMetalinkParserState::PIECES("pieces");
|
||||
|
||||
const std::string VerificationMetalinkParserState::LENGTH("length");
|
||||
|
||||
void VerificationMetalinkParserState::beginElement(MetalinkParserStateMachine* stm,
|
||||
const std::string& name,
|
||||
const std::map<std::string, std::string>& attrs)
|
||||
{
|
||||
if(name == "hash") {
|
||||
if(name == VerificationMetalinkParserState::HASH) {
|
||||
stm->setHashState();
|
||||
std::map<std::string, std::string>::const_iterator itr = attrs.find("type");
|
||||
std::map<std::string, std::string>::const_iterator itr =
|
||||
attrs.find(VerificationMetalinkParserState::TYPE);
|
||||
if(itr == attrs.end()) {
|
||||
return;
|
||||
} else {
|
||||
|
@ -53,12 +62,13 @@ void VerificationMetalinkParserState::beginElement(MetalinkParserStateMachine* s
|
|||
stm->newChecksumTransaction();
|
||||
stm->setTypeOfChecksum(type);
|
||||
}
|
||||
} else if(name == "pieces") {
|
||||
} else if(name == VerificationMetalinkParserState::PIECES) {
|
||||
stm->setPiecesState();
|
||||
try {
|
||||
size_t length;
|
||||
{
|
||||
std::map<std::string, std::string>::const_iterator itr = attrs.find("length");
|
||||
std::map<std::string, std::string>::const_iterator itr =
|
||||
attrs.find(VerificationMetalinkParserState::LENGTH);
|
||||
if(itr == attrs.end()) {
|
||||
return;
|
||||
} else {
|
||||
|
@ -67,7 +77,8 @@ void VerificationMetalinkParserState::beginElement(MetalinkParserStateMachine* s
|
|||
}
|
||||
std::string type;
|
||||
{
|
||||
std::map<std::string, std::string>::const_iterator itr = attrs.find("type");
|
||||
std::map<std::string, std::string>::const_iterator itr =
|
||||
attrs.find(VerificationMetalinkParserState::TYPE);
|
||||
if(itr == attrs.end()) {
|
||||
return;
|
||||
} else {
|
||||
|
|
|
@ -41,6 +41,14 @@ namespace aria2 {
|
|||
|
||||
class VerificationMetalinkParserState:public MetalinkParserState
|
||||
{
|
||||
private:
|
||||
static const std::string HASH;
|
||||
|
||||
static const std::string TYPE;
|
||||
|
||||
static const std::string PIECES;
|
||||
|
||||
static const std::string LENGTH;
|
||||
public:
|
||||
void beginElement(MetalinkParserStateMachine* stm,
|
||||
const std::string& name, const std::map<std::string, std::string>& attrs);
|
||||
|
|
Loading…
Reference in New Issue