suppose I declare:
struct [[eosio::table]] tst {
asset component;
uint64_t primary_key() const {
return component.symbol.code().raw();
}
};
where I mean to keep a list of assets. when it's time to find a record in the table I want to do something like:
void token::find(char *symbol) {
tst t(_self, _self.value);
auto o = t.find(symbol);
but this results in an error:
t.cpp:127:20: error: cannot initialize a parameter of type 'uint64_t' (aka 'unsigned long long') with an lvalue of type 'char *' auto o = t.find(symbol);
changing the parameter definition to:
void token::find(std::string symbol) {
produces a similar message:
t.cpp:127:20: error: no viable conversion from 'std::string' (aka 'basic_string, allocator >') to 'uint64_t' (aka 'unsigned long long') auto o = t.find(symbol);
in other code I've seen these finds done given an asset. something like this works:
auto o = t.find(someAsset.symbol.code().raw());
which ultimately resolves to a uint64_t
so I need somehow to convert my string to an integer. can anyone provide a hint as to how I might do this?