コード例 #1
0
ファイル: hash.hpp プロジェクト: PutiZL/ironbee
    /**
     * 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
0
ファイル: hash.hpp プロジェクト: PutiZL/ironbee
 /**
  * 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
0
ファイル: standard_string.cpp プロジェクト: robguima/ironbee
    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
0
ファイル: action.cpp プロジェクト: B0SB05/ironbee
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
0
ファイル: operator.cpp プロジェクト: B0SB05/ironbee
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
0
ファイル: list.hpp プロジェクト: B0SB05/ironbee
 /**
  * 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);
 }