text:
// Boost.TypeErasure library
//
// Copyright 2012 Steven Watanabe
//
// Distributed under the Boost Software License Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// $Id: test_same_type.cpp 78459 2012-05-13 18:20:31Z steven_watanabe $

#include <boost/type_erasure/any.hpp>
#include <boost/type_erasure/builtin.hpp>
#include <boost/type_erasure/operators.hpp>
#include <boost/type_erasure/any_cast.hpp>
#include <boost/type_erasure/deduced.hpp>
#include <boost/type_erasure/same_type.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/type_traits/remove_pointer.hpp>
#include <boost/type_traits/is_same.hpp>

#define BOOST_TEST_MAIN
#include <boost/test/unit_test.hpp>

using namespace boost::type_erasure;

BOOST_AUTO_TEST_CASE(test_deduce_dereference)
{
    typedef ::boost::mpl::vector<
        copy_constructible<>,
        typeid_<_a>,
        dereferenceable<deduced<boost::remove_pointer<_self> >&>,
        same_type<deduced<boost::remove_pointer<_self> >, _a>
    > test_concept;
    int i;

    any<test_concept> x(&i);
    any<test_concept, _a&> y(*x);
    BOOST_CHECK_EQUAL(&any_cast<int&>(y), &i);
}

BOOST_MPL_ASSERT((
    boost::is_same<
        deduced<boost::remove_pointer<_self> >::type,
        deduced<boost::remove_pointer<_self> > >));

BOOST_MPL_ASSERT((
    boost::is_same<deduced<boost::remove_pointer<int*> >::type, int >));

BOOST_AUTO_TEST_CASE(test_duplicate)
{
    typedef ::boost::mpl::vector<
        copy_constructible<>,
        typeid_<_a>,
        dereferenceable<deduced<boost::remove_pointer<_self> >&>,
        same_type<deduced<boost::remove_pointer<_self> >, _a>,
        same_type<deduced<boost::remove_pointer<_self> >, _a>
    > test_concept;
    int i;

    any<test_concept> x(&i);
    any<test_concept, _a&> y(*x);
    BOOST_CHECK_EQUAL(&any_cast<int&>(y), &i);
}

BOOST_AUTO_TEST_CASE(test_convert)
{
    typedef ::boost::mpl::vector<
        copy_constructible<>,
        typeid_<_a>,
        dereferenceable<deduced<boost::remove_pointer<_self> >&>,
        same_type<deduced<boost::remove_pointer<_self> >, _a>
    > test_concept_src;
    typedef ::boost::mpl::vector<
        copy_constructible<_b>,
        typeid_<_c>,
        dereferenceable<deduced<boost::remove_pointer<_b> >&, _b>,
        same_type<deduced<boost::remove_pointer<_b> >, _c>
    > test_concept_dest;
    int i;

    any<test_concept_src> x1(&i);
    any<test_concept_src, _a&> y1(*x1);
    any<test_concept_dest, _b> x2(x1);
    any<test_concept_dest, _c&> y2(*x2);
    BOOST_CHECK_EQUAL(&any_cast<int&>(y2), &i);
}

ext: cpp

max_stars_repo_name: NixaSoftware/CVis

max_issues_repo_name: NixaSoftware/CVis

max_forks_repo_name: NixaSoftware/CVis


text:
// Copyright (C) 2020 T. Zachary Laine
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_TEXT_NORMALIZE_STRING_HPP
#define BOOST_TEXT_NORMALIZE_STRING_HPP

#include <boost/text/concepts.hpp>
#include <boost/text/normalize.hpp>
#include <boost/text/transcode_view.hpp>
#include <boost/text/detail/normalize.hpp>

namespace boost { namespace text { namespace detail {
    template<
        nf Normalization,
        typename String,
        typename CPIter,
        typename Sentinel,
        bool UTF8Input =
            boost::text::detail::utf8_fast_path<CPIter, Sentinel>::value &&
                Normalization != nf::d && Normalization != nf::kd,
        bool UTF8Output = sizeof(*std::declval<String>().begin()) == 1>
    struct normalization_string_appender
    {
        using type = detail::utf16_string_appender<String>;
    };

    template<
        nf Normalization,
        typename String,
        typename CPIter,
        typename Sentinel>
    struct normalization_string_appender<
        Normalization,
        String,
        CPIter,
        Sentinel,
        false,
        true>
    {
        using type = detail::utf16_to_utf8_string_appender<String>;
    };

