本文整理汇总了C++中MemoryManager::ib方法的典型用法代码示例。如果您正苦于以下问题:C++ MemoryManager::ib方法的具体用法?C++ MemoryManager::ib怎么用?C++ MemoryManager::ib使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MemoryManager
的用法示例。
在下文中一共展示了MemoryManager::ib方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: create
/**
* Create new hash with custom hash and equal functions.
*
* @param[in] memory_manager Memory manager to use.
* @param[in] slots Initial size of hash.
* @param[in] hash Function to use to hash keys.
* @param[in] equal Function to use to compare keys.
* @return Empty Hash.
**/
static
Hash create(
MemoryManager memory_manager,
size_t slots,
key_hash_t hash,
key_equal_t equal
)
{
std::pair<ib_hash_function_t, void*> hash_trampoline;
std::pair<ib_hash_equal_t, void*> equal_trampoline;
ib_hash_t* h;
hash_trampoline = make_c_trampoline<
uint32_t(const char*, size_t, uint32_t)
>(hash);
equal_trampoline = make_c_trampoline<
int(const char*, size_t, const char*, size_t)
>(equal);
memory_manager.register_cleanup(
boost::bind(delete_c_trampoline, hash_trampoline.second)
);
memory_manager.register_cleanup(
boost::bind(delete_c_trampoline, equal_trampoline.second)
);
throw_if_error(
ib_hash_create_ex(
&h, memory_manager.ib(), slots,
hash_trampoline.first, hash_trampoline.second,
equal_trampoline.first, equal_trampoline.second
)
);
return Hash(h);
}
示例2: create_nocase
/**
* Create new hash. Case insensitive.
*
* Creates a new case sensitive hash.
*
* @param[in] memory_manager Memory manager to use.
* @param[in] slots Initial size of hash.
* @return Empty Hash.
**/
static Hash create_nocase(MemoryManager memory_manager, size_t slots = 16)
{
ib_hash_t* h;
throw_if_error(
ib_hash_create_ex(
&h, memory_manager.ib(), slots,
&ib_hashfunc_djb2_nocase, NULL,
&ib_hashequal_nocase, NULL
)
);
return Hash(h);
}
示例3: eval_map
Value eval_map(
MemoryManager mm,
const Functional::value_vec_t& secondary_args,
boost::any& map_state,
Value subvalue
) const
{
/* If the subvalue we've been given is NULL, likewise return a NULL
* subvalue. We can't change anything. */
if (! subvalue) {
return Value();
}
if (subvalue.type() != Value::STRING) {
return Value();
}
ConstByteString text = subvalue.as_string();
boost::shared_ptr<vector<char> > result(new vector<char>());
// Ensure that result.data() is non-null, even if we never insert
// anything.
result->reserve(1);
// value_to_data() ensures that a copy is associated with the memory
// pool and will be deleted when the memory pool goes away.
value_to_data(result, mm.ib());
boost::regex_replace(
back_inserter(*result),
text.const_data(), text.const_data() + text.length(),
m_expression,
m_replacement
);
return Value::create_string(
mm,
subvalue.name(), subvalue.name_length(),
ByteString::create_alias(
mm,
result->data(), result->size()
)
);
}
示例4: create
ActionInstance ActionInstance::create(
MemoryManager memory_manager,
Context context,
ConstAction action,
const char* parameters
)
{
ib_action_inst_t* actioninst;
throw_if_error(
ib_action_inst_create(
&actioninst,
memory_manager.ib(),
context.ib(),
action.ib(),
parameters
)
);
return ActionInstance(actioninst);
}
示例5: create
OperatorInstance OperatorInstance::create(
MemoryManager memory_manager,
Context context,
ConstOperator op,
ib_flags_t required_capabilities,
const char* parameters
)
{
ib_operator_inst_t* opinst;
throw_if_error(
ib_operator_inst_create(
&opinst,
memory_manager.ib(),
context.ib(),
op.ib(),
required_capabilities,
parameters
)
);
return OperatorInstance(opinst);
}
示例6: create
/**
* Create new list.
*
* Creates a new empty list using @a memory_manager for memory.
*
* @param[in] memory_manager Memory manager to use.
* @return Empty List.
**/
static List create(MemoryManager memory_manager)
{
ib_list_t* ib_list;
throw_if_error(ib_list_create(&ib_list, memory_manager.ib()));
return List(ib_list);
}