Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
sysio::chain::impl::abi_traverse_context_with_path Struct Reference

#include <abi_serializer.hpp>

Inheritance diagram for sysio::chain::impl::abi_traverse_context_with_path:
Collaboration diagram for sysio::chain::impl::abi_traverse_context_with_path:

Public Member Functions

 abi_traverse_context_with_path (const abi_serializer &abis, abi_serializer::yield_function_t yield, const std::string_view &type)
 
 abi_traverse_context_with_path (const abi_serializer &abis, const abi_traverse_context &ctx, const std::string_view &type)
 
void set_path_root (const std::string_view &type)
 
fc::scoped_exit< std::function< void()> > push_to_path (const path_item &item)
 
void set_array_index_of_path_back (uint32_t i)
 
void hint_array_type_if_in_array ()
 
void hint_struct_type_if_in_array (const map< type_name, struct_def >::const_iterator &itr)
 
void hint_variant_type_if_in_array (const map< type_name, variant_def >::const_iterator &itr)
 
string get_path_string () const
 
string maybe_shorten (const std::string_view &str)
 
- Public Member Functions inherited from sysio::chain::impl::abi_traverse_context
 abi_traverse_context (abi_serializer::yield_function_t yield)
 
void logging ()
 
bool is_logging () const
 
void check_deadline () const
 
abi_serializer::yield_function_t get_yield_function ()
 
fc::scoped_exit< std::function< void()> > enter_scope ()
 

Public Attributes

bool short_path = false
 

Protected Attributes

const abi_serializerabis
 
path_root root_of_path
 
vector< path_itempath
 
- Protected Attributes inherited from sysio::chain::impl::abi_traverse_context
abi_serializer::yield_function_t yield
 
size_t recursion_depth = 0
 
bool log = false
 

Detailed Description

Definition at line 227 of file abi_serializer.hpp.

Constructor & Destructor Documentation

◆ abi_traverse_context_with_path() [1/2]

sysio::chain::impl::abi_traverse_context_with_path::abi_traverse_context_with_path ( const abi_serializer & abis,
abi_serializer::yield_function_t yield,
const std::string_view & type )
inline

Definition at line 228 of file abi_serializer.hpp.

229 : abi_traverse_context( std::move( yield ) ), abis(abis)
230 {
231 set_path_root(type);
232 }
void set_path_root(const std::string_view &type)
abi_traverse_context(abi_serializer::yield_function_t yield)
abi_serializer::yield_function_t yield
Here is the call graph for this function:

◆ abi_traverse_context_with_path() [2/2]

sysio::chain::impl::abi_traverse_context_with_path::abi_traverse_context_with_path ( const abi_serializer & abis,
const abi_traverse_context & ctx,
const std::string_view & type )
inline

Definition at line 234 of file abi_serializer.hpp.

236 {
237 set_path_root(type);
238 }
Here is the call graph for this function:

Member Function Documentation

◆ get_path_string()

string sysio::chain::impl::abi_traverse_context_with_path::get_path_string ( ) const

Definition at line 844 of file abi_serializer.cpp.

844 {
845 bool full_path = !short_path;
846 bool shorten_names = short_path;
847
848 generate_path_string_visitor visitor(shorten_names, !full_path);
849 if( full_path )
850 std::visit( visitor, root_of_path );
851 for( size_t i = 0, n = path.size(); i < n; ++i ) {
852 if( full_path && !std::holds_alternative<array_index_path_item>(path[i]) )
853 visitor.add_dot();
854
855 std::visit( visitor, path[i] );
856
857 }
858
859 if( !full_path ) {
860 if( std::holds_alternative<empty_path_item>(visitor.last_path_item) ) {
861 std::visit( visitor, root_of_path );
862 } else {
863 path_item_type_visitor vis2(visitor.s, shorten_names);
864 std::visit(vis2, visitor.last_path_item);
865 }
866 }
867
868 return visitor.s.str();
869 }

◆ hint_array_type_if_in_array()

void sysio::chain::impl::abi_traverse_context_with_path::hint_array_type_if_in_array ( )

Definition at line 682 of file abi_serializer.cpp.

682 {
683 if( path.size() == 0 || !std::holds_alternative<array_index_path_item>(path.back()) )
684 return;
685
686 std::get<array_index_path_item>(path.back()).type_hint = array_type_path_root{};
687 }