    template<
        nf Normalization,
        typename String,
        typename CPIter,
        typename Sentinel>
    struct normalization_string_appender<
        Normalization,
        String,
        CPIter,
        Sentinel,
        true,
        true>
    {
        using type = detail::utf8_string_appender<String>;
    };

    template<
        nf Normalization,
        typename String,
        typename CPIter,
        typename Sentinel>
    using normalization_string_appender_t =
        typename normalization_string_appender<
            Normalization,
            String,
            CPIter,
            Sentinel>::type;
}}}

namespace boost { namespace text { BOOST_TEXT_NAMESPACE_V1 {

    namespace dtl {
        template<
            nf Normalization,
            typename CPIter,
            typename Sentinel,
            typename String>
        inline void
        normalize_append_impl_impl(CPIter first, Sentinel last, String & s)
        {
            detail::normalization_string_appender_t<
                Normalization,
                String,
                CPIter,
                Sentinel>
                appender(s);
            detail::norm_impl<
                Normalization,
                decltype(s.begin()),
                CPIter,
                Sentinel>::call(first, last, appender);
        }

        template<
            nf Normalization,
            typename String,
            bool IntegralElement =
                std::is_integral<typename std::remove_reference<decltype(
                    *std::declval<String>().begin())>::type>::value,
            int ElementSize = sizeof(*std::declval<String>().begin())>
        struct normalize_append_impl
        {};

        template<nf Normalization, typename String>
        struct normalize_append_impl<Normalization, String, true, 1>
        {
            template<typename CPIter, typename Sentinel>
            static void call(CPIter first, Sentinel last, String & s)
            {
                normalize_append_impl_impl<Normalization>(first, last, s);
            }
        };

        template<nf Normalization, typename String>
        struct normalize_append_impl<Normalization, String, true, 2>
        {
            template<typename CPIter, typename Sentinel>
            static void call(CPIter first, Sentinel last, String & s)
            {
                normalize_append_impl_impl<Normalization>(first, last, s);
            }
        };

        template<typename T>
        using has_capacity_reserve =
            decltype(std::declval<T>().reserve(std::declval<T>().capacity()));

        template<
            typename String,
            bool Enable = is_detected_v<has_capacity_reserve, String>>
        struct normalize_string_impl
        {
            static void prefix(String const & s, String & temp) {}
            static void suffix(String & s, String & temp)
            {
                s = std::move(temp);
            }
        };

        template<typename String>
        struct normalize_string_impl<String, true>
        {
            static void prefix(String const & s, String & temp)
            {
                temp.reserve(s.size() * 2);
            }
            static void suffix(String & s, String & temp)
            {
                if (temp.size() <= s.capacity()) {
                    s = temp;
                } else {
                    using std::swap;
                    swap(s, temp);
                }
            }
        };
    }

    /** Appends sequence `[first, last)` in normalization form `Normalization`
        to `s`.  The output is UTF-8 if `sizeof(*s.begin()) == 1`, and UTF-16
        otherwise.

        This function only participates in overload resolution if `CPIter`
        models the CPIter concept. */
    template<
        nf Normalization,
        typename CPIter,
        typename Sentinel,
        typename String>
    auto normalize_append(CPIter first, Sentinel last, String & s)
        ->detail::cp_iter_ret_t<
            decltype(dtl::normalize_append_impl<Normalization, String>::call(
                first, last, s)),
            CPIter>
    {
        dtl::normalize_append_impl<Normalization, String>::call(first, last, s);
    }

    /** Appends sequence `r` in normalization form `Normalization` to `s`.
        The output is UTF-8 if `sizeof(*s.begin()) == 1`, and UTF-16
        otherwise. */
    template<nf Normalization, typename CPRange, typename String>
    void normalize_append(CPRange && r, String & s)
    {
        return boost::text::v1::normalize_append<Normalization>(
            std::begin(r), std::end(r), s);
    }

    /** Puts the contents of `s` in Unicode normalization form `Normalize`. */
    template<nf Normalization, typename String>
    void normalize(String & s)
    {
        auto const r = as_utf32(s);

        dtl::normalize_string_impl<String> impl;

        String temp;
        impl.prefix(s, temp);

        boost::text::v1::normalize_append<Normalization>(
            r.begin(), r.end(), temp);

        impl.suffix(s, temp);
    }

}}}

#if defined(BOOST_TEXT_DOXYGEN) || BOOST_TEXT_USE_CONCEPTS

namespace boost { namespace text { BOOST_TEXT_NAMESPACE_V2 {

