switch to std::vector from fc::vector
This commit is contained in:
parent
6563c12f88
commit
1f3e6739c6
12 changed files with 52 additions and 41 deletions
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
#include <fc/log/appender.hpp>
|
||||
#include <fc/log/logger.hpp>
|
||||
#include <vector>
|
||||
|
||||
namespace fc
|
||||
{
|
||||
|
|
@ -41,7 +42,7 @@ namespace fc
|
|||
|
||||
fc::string format;
|
||||
console_appender::stream::type stream;
|
||||
fc::vector<level_color> level_colors;
|
||||
std::vector<level_color> level_colors;
|
||||
bool flush;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ namespace fc
|
|||
void to_variant( const log_message& l, variant& v );
|
||||
void from_variant( const variant& l, log_message& c );
|
||||
|
||||
typedef fc::vector<log_message> log_messages;
|
||||
typedef std::vector<log_message> log_messages;
|
||||
|
||||
|
||||
} // namespace fc
|
||||
|
|
|
|||
|
|
@ -21,16 +21,16 @@ namespace fc {
|
|||
bool enabled;
|
||||
/// if any appenders are sepecified, then parent's appenders are not set.
|
||||
bool additivity;
|
||||
fc::vector<string> appenders;
|
||||
std::vector<string> appenders;
|
||||
|
||||
logger_config& add_appender( const string& s );
|
||||
};
|
||||
|
||||
struct logging_config {
|
||||
static logging_config default_config();
|
||||
fc::vector<string> includes;
|
||||
fc::vector<appender_config> appenders;
|
||||
fc::vector<logger_config> loggers;
|
||||
std::vector<string> includes;
|
||||
std::vector<appender_config> appenders;
|
||||
std::vector<logger_config> loggers;
|
||||
};
|
||||
|
||||
void configure_logging( const fc::path& log_config );
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
#pragma once
|
||||
#include <fc/vector.hpp>
|
||||
#include <vector>
|
||||
#include <fc/optional.hpp>
|
||||
#include <fc/string.hpp>
|
||||
#include <memory>
|
||||
#include <string.h> // memset
|
||||
|
||||
namespace fc
|
||||
{
|
||||
|
|
@ -35,8 +36,8 @@ namespace fc
|
|||
void from_variant( const variant& var, variant_object& vo );
|
||||
void to_variant( const mutable_variant_object& var, variant& vo );
|
||||
void from_variant( const variant& var, mutable_variant_object& vo );
|
||||
void to_variant( const vector<char>& var, variant& vo );
|
||||
void from_variant( const variant& var, vector<char>& vo );
|
||||
void to_variant( const std::vector<char>& var, variant& vo );
|
||||
void from_variant( const variant& var, std::vector<char>& vo );
|
||||
void to_variant( const time_point& var, variant& vo );
|
||||
void from_variant( const variant& var, time_point& vo );
|
||||
#ifdef __APPLE__
|
||||
|
|
@ -50,7 +51,7 @@ namespace fc
|
|||
template<typename T>
|
||||
void from_variant( const variant& var, std::shared_ptr<T>& vo );
|
||||
|
||||
typedef vector<variant> variants;
|
||||
typedef std::vector<variant> variants;
|
||||
|
||||
/**
|
||||
* @brief stores null, int64, uint64, double, bool, string, vector<variant>,
|
||||
|
|
@ -246,7 +247,7 @@ namespace fc
|
|||
|
||||
/** @ingroup Serializable */
|
||||
template<typename T>
|
||||
void from_variant( const variant& var, vector<T>& tmp )
|
||||
void from_variant( const variant& var, std::vector<T>& tmp )
|
||||
{
|
||||
const variants& vars = var.get_array();
|
||||
tmp.clear();
|
||||
|
|
@ -257,9 +258,9 @@ namespace fc
|
|||
|
||||
/** @ingroup Serializable */
|
||||
template<typename T>
|
||||
void to_variant( const vector<T>& t, variant& v )
|
||||
void to_variant( const std::vector<T>& t, variant& v )
|
||||
{
|
||||
vector<variant> vars(t.size());
|
||||
std::vector<variant> vars(t.size());
|
||||
for( size_t i = 0; i < t.size(); ++i )
|
||||
vars[i] = variant(t[i]);
|
||||
v = vars;
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ namespace fc
|
|||
variant _value;
|
||||
};
|
||||
|
||||
typedef vector< entry >::const_iterator iterator;
|
||||
typedef std::vector< entry >::const_iterator iterator;
|
||||
|
||||
/**
|
||||
* @name Immutable Interface
|
||||
|
|
@ -69,7 +69,7 @@ namespace fc
|
|||
|
||||
template<typename T>
|
||||
variant_object( string key, T&& val )
|
||||
:_key_value( std::make_shared<vector<entry> >() )
|
||||
:_key_value( std::make_shared<std::vector<entry> >() )
|
||||
{
|
||||
*this = variant_object( move(key), variant(forward<T>(val)) );
|
||||
}
|
||||
|
|
@ -86,7 +86,7 @@ namespace fc
|
|||
variant_object& operator=( const mutable_variant_object& );
|
||||
|
||||
private:
|
||||
std::shared_ptr< vector< entry > > _key_value;
|
||||
std::shared_ptr< std::vector< entry > > _key_value;
|
||||
friend class mutable_variant_object;
|
||||
};
|
||||
/** @ingroup Serializable */
|
||||
|
|
@ -112,8 +112,8 @@ namespace fc
|
|||
/** @brief a key/value pair */
|
||||
typedef variant_object::entry entry;
|
||||
|
||||
typedef vector< entry >::iterator iterator;
|
||||
typedef vector< entry >::const_iterator const_iterator;
|
||||
typedef std::vector< entry >::iterator iterator;
|
||||
typedef std::vector< entry >::const_iterator const_iterator;
|
||||
|
||||
/**
|
||||
* @name Immutable Interface
|
||||
|
|
@ -181,7 +181,7 @@ namespace fc
|
|||
|
||||
template<typename T>
|
||||
explicit mutable_variant_object( T&& v )
|
||||
:_key_value( new vector<entry>() )
|
||||
:_key_value( new std::vector<entry>() )
|
||||
{
|
||||
*this = variant(fc::forward<T>(v)).get_object();
|
||||
}
|
||||
|
|
@ -192,7 +192,7 @@ namespace fc
|
|||
mutable_variant_object( string key, variant val );
|
||||
template<typename T>
|
||||
mutable_variant_object( string key, T&& val )
|
||||
:_key_value( new vector<entry>() )
|
||||
:_key_value( new std::vector<entry>() )
|
||||
{
|
||||
set( move(key), variant(forward<T>(val)) );
|
||||
}
|
||||
|
|
@ -205,7 +205,7 @@ namespace fc
|
|||
mutable_variant_object& operator=( const mutable_variant_object& );
|
||||
mutable_variant_object& operator=( const variant_object& );
|
||||
private:
|
||||
std::unique_ptr< vector< entry > > _key_value;
|
||||
std::unique_ptr< std::vector< entry > > _key_value;
|
||||
friend class variant_object;
|
||||
};
|
||||
/** @ingroup Serializable */
|
||||
|
|
|
|||
|
|
@ -3,7 +3,15 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <fc/utility.hpp>
|
||||
#include <vector>
|
||||
|
||||
namespace fc
|
||||
{
|
||||
template<typename T>
|
||||
using vector = std::vector<T>;
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
namespace fc {
|
||||
namespace detail {
|
||||
|
|
@ -400,3 +408,4 @@ namespace fc {
|
|||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -609,12 +609,12 @@ fc::string to_base58( const char* d, size_t s ) {
|
|||
return EncodeBase58( (const unsigned char*)d, (const unsigned char*)d+s ).c_str();
|
||||
}
|
||||
|
||||
fc::vector<char> from_base58( const fc::string& base58_str ) {
|
||||
std::vector<char> from_base58( const fc::string& base58_str ) {
|
||||
std::vector<unsigned char> out;
|
||||
if( !DecodeBase58( base58_str.c_str(), out ) ) {
|
||||
FC_THROW_EXCEPTION( exception, "Unable to decode base58 string ${base58_str}", ("base58_str",base58_str) );
|
||||
}
|
||||
return fc::vector<char>((const char*)out.data(), ((const char*)out.data())+out.size() );
|
||||
return std::vector<char>((const char*)out.data(), ((const char*)out.data())+out.size() );
|
||||
}
|
||||
/**
|
||||
* @return the number of bytes decoded
|
||||
|
|
|
|||
|
|
@ -85,11 +85,11 @@ namespace fc {
|
|||
|
||||
void to_variant( const sha256& bi, variant& v )
|
||||
{
|
||||
v = fc::vector<char>( (const char*)&bi, ((const char*)&bi) + sizeof(bi) );
|
||||
v = std::vector<char>( (const char*)&bi, ((const char*)&bi) + sizeof(bi) );
|
||||
}
|
||||
void from_variant( const variant& v, sha256& bi )
|
||||
{
|
||||
fc::vector<char> ve = v.as< vector<char> >();
|
||||
std::vector<char> ve = v.as< std::vector<char> >();
|
||||
if( ve.size() )
|
||||
{
|
||||
memcpy(&bi, ve.data(), fc::min<size_t>(ve.size(),sizeof(bi)) );
|
||||
|
|
|
|||
|
|
@ -89,11 +89,11 @@ namespace fc {
|
|||
|
||||
void to_variant( const sha512& bi, variant& v )
|
||||
{
|
||||
v = fc::vector<char>( (const char*)&bi, ((const char*)&bi) + sizeof(bi) );
|
||||
v = std::vector<char>( (const char*)&bi, ((const char*)&bi) + sizeof(bi) );
|
||||
}
|
||||
void from_variant( const variant& v, sha512& bi )
|
||||
{
|
||||
fc::vector<char> ve = v.as< vector<char> >();
|
||||
std::vector<char> ve = v.as< std::vector<char> >();
|
||||
if( ve.size() )
|
||||
{
|
||||
memcpy(&bi, ve.data(), fc::min<size_t>(ve.size(),sizeof(bi)) );
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@
|
|||
|
||||
namespace fc
|
||||
{
|
||||
fc::vector<fc::ip::endpoint> resolve( const fc::string& host, uint16_t port )
|
||||
std::vector<fc::ip::endpoint> resolve( const fc::string& host, uint16_t port )
|
||||
{
|
||||
auto ep = fc::asio::tcp::resolve( host, std::to_string(uint64_t(port)) );
|
||||
fc::vector<fc::ip::endpoint> eps;
|
||||
std::vector<fc::ip::endpoint> eps;
|
||||
eps.reserve(ep.size());
|
||||
for( auto itr = ep.begin(); itr != ep.end(); ++itr )
|
||||
eps.push_back( fc::ip::endpoint(itr->address().to_v4().to_ulong(), itr->port()) );
|
||||
|
|
|
|||
|
|
@ -14,16 +14,16 @@ namespace fc
|
|||
void to_variant( const uint16_t& var, variant& vo ) { vo = uint64_t(var); }
|
||||
// TODO: warn on overflow?
|
||||
void from_variant( const variant& var, uint16_t& vo ){ vo = static_cast<uint16_t>(var.as_uint64()); }
|
||||
void to_variant( const vector<char>& var, variant& vo )
|
||||
void to_variant( const std::vector<char>& var, variant& vo )
|
||||
{
|
||||
if( var.size() )
|
||||
vo = variant(base64_encode((unsigned char*)var.data(),var.size()));
|
||||
else vo = "";
|
||||
}
|
||||
void from_variant( const variant& var, vector<char>& vo )
|
||||
void from_variant( const variant& var, std::vector<char>& vo )
|
||||
{
|
||||
std::string b64 = base64_decode( var.as_string() );
|
||||
vo = fc::vector<char>( b64.c_str(), b64.c_str() + b64.size() );
|
||||
vo = std::vector<char>( b64.c_str(), b64.c_str() + b64.size() );
|
||||
}
|
||||
/**
|
||||
* The TypeID is stored in the 'last byte' of the variant.
|
||||
|
|
|
|||
|
|
@ -96,12 +96,12 @@ namespace fc
|
|||
}
|
||||
|
||||
variant_object::variant_object()
|
||||
:_key_value(std::make_shared<fc::vector<entry>>() )
|
||||
:_key_value(std::make_shared<std::vector<entry>>() )
|
||||
{
|
||||
}
|
||||
|
||||
variant_object::variant_object( string key, variant val )
|
||||
: _key_value(std::make_shared<fc::vector<entry>>())
|
||||
: _key_value(std::make_shared<std::vector<entry>>())
|
||||
{
|
||||
//_key_value->push_back(entry(fc::move(key), fc::move(val)));
|
||||
_key_value->emplace_back(entry(fc::move(key), fc::move(val)));
|
||||
|
|
@ -116,12 +116,12 @@ namespace fc
|
|||
variant_object::variant_object( variant_object&& obj)
|
||||
: _key_value( fc::move(obj._key_value) )
|
||||
{
|
||||
obj._key_value = std::make_shared<fc::vector<entry>>();
|
||||
obj._key_value = std::make_shared<std::vector<entry>>();
|
||||
assert( _key_value != nullptr );
|
||||
}
|
||||
|
||||
variant_object::variant_object( const mutable_variant_object& obj )
|
||||
: _key_value(std::make_shared<fc::vector<entry>>(*obj._key_value))
|
||||
: _key_value(std::make_shared<std::vector<entry>>(*obj._key_value))
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -153,7 +153,7 @@ namespace fc
|
|||
variant_object& variant_object::operator=( mutable_variant_object&& obj )
|
||||
{
|
||||
_key_value = fc::move(obj._key_value);
|
||||
obj._key_value.reset( new fc::vector<entry>() );
|
||||
obj._key_value.reset( new std::vector<entry>() );
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
@ -260,23 +260,23 @@ namespace fc
|
|||
}
|
||||
|
||||
mutable_variant_object::mutable_variant_object()
|
||||
:_key_value(new fc::vector<entry>)
|
||||
:_key_value(new std::vector<entry>)
|
||||
{
|
||||
}
|
||||
|
||||
mutable_variant_object::mutable_variant_object( string key, variant val )
|
||||
: _key_value(new fc::vector<entry>())
|
||||
: _key_value(new std::vector<entry>())
|
||||
{
|
||||
_key_value->push_back(entry(fc::move(key), fc::move(val)));
|
||||
}
|
||||
|
||||
mutable_variant_object::mutable_variant_object( const variant_object& obj )
|
||||
: _key_value( new fc::vector<entry>(*obj._key_value) )
|
||||
: _key_value( new std::vector<entry>(*obj._key_value) )
|
||||
{
|
||||
}
|
||||
|
||||
mutable_variant_object::mutable_variant_object( const mutable_variant_object& obj )
|
||||
: _key_value( new fc::vector<entry>(*obj._key_value) )
|
||||
: _key_value( new std::vector<entry>(*obj._key_value) )
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue