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

Representation of a string. More...

#include <BString.h>

Inheritance diagram for bencoding::BString:
bencoding::BItem

Public Types

using ValueType = std::string
 Type of the underlying string value. More...
 

Public Member Functions

ValueType value () const
 Returns the string's value. More...
 
void setValue (ValueType value)
 Sets a new value. More...
 
ValueType::size_type length () const
 Returns the number of characters in the string. 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< BStringcreate (ValueType value)
 Creates and returns a new string. More...
 

Private Member Functions

 BString (ValueType value)
 Constructs the string with the given value. More...
 

Private Attributes

ValueType _value
 

Additional Inherited Members

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

Detailed Description

Representation of a string.

Use create() to create instances of the class.

Member Typedef Documentation

◆ ValueType

using bencoding::BString::ValueType = std::string

Type of the underlying string value.

Constructor & Destructor Documentation

◆ BString()

bencoding::BString::BString ( ValueType  value)
explicitprivate

Constructs the string with the given value.

Member Function Documentation

◆ accept()

void bencoding::BString::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.

◆ create()

std::unique_ptr< BString > bencoding::BString::create ( ValueType  value)
static

Creates and returns a new string.

◆ length()

auto bencoding::BString::length ( ) const

Returns the number of characters in the string.

◆ setValue()

void bencoding::BString::setValue ( ValueType  value)

Sets a new value.

◆ value()

auto bencoding::BString::value ( ) const

Returns the string's value.

Member Data Documentation

◆ _value

ValueType bencoding::BString::_value
private

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