Equity
Bitcoin Protocol Library
Classes | Functions
P2p Namespace Reference

Classes

class  BitArray
 An array of bits. More...
 
class  DeserializationError
 Exception thrown for a deserialization error. More...
 
struct  DeserializeArrayImpl
 A helper class for deserialization of an std::array. More...
 
struct  DeserializeArrayImpl< std::array< uint8_t, N > >
 A helper class for deserialization of a std::array of uint8_t. More...
 
struct  InvalidMessageError
 Thrown by a message constructor if the data in the message is invalid. More...
 
class  Message
 A P2P network message. More...
 
class  Peer
 
class  Serializable
 An abstract class that enables an object to be serialized by the serialization functions. More...
 
struct  SerializeArrayImpl
 A helper class for serialization of an std::array. More...
 
struct  SerializeArrayImpl< uint8_t, N >
 A helper class for serialization of an std::array of uint8_t. More...
 
struct  ToJsonArrayImpl
 A helper class for converting an std::array to JSON. More...
 
struct  ToJsonArrayImpl< uint8_t, N >
 A helper class for converting an std::array<uint8_t, N> to JSON. More...
 
class  VarArray
 An array of objects. More...
 
class  VarArray< std::array< T, N > >
 An array of std::array. More...
 
class  VarArray< uint8_t >
 An array of uint8_t. More...
 
class  VarString
 A variable-length string. More...
 
class  VASize
 A compressed 64-bit value. More...
 

Functions

void serialize (uint8_t const &a, std::vector< uint8_t > &out)
 Serializes a uint8_t. More...
 
void serialize (uint16_t const &a, std::vector< uint8_t > &out)
 Serializes a uint16_t. More...
 
void serialize (uint32_t const &a, std::vector< uint8_t > &out)
 Serializes a uint32_t. More...
 
void serialize (uint64_t const &a, std::vector< uint8_t > &out)
 Serializes a uint64_t. More...
 
void serialize (std::string const &s, std::vector< uint8_t > &out)
 Serializes an std::string. More...
 
void serialize (char const *s, std::vector< uint8_t > &out)
 Serializes a string. More...
 
template<>
void serialize< uint8_t > (std::vector< uint8_t > const &a, std::vector< uint8_t > &out)
 Serializes a vector of uint8_t. More...
 
template<>
uint8_t deserialize< uint8_t > (uint8_t const *&in, size_t &size)
 Deserializes a uint8_t. More...
 
template<>
uint16_t deserialize< uint16_t > (uint8_t const *&in, size_t &size)
 Deserializes a uint16_t. More...
 
template<>
uint32_t deserialize< uint32_t > (uint8_t const *&in, size_t &size)
 Deserializes a uint32_t. More...
 
template<>
uint64_t deserialize< uint64_t > (uint8_t const *&in, size_t &size)
 Deserializes a uint64_t. More...
 
template<>
std::vector< uint8_t > deserializeVector< uint8_t > (size_t n, uint8_t const *&in, size_t &size)
 Deserializes a vector of uint8_t. More...
 
std::string deserializeString (size_t n, uint8_t const *&in, size_t &size)
 Deserializes a string. More...
 
template<>
json toJson (std::vector< uint8_t > const &v)
 Converts a std::vector<uint8_t> to a JSON hex string toJson. More...
 
void serialize (Serializable const &a, std::vector< uint8_t > &out)
 Serializes a Serializable. More...
 
template<typename T >
void serialize (std::vector< T > const &v, std::vector< uint8_t > &out)
 Serializes an std::vector. More...
 
template<typename T , size_t N>
void serialize (std::vector< std::array< T, N > > const &v, std::vector< uint8_t > &out)
 Serializes a vector of std::array. More...
 
template<typename T , size_t N>
void serialize (std::array< T, N > const &a, std::vector< uint8_t > &out)
 Serializes an std::array. More...
 
json toJson (Serializable const &x)
 Converts a Serializable to JSON object. More...
 
template<typename T >
json toJson (T const *v, size_t size)
 Converts a generic array to a JSON array value toJson. More...
 
template<typename T >
json toJson (std::vector< T > const &v)
 Converts a std::vector to a JSON array value toJson. More...
 
template<typename T , size_t N>
json toJson (std::array< T, N > const &a)
 Converts a generic std::array to a JSON array value. More...
 
template<typename T >
deserialize (uint8_t const *&in, size_t &size)
 Deserializes an object with a deserialization constructor. More...
 
template<typename T >
std::vector< T > deserializeVector (size_t n, uint8_t const *&in, size_t &size)
 Deserializes a vector. More...
 
template<typename T >
deserializeArray (uint8_t const *&in, size_t &size)
 Deserializes an std::array. More...
 
template<typename T , size_t N>
std::vector< std::array< T, N > > deserializeVector (size_t n, uint8_t const *&in, size_t &size)
 Deserializes a vector of std::array. More...
 

Detailed Description

Todo:
Move serialization to Serializer class in Network namespace

Function Documentation

template<typename T >
T P2p::deserialize ( uint8_t const *&  in,
size_t &  size 
)

Deserializes an object with a deserialization constructor.

Parameters
[in,out]inpointer to the next byte to deserialize
[in,out]sizenumber of bytes remaining in the serialized stream
Note
The object being deserialized must have a constructor of the form T(uint8_t const * & in, size_t & size)
template<>
uint16_t P2p::deserialize< uint16_t > ( uint8_t const *&  in,
size_t &  size 
)

Deserializes a uint16_t.

