LCOV - code coverage report
Current view: top level - include - BList.h (source / functions) Hit Total Coverage
Test: cpp-bencoding code coverage Lines: 1 1 100.0 %
Date: 2018-04-21 15:28:44 Functions: 3 3 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /**
       2             : * @file      BList.h
       3             : * @copyright (c) 2014 by Petr Zemek (s3rvac@gmail.com) and contributors
       4             : * @license   BSD, see the @c LICENSE file for more details
       5             : * @brief     Representation of a list.
       6             : */
       7             : 
       8             : #ifndef BENCODING_BLIST_H
       9             : #define BENCODING_BLIST_H
      10             : 
      11             : #include <initializer_list>
      12             : #include <list>
      13             : #include <memory>
      14             : 
      15             : #include "BItem.h"
      16             : 
      17             : namespace bencoding {
      18             : 
      19             : /**
      20             : * @brief Representation of a list.
      21             : *
      22             : * The interface models the interface of @c std::list.
      23             : *
      24             : * Use create() to create instances of the class.
      25             : */
      26          76 : class BList: public BItem {
      27             : private:
      28             :     /// List of items.
      29             :     using BItemList = std::list<std::shared_ptr<BItem>>;
      30             : 
      31             : public:
      32             :     /// Value type.
      33             :     using value_type = BItemList::value_type;
      34             : 
      35             :     /// Size type.
      36             :     using size_type = BItemList::size_type;
      37             : 
      38             :     /// Reference.
      39             :     using reference = BItemList::reference;
      40             : 
      41             :     /// Constant reference.
      42             :     using const_reference = BItemList::const_reference;
      43             : 
      44             :     /// Iterator (@c BidirectionalIterator).
      45             :     using iterator = BItemList::iterator;
      46             : 
      47             :     /// Constant iterator (constant @c BidirectionalIterator).
      48             :     using const_iterator = BItemList::const_iterator;
      49             : 
      50             : public:
      51             :     static std::unique_ptr<BList> create();
      52             :     static std::unique_ptr<BList> create(std::initializer_list<value_type> items);
      53             : 
      54             :     /// @name Capacity
      55             :     /// @{
      56             :     size_type size() const;
      57             :     bool empty() const;
      58             :     /// @}
      59             : 
      60             :     /// @name Modifiers
      61             :     /// @{
      62             :     void push_back(const value_type &bItem);
      63             :     void pop_back();
      64             :     /// @}
      65             : 
      66             :     /// @name Element Access
      67             :     /// @{
      68             :     reference front();
      69             :     const_reference front() const;
      70             :     reference back();
      71             :     const_reference back() const;
      72             :     /// @}
      73             : 
      74             :     /// @name Iterators
      75             :     /// @{
      76             :     iterator begin();
      77             :     iterator end();
      78             :     const_iterator begin() const;
      79             :     const_iterator end() const;
      80             :     const_iterator cbegin() const;
      81             :     const_iterator cend() const;
      82             :     /// @}
      83             : 
      84             :     /// @name BItemVisitor Support
      85             :     /// @{
      86             :     virtual void accept(BItemVisitor *visitor) override;
      87             :     /// @}
      88             : 
      89             : private:
      90             :     BList();
      91             :     explicit BList(std::initializer_list<value_type> items);
      92             : 
      93             : private:
      94             :     /// Underlying list of items.
      95             :     BItemList itemList;
      96             : };
      97             : 
      98             : } // namespace bencoding
      99             : 
     100             : #endif

Generated by: LCOV version 1.13