summaryrefslogtreecommitdiff
path: root/src/FeatureConfig.h
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2006-08-03 12:36:02 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2006-08-03 12:36:02 +0000
commit9251b47f6cccc7cd5175ab6858c3330eb0752061 (patch)
treeabc942ea6adea78fcb3b97d47df801b5232a74fa /src/FeatureConfig.h
parent928465b7bc638380004b39d6a5c6737f9f30faa0 (diff)
2006-08-03 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* src/Option.h (getAsBool): New function. * src/Option.cc (prefs.h): Included. (defined): 0-length value is now recognized as undefined. (getAsInt): Rewritten. (getAsLLInt): Rewritten. (getAsBool): New function. * src/FeatureConfig.h: Rewritten. * src/FeatureConfig.cc: Rewritten. * src/prefs.h (PREF_STDOUT_LOG): New definition. (PREF_LOG): New definition. (PREF_DIR): New definition. (PREF_OUT): New definition. (PREF_SPLIT): New definition. (PREF_DAEMON): New definition. (PREF_REFERER): New definition. (PREF_TORRENT_FILE): New definition. (PREF_LISTEN_PORT): New definition. (PREF_METALINK_FILE): New definition. (PREF_METALINK_VERSION): New definition. (PREF_METALINK_LANGUAGE): New definition. (PREF_METALINK_OS): New definition. (PREF_METALINK_SERVERS): New definition. * src/main.cc (main): Following command-line parameters are now put into Option class: stdoutLog, logfile, dir, ufilename, split, daemonMode, referer, torrentFile, metalinkFile, listenPort, metalinkVersion, metalinkLanguage, metalinkOs, metalinkServers To fix the bug that aria2 can not handle http response header properly. * src/HttpHeader.cc (put): Made name lowercased. (defined): Made name lowercased. (getFirst): Made name lowercased. (get): Made name lowercased. (getFirstAsInt): Rewritten. (getFirstAsLLInt): Rewritten.
Diffstat (limited to 'src/FeatureConfig.h')
-rw-r--r--src/FeatureConfig.h70
1 files changed, 41 insertions, 29 deletions
diff --git a/src/FeatureConfig.h b/src/FeatureConfig.h
index 3c048ef3..744f8a42 100644
--- a/src/FeatureConfig.h
+++ b/src/FeatureConfig.h
@@ -25,48 +25,60 @@
#include "common.h"
#include <map>
-typedef map<string, int> ProtocolPortMap;
-typedef map<string, bool> SupportedFeatureMap;
+typedef map<string, int> PortMap;
+typedef map<string, bool> FeatureMap;
class FeatureConfig {
private:
- static ProtocolPortMap defaultPorts;
- static SupportedFeatureMap supportedFeatures;
+ static FeatureConfig* featureConfig;
+
+ PortMap defaultPorts;
+ FeatureMap supportedFeatures;
+ Strings features;
+
+ FeatureConfig();
+ ~FeatureConfig() {}
public:
- static string FEATURE_HTTP;
- static string FEATURE_HTTPS;
- static string FEATURE_FTP;
- static string FEATURE_BITTORRENT;
- static string FEATURE_METALINK;
+ static FeatureConfig* getInstance() {
+ if(!featureConfig) {
+ featureConfig = new FeatureConfig();
+ }
+ return featureConfig;
+ }
- static int getDefaultPort(const string& protocol) {
- if(defaultPorts.count(protocol)) {
- return defaultPorts[protocol];
- } else {
+ static void release() {
+ delete featureConfig;
+ featureConfig = 0;
+ }
+
+ int getDefaultPort(const string& protocol) const {
+ PortMap::const_iterator itr = defaultPorts.find(protocol);
+ if(itr == defaultPorts.end()) {
return 0;
+ } else {
+ return itr->second;
}
}
- static bool isSupported(const string& protocol) {
- if(supportedFeatures.count(protocol)) {
- return supportedFeatures[protocol];
- } else {
+ bool isSupported(const string& feature) const {
+ FeatureMap::const_iterator itr = supportedFeatures.find(feature);
+ if(itr == supportedFeatures.end()) {
return false;
+ } else {
+ return itr->second;
}
}
-
- static string getConfigurationSummary() {
- string protos[] = {
- FEATURE_HTTP,
- FEATURE_HTTPS,
- FEATURE_FTP,
- FEATURE_BITTORRENT,
- FEATURE_METALINK
- };
+
+ const Strings& getFeatures() const {
+ return features;
+ }
+
+ string getConfigurationSummary() const {
string summary;
- for(int i = 0; i < (int)(sizeof(protos)/sizeof(string)); i++) {
- summary += protos[i];
- if(isSupported(protos[i])) {
+ for(Strings::const_iterator itr = features.begin();
+ itr != features.end(); itr++) {
+ summary += *itr;
+ if(isSupported(*itr)) {
summary += ": yes";
} else {
summary += ": no";