本文整理汇总了C++中std::unordered_multimap::emplace方法的典型用法代码示例。如果您正苦于以下问题:C++ unordered_multimap::emplace方法的具体用法?C++ unordered_multimap::emplace怎么用?C++ unordered_multimap::emplace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::unordered_multimap
的用法示例。
在下文中一共展示了unordered_multimap::emplace方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
bool DataVariantTextPlain::parse
(
const Socket &sock,
const std::chrono::milliseconds &timeout,
std::string &str,
const size_t leftBytes,
const std::unordered_map<std::string, std::string> ¶ms,
std::unordered_multimap<std::string, std::string> &data,
std::unordered_multimap<std::string, FileIncoming> &files
)
{
if (str.empty() )
{
return true;
}
for (size_t var_pos = 0, var_end = 0; std::string::npos != var_end; var_pos = var_end + 1)
{
// Поиск следующего параметра
var_end = str.find('&', var_pos);
// Поиск значения параметра
size_t delimiter = str.find('=', var_pos);
if (delimiter >= var_end)
{
// Получить имя параметра
std::string var_name = str.substr(var_pos, std::string::npos != var_end ? var_end - var_pos : std::string::npos);
// Сохранить параметр с пустым значением
data.emplace(std::move(var_name), "");
}
else
{
// Получить имя параметра
std::string var_name = str.substr(var_pos, delimiter - var_pos);
++delimiter;
// Получить значение параметра
std::string var_value = str.substr(delimiter, std::string::npos != var_end ? var_end - delimiter : std::string::npos);
// Сохранить параметр и значение
data.emplace(std::move(var_name), std::move(var_value) );
}
}
str.clear();
return true;
}
示例2: rawFilesInfoToFilesIncoming
void rawFilesInfoToFilesIncoming(std::unordered_multimap<std::string, HttpServer::FileIncoming> &map, const Utils::raw_fileinfo raw[], const size_t count)
{
for (size_t i = 0; i < count; ++i)
{
map.emplace(raw[i].key ? raw[i].key : "", HttpServer::FileIncoming(raw[i].file_name, raw[i].file_type, raw[i].file_size) );
}
}
示例3: parseCookies
bool parseCookies(const std::string &cookieHeader, std::unordered_multimap<std::string, std::string> &cookies)
{
if (cookieHeader.empty() )
{
return true;
}
for (size_t cur_pos = 0, next_value; std::string::npos != cur_pos; cur_pos = next_value)
{
next_value = cookieHeader.find(';', cur_pos);
size_t delimiter = cookieHeader.find('=', cur_pos);
if (std::string::npos == delimiter || delimiter > next_value)
{
return false;
}
std::string key = cookieHeader.substr(cur_pos, delimiter - cur_pos);
trim(key);
key = urlDecode(key);
++delimiter;
std::string value = cookieHeader.substr(delimiter, std::string::npos != next_value ? next_value - delimiter : next_value);
trim(value);
value = urlDecode(value);
cookies.emplace(std::move(key), std::move(value) );
if (std::string::npos != next_value)
{
++next_value;
}
}
return true;
}
示例4: add
void add( ID id, const POINTER& c ) { components.emplace( id, c ); }
示例5: search_hierarchy_for_matches
void search_hierarchy_for_matches(DexMethod* bridge, DexMethod* bridgee) {
/*
* Direct reference. The only one if it's non-virtual.
*/
auto clstype = bridgee->get_class();
auto name = bridgee->get_name();
auto proto = bridgee->get_proto();
TRACE(BRIDGE, 5, " %s %s %s\n", SHOW(clstype), SHOW(name), SHOW(proto));
m_potential_bridgee_refs.emplace(MethodRef(clstype, name, proto), bridge);
if (!bridgee->is_virtual()) return;
/*
* Search super classes
*
* A bridge method in a derived class may be referred to using the name
* of a super class if a method with a matching signature is defined in
* that super class.
*
* To build the set of potential matches, we accumulate potential refs in
* maybe_refs, and when we find a matching signature in a super class, we
* add everything in maybe_refs to the set.
*/
std::vector<std::pair<MethodRef, DexMethod*>> maybe_refs;
for (auto super = type_class(type_class(clstype)->get_super_class());
super != nullptr;
super = type_class(super->get_super_class())) {
maybe_refs.emplace_back(
MethodRef(super->get_type(), name, proto), bridge);
for (auto vmethod : super->get_vmethods()) {
if (signature_matches(bridgee, vmethod)) {
for (auto DEBUG_ONLY refp : maybe_refs) {
TRACE(BRIDGE,
5,
" %s %s %s\n",
SHOW(std::get<0>(refp.first)),
SHOW(std::get<1>(refp.first)),
SHOW(std::get<2>(refp.first)));
}
m_potential_bridgee_refs.insert(maybe_refs.begin(), maybe_refs.end());
maybe_refs.clear();
}
}
}
/*
* Search sub classes
*
* Easy. Any subclass can refer to the bridgee.
*/
TypeVector subclasses;
get_all_children(clstype, subclasses);
for (auto subclass : subclasses) {
m_potential_bridgee_refs.emplace(MethodRef(subclass, name, proto),
bridge);
TRACE(BRIDGE,
5,
" %s %s %s\n",
SHOW(subclass),
SHOW(name),
SHOW(proto));
}
}
示例6: daemonThreadFunc
//.........这里部分代码省略.........
auto rawTx = rpcClient->CallMethod("getrawtransaction", parameters);
auto data = rawTx.asCString();
auto bufferLength = strlen(data) / 2;
llvm::SmallVector<uint8_t, 65536> buffer;
buffer.resize(bufferLength);
encodeHexString(buffer.begin(), bufferLength, data);
BlockChain::BlockTransaction tx2;
if (!blockChain->processSingleTransaction(buffer.begin(), bufferLength, tx2))
assert("could not read tx" && false);
assert(memcmp(tx2.transactionHash, &txHash, 32) == 0);
uint64_t totalOutput = 0;
bool needBroadcast = false;
auto txIndex = dbHelper.txLoad(txHash, dbTx, NULL, NULL);
if (txIndex == 0)
{
{
boost::unique_lock<boost::mutex> guard(pendingTransactionsMutex);
try
{
txIndex = processTransaction(batch, dbTx, tx2, time(NULL), false, &pendingTransactionIndices, &pendingTransactions);
}
catch (std::exception e)
{
batch.Clear();
continue;
}
}
needBroadcast = true;
dbHelper.txSave(batch, txHash, dbTx);
db->Write(leveldb::WriteOptions(), &batch);
}
{
boost::unique_lock<boost::mutex> guard(pendingTransactionsMutex);
pendingTransactionIndices[txHash] = pendingTransactions.size();
pendingTransactions.emplace_back(txHash, dbTx);
// lastPendingTransactions only holds last N items
if (lastPendingTransactions.size() >= lastPendingTransactionsSize)
lastPendingTransactions.pop_front();
lastPendingTransactions.emplace_back(txHash, dbTx);
for (auto output = dbTx.outputs.begin(); output != dbTx.outputs.end(); ++output)
{
if (output->address.IsNull())
continue;
totalOutput += output->value;
pendingTransactionsByAddress.emplace(output->address, pendingTransactions.size() - 1);
}
for (auto input = dbTx.inputs.begin(); input != dbTx.inputs.end(); ++input)
{
if (input->address.IsNull())
continue;
pendingTransactionsByAddress.emplace(input->address, pendingTransactions.size() - 1);
}
}
if (needBroadcast)
{
Json::Value txResult;
// Broadcast tx for live update
txResult["item"] = "tx";
txResult["output"] = (double)totalOutput;
char timeBuffer[65];
convertTime(dbTx.getBestTimeStamp(), timeBuffer, sizeof(timeBuffer));
txResult["time"] = timeBuffer;
txResult["coinage_destroyed"] = dbTx.coinAgeDestroyed / 86400.0;
txResult["hash"] = *tx;
websocket_server.broadcast_livetx(txResult.toStyledString().c_str());
}
}
}
}
catch (std::exception e)
{
boost::lock_guard<boost::mutex> guard(pendingTransactionsMutex);
pendingTransactionIndices.clear();
pendingTransactions.clear();
pendingTransactionsByAddress.clear();
printf("Error processing live transactions: %s!\n", e.what());
}
}
}
示例7: getIncomingVars
static void getIncomingVars(
std::unordered_multimap<std::string, std::string> ¶ms,
const std::string &uri
) {
const size_t start = uri.find('?');
if (std::string::npos == start) {
return;
}
const size_t finish = uri.find('#');
if (finish < start) {
return;
}
for (
size_t var_pos = start + 1, var_end = 0;
std::string::npos != var_end;
var_pos = var_end + 1
) {
var_end = uri.find('&', var_pos);
if (var_end > finish) {
var_end = std::string::npos;
}
size_t delimiter = uri.find('=', var_pos);
if (delimiter >= var_end) {
std::string var_name = Utils::urlDecode(
uri.substr(
var_pos,
std::string::npos != var_end
? var_end - var_pos
: std::string::npos
)
);
params.emplace(
std::move(var_name),
std::string()
);
} else {
std::string var_name = Utils::urlDecode(
uri.substr(
var_pos,
delimiter - var_pos
)
);
++delimiter;
std::string var_value = Utils::urlDecode(
uri.substr(
delimiter,
std::string::npos != var_end
? var_end - delimiter
: std::string::npos
)
);
params.emplace(
std::move(var_name),
std::move(var_value)
);
}
}
}