    /** Appends `[first, last)` in normalization form `Normalization` to `s`.
        The output is UTF-8 if `sizeof(*s.begin()) == 1`, and UTF-16
        otherwise. */
    template<
        nf Normalization,
        code_point_iter I,
        std::sentinel_for<I> S,
        utf_string String>
    inline void normalize_append(I first, S last, String & s)
    {
        detail::normalization_string_appender_t<Normalization, String, I, S>
            appender(s);
        detail::norm_impl<Normalization, decltype(s.begin()), I, S>::call(
            first, last, appender);
    }

    /** Appends `r` in normalization form `Normalization` to `s`.  The output
        is UTF-8 if `sizeof(*s.begin()) == 1`, and UTF-16 otherwise. */
    template<nf Normalization, code_point_range R, utf_string String>
    inline void normalize_append(R && r, String & s)
    {
        return boost::text::normalize_append<Normalization>(
            std::begin(r), std::end(r), s);
    }

    namespace dtl {
        template<typename T>
        concept reserve_capacity_sized_range =
            // clang-format off
            std::ranges::sized_range<T> && requires(T const tc, T t) {
            { tc.capacity() } -> std::integral;
            { tc.reserve(tc.capacity()) };
            // clang-format on
        };
    }

    /** Puts the contents of `s` into Unicode normalization form
        `Normalize`. */
    template<nf Normalization, utf_string String>
    void normalize(String & s)
    {
        auto const r = as_utf32(s);

        String temp;
        if constexpr (dtl::reserve_capacity_sized_range<String>) {
            if constexpr (Normalization == nf::d || Normalization == nf::kd)
                temp.reserve(s.size() / 2 * 3);
            else
                temp.reserve(s.size());
        }

        boost::text::normalize_append<Normalization>(r.begin(), r.end(), temp);

        if constexpr (dtl::reserve_capacity_sized_range<String>) {
            if (temp.size() <= s.capacity()) {
                s = temp;
                return;
            }
        }
        std::ranges::swap(s, temp);
    }

}}}

#endif

#endif

ext: hpp


text:
/*****************************************************************************
 * Licensed to Qualys, Inc. (QUALYS) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * QUALYS licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 ****************************************************************************/

/**
 * @file
 * @brief IronBee --- CLIPP Aggregate Modifier
 *
 * @author Christopher Alfeld <calfeld@qualys.com>
 */

#ifndef __IRONBEE__CLIPP__AGGREGATE_MODIFIER__
#define __IRONBEE__CLIPP__AGGREGATE_MODIFIER__

#include <clipp/input.hpp>

#include <boost/shared_ptr.hpp>

namespace IronBee {
namespace CLIPP {

/**
 * Aggregates transactions from multiple connections into a single connection.
 *
 * Pre- and post- transaction events are @e only taken from the first
 * connection in each aggregate.
 *
 * Specifically, this modifier returns false until it has amassed more than
 * n connections, at which points it changes the input to a new aggregate
 * input and returns true.  If end-of-input occurs, produces an input with
 * all amassed inputs.
 **/
class AggregateModifier
{
public:
    /**
     * Constructor.
     *
     * @param[in] n If 0, aggregate all connections together, otherwise
     *              aggregate such that every connection has at least @a n
     *              transactions.
     **/
    explicit
    AggregateModifier(size_t n = 0);

    //! Process an input.
    bool operator()(Input::input_p& input);

    /**
     * Aggregate with sizes chosen uniformly from [@a min, @a max].
     *
     * @param[in] min Minimum size (except for last).
     * @param[in] max Maximum size.
     **/
    static
    AggregateModifier uniform(unsigned int min, unsigned int max);

    /**
     * Aggregate with sizes chosen from binomial distribution.
     *
     * n is chosen as the number of successful trials out of @a t where
     * success occurs with probability @a p.
     *
     * @param[in] t Number of trials.
     * @param[in] p Probability of success.
     **/
    static
    AggregateModifier binomial(unsigned int t, double p);

    /**
     * Aggregate with sizes chosen from geometric distribution.
     *
     * n is chosen as the number trials before a failure of probability
     * 1-@a p.
     *
     * @param[in] p Probability of success.
     **/
    static
    AggregateModifier geometric(double p);

    /**
     * Aggregate with sizes chosen from poisson distribution.
     *
     * n is chosen from a poisson distribution with mean @a mean.
     *
     * @param[in] mean Mean of distribution.
     **/
    static
    AggregateModifier poisson(double mean);

public:
    struct State;
    boost::shared_ptr<State> m_state;
};

} // CLIPP
} // IronBee

