summaryrefslogtreecommitdiff
path: root/src/bencode.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2008-12-14 03:59:24 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2008-12-14 03:59:24 +0000
commitb618ada28a49ed0e493647a6ea149bcd993129c1 (patch)
tree636f159a851b743a68d4746a12ebba687c560336 /src/bencode.cc
parenta67ed743a22b78c441af2db49816aa7ccadb7fd0 (diff)
2008-12-14 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Added missing #ifdef guard. Added uc() function for String and removeKey() for Dict. * src/bencode.cc * src/bencode.h * test/BencodeTest.cc
Diffstat (limited to 'src/bencode.cc')
-rw-r--r--src/bencode.cc17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/bencode.cc b/src/bencode.cc
index 60a790a2..ec60544f 100644
--- a/src/bencode.cc
+++ b/src/bencode.cc
@@ -120,6 +120,15 @@ const std::string& BDE::s() const throw(RecoverableException)
}
}
+const unsigned char* BDE::uc() const throw(RecoverableException)
+{
+ if(isString()) {
+ return reinterpret_cast<const unsigned char*>(_string->data());
+ } else {
+ throw RecoverableException("Not String");
+ }
+}
+
// Dictionary Interface
bool BDE::isDict() const throw()
@@ -160,6 +169,14 @@ bool BDE::containsKey(const std::string& key) const throw(RecoverableException)
}
}
+void BDE::removeKey(const std::string& key) const throw(RecoverableException)
+{
+ if(isDict()) {
+ _dict->erase(key);
+ } else {
+ throw RecoverableException("Not Dict");
+ }
+}
BDE::Dict::iterator BDE::dictBegin() throw(RecoverableException)
{