* New non-template VariableStringSlot and VariableValueSlot.

* Support B, K, M and G in options.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@670 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2006-04-20 20:03:03 +00:00
parent 2f6b5affd1
commit c4256079ae
15 changed files with 427 additions and 179 deletions
+54
View File
@@ -163,4 +163,58 @@ VariableObject::set(const torrent::Object& arg) {
}
}
//
// New and prettified.
//
const torrent::Object&
VariableValueSlot::get() {
m_cache = m_slotGet() / m_unit;
return m_cache;
}
void
VariableValueSlot::set(const torrent::Object& arg) {
value_type value;
switch (arg.type()) {
case torrent::Object::TYPE_STRING:
string_to_value_unit(arg.as_string().c_str(), &value, m_base, m_unit);
// Check if we hit the end of the input.
m_slotSet(value);
break;
case torrent::Object::TYPE_VALUE:
m_slotSet(arg.as_value());
break;
default:
throw torrent::input_error("Not a value");
}
}
const torrent::Object&
VariableStringSlot::get() {
m_cache = m_slotGet();
return m_cache;
}
void
VariableStringSlot::set(const torrent::Object& arg) {
switch (arg.type()) {
case torrent::Object::TYPE_STRING:
m_slotSet(arg.as_string());
break;
case torrent::Object::TYPE_NONE:
m_slotSet(std::string());
break;
default:
throw torrent::input_error("Not a string.");
}
}
}