#endif

max_issues_repo_name: ErikHendriks/ironbee

max_forks_repo_name: ErikHendriks/ironbee


text:
#include <boost/test/execution_monitor.hpp>
#include <boost/test/unit_test.hpp>
#include <boost/test/unit_test_suite.hpp>
#include "HttpRequestEncoder.h"
#include "HttpClientLogHelper.h"

#include <iostream>
using namespace std;

struct MsgHttpRequestEncoderFixture
{
    MsgHttpRequestEncoderFixture(){cout << "MsgHttpRequestEncoderFixture()" << endl;}
    ~MsgHttpRequestEncoderFixture(){cout << "~MsgHttpRequestEncoderFixture()" << endl;}
};

//BOOST_AUTO_TEST_SUITE(test_requestMsgDecoder)
BOOST_FIXTURE_TEST_SUITE(test_httpRequestEncoder,MsgHttpRequestEncoderFixture)

// no body
BOOST_AUTO_TEST_CASE(test_httpRequestEncoder1)
{
	CHttpRequestEncoder encoder;
	string str = encoder.Encode("http://zhr.php5-3.com:8008/smgHttpServer/fail.php","","zhr.php5-3.com:8008");
	printf("\nstr:\n%s\n\n",str.c_str());

}

BOOST_AUTO_TEST_SUITE_END()

max_stars_repo_name: shrewdlin/BPE

max_issues_repo_name: shrewdlin/BPE

max_forks_repo_name: shrewdlin/BPE


text:
// Copyright (C) 2015, Pawel Tomulik <ptomulik@meil.pw.edu.pl>
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
//  http://www.boost.org/LICENSE_1_0.txt)

// txpl/vm/dumper.hpp

/** // doc: txpl/vm/dumper.hpp {{{
 * \file txpl/vm/dumper.hpp
 * \todo Write documentation
 */ // }}}
#ifndef TXPL_VM_DUMPER_HPP
#define TXPL_VM_DUMPER_HPP

#include <txpl/vm/dump_fwd.hpp>
#include <txpl/vm/value.hpp>
#include <txpl/vm/value_traits.hpp>
#include <txpl/vm/array.hpp>
#include <txpl/vm/dict.hpp>
#include <boost/variant/static_visitor.hpp>
#include <boost/variant/apply_visitor.hpp>
#include <regex>
#include <string>
#include <ostream>

namespace txpl { namespace vm {
/** // doc: dumper_visitor {{{
 * \ingroup VmGroup
 * \todo Write documentation
 */ // }}}
template<typename Value, typename Ostream>
struct dumper_visitor;
/** // doc: dumper_visitor {{{
 * \ingroup VmGroup
 * \todo Write documentation
 */ // }}}
template<typename Value, typename CharT, typename Traits>
struct dumper_visitor<Value, std::basic_ostream<CharT, Traits> >
  : boost::static_visitor<std::basic_ostream<CharT, Traits>&>
{
  /** // doc: ostream_type {{{
   * \todo Write documentation
   */ // }}}
  typedef std::basic_ostream<CharT, Traits> ostream_type;
  /** // doc: value_type {{{
   * \todo Write documentation
   */ // }}}
  typedef Value value_type;
  /** // doc: blank_type {{{
   * \todo Write documentation
   */ // }}}
  typedef typename value_traits<Value>::blank_type blank_type;
  /** // doc: char_type {{{
   * \todo Write documentation
   */ // }}}
  typedef typename value_traits<Value>::char_type char_type;
  /** // doc: int_type {{{
   * \todo Write documentation
   */ // }}}
  typedef typename value_traits<Value>::int_type int_type;
  /** // doc: bool_type {{{
   * \todo Write documentation
   */ // }}}
  typedef typename value_traits<Value>::bool_type bool_type;
  /** // doc: real_type {{{
   * \todo Write documentation
   */ // }}}
  typedef typename value_traits<Value>::real_type real_type;
  /** // doc: string_type {{{
   * \todo Write documentation
   */ // }}}
  typedef typename value_traits<Value>::string_type string_type;
  /** // doc: regex_type {{{
   * \todo Write documentation
   */ // }}}
  typedef typename value_traits<Value>::regex_type regex_type;
  /** // doc: array_type {{{
   * \todo Write documentation
   */ // }}}
  typedef array<Value> array_type;
  /** // doc: dict_type {{{
   * \todo Write documentation
   */ // }}}
  typedef dict<Value> dict_type;
  /** // doc: dumper_visitor() {{{
   * \todo Write documentation
   */ // }}}
  dumper_visitor(ostream_type& os) :_os(os) { }
  /** // doc: operator() {{{
   * \todo Write documentation
   */ // }}}
  ostream_type& operator()(blank_type) const
  { return _os; }
  /** // doc: operator() {{{
   * \todo Write documentation
   */ // }}}
  ostream_type& operator()(char_type x) const
  {
    // FIXME: implement escape sequences
    _os << CharT{'\''} << x << CharT{'\''};
    return _os;
  }
  /** // doc: operator() {{{
   * \todo Write documentation
   */ // }}}
  ostream_type& operator()(int_type x) const
  {
    _os << x;
    return _os;
  }
  /** // doc: operator() {{{
   * \todo Write documentation
   */ // }}}
  ostream_type& operator()(bool_type x) const
  {
    typedef std::basic_string<CharT,Traits> S;
    const char *f = "false";
    const char *t = "true";
    _os << (x ? S(t, t+4) : S(f, f+5));
    return _os;
  }
  /** // doc: operator() {{{
   * \todo Write documentation
   */ // }}}
  ostream_type& operator()(real_type x) const
  {
    _os << x;
    return _os;
  }
  /** // doc: operator() {{{
   * \todo Write documentation
   */ // }}}
  ostream_type& operator()(string_type x) const
  {
    // FIXME: implement escape sequences
    _os << CharT{'\"'} << x << CharT{'\"'};
    return _os;
  }
  /** // doc: operator() {{{
   * \todo Write documentation
   */ // }}}
  ostream_type& operator()(regex_type x) const
  {
    if(x.flags() & std::regex_constants::ECMAScript) _os << CharT{'r'};
    else if(x.flags() & std::regex_constants::basic) _os << CharT{'b'};
    else if(x.flags() & std::regex_constants::extended) _os << CharT{'x'};
    else if(x.flags() & std::regex_constants::awk) _os << CharT{'a'};
    else if(x.flags() & std::regex_constants::grep) _os << CharT{'g'};
    else _os << CharT{'e'};

    _os << CharT{'\"'} << "<not-implemented>" << CharT{'\"'};

    if(x.flags() & std::regex_constants::icase) _os << CharT{'i'};
    if(x.flags() & std::regex_constants::collate) _os << CharT{'c'};
    return _os;
  }
  /** // doc: operator() {{{
   * \todo Write documentation
   */ // }}}
  ostream_type& operator()(array_type x) const
  {
    _os << CharT{'['};
    if(x.size() != 0)
      {
        _os << CharT{' '};
        auto it = x.begin();
        dump(_os, *it);
        for(++it; it != x.end(); ++it)
          {
            _os << CharT{','} << CharT{' '};
            dump(_os, *it);
          }
        _os << CharT{' '};
      }
    _os << CharT{']'};
    return _os;
  }
  /** // doc: operator() {{{
   * \todo Write documentation
   */ // }}}
  ostream_type& operator()(dict_type x) const
  {
    _os << CharT{'{'};
    if(x.size() != 0)
      {
        _os << CharT{' '};
        auto it = x.begin();
        this->operator()(it->first);
        _os << CharT{' '} << CharT{':'} << CharT{' '};
        dump(_os, it->second);
        for(++it; it != x.end(); ++it)
          {
            _os << CharT{','} << CharT{' '};
            this->operator()(it->first);
            _os << CharT{' '} << CharT{':'} << CharT{' '};
            dump(_os, it->second);
          }
        _os << CharT{' '};
      }
    _os << CharT{'}'};
    return _os;
  }
private:
  ostream_type& _os;
};
/** // doc: dumper() {{{
 * \todo Write documentation
 */ // }}}
template<typename Value, typename Ostream>
dumper_visitor<Value, Ostream>
dumper(Ostream& os)
{ return dumper_visitor<Value, Ostream>(os); }
} } // end namespace txpl::vm

#include <txpl/vm/dump.hpp>

#endif /* TXPL_VM_DUMPER_HPP */
// vim: set expandtab tabstop=2 shiftwidth=2:
// vim: set foldmethod=marker foldcolumn=4:

max_stars_repo_name: ptomulik/txpl

max_issues_repo_name: ptomulik/txpl

max_forks_repo_name: ptomulik/txpl