本文整理汇总了C++中Account::GetInstrumentDefinitionID方法的典型用法代码示例。如果您正苦于以下问题:C++ Account::GetInstrumentDefinitionID方法的具体用法?C++ Account::GetInstrumentDefinitionID怎么用?C++ Account::GetInstrumentDefinitionID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Account
的用法示例。
在下文中一共展示了Account::GetInstrumentDefinitionID方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddAccountRecord
bool AssetContract::AddAccountRecord(const Account& theAccount) const // adds
// the
// account
// to the
// list.
// (When
// account
// is
// created.)
{
// Load up account list StringMap. Create it if doesn't already exist.
// See if account is already there in the map. Add it otherwise.
// Save the StringMap back again. (The account records list for a given
// instrument definition.)
const char* szFunc = "OTAssetContract::AddAccountRecord";
if (theAccount.GetInstrumentDefinitionID() != m_ID) {
otErr << szFunc << ": Error: theAccount doesn't have the same asset "
"type ID as *this does.\n";
return false;
}
const Identifier theAcctID(theAccount);
const String strAcctID(theAcctID);
String strInstrumentDefinitionID, strAcctRecordFile;
GetIdentifier(strInstrumentDefinitionID);
strAcctRecordFile.Format("%s.a", strInstrumentDefinitionID.Get());
OTDB::Storable* pStorable = nullptr;
std::unique_ptr<OTDB::Storable> theAngel;
OTDB::StringMap* pMap = nullptr;
if (OTDB::Exists(OTFolders::Contract().Get(),
strAcctRecordFile.Get())) // the file already exists; let's
// try to load it up.
pStorable = OTDB::QueryObject(OTDB::STORED_OBJ_STRING_MAP,
OTFolders::Contract().Get(),
strAcctRecordFile.Get());
else // the account records file (for this instrument definition) doesn't
// exist.
pStorable = OTDB::CreateObject(
OTDB::STORED_OBJ_STRING_MAP); // this asserts already, on failure.
theAngel.reset(pStorable);
pMap = (nullptr == pStorable) ? nullptr
: dynamic_cast<OTDB::StringMap*>(pStorable);
// It exists.
//
if (nullptr == pMap) {
otErr << szFunc
<< ": Error: failed trying to load or create the account records "
"file for instrument definition: " << strInstrumentDefinitionID
<< "\n";
return false;
}
auto& theMap = pMap->the_map;
auto map_it = theMap.find(strAcctID.Get());
if (theMap.end() != map_it) // we found it.
{ // We were ADDING IT, but it was ALREADY THERE.
// (Thus, we're ALREADY DONE.)
// Let's just make sure the right instrument definition ID is associated
// with this
// account
// (it better be, since we loaded the account records file based on the
// instrument definition ID as its filename...)
//
const std::string& str2 = map_it->second; // Containing the instrument
// definition ID. (Just in
// case
// someone copied the wrong file here,
// -------------------------------- // every account should map
// to the SAME instrument definition id.)
if (false == strInstrumentDefinitionID.Compare(str2.c_str())) // should
// never
// happen.
{
otErr << szFunc << ": Error: wrong instrument definition found in "
"account records "
"file...\n For instrument definition: "
<< strInstrumentDefinitionID << "\n "
"For account: " << strAcctID
<< "\n Found wrong instrument definition: " << str2 << "\n";
return false;
}
return true; // already there (no need to add.) + the instrument
// definition ID
// matches.
}
// it wasn't already on the list...
// ...so add it.
//
//.........这里部分代码省略.........