◆ hint_struct_type_if_in_array()

void sysio::chain::impl::abi_traverse_context_with_path::hint_struct_type_if_in_array ( const map< type_name, struct_def >::const_iterator & itr)

Definition at line 689 of file abi_serializer.cpp.

689 {
690 if( path.size() == 0 || !std::holds_alternative<array_index_path_item>(path.back()) )
691 return;
692
693 std::get<array_index_path_item>(path.back()).type_hint = struct_type_path_root{ .struct_itr = itr };
694 }

◆ hint_variant_type_if_in_array()

void sysio::chain::impl::abi_traverse_context_with_path::hint_variant_type_if_in_array ( const map< type_name, variant_def >::const_iterator & itr)

Definition at line 696 of file abi_serializer.cpp.

696 {
697 if( path.size() == 0 || !std::holds_alternative<array_index_path_item>(path.back()) )
698 return;
699
700 std::get<array_index_path_item>(path.back()).type_hint = variant_type_path_root{ .variant_itr = itr };
701 }

◆ maybe_shorten()

string sysio::chain::impl::abi_traverse_context_with_path::maybe_shorten ( const std::string_view & str)

Definition at line 871 of file abi_serializer.cpp.

871 {
872 if( !short_path )
873 return std::string(str);
874
875 std::stringstream s;
876 output_name( s, str, true );
877 return s.str();
878 }
void output_name(std::ostream &s, const string_view &str, bool shorten, size_t max_length=64)
char * s
Here is the call graph for this function:

◆ push_to_path()

fc::scoped_exit< std::function< void()> > sysio::chain::impl::abi_traverse_context_with_path::push_to_path ( const path_item & item)

Definition at line 660 of file abi_serializer.cpp.

660 {
661 std::function<void()> callback = [this](){
662 SYS_ASSERT( path.size() > 0, abi_exception,
663 "invariant failure in variant_to_binary_context: path is empty on scope exit" );
664 path.pop_back();
665 };
666
667 path.push_back( item );
668
669 return {std::move(callback)};
670 }
#define SYS_ASSERT(expr, exc_type, FORMAT,...)
Definition exceptions.hpp:7

◆ set_array_index_of_path_back()

void sysio::chain::impl::abi_traverse_context_with_path::set_array_index_of_path_back ( uint32_t i)

Definition at line 672 of file abi_serializer.cpp.

672 {
673 SYS_ASSERT( path.size() > 0, abi_exception, "path is empty" );
674
675 auto& b = path.back();
676
677 SYS_ASSERT( std::holds_alternative<array_index_path_item>(b), abi_exception, "trying to set array index without first pushing new array index item" );
678
679 std::get<array_index_path_item>(b).array_index = i;
680 }

◆ set_path_root()

void sysio::chain::impl::abi_traverse_context_with_path::set_path_root ( const std::string_view & type)

Definition at line 642 of file abi_serializer.cpp.

642 {
643 auto rtype = abis.resolve_type(type);
644
645 if( abis.is_array(rtype) ) {
646 root_of_path = array_type_path_root{};
647 } else {
648 auto itr1 = abis.structs.find(rtype);
649 if( itr1 != abis.structs.end() ) {
650 root_of_path = struct_type_path_root{ .struct_itr = itr1 };
651 } else {
652 auto itr2 = abis.variants.find(rtype);
653 if( itr2 != abis.variants.end() ) {
654 root_of_path = variant_type_path_root{ .variant_itr = itr2 };
655 }
656 }
657 }
658 }
std::string_view resolve_type(const std::string_view &t) const
bool is_array(const std::string_view &type) const
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ abis

const abi_serializer& sysio::chain::impl::abi_traverse_context_with_path::abis
protected

Definition at line 254 of file abi_serializer.hpp.

◆ path

vector<path_item> sysio::chain::impl::abi_traverse_context_with_path::path
protected

Definition at line 256 of file abi_serializer.hpp.

◆ root_of_path

path_root sysio::chain::impl::abi_traverse_context_with_path::root_of_path
protected

Definition at line 255 of file abi_serializer.hpp.

◆ short_path

bool sysio::chain::impl::abi_traverse_context_with_path::short_path = false

Definition at line 258 of file abi_serializer.hpp.


The documentation for this struct was generated from the following files: