cpp-bencoding
BString.h
Go to the documentation of this file.
1 
8 #ifndef BENCODING_BSTRING_H
9 #define BENCODING_BSTRING_H
10 
11 #include <memory>
12 #include <string>
13 
14 #include "BItem.h"
15 
16 namespace bencoding {
17 
23 class BString: public BItem {
24 public:
26  using ValueType = std::string;
27 
28 public:
29  static std::unique_ptr<BString> create(ValueType value);
30 
31  ValueType value() const;
32  void setValue(ValueType value);
33  ValueType::size_type length() const;
34 
37  virtual void accept(BItemVisitor *visitor) override;
39 
40 private:
41  explicit BString(ValueType value);
42 
43 private:
45 };
46 
47 } // namespace bencoding
48 
49 #endif
void setValue(ValueType value)
Sets a new value.
Definition: BString.cpp:36
Base class for all items (integers, strings, etc.).
Definition: BItem.h:20
ValueType::size_type length() const
Returns the number of characters in the string.
Definition: BString.cpp:43
virtual void accept(BItemVisitor *visitor) override
Accepts the item by the given visitor.
Definition: BString.cpp:47
Base class for all visitors of the BItem subclasses.
Definition: BItemVisitor.h:25
ValueType value() const
Returns the string&#39;s value.
Definition: BString.cpp:29
std::string ValueType
Type of the underlying string value.
Definition: BString.h:26
BString(ValueType value)
Constructs the string with the given value.
Definition: BString.cpp:17
Main namespace of the bencoding library.
static std::unique_ptr< BString > create(ValueType value)
Creates and returns a new string.
Definition: BString.cpp:22
Base class for all items (integers, strings, etc.).
ValueType _value
Definition: BString.h:44
Representation of a string.
Definition: BString.h:23