Parameters
[in,out]inpointer to the next byte to deserialize
[in,out]sizenumber of bytes remaining in the serialized stream
template<>
uint32_t P2p::deserialize< uint32_t > ( uint8_t const *&  in,
size_t &  size 
)

Deserializes a uint32_t.

Parameters
[in,out]inpointer to the next byte to deserialize
[in,out]sizenumber of bytes remaining in the serialized stream
template<>
uint64_t P2p::deserialize< uint64_t > ( uint8_t const *&  in,
size_t &  size 
)

Deserializes a uint64_t.

Parameters
[in,out]inpointer to the next byte to deserialize
[in,out]sizenumber of bytes remaining in the serialized stream
template<>
uint8_t P2p::deserialize< uint8_t > ( uint8_t const *&  in,
size_t &  size 
)

Deserializes a uint8_t.

Parameters
[in,out]inpointer to the next byte to deserialize
[in,out]sizenumber of bytes remaining in the serialized stream
template<typename T >
T P2p::deserializeArray ( uint8_t const *&  in,
size_t &  size 
)

Deserializes an std::array.

Parameters
[in,out]inpointer to the next byte to deserialize
[in,out]sizenumber of bytes remaining in the serialized stream
Note
The reason for this ridiculous code is that partial template specialization is not allowed with functions
std::string P2p::deserializeString ( size_t  n,
uint8_t const *&  in,
size_t &  size 
)

Deserializes a string.

Parameters
nNumber of characters to deserialize
[in,out]inpointer to the next byte to deserialize
[in,out]sizenumber of bytes remaining in the serialized stream
template<typename T >
std::vector< T > P2p::deserializeVector ( size_t  n,
uint8_t const *&  in,
size_t &  size 
)

Deserializes a vector.

Parameters
nNumber of elements to deserialize
[in,out]inpointer to the next byte to deserialize
[in,out]sizenumber of bytes remaining in the serialized stream
Note
The elements of the vector must support deserialization
template<typename T , size_t N>
std::vector< std::array< T, N > > P2p::deserializeVector ( size_t  n,
uint8_t const *&  in,
size_t &  size 
)

Deserializes a vector of std::array.

Parameters
nNumber of std::array to deserialize
[in,out]inpointer to the next byte to deserialize
[in,out]sizenumber of bytes remaining in the serialized stream
Note
The elements of the array must support deserialization
template<>
std::vector< uint8_t > P2p::deserializeVector< uint8_t > ( size_t  n,
uint8_t const *&  in,
size_t &  size 
)

Deserializes a vector of uint8_t.

Parameters
nNumber of uint8_t to deserialize
[in,out]inpointer to the next byte to deserialize
[in,out]sizenumber of bytes remaining in the serialized stream
void P2p::serialize ( uint8_t const &  a,
std::vector< uint8_t > &  out 
)

Serializes a uint8_t.

Parameters
avalue to be serialized
outdestination
void P2p::serialize ( uint16_t const &  a,
std::vector< uint8_t > &  out 
)

Serializes a uint16_t.

Parameters
avalue to be serialized
outdestination
void P2p::serialize ( uint32_t const &  a,
std::vector< uint8_t > &  out 
)

Serializes a uint32_t.

Parameters
avalue to be serialized
outdestination
void P2p::serialize ( uint64_t const &  a,
std::vector< uint8_t > &  out 
)

Serializes a uint64_t.

Parameters
avalue to be serialized
outdestination
void P2p::serialize ( std::string const &  s,
std::vector< uint8_t > &  out 
)

Serializes an std::string.

Parameters
sstd::string to be serialized
outdestination
void P2p::serialize ( char const *  s,
std::vector< uint8_t > &  out 
)

Serializes a string.

Parameters
sstring to be serialized
outdestination
void P2p::serialize ( Serializable const &  a,
std::vector< uint8_t > &  out 
)
inline

Serializes a Serializable.

Parameters
aobject to be serialized
outdestination
template<typename T >
void P2p::serialize ( std::vector< T > const &  v,
std::vector< uint8_t > &  out 
)

Serializes an std::vector.

Parameters
vstd::vector to be serialized
outdestination
template<typename T , size_t N>
void P2p::serialize ( std::vector< std::array< T, N > > const &  v,
std::vector< uint8_t > &  out 
)

Serializes a vector of std::array.

Parameters
vstd::vector to be serialized
outdestination
template<typename T , size_t N>
void P2p::serialize ( std::array< T, N > const &  a,
std::vector< uint8_t > &  out 
)

Serializes an std::array.

Parameters
astd::array to be serialized
outdestination
template<>
void P2p::serialize< uint8_t > ( std::vector< uint8_t > const &  a,
std::vector< uint8_t > &  out 
)

Serializes a vector of uint8_t.

Parameters
astd::vector to be serialized
outdestination
template<>
json P2p::toJson ( std::vector< uint8_t > const &  v)

Converts a std::vector<uint8_t> to a JSON hex string toJson.

Parameters
v
json P2p::toJson ( Serializable const &  x)
inline

Converts a Serializable to JSON object.

Parameters
xobject to be serialized
template<typename T >
json P2p::toJson ( T const *  v,
size_t  size 
)

Converts a generic array to a JSON array value toJson.

Parameters
vpointer to array
sizenumber of elements in the array
template<typename T >
json P2p::toJson ( std::vector< T > const &  v)

Converts a std::vector to a JSON array value toJson.

Parameters
vstd::vector to be serialized
template<typename T , size_t N>
json P2p::toJson ( std::array< T, N > const &  a)

Converts a generic std::array to a JSON array value.

Parameters
astd::array to be serialized