std::string MTNameLookupQT::GetAcctName(const std::string & str_id, const std::string * p_nym_id/*=NULL*/, const std::string * p_server_id/*=NULL*/, const std::string * p_asset_id/*=NULL*/) const { std::string str_result(""); // ------------------------ str_result = this->MTNameLookup::GetAcctName(str_id, p_nym_id, p_server_id, p_asset_id); // ------------------------ if (str_result.empty()) { int nContactID = MTContactHandler::getInstance()->FindContactIDByAcctID(QString::fromStdString(str_id), (NULL == p_nym_id) ? QString("") : QString::fromStdString(*p_nym_id), (NULL == p_server_id) ? QString("") : QString::fromStdString(*p_server_id), (NULL == p_asset_id) ? QString("") : QString::fromStdString(*p_asset_id)); if (nContactID > 0) { QString contact_name = MTContactHandler::getInstance()->GetContactName(nContactID); if (!contact_name.isEmpty()) str_result = contact_name.toStdString(); } } // ------------------------ return str_result; }
std::string AssetContract::formatLongAmount(int64_t lValue, int32_t nFactor, int32_t nPower, const char* szCurrencySymbol, const char* szThousandSeparator, const char* szDecimalPoint) { std::stringstream sss; // Handle negative values if (lValue < 0) { sss << "-"; lValue = -lValue; } if (NULL != szCurrencySymbol) sss << szCurrencySymbol << " "; // For example, if 506 is supposed to be $5.06, then dividing by a factor of // 100 results in 5 dollars (integer value) and 6 cents (fractional value). // Handle integer value with thousand separaters separateThousands(sss, lValue / nFactor, szThousandSeparator); // Handle fractional value if (1 < nFactor) { sss << szDecimalPoint << std::setfill('0') << std::setw(nPower) << (lValue % nFactor); } std::string str_result(sss.str()); return str_result; }
std::string MTNameLookupQT::GetNymName(const std::string & str_id, const std::string * p_server_id/*=NULL*/) const { std::string str_result(""); // ------------------------ str_result = this->MTNameLookup::GetNymName(str_id, p_server_id); // ------------------------ if (str_result.empty()) { int nContactID = MTContactHandler::getInstance()->FindContactIDByNymID(QString::fromStdString(str_id)); if (nContactID > 0) { QString contact_name = MTContactHandler::getInstance()->GetContactName(nContactID); if (!contact_name.isEmpty()) str_result = contact_name.toStdString(); // ----------------------------------------------- if ((NULL != p_server_id) && !p_server_id->empty()) MTContactHandler::getInstance()->NotifyOfNymServerPair(QString::fromStdString(str_id), QString::fromStdString(*p_server_id)); } } // ------------------------ return str_result; }
string remove_headtail_space( const string & s ) { string::const_iterator istart = s.begin() , iend = s.end(); while( istart != iend ) { if( *istart != ' ' ) break; ++istart; } while( iend != istart ) { --iend; if( *iend != ' ' ) { ++iend; break; } } string str_result(istart,iend); return str_result; }