Пример #1
0
std::list<LedgerEntry>::const_iterator
LedgerStateRoot::Impl::loadOffers(StatementContext& prep,
                                  std::list<LedgerEntry>& offers) const
{
    std::string actIDStrKey;
    unsigned int sellingAssetType, buyingAssetType;
    std::string sellingAssetCode, buyingAssetCode, sellingIssuerStrKey,
        buyingIssuerStrKey;
    soci::indicator sellingAssetCodeIndicator, buyingAssetCodeIndicator,
        sellingIssuerIndicator, buyingIssuerIndicator;

    LedgerEntry le;
    le.data.type(OFFER);
    OfferEntry& oe = le.data.offer();

    auto& st = prep.statement();
    st.exchange(soci::into(actIDStrKey));
    st.exchange(soci::into(oe.offerID));
    st.exchange(soci::into(sellingAssetType));
    st.exchange(soci::into(sellingAssetCode, sellingAssetCodeIndicator));
    st.exchange(soci::into(sellingIssuerStrKey, sellingIssuerIndicator));
    st.exchange(soci::into(buyingAssetType));
    st.exchange(soci::into(buyingAssetCode, buyingAssetCodeIndicator));
    st.exchange(soci::into(buyingIssuerStrKey, buyingIssuerIndicator));
    st.exchange(soci::into(oe.amount));
    st.exchange(soci::into(oe.price.n));
    st.exchange(soci::into(oe.price.d));
    st.exchange(soci::into(oe.flags));
    st.exchange(soci::into(le.lastModifiedLedgerSeq));
    st.define_and_bind();
    st.execute(true);

    auto iterNext = offers.cend();
    while (st.got_data())
    {
        oe.sellerID = KeyUtils::fromStrKey<PublicKey>(actIDStrKey);
        processAsset(oe.selling, (AssetType)sellingAssetType,
                     sellingIssuerStrKey, sellingIssuerIndicator,
                     sellingAssetCode, sellingAssetCodeIndicator);
        processAsset(oe.buying, (AssetType)buyingAssetType, buyingIssuerStrKey,
                     buyingIssuerIndicator, buyingAssetCode,
                     buyingAssetCodeIndicator);

        if (iterNext == offers.cend())
        {
            iterNext = offers.emplace(iterNext, le);
        }
        else
        {
            offers.emplace_back(le);
        }
        st.fetch();
    }

    return iterNext;
}
 task_handle schedule(task_type&& task, const time_point& start, const duration& repeat=duration::zero()) {
     task_handle h;
     {
         std::lock_guard<std::mutex> lk(mutex);
         h = tasks.emplace(tasks.end(), std::move(task), start, repeat);
         handles.push_back(h);
     }
     tasks_updated.notify_all();
     return h;
 }
Пример #3
0
		template<class... Ts>void init(Ts... args)
		{
			init_impl(args...);
			if (sizeof...(Ts) <= 1)
				return;
			auto ite = sentence.begin();
			auto before = sentence.begin();
			++ite;
			auto end = sentence.end();
			for (; ite != end; ++ite)
			{
				before = std::prev(ite);
				if ((*before).type_ == parse_helper::data_type::token &&
					(*ite).type_ == parse_helper::data_type::token)
				{
					sentence.emplace(ite, " ");
					sentence.emplace(ite, placeholder::space_holder);
				}
				else if ((*before).type_ == parse_helper::data_type::token &&
					(*ite).type_ == parse_helper::data_type::string&&
					token_string_check(*(*ite).str_.c_str()))
				{
					sentence.emplace(ite, " ");
					sentence.emplace(ite, placeholder::space_holder);
				}
				else if((*ite).type_ == parse_helper::data_type::token &&
					(*before).type_ == parse_helper::data_type::string &&
					token_string_check(*(std::prev((*before).str_.end()))))
				{
					sentence.emplace(ite, " ");
					sentence.emplace(ite, placeholder::space_holder);
				}
			}
		}
Пример #4
0
 // Allocates a buffer that lives for the entire life time of the app
 // Used by HOOK_SetImgDscName
 const char* AllocBufferForString(const char* str)
 {
     static std::list<std::string> buffers;
     return buffers.emplace(buffers.end(), str)->c_str();
 }
void good_emplace_list1(std::list<int> &L, int n) {
  auto i1 = L.cbegin(), i0 = i1++;
  L.emplace(i1, n);
  *i0; // no-warning
  *i1; // no-warning
}
Пример #6
0
 auto& emplace(Args&&... args)
 {
   auto& n = *m_children.emplace(std::forward<Args>(args)...);
   n.setParent(this);
   return n;
 }