adding support for more value serialization

This commit is contained in:
Daniel Larimer 2012-12-16 20:13:09 -05:00
parent 12b637970e
commit 6471249bb8
5 changed files with 26 additions and 4 deletions

View file

@ -69,5 +69,9 @@ namespace fc {
path unique_path(); path unique_path();
path temp_directory_path(); path temp_directory_path();
class value;
void pack( fc::value& , const fc::path& );
void unpack( const fc::value& , fc::path& );
} }

View file

@ -1,5 +1,4 @@
#ifndef _FC_IP_HPP_ #pragma once
#define _FC_IP_HPP_
#include <fc/string.hpp> #include <fc/string.hpp>
namespace fc { namespace fc {
@ -47,5 +46,7 @@ namespace fc {
uint32_t _port; uint32_t _port;
}; };
} }
class value;
void pack( fc::value& , const fc::ip::endpoint& );
void unpack( const fc::value& , fc::ip::endpoint& );
} }
#endif // _FC_ENDPOINT_HPP_

View file

@ -2,8 +2,15 @@
#include <fc/fwd_impl.hpp> #include <fc/fwd_impl.hpp>
#include <fc/utility.hpp> #include <fc/utility.hpp>
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
#include <fc/value_cast.hpp>
namespace fc { namespace fc {
void pack( fc::value& v, const fc::path& s ) {
v = s.generic_string();
}
void unpack( const fc::value& v, fc::path& s ) {
s = path(fc::value_cast<fc::string>(v));
}
path::path(){} path::path(){}
path::~path(){}; path::~path(){};

View file

@ -1,4 +1,5 @@
#include <fc/ip.hpp> #include <fc/ip.hpp>
#include <fc/value_cast.hpp>
#include <boost/asio.hpp> #include <boost/asio.hpp>
#include <boost/lexical_cast.hpp> #include <boost/lexical_cast.hpp>
#include <string> #include <string>
@ -53,4 +54,12 @@ namespace fc { namespace ip {
return string(_ip) + ':' + fc::string(boost::lexical_cast<std::string>(_port).c_str()); return string(_ip) + ':' + fc::string(boost::lexical_cast<std::string>(_port).c_str());
} }
} } }
void pack( fc::value& v, const fc::ip::endpoint& s ) {
v = fc::string(s);
}
void unpack( const fc::value& v, fc::ip::endpoint& s ) {
s = fc::ip::endpoint::from_string(fc::value_cast<fc::string>(v));
}
}

View file

@ -3,6 +3,7 @@
#include <fc/exception.hpp> #include <fc/exception.hpp>
#include <fc/raw.hpp> #include <fc/raw.hpp>
#include <fc/value.hpp> #include <fc/value.hpp>
#include <fc/value_cast.hpp>
#include <fc/base58.hpp> #include <fc/base58.hpp>
#include <iostream> #include <iostream>
#include <fc/sha1.hpp> #include <fc/sha1.hpp>