#include <OTStash.hpp>
Definition at line 160 of file OTStash.hpp.
opentxs::OTStash::OTStash |
( |
| ) |
|
opentxs::OTStash::OTStash |
( |
std::string |
str_stash_name | ) |
|
|
inline |
Definition at line 183 of file OTStash.hpp.
184 : m_str_stash_name(str_stash_name)
opentxs::OTStash::OTStash |
( |
const OTString & |
strAssetTypeID, |
|
|
int64_t |
lAmount = 0 |
|
) |
| |
Definition at line 241 of file OTStash.cpp.
243 OTStashItem* pItem =
new OTStashItem(strAssetTypeID, lAmount);
246 m_mapStashItems.insert(
247 std::pair<std::string, OTStashItem*>(strAssetTypeID.Get(), pItem));
opentxs::OTStash::OTStash |
( |
const OTIdentifier & |
theAssetTypeID, |
|
|
int64_t |
lAmount = 0 |
|
) |
| |
Definition at line 250 of file OTStash.cpp.
252 OTStashItem* pItem =
new OTStashItem(theAssetTypeID, lAmount);
255 OTString strAssetTypeID(theAssetTypeID);
257 m_mapStashItems.insert(
258 std::pair<std::string, OTStashItem*>(strAssetTypeID.Get(), pItem));
opentxs::OTStash::~OTStash |
( |
| ) |
|
|
virtual |
Definition at line 261 of file OTStash.cpp.
263 while (!m_mapStashItems.empty()) {
264 OTStashItem* pTemp = m_mapStashItems.begin()->second;
268 m_mapStashItems.erase(m_mapStashItems.begin());
bool opentxs::OTStash::CreditStash |
( |
std::string |
str_asset_type_id, |
|
|
const int64_t & |
lAmount |
|
) |
| |
Definition at line 306 of file OTStash.cpp.
308 OTStashItem* pStashItem =
312 return pStashItem->CreditStash(lAmount);
OTStashItem * GetStash(const std::string &str_asset_type_id)
bool opentxs::OTStash::DebitStash |
( |
std::string |
str_asset_type_id, |
|
|
const int64_t & |
lAmount |
|
) |
| |
Definition at line 315 of file OTStash.cpp.
317 OTStashItem* pStashItem =
321 return pStashItem->DebitStash(lAmount);
OTStashItem * GetStash(const std::string &str_asset_type_id)
int64_t opentxs::OTStash::GetAmount |
( |
std::string |
str_asset_type_id | ) |
|
Definition at line 297 of file OTStash.cpp.
299 OTStashItem* pStashItem =
303 return pStashItem->GetAmount();
OTStashItem * GetStash(const std::string &str_asset_type_id)
const std::string opentxs::OTStash::GetName |
( |
| ) |
const |
|
inline |
Definition at line 167 of file OTStash.hpp.
169 return m_str_stash_name;
OTStashItem * opentxs::OTStash::GetStash |
( |
const std::string & |
str_asset_type_id | ) |
|
Definition at line 275 of file OTStash.cpp.
277 auto it = m_mapStashItems.find(str_asset_type_id);
279 if (m_mapStashItems.end() ==
282 const OTString strAssetTypeID(str_asset_type_id.c_str());
283 OTStashItem* pStashItem =
new OTStashItem(strAssetTypeID);
286 m_mapStashItems.insert(std::pair<std::string, OTStashItem*>(
287 strAssetTypeID.Get(), pStashItem));
291 OTStashItem* pStashItem = it->second;
Definition at line 165 of file OTStash.cpp.
169 if (!strStashName.Exists()) {
170 otErr <<
"OTStash::ReadFromXMLNode: Failed: Empty stash 'name' "
175 m_str_stash_name = strStashName.Get();
180 int32_t nCount = strItemCount.Exists() ? atoi(strItemCount.Get()) : 0;
182 while (nCount-- > 0) {
185 otOut <<
"OTStash::ReadFromXMLNode: Failure: Unable to find "
186 "expected element.\n";
190 if ((xml->getNodeType() == irr::io::EXN_ELEMENT) &&
191 (!strcmp(
"stashItem", xml->getNodeName()))) {
192 OTString strAssetTypeID = xml->getAttributeValue(
194 OTString strAmount = xml->getAttributeValue(
197 if (!strAssetTypeID.Exists() || !strAmount.Exists()) {
198 otErr <<
"OTStash::ReadFromXMLNode: Error loading "
199 "stashItem: Either the assetTypeID ("
200 << strAssetTypeID <<
"), or the balance ("
201 << strAmount <<
") was EMPTY.\n";
206 atol(strAmount.Get())))
208 otErr <<
"OTStash::ReadFromXMLNode: Failed crediting "
209 "stashItem for stash " << strStashName
210 <<
". assetTypeID (" << strAssetTypeID
211 <<
"), balance (" << strAmount <<
").\n";
218 otErr <<
"OTStash::ReadFromXMLNode: Expected stashItem "
227 otOut <<
"*** OTStash::ReadFromXMLNode: Bad data? Expected "
228 "EXN_ELEMENT_END here, but "
229 "didn't get it. Returning -1.\n";
OTLOG_IMPORT OTLogStream otOut
static bool SkipAfterLoadingField(irr::io::IrrXMLReader *&xml)
static bool SkipToElement(irr::io::IrrXMLReader *&xml)
OTLOG_IMPORT OTLogStream otErr
bool CreditStash(std::string str_asset_type_id, const int64_t &lAmount)
void opentxs::OTStash::Serialize |
( |
OTString & |
strAppend | ) |
const |
Definition at line 147 of file OTStash.cpp.
149 strAppend.Concatenate(
"<stash name=\"%s\" count=\"%d\" >\n\n",
150 m_str_stash_name.c_str(), m_mapStashItems.size());
152 for (
auto& it : m_mapStashItems) {
153 const std::string str_asset_type_id = it.first;
154 OTStashItem* pStashItem = it.second;
155 OT_ASSERT((str_asset_type_id.size() > 0) && (
nullptr != pStashItem));
157 strAppend.Concatenate(
158 "<stashItem assetTypeID=\"%s\" balance=\"%lld\" />\n\n",
159 pStashItem->GetAssetTypeID().Get(), pStashItem->GetAmount());
162 strAppend.Concatenate(
"</stash>\n\n");
The documentation for this class was generated from the following files:
- /usr/local/src/opentxs/include/opentxs/core/script/OTStash.hpp
- /usr/local/src/opentxs/src/core/script/OTStash.cpp