cpp-bencoding
Public Types | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
bencoding::BList Class Reference

Representation of a list. More...

#include <BList.h>

Inheritance diagram for bencoding::BList:
bencoding::BItem

Public Types

using value_type = BItemList::value_type
 Value type. More...
 
using size_type = BItemList::size_type
 Size type. More...
 
using reference = BItemList::reference
 Reference. More...
 
using const_reference = BItemList::const_reference
 Constant reference. More...
 
using iterator = BItemList::iterator
 Iterator (BidirectionalIterator). More...
 
using const_iterator = BItemList::const_iterator
 Constant iterator (constant BidirectionalIterator). More...
 

Public Member Functions

Capacity
size_type size () const
 Returns the number of items in the list. More...
 
bool empty () const
 Checks if the list is empty. More...
 
Modifiers
void push_back (const value_type &bItem)
 Appends the given item to the end of the list. More...
 
void pop_back ()
 Removes the last element of the list. More...
 
Element Access
reference front ()
 Returns a reference to the first item in the list. More...
 
const_reference front () const
 Returns a constant reference to the first item in the list. More...
 
reference back ()
 Returns a reference to the last item in the list. More...
 
const_reference back () const
 Returns a constant reference to the last item in the list. More...
 
Iterators
iterator begin ()
 Returns an iterator to the beginning of the list. More...
 
iterator end ()
 Returns an iterator to the end of the list. More...
 
const_iterator begin () const
 Returns a constant iterator to the beginning of the list. More...
 
const_iterator end () const
 Returns a constant iterator to the end of the list. More...
 
const_iterator cbegin () const
 Returns a constant iterator to the beginning of the list. More...
 
const_iterator cend () const
 Returns a constant iterator to the end of the list. More...
 
BItemVisitor Support
virtual void accept (BItemVisitor *visitor) override
 Accepts the item by the given visitor. More...
 
- Public Member Functions inherited from bencoding::BItem
virtual ~BItem ()=0
 Destructs the item. More...
 
template<typename T >
std::shared_ptr< T > as ()
 Casts the item to the given subclass of BItem. More...
 

Static Public Member Functions

static std::unique_ptr< BListcreate ()
 Creates and returns a new list. More...
 
static std::unique_ptr< BListcreate (std::initializer_list< value_type > items)
 Creates a returns a new list containing the given items. More...
 

Private Types

using BItemList = std::list< std::shared_ptr< BItem > >
 List of items. More...
 

Private Member Functions

 BList ()
 Constructs an empty list. More...
 
 BList (std::initializer_list< value_type > items)
 Constructs a list containing the given items. More...
 

Private Attributes

BItemList itemList
 Underlying list of items. More...
 

Additional Inherited Members

- Protected Member Functions inherited from bencoding::BItem
 BItem ()
 Constructs the item. More...
 

Detailed Description

Representation of a list.

The interface models the interface of std::list.

Use create() to create instances of the class.

Member Typedef Documentation

◆ BItemList

using bencoding::BList::BItemList = std::list<std::shared_ptr<BItem> >
private

List of items.

◆ const_iterator

using bencoding::BList::const_iterator = BItemList::const_iterator

Constant iterator (constant BidirectionalIterator).

◆ const_reference

using bencoding::BList::const_reference = BItemList::const_reference

Constant reference.

◆ iterator

using bencoding::BList::iterator = BItemList::iterator

Iterator (BidirectionalIterator).

◆ reference

using bencoding::BList::reference = BItemList::reference

Reference.

◆ size_type

using bencoding::BList::size_type = BItemList::size_type

Size type.

◆ value_type

using bencoding::BList::value_type = BItemList::value_type

Value type.

Constructor & Destructor Documentation

◆ BList() [1/2]

bencoding::BList::BList ( )
privatedefault

Constructs an empty list.

◆ BList() [2/2]

bencoding::BList::BList ( std::initializer_list< value_type items)
explicitprivate

Constructs a list containing the given items.

Member Function Documentation

◆ accept()

void bencoding::BList::accept ( BItemVisitor visitor)
overridevirtual

Accepts the item by the given visitor.

Subclasses should implement this function in this way:

void Subclass::accept(BItemVisitor *visitor) {
visitor->visit(this);
}

Implements bencoding::BItem.

◆ back() [1/2]

BList::reference bencoding::BList::back ( )

Returns a reference to the last item in the list.

Preconditions
  • list is non-empty

◆ back() [2/2]

BList::const_reference bencoding::BList::back ( ) const

Returns a constant reference to the last item in the list.

Preconditions
  • list is non-empty

◆ begin() [1/2]

BList::iterator bencoding::BList::begin ( )

Returns an iterator to the beginning of the list.

◆ begin() [2/2]

BList::const_iterator bencoding::BList::begin ( ) const

Returns a constant iterator to the beginning of the list.

◆ cbegin()

BList::const_iterator bencoding::BList::cbegin ( ) const

Returns a constant iterator to the beginning of the list.

◆ cend()

BList::const_iterator bencoding::BList::cend ( ) const

Returns a constant iterator to the end of the list.

◆ create() [1/2]

std::unique_ptr< BList > bencoding::BList::create ( )
static

Creates and returns a new list.

◆ create() [2/2]

std::unique_ptr< BList > bencoding::BList::create ( std::initializer_list< value_type items)
static

Creates a returns a new list containing the given items.

◆ empty()

bool bencoding::BList::empty ( ) const

Checks if the list is empty.

Returns
true if the list is empty, false otherwise.

◆ end() [1/2]

BList::iterator bencoding::BList::end ( )

Returns an iterator to the end of the list.

◆ end() [2/2]

BList::const_iterator bencoding::BList::end ( ) const

Returns a constant iterator to the end of the list.

◆ front() [1/2]

BList::reference bencoding::BList::front ( )

Returns a reference to the first item in the list.

Preconditions
  • list is non-empty

◆ front() [2/2]

BList::const_reference bencoding::BList::front ( ) const

Returns a constant reference to the first item in the list.

Preconditions
  • list is non-empty

◆ pop_back()

void bencoding::BList::pop_back ( )

Removes the last element of the list.

References and iterators to the erased element are invalidated.

Preconditions
  • list is non-empty

◆ push_back()

void bencoding::BList::push_back ( const value_type bItem)

Appends the given item to the end of the list.

Preconditions
  • bItem is non-null

◆ size()

BList::size_type bencoding::BList::size ( ) const

Returns the number of items in the list.

Member Data Documentation

◆ itemList

BItemList bencoding::BList::itemList
private

Underlying list of items.


The documentation for this class was generated from the following files: