2006-02-17 13:35:04 +00:00
|
|
|
/* <!-- copyright */
|
|
|
|
/*
|
2006-09-21 15:31:24 +00:00
|
|
|
* aria2 - The high speed download utility
|
2006-02-17 13:35:04 +00:00
|
|
|
*
|
|
|
|
* 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
|
2010-01-05 16:01:46 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2006-09-21 15:31:24 +00:00
|
|
|
*
|
|
|
|
* 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.
|
2006-02-17 13:35:04 +00:00
|
|
|
*/
|
|
|
|
/* copyright --> */
|
2010-10-31 07:23:53 +00:00
|
|
|
#ifndef D_OPTION_H
|
|
|
|
#define D_OPTION_H
|
2006-02-17 13:35:04 +00:00
|
|
|
|
2006-02-28 02:25:45 +00:00
|
|
|
#include "common.h"
|
2011-10-21 12:56:42 +00:00
|
|
|
|
2006-02-17 13:35:04 +00:00
|
|
|
#include <string>
|
2011-10-21 12:56:42 +00:00
|
|
|
#include <vector>
|
2013-06-21 16:10:38 +00:00
|
|
|
#include <memory>
|
2013-04-11 12:44:30 +00:00
|
|
|
|
2013-09-23 06:48:22 +00:00
|
|
|
#include "prefs.h"
|
2006-02-17 13:35:04 +00:00
|
|
|
|
2013-09-23 06:48:22 +00:00
|
|
|
namespace aria2 {
|
2011-10-21 12:56:42 +00:00
|
|
|
|
2006-02-17 13:35:04 +00:00
|
|
|
class Option {
|
|
|
|
private:
|
2011-10-21 12:56:42 +00:00
|
|
|
std::vector<std::string> table_;
|
|
|
|
std::vector<unsigned char> use_;
|
2013-06-21 16:10:38 +00:00
|
|
|
std::shared_ptr<Option> parent_;
|
2015-12-27 09:39:47 +00:00
|
|
|
|
2006-02-17 13:35:04 +00:00
|
|
|
public:
|
|
|
|
Option();
|
|
|
|
~Option();
|
2011-10-21 12:56:42 +00:00
|
|
|
Option(const Option& option);
|
|
|
|
Option& operator=(const Option& option);
|
2006-02-17 13:35:04 +00:00
|
|
|
|
2013-08-25 15:36:53 +00:00
|
|
|
void put(PrefPtr pref, const std::string& value);
|
2013-04-11 12:44:30 +00:00
|
|
|
// Returns true if name is defined. Otherwise returns false. Note
|
|
|
|
// that even if the value is a empty string, this method returns
|
|
|
|
// true. If option is not defined in this object and parent_ is not
|
|
|
|
// NULL, lookup parent_ to check |pref| is defined.
|
2013-08-25 15:36:53 +00:00
|
|
|
bool defined(PrefPtr pref) const;
|
2013-04-11 12:44:30 +00:00
|
|
|
// Just like defined(), but this function does not lookup parent_.
|
2013-08-25 15:36:53 +00:00
|
|
|
bool definedLocal(PrefPtr pref) const;
|
2008-12-04 13:05:05 +00:00
|
|
|
// Returns true if name is not defined or the value is a empty string.
|
|
|
|
// Otherwise returns false.
|
2013-08-25 15:36:53 +00:00
|
|
|
bool blank(PrefPtr pref) const;
|
2013-04-11 12:44:30 +00:00
|
|
|
// Returns option value for |pref|. If the |pref| is not defined in
|
|
|
|
// this object, parent_ is looked up.
|
2013-08-25 15:36:53 +00:00
|
|
|
const std::string& get(PrefPtr pref) const;
|
|
|
|
int32_t getAsInt(PrefPtr pref) const;
|
|
|
|
int64_t getAsLLInt(PrefPtr pref) const;
|
|
|
|
bool getAsBool(PrefPtr pref) const;
|
|
|
|
double getAsDouble(PrefPtr pref) const;
|
2013-04-11 12:44:30 +00:00
|
|
|
// Removes |pref| from this object. This function does not modify
|
|
|
|
// parent_.
|
2015-11-28 03:45:05 +00:00
|
|
|
void removeLocal(PrefPtr pref);
|
|
|
|
// Removes |pref| from this object from all option hierarchy.
|
2013-08-25 15:36:53 +00:00
|
|
|
void remove(PrefPtr pref);
|
2013-04-11 12:44:30 +00:00
|
|
|
// Removes all option values from this object. This function does
|
|
|
|
// not modify parent_.
|
2007-03-26 12:16:57 +00:00
|
|
|
void clear();
|
2013-04-11 12:44:30 +00:00
|
|
|
// Returns the option value table of this object. It does not
|
|
|
|
// contain option values in parent_ and so forth.
|
2015-12-27 09:39:47 +00:00
|
|
|
const std::vector<std::string>& getTable() const { return table_; }
|
2013-04-11 12:44:30 +00:00
|
|
|
// Copy option values defined in option to this option. parent_ is
|
|
|
|
// left unmodified for this object.
|
2011-10-22 10:08:20 +00:00
|
|
|
void merge(const Option& option);
|
2013-04-11 12:44:30 +00:00
|
|
|
// Sets parent Option object for this object.
|
2013-06-21 16:10:38 +00:00
|
|
|
void setParent(const std::shared_ptr<Option>& parent);
|
|
|
|
const std::shared_ptr<Option>& getParent() const;
|
2016-05-06 09:23:44 +00:00
|
|
|
// Returns true if there is no option stored.
|
|
|
|
bool emptyLocal() const;
|
2006-02-17 13:35:04 +00:00
|
|
|
};
|
|
|
|
|
2008-02-08 15:53:45 +00:00
|
|
|
} // namespace aria2
|
|
|
|
|
2010-10-31 07:23:53 +00:00
|
|
|
#endif // D_OPTION_H
|