Fabcoin Core  0.16.2
P2P Digital Currency
Namespaces | Enumerations | Functions
CommonData.h File Reference
#include <vector>
#include <algorithm>
#include <unordered_set>
#include <type_traits>
#include <cstring>
#include <string>
#include "Common.h"
Include dependency graph for CommonData.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

 dev
 Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c Originally by RenĂ© Nyffenegger.
 

Enumerations

enum  dev::WhenError { dev::WhenError::DontThrow = 0, dev::WhenError::Throw = 1 }
 
enum  dev::HexPrefix { dev::HexPrefix::DontAdd = 0, dev::HexPrefix::Add = 1 }
 

Functions

template<class T >
std::string dev::toHex (T const &_data, int _w=2, HexPrefix _prefix=HexPrefix::DontAdd)
 
bytes dev::fromHex (std::string const &_s, WhenError _throw=WhenError::DontThrow)
 
bool dev::isHex (std::string const &_s) noexcept
 
std::string dev::asString (bytes const &_b)
 Converts byte array to a string containing the same (binary) data. More...
 
std::string dev::asString (bytesConstRef _b)
 Converts byte array ref to a string containing the same (binary) data. More...
 
bytes dev::asBytes (std::string const &_b)
 Converts a string to a byte array containing the string's (byte) data. More...
 
bytes dev::asNibbles (bytesConstRef const &_s)
 
template<class T , class Out >
void dev::toBigEndian (T _val, Out &o_out)
 Converts a templated integer value to the big-endian byte-stream represented on a templated collection. More...
 
template<class T , class _In >
T dev::fromBigEndian (_In const &_bytes)
 Converts a big-endian byte-stream represented on a templated collection to a templated integer value. More...
 
std::string dev::toBigEndianString (u256 _val)
 Convenience functions for toBigEndian. More...
 
std::string dev::toBigEndianString (u160 _val)
 
bytes dev::toBigEndian (u256 _val)
 
bytes dev::toBigEndian (u160 _val)
 
template<class T >
bytes dev::toCompactBigEndian (T _val, unsigned _min=0)
 Convenience function for toBigEndian. More...
 
bytes dev::toCompactBigEndian (byte _val, unsigned _min=0)
 
template<class T >
std::string dev::toCompactBigEndianString (T _val, unsigned _min=0)
 Convenience function for toBigEndian. More...
 
std::string dev::toHex (u256 val, HexPrefix prefix=HexPrefix::DontAdd)
 Convenience function for conversion of a u256 to hex. More...
 
std::string dev::toCompactHex (u256 val, HexPrefix prefix=HexPrefix::DontAdd, unsigned _min=0)
 
std::string dev::escaped (std::string const &_s, bool _all=true)
 Escapes a string into the C-string representation. More...
 
template<class T , class _U >
unsigned dev::commonPrefix (T const &_t, _U const &_u)
 
std::string dev::randomWord ()
 Creates a random, printable, word. More...
 
template<class T >
unsigned dev::bytesRequired (T _i)
 Determine bytes required to encode the given integer value. More...
 
template<class T >
void dev::trimFront (T &_t, unsigned _elements)
 Trims a given number of elements from the front of a collection. More...
 
template<class T , class _U >
void dev::pushFront (T &_t, _U _e)
 Pushes an element on to the front of a collection. More...
 
template<class T >
std::vector< T > & dev::operator+= (std::vector< typename std::enable_if< std::is_pod< T >::value, T >::type > &_a, std::vector< T > const &_b)
 Concatenate two vectors of elements of POD types. More...
 
template<class T >
std::vector< T > & dev::operator+= (std::vector< typename std::enable_if<!std::is_pod< T >::value, T >::type > &_a, std::vector< T > const &_b)
 Concatenate two vectors of elements. More...
 
template<class T , class U >
std::set< T > & dev::operator+= (std::set< T > &_a, U const &_b)
 Insert the contents of a container into a set. More...
 
template<class T , class U >
std::unordered_set< T > & dev::operator+= (std::unordered_set< T > &_a, U const &_b)
 Insert the contents of a container into an unordered_set. More...
 
template<class T , class U >
std::vector< T > & dev::operator+= (std::vector< T > &_a, U const &_b)
 Concatenate the contents of a container onto a vector. More...
 
template<class T , class U >
std::set< Tdev::operator+ (std::set< T > _a, U const &_b)
 Insert the contents of a container into a set. More...
 
template<class T , class U >
std::unordered_set< Tdev::operator+ (std::unordered_set< T > _a, U const &_b)
 Insert the contents of a container into an unordered_set. More...
 
template<class T , class U >
std::vector< Tdev::operator+ (std::vector< T > _a, U const &_b)
 Concatenate the contents of a container onto a vector. More...
 
template<class T >
std::vector< Tdev::operator+ (std::vector< T > const &_a, std::vector< T > const &_b)
 Concatenate two vectors of elements. More...
 
template<class T >
std::set< T > & dev::operator+= (std::set< T > &_a, std::set< T > const &_b)
 Merge two sets of elements. More...
 
template<class T >
std::set< Tdev::operator+ (std::set< T > const &_a, std::set< T > const &_b)
 Merge two sets of elements. More...
 
template<class A , class B >
std::unordered_map< A, B > & dev::operator+= (std::unordered_map< A, B > &_x, std::unordered_map< A, B > const &_y)
 
template<class A , class B >
std::unordered_map< A, B > dev::operator+ (std::unordered_map< A, B > const &_x, std::unordered_map< A, B > const &_y)
 
std::string dev::toString (string32 const &_s)
 Make normal string from fixed-length string. More...
 
template<class T , class U >
std::vector< Tdev::keysOf (std::map< T, U > const &_m)
 
template<class T , class U >
std::vector< Tdev::keysOf (std::unordered_map< T, U > const &_m)
 
template<class T , class U >
std::vector< U > dev::valuesOf (std::map< T, U > const &_m)
 
template<class T , class U >
std::vector< U > dev::valuesOf (std::unordered_map< T, U > const &_m)
 
template<class T , class V >
bool dev::contains (T const &_t, V const &_v)
 

Detailed Description

Author
Gav Wood i@gav.nosp@m.wood.nosp@m..com
Date
2014

Shared algorithms and data types.

Definition in file CommonData.h.