Back to Site
Loading...
Searching...
No Matches
librats::BencodeValue Class Reference

Represents a bencoded value which can be: More...

#include <bencode.h>

Public Types

enum class  Type { Integer , String , List , Dictionary }
 

Public Member Functions

 BencodeValue ()
 
 BencodeValue (int64_t value)
 
 BencodeValue (const std::string &value)
 
 BencodeValue (const char *value)
 
 BencodeValue (const BencodeList &value)
 
 BencodeValue (const BencodeDict &value)
 
 BencodeValue (const BencodeValue &other)
 
 BencodeValue (BencodeValue &&other) noexcept
 
BencodeValueoperator= (const BencodeValue &other)
 
BencodeValueoperator= (BencodeValue &&other) noexcept
 
 ~BencodeValue ()
 
Type get_type () const
 
bool is_integer () const
 
bool is_string () const
 
bool is_list () const
 
bool is_dict () const
 
int64_t as_integer () const
 
const std::string & as_string () const
 
const BencodeListas_list () const
 
const BencodeDictas_dict () const
 
BencodeListas_list ()
 
BencodeDictas_dict ()
 
bool has_key (const std::string &key) const
 
const BencodeValueoperator[] (const std::string &key) const
 
BencodeValueoperator[] (const std::string &key)
 
const BencodeValueoperator[] (size_t index) const
 
BencodeValueoperator[] (size_t index)
 
void push_back (const BencodeValue &value)
 
size_t size () const
 
std::vector< uint8_t > encode () const
 
std::string encode_string () const
 

Static Public Member Functions

static BencodeValue create_integer (int64_t value)
 
static BencodeValue create_string (const std::string &value)
 
static BencodeValue create_list ()
 
static BencodeValue create_dict ()
 

Detailed Description

Represents a bencoded value which can be:

  • Integer (signed 64-bit)
  • String (byte string)
  • List (array of bencoded values)
  • Dictionary (map of string keys to bencoded values)

Definition at line 33 of file bencode.h.

Member Enumeration Documentation

◆ Type

enum class librats::BencodeValue::Type
strong
Enumerator
Integer 
String 
List 
Dictionary 

Definition at line 35 of file bencode.h.

Constructor & Destructor Documentation

◆ BencodeValue() [1/8]

librats::BencodeValue::BencodeValue ( )

◆ BencodeValue() [2/8]

librats::BencodeValue::BencodeValue ( int64_t  value)

◆ BencodeValue() [3/8]

librats::BencodeValue::BencodeValue ( const std::string &  value)

◆ BencodeValue() [4/8]

librats::BencodeValue::BencodeValue ( const char *  value)

◆ BencodeValue() [5/8]

librats::BencodeValue::BencodeValue ( const BencodeList value)

◆ BencodeValue() [6/8]

librats::BencodeValue::BencodeValue ( const BencodeDict value)

◆ BencodeValue() [7/8]

librats::BencodeValue::BencodeValue ( const BencodeValue other)

◆ BencodeValue() [8/8]

librats::BencodeValue::BencodeValue ( BencodeValue &&  other)
noexcept

◆ ~BencodeValue()

librats::BencodeValue::~BencodeValue ( )

Member Function Documentation

◆ as_dict() [1/2]

BencodeDict & librats::BencodeValue::as_dict ( )

◆ as_dict() [2/2]

const BencodeDict & librats::BencodeValue::as_dict ( ) const

◆ as_integer()

int64_t librats::BencodeValue::as_integer ( ) const

◆ as_list() [1/2]

BencodeList & librats::BencodeValue::as_list ( )

◆ as_list() [2/2]

const BencodeList & librats::BencodeValue::as_list ( ) const

◆ as_string()

const std::string & librats::BencodeValue::as_string ( ) const

◆ create_dict()

static BencodeValue librats::BencodeValue::create_dict ( )
static

◆ create_integer()

static BencodeValue librats::BencodeValue::create_integer ( int64_t  value)
static

◆ create_list()

static BencodeValue librats::BencodeValue::create_list ( )
static

◆ create_string()

static BencodeValue librats::BencodeValue::create_string ( const std::string &  value)
static

◆ encode()

std::vector< uint8_t > librats::BencodeValue::encode ( ) const

◆ encode_string()

std::string librats::BencodeValue::encode_string ( ) const

◆ get_type()

Type librats::BencodeValue::get_type ( ) const
inline

Definition at line 59 of file bencode.h.

◆ has_key()

bool librats::BencodeValue::has_key ( const std::string &  key) const

◆ is_dict()

bool librats::BencodeValue::is_dict ( ) const
inline

Definition at line 63 of file bencode.h.

References Dictionary.

◆ is_integer()

bool librats::BencodeValue::is_integer ( ) const
inline

Definition at line 60 of file bencode.h.

References Integer.

◆ is_list()

bool librats::BencodeValue::is_list ( ) const
inline

Definition at line 62 of file bencode.h.

References List.

◆ is_string()

bool librats::BencodeValue::is_string ( ) const
inline

Definition at line 61 of file bencode.h.

References String.

◆ operator=() [1/2]

BencodeValue & librats::BencodeValue::operator= ( BencodeValue &&  other)
noexcept

◆ operator=() [2/2]

BencodeValue & librats::BencodeValue::operator= ( const BencodeValue other)

◆ operator[]() [1/4]

BencodeValue & librats::BencodeValue::operator[] ( const std::string &  key)

◆ operator[]() [2/4]

const BencodeValue & librats::BencodeValue::operator[] ( const std::string &  key) const

◆ operator[]() [3/4]

BencodeValue & librats::BencodeValue::operator[] ( size_t  index)

◆ operator[]() [4/4]

const BencodeValue & librats::BencodeValue::operator[] ( size_t  index) const

◆ push_back()

void librats::BencodeValue::push_back ( const BencodeValue value)

◆ size()

size_t librats::BencodeValue::size ( ) const

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