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