8 #ifndef BENCODING_BITEM_H 9 #define BENCODING_BITEM_H 20 class BItem:
public std::enable_shared_from_this<BItem> {
47 std::shared_ptr<T>
as() {
48 static_assert(std::is_base_of<BItem, T>::value,
49 "T has to be a subclass of BItem");
51 return std::dynamic_pointer_cast<T>(shared_from_this());
Base class for all items (integers, strings, etc.).
Definition: BItem.h:20
Base class for all visitors of the BItem subclasses.
Definition: BItemVisitor.h:25
virtual ~BItem()=0
Destructs the item.
std::shared_ptr< T > as()
Casts the item to the given subclass of BItem.
Definition: BItem.h:47
BItem & operator=(const BItem &)=delete
Main namespace of the bencoding library.
BItem()
Constructs the item.
virtual void accept(BItemVisitor *visitor)=0
Accepts the item by the given visitor.