In order to access this information, you must create a struct
as follows:
struct [[eosio::table, eosio::contract("eosio.system")]] user_resources {
name owner;
asset net_weight;
asset cpu_weight;
int64_t ram_bytes = 0;
uint64_t primary_key()const { return owner.value; }
// explicit serialization macro is not necessary, used here only to improve compilation time
EOSLIB_SERIALIZE( user_resources, (owner)(net_weight)(cpu_weight)(ram_bytes) )
};
typedef eosio::multi_index< "userres"_n, user_resources > user_resources_table;
Then, in order to access a user's resources, you can do:
user_resources_table userres( _self, username.value );
auto user = userres.find(username.value);
print("User's NET EOS staked: ",user->net_weight,"\n");
print("User's CPU EOS staked: ",user->_weight,"\n");
print("User's RAM: ",user->ram_bytes,"\n");
Note: I haven't tested this code yet. Please edit appropriately if there is a typo or other mistake