text:
#include "boost/pointer_cast.hpp"
#include <czmq.h>
#include <thread>
#include <boost/thread.hpp>

#include "ShotgunAlienTests.h"
#include "Death.h"
#include "FileIO.h"
void * ShotgunAlienTests::ShotgunThread(void * arg) {
   ShotgunAmmo* ammo = static_cast<ShotgunAmmo*> (arg);
   printf("shooting %d bullet(s) at %s\n", ammo->count, ammo->location.c_str());
   Shotgun* shotgun = new Shotgun;
   shotgun->Aim(ammo->location);
   std::string msg("Fire!");
   //std::cout << "wait for it" << std::endl;
   sleep(ammo->delay);
   //std::cout << "done waiting" << std::endl;
   for (int i = 0; i <= ammo->count && !zctx_interrupted; i++) {
       //std::cout << "bang! " << std::endl;
      shotgun->Fire(msg);
   }
   delete shotgun;
   std::cout << "Shotgun deleted" << std::endl;
   return nullptr;
}
void * ShotgunAlienTests::Buckshothread(void * arg) {
   ShotgunAmmo* ammo = static_cast<ShotgunAmmo*> (arg);
   printf("shooting %d bullet(s) at %s\n", ammo->count, ammo->location.c_str());
   Shotgun shotgun;
   shotgun.Aim(ammo->location);
   std::string msg("Fire!");
   std::vector<std::string> fullShot;
   fullShot.push_back(msg);
   msg.append("again!");
   fullShot.push_back(msg);
   sleep(1);
   for (int i = 0; i <= ammo->count && !zctx_interrupted; i++) {
      shotgun.Fire(fullShot);
   }
   return nullptr;
}
std::string ShotgunAlienTests::GetTcpLocation() {
   int max = 15000;
   int min = 13000;
   int port = (rand()%(max-min))+min;
   std::string tcpLocation("tcp://127.0.0.1:");
   tcpLocation.append(boost::lexical_cast<std::string > (port));
   return tcpLocation;
}

std::string ShotgunAlienTests::GetIpcLocation() {
   int pid = getpid();
   std::string ipcLocation("ipc:///tmp/");
   ipcLocation.append("ShotgunAlienTests");
   ipcLocation.append(boost::lexical_cast<std::string > (pid));
   ipcLocation.append(".ipc");
   return ipcLocation;
}

std::string ShotgunAlienTests::GetInprocLocation() {
   int pid = getpid();
   std::string inprocLocation("inproc://ShotgunAlienTests");
   inprocLocation.append(boost::lexical_cast<std::string > (pid));
   return inprocLocation;
}

TEST_F(ShotgunAlienTests, ShotInTheDark) {
   Shotgun shotgun;

   std::string location = ShotgunAlienTests::GetTcpLocation();
   shotgun.Aim(location);
   std::string msg("Fire!");
   shotgun.Fire(msg);
}

TEST_F(ShotgunAlienTests, ShootOneAlienOnce) {
   Alien alien;
   ShotgunAmmo* ammo = new ShotgunAmmo();
   ammo->count = 1;
   ammo->location.assign(ShotgunAlienTests::GetTcpLocation());
   ammo->delay = 10;
   alien.PrepareToBeShot(ammo->location);
   zthread_new(ShotgunAlienTests::ShotgunThread, ammo);
   std::vector<std::string> reply = alien.GetShot();
   int count=0;
   while (reply.empty() && count++ < 100 && !zctx_interrupted) {
      reply = alien.GetShot();
      std::this_thread::sleep_for(std::chrono::milliseconds(100));
   }
   ASSERT_EQ(2,reply.size());
   EXPECT_FALSE(reply[0].empty());
   EXPECT_FALSE(reply[1].empty());
   delete ammo;
}

TEST_F(ShotgunAlienTests, ShootOneAlienTenThousandTimesTCP) {
   Alien alien;
   ShotgunAmmo* ammo = new ShotgunAmmo();
   ammo->count = 10000;
   ammo->location.assign(ShotgunAlienTests::GetTcpLocation());
   ammo->delay = 10;
   zthread_new(ShotgunAlienTests::ShotgunThread, ammo);
   alien.PrepareToBeShot(ammo->location);
   int failures = 0;
   for(int i=0; i <= ammo->count && !zctx_interrupted; i++) {
       std::vector<std::string> shots;
       alien.GetShot(1000,shots);

       // See if the queue of shots if full
       if(shots.size() == 0) {
              sleep(ammo->delay);
           std::cout << "Got Zero Length shot" << std::endl;
          i--;
          if (failures++ > 100 ) {
              ASSERT_FALSE(false);
          }
       }
   }
   delete ammo;
}
TEST_F(ShotgunAlienTests, ShootOneAlienOnceMulti) {
   Alien alien;
   ShotgunAmmo* ammo = new ShotgunAmmo();
   ammo->count = 1;
   ammo->location.assign(ShotgunAlienTests::GetTcpLocation());
   zthread_new(ShotgunAlienTests::Buckshothread, ammo);
   alien.PrepareToBeShot(ammo->location);

   std::vector<std::string> replies = alien.GetShot();
   ASSERT_EQ(2,replies.size());
   delete ammo;
}
TEST_F(ShotgunAlienTests, ShootOneAlienTenThousandTimesIPC) {
   Alien alien;
   ShotgunAmmo* ammo = new ShotgunAmmo();
   ammo->count = 10000;
   ammo->location.assign(ShotgunAlienTests::GetIpcLocation());
   alien.PrepareToBeShot(ammo->location);
   zthread_new(ShotgunAlienTests::ShotgunThread, ammo);
   alien.GetShot();
   delete ammo;
}

TEST_F(ShotgunAlienTests, AlienThatCantBeShot) {
   Alien alien;
   std::string location("bad_location");
   try {
   alien.PrepareToBeShot(location);
   //should not get here.
   ASSERT_TRUE(false);
   } catch(...) {
      ASSERT_TRUE(true);
   }

}

TEST_F(ShotgunAlienTests, ShotgunBadAim) {
   Shotgun shotgun;
   std::string location("bad_location");
   try {
   shotgun.Aim(location);
   //should not get here.
   ASSERT_TRUE(false);
   } catch(...) {
      ASSERT_TRUE(true);
   }

}

TEST_F(ShotgunAlienTests, ipcFilesCleanedOnNormalExit) {
   std::string target("ipc:///ShotgunAlienTestsExit");
   std::string addressRealPath(target,target.find("ipc://")+6);
   {
      Shotgun stick;
      Alien alien;
      stick.Aim(target);
      alien.PrepareToBeShot(target);
      ASSERT_TRUE(FileIO::DoesFileExist(addressRealPath));
   }
   ASSERT_FALSE(FileIO::DoesFileExist(addressRealPath)) << "Shotgun did not clean up ipc file: " << addressRealPath;
}

TEST_F(ShotgunAlienTests, ipcFilesCleanedOnFatal) {
   std::string target("ipc:///ShotgunAlienTestsDeath");
   Shotgun stick;
   Alien alien;
   std::string addressRealPath(target,target.find("ipc://")+6);
   Death::SetupExitHandler();
   stick.Aim(target);
   alien.PrepareToBeShot(target);
   ASSERT_TRUE(FileIO::DoesFileExist(addressRealPath));
   CHECK(false);
   ASSERT_FALSE(FileIO::DoesFileExist(addressRealPath));
}

max_stars_repo_name: john-gress/QueueNado

max_issues_repo_name: LogRhythm/QueueNado

max_forks_repo_name: john-gress/QueueNado


text:
// Andrew Naplavkov

#ifndef BRIG_BOOST_DETAIL_CORRECT_VISITOR_HPP
#define BRIG_BOOST_DETAIL_CORRECT_VISITOR_HPP

#include <boost/geometry/geometry.hpp>
#include <brig/boost/geometry.hpp>

namespace brig { namespace boost { namespace detail {

class correct_visitor : public ::boost::static_visitor<geometry> {
  template <typename T>
  geometry correct_impl(const T&) const;
public:
  geometry operator()(const point& r) const  { return r; }
  geometry operator()(const linestring& r) const  { return r; }
  geometry operator()(const polygon& r) const  { return correct_impl(r); }
  geometry operator()(const multi_point& r) const  { return r; }
  geometry operator()(const multi_linestring& r) const  { return r; }
  geometry operator()(const multi_polygon& r) const  { return correct_impl(r); }
  geometry operator()(const ::boost::recursive_wrapper<geometry_collection>&) const;
}; // correct_visitor

template <typename T>
geometry correct_visitor::correct_impl(const T& r) const
{
  T res(r);
  ::boost::geometry::correct(res);
  return res;
}

inline geometry correct_visitor::operator()(const ::boost::recursive_wrapper<geometry_collection>& r) const
{
  geometry_collection res;
  detail::correct_visitor visitor;
  for (const auto& g: r.get())
    res.push_back( ::boost::apply_visitor(visitor, g) );
  return res;
} // correct_visitor::

} } } // brig::boost::detail

#endif // BRIG_BOOST_DETAIL_CORRECT_VISITOR_HPP

ext: hpp

max_stars_repo_name: isadchenko/brig

max_issues_repo_name: isadchenko/brig

max_forks_repo_name: isadchenko/brig


text:
// Copyright Oleg Maximenko 2014.
// 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)
//
// See http://github.com/svgpp/svgpp for library home page.

#pragma once

#include <svgpp/detail/adapt_context.hpp>
#include <svgpp/utility/calculate_viewbox_transform.hpp>
#include <boost/optional.hpp>
#include <boost/mpl/set.hpp>
#include <boost/noncopyable.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/tuple/tuple.hpp>
#include <boost/variant.hpp>

namespace svgpp
{

// Pairs of <referencing element tag, referenced element tag> combinations in which
// calculate_viewport_adapter needs to know type of referenced element
typedef boost::mpl::set3<
  boost::mpl::pair<tag::element::use_,  tag::element::svg>,
  boost::mpl::pair<tag::element::image, tag::element::svg>,
  boost::mpl::pair<tag::element::use_,  tag::element::symbol>
> viewport_adapter_needs_to_know_referencing_element;

namespace tag { namespace viewport_size_source
{
  struct use_own; // 'width' and 'height' attributes are set on element
  struct use_reference; // Like 'symbol' element referenced by 'use'
  struct reference_override_own; // Like 'svg' element referenced by 'use'
}}

template<
  class ReferencingElementTag, // 'void' means that element is not referenced or
                               // referencing element type doesn't matter (e.g. 'symbol' may be referenced only by 'use')
                               // see viewport_adapter_needs_to_know_referencing_element
  class ElementTag
>
struct get_viewport_size_source; // Shouldn't be called for anything other than 'svg' and 'symbol',
                                 // referenced by 'use' or 'image'
                                 // 'symbol' must only be used while referenced by 'use'

template<>
struct get_viewport_size_source<tag::element::use_, tag::element::svg>
{
  typedef tag::viewport_size_source::reference_override_own type;
};

template<>
struct get_viewport_size_source<tag::element::image, tag::element::svg>
{
  typedef tag::viewport_size_source::use_reference type;
};

template<>
struct get_viewport_size_source<void, tag::element::svg>
{
  typedef tag::viewport_size_source::use_own type;
};

template<>
struct get_viewport_size_source<tag::element::use_, tag::element::symbol>
{
  typedef tag::viewport_size_source::use_reference type;
};

template<>
struct get_viewport_size_source<void, tag::element::pattern>
{
  typedef tag::viewport_size_source::use_own type;
};

namespace detail
{
  template<class Length, class Coordinate, class ViewportSizeSourceTag>
  class calculate_viewport_adapter_size_holder;

  template<class Length, class Coordinate>
  class calculate_viewport_adapter_size_holder<Length, Coordinate, tag::viewport_size_source::use_own>
  {
  public:
    void set(tag::attribute::width,         Length const & val) { viewport_width_ = val; }
    void set(tag::attribute::height,        Length const & val) { viewport_height_ = val; }

  protected:
    template<class EventsPolicy, class Context, class LengthToUserCoordinatesConverter>
    void get_viewport_size(Context & context, LengthToUserCoordinatesConverter const & converter,
      Coordinate & viewport_width, Coordinate & viewport_height) const
    {
      viewport_width = converter.length_to_user_coordinate(
        viewport_width_
          ? *viewport_width_
          : converter.create_length(100, tag::length_units::percent(), tag::length_dimension::width()),
        tag::length_dimension::width());
      viewport_height = converter.length_to_user_coordinate(
        viewport_height_
          ? *viewport_height_
          : converter.create_length(100, tag::length_units::percent(), tag::length_dimension::height()),
        tag::length_dimension::height());
    }

  private:
    boost::optional<Length> viewport_width_, viewport_height_;
  };

  template<class Length, class Coordinate>
  class calculate_viewport_adapter_size_holder<Length, Coordinate, tag::viewport_size_source::use_reference>
  {
  protected:
    template<class EventsPolicy, class Context, class LengthToUserCoordinatesConverter>
    void get_viewport_size(Context & context, LengthToUserCoordinatesConverter const & converter,
      Coordinate & viewport_width, Coordinate & viewport_height) const
    {
      // Init with defaults first
      viewport_width = converter.length_to_user_coordinate(
        converter.create_length(100, tag::length_units::percent(), tag::length_dimension::width()),
        tag::length_dimension::width());
      viewport_height = converter.length_to_user_coordinate(
        converter.create_length(100, tag::length_units::percent(), tag::length_dimension::height()),
        tag::length_dimension::height());

      EventsPolicy::get_reference_viewport_size(context, viewport_width, viewport_height);
    }

    struct some_dummy_type;
    void set(some_dummy_type); // The only purpose of this declaration is to make
                               // "use base_type::set;" possible in inherited type
  };

  template<class Length, class Coordinate>
  class calculate_viewport_adapter_size_holder<Length, Coordinate, tag::viewport_size_source::reference_override_own>
    : public calculate_viewport_adapter_size_holder<Length, Coordinate, tag::viewport_size_source::use_own>
  {
  protected:
    template<class EventsPolicy, class Context, class LengthToUserCoordinatesConverter>
    void get_viewport_size(Context & context, LengthToUserCoordinatesConverter const & converter,
      Coordinate & viewport_width, Coordinate & viewport_height) const
    {
      calculate_viewport_adapter_size_holder<Length, Coordinate, tag::viewport_size_source::use_own>
        ::template get_viewport_size<EventsPolicy>(context, converter, viewport_width, viewport_height);
      // get_reference_viewport_size must only set values which was specified for referenced element
      // and keep values from current element if referenced element lacks them
      EventsPolicy::get_reference_viewport_size(context, viewport_width, viewport_height);
    }
  };

  template<class Coordinate>
  class collect_viewbox_adapter
  {
  protected:
    typedef boost::tuple<Coordinate, Coordinate, Coordinate, Coordinate> viewbox_type; // x, y, width, height

  public:
    collect_viewbox_adapter()
      : defer_(false)
      , align_(tag::value::xMidYMid())
      , meetOrSlice_(tag::value::meet())
    {}

    void set(tag::attribute::viewBox, Coordinate x, Coordinate y, Coordinate w, Coordinate h)
    {
      viewbox_ = viewbox_type(x, y, w, h);
    }

    void set(tag::attribute::preserveAspectRatio, bool defer, tag::value::none align_tag)
    {
      defer_ = defer;
      align_ = align_tag;
    }

    template<class AlignTag, class MeetOrSliceTag>
    void set(tag::attribute::preserveAspectRatio, bool defer, AlignTag align_tag, MeetOrSliceTag meetOrSlice)
    {
      defer_ = defer;
      align_ = align_tag;
      meetOrSlice_ = meetOrSlice;
    }

  protected:
    boost::optional<viewbox_type> viewbox_;
    bool defer_;
    boost::variant<
      tag::value::none,
      tag::value::xMinYMin,
      tag::value::xMidYMin,
      tag::value::xMaxYMin,
      tag::value::xMinYMid,
      tag::value::xMidYMid,
      tag::value::xMaxYMid,
      tag::value::xMinYMax,
      tag::value::xMidYMax,
      tag::value::xMaxYMax> align_;
    boost::variant<tag::value::meet, tag::value::slice> meetOrSlice_;

    template<class LengthToUserCoordinatesConverter>
    class options_visitor:
      public boost::static_visitor<>,
      boost::noncopyable
    {
    public:
      options_visitor(viewbox_type const & viewbox,
        Coordinate viewport_width, Coordinate viewport_height,
        Coordinate & translate_x, Coordinate & translate_y, Coordinate & scale_x, Coordinate & scale_y)
        : viewbox_(viewbox)
        , viewport_width_(viewport_width)
        , viewport_height_(viewport_height)
        , translate_x_(translate_x)
        , translate_y_(translate_y)
        , scale_x_(scale_x)
        , scale_y_(scale_y)
      {
      }

      template<class AlignTag, class MeetOrSliceTag>
      void operator()(const AlignTag & align_tag, const MeetOrSliceTag & meetOrSlice_tag) const
      {
        calculate_viewbox_transform<Coordinate>::calculate(
          viewport_width_, viewport_height_,
          viewbox_.template get<0>(), viewbox_.template get<1>(), viewbox_.template get<2>(), viewbox_.template get<3>(),
          align_tag,
          meetOrSlice_tag,
          translate_x_, translate_y_, scale_x_, scale_y_);
      }

    private:
      viewbox_type const & viewbox_;
      Coordinate viewport_width_, viewport_height_;
      Coordinate & translate_x_, & translate_y_, & scale_x_, & scale_y_;
    };
  };

} // namespace detail

template<
  class ElementTag,
  class ReferencingElement,
  class Length,
  class Coordinate
>
class calculate_viewport_adapter:
  public detail::calculate_viewport_adapter_size_holder<
    Length,
    Coordinate,
    typename get_viewport_size_source<ReferencingElement, ElementTag>::type
  >,
  public detail::collect_viewbox_adapter<Coordinate>,
  boost::noncopyable
{
  typedef detail::calculate_viewport_adapter_size_holder<
    Length, Coordinate,
    typename get_viewport_size_source<ReferencingElement, ElementTag>::type
  > base_size_holder;
  typedef detail::collect_viewbox_adapter<Coordinate> base_viewbox_adapter;
  typedef boost::tuple<Coordinate, Coordinate, Coordinate, Coordinate> viewbox_type; // x, y, width, height

public:
  template<class Context>
  bool on_exit_attributes(Context & context) const
  {
    typedef detail::unwrap_context<Context, tag::viewport_events_policy> viewport_events;
    typedef detail::unwrap_context<Context, tag::error_policy> error_policy;
    typedef detail::unwrap_context<Context, tag::length_policy> length_policy_context;
    typedef typename length_policy_context::policy length_policy_t;

    typename length_policy_t::length_factory_type & converter
      = length_policy_t::length_factory(length_policy_context::get(context));

    Coordinate viewport_x = converter.length_to_user_coordinate(
      viewport_x_ ? *viewport_x_ : converter.create_length(0, tag::length_units::none()),
      tag::length_dimension::width());
    Coordinate viewport_y = converter.length_to_user_coordinate(
      viewport_y_ ? *viewport_y_ : converter.create_length(0, tag::length_units::none()),
      tag::length_dimension::height());

    Coordinate viewport_width = 0, viewport_height = 0;
    base_size_holder::template get_viewport_size<typename viewport_events::policy>(context, converter, viewport_width, viewport_height);

    if (viewport_width == 0 || viewport_height == 0)
    {
      viewport_events::policy::disable_rendering(viewport_events::get(context));
      return true;
    }

    if (viewport_width < 0)
      return error_policy::policy::negative_value(error_policy::get(context), tag::attribute::width());
    if (viewport_height < 0)
      return error_policy::policy::negative_value(error_policy::get(context), tag::attribute::height());

    viewport_events::policy::set_viewport(viewport_events::get(context), viewport_x, viewport_y, viewport_width, viewport_height);

    if (this->viewbox_)
    {
      if (this->viewbox_->template get<2>() == 0 || this->viewbox_->template get<3>() == 0)
      {
        viewport_events::policy::disable_rendering(viewport_events::get(context));
        return true;
      }

      if (this->viewbox_->template get<2>() < 0 || this->viewbox_->template get<3>() < 0)
        return error_policy::policy::negative_value(error_policy::get(context), tag::attribute::viewBox());

      Coordinate translate_x, translate_y, scale_x, scale_y;
      boost::apply_visitor(
        typename base_viewbox_adapter::template options_visitor<typename length_policy_t::length_factory_type>(*this->viewbox_,
          viewport_width, viewport_height,
          translate_x, translate_y, scale_x, scale_y),
        this->align_, this->meetOrSlice_);
      viewport_events::policy::set_viewbox_transform(viewport_events::get(context),
        translate_x, translate_y, scale_x, scale_y, this->defer_);

      viewport_events::policy::set_viewbox_size(viewport_events::get(context),
        this->viewbox_->template get<2>(), this->viewbox_->template get<3>());
    }
    return true;
  }

  using base_size_holder::set;
  using base_viewbox_adapter::set;
  void set(tag::attribute::x,             Length const & val) { viewport_x_ = val; }
  void set(tag::attribute::y,             Length const & val) { viewport_y_ = val; }

private:
  boost::optional<Length> viewport_x_, viewport_y_;
};

struct viewport_transform_adapter
{
  template<class Context, class Coordinate>
  static void set_viewbox_transform(Context & context, Coordinate translate_x, Coordinate translate_y,
    Coordinate scale_x, Coordinate scale_y, bool)
  {
    typedef detail::unwrap_context<Context, tag::transform_events_policy> transform_events;

    transform_events::policy::transform_translate(transform_events::get(context), translate_x, translate_y);
    transform_events::policy::transform_scale(transform_events::get(context), scale_x, scale_y);
  }

  template<class Context, class Coordinate>
  static void set_viewport(Context & context, Coordinate viewport_x, Coordinate viewport_y,
    Coordinate viewport_width, Coordinate viewport_height)
  {
    typedef detail::unwrap_context<Context, tag::viewport_events_policy> viewport_events;
    typedef detail::unwrap_context<Context, tag::transform_events_policy> transform_events;

    viewport_events::policy::set_viewport(viewport_events::get(context), viewport_x, viewport_y, viewport_width, viewport_height);
    transform_events::policy::transform_translate(transform_events::get(context), viewport_x, viewport_y);
  }

  template<class Context, class Coordinate>
  static void get_reference_viewport_size(Context & context, Coordinate & viewport_width, Coordinate & viewport_height)
  {
    typedef detail::unwrap_context<Context, tag::viewport_events_policy> viewport_events;

    viewport_events::policy::get_reference_viewport_size(viewport_events::get(context), viewport_width, viewport_height);
  }

  template<class Context, class Coordinate>
  static void set_viewbox_size(Context & context, Coordinate viewbox_width, Coordinate viewbox_height)
  {
    typedef detail::unwrap_context<Context, tag::viewport_events_policy> viewport_events;

    viewport_events::policy::set_viewbox_size(viewport_events::get(context), viewbox_width, viewbox_height);
  }

  template<class Context>
  static void disable_rendering(Context & context)
  {
    typedef detail::unwrap_context<Context, tag::viewport_events_policy> viewport_events;

    viewport_events::policy::disable_rendering(viewport_events::get(context));
  }
};

}

max_stars_repo_name: RichardCory/svgpp


text:
#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE uri

#include <chrono>
#include <boost/test/unit_test.hpp>
#include <http_parser/uri_parser.hpp>

namespace utf = boost::unit_test;

constexpr bool enable_speed_tests =
        #ifdef  ENABLE_SPEED_TESTS
        true
        #else
        false
        #endif
        ;

BOOST_AUTO_TEST_SUITE(core)
BOOST_AUTO_TEST_SUITE(uri)

using uri_parser = http_parser::basic_uri_parser<std::string_view>;

BOOST_AUTO_TEST_CASE(example)
{
	uri_parser rb("https://user:pa$s@google.com:81/some/path?a=12#b");
	BOOST_TEST(rb.scheme() == "https");
	BOOST_TEST(rb.host() == "google.com");
	BOOST_TEST(rb.port() == 81);
	BOOST_TEST(rb.user() == "user");
	BOOST_TEST(rb.pass() == "pa$s");
	BOOST_TEST(rb.path() == "/some/path");
	BOOST_TEST(rb.request() == "/some/path?a=12");
	BOOST_TEST(rb.anchor() == "b");
	BOOST_TEST(rb.params() == "a=12");
	BOOST_TEST(rb.param("a").value() == "12");
	BOOST_TEST(rb.param("b").has_value() == false);
}
BOOST_AUTO_TEST_CASE(speed, * utf::label("speed") * utf::enable_if<enable_speed_tests>())
{
	using namespace std::literals;
	uri_parser prs;
	auto start = std::chrono::high_resolution_clock::now();
	for(std::size_t i=0;i<10'000'000;++i)
		prs.uri("https://user:pa$s@google.com:81/some/path?a=12#b"sv);
	auto stop = std::chrono::high_resolution_clock::now();
	auto dur = stop - start;
	BOOST_TEST(std::chrono::duration_cast<std::chrono::milliseconds>(dur).count() < 1500);
}
BOOST_AUTO_TEST_CASE(wide)
{
	using uri_wparser = http_parser::basic_uri_parser<std::wstring_view>;
	uri_wparser rb(L"https://user:pa$s@google.com:81/some/path?a=12#b");
	BOOST_CHECK(rb.scheme() == L"https");
	BOOST_CHECK(rb.path() == L"/some/path");
	BOOST_CHECK(rb.param(L"a").value() == L"12");
	BOOST_CHECK(rb.port() == 81);

	BOOST_TEST((uri_wparser(L"http://g.com")).port() == 80);
	BOOST_CHECK((uri_wparser(L"http://g.com")).path() == L"/");
	BOOST_TEST((uri_wparser(L"https://g.c/s/p?a=1#b")).port() == 443);
	BOOST_TEST((uri_wparser(L"https://u:pa$s@g.c:81/s/p?a=1#b")).port() == 81);
}
BOOST_AUTO_TEST_CASE(request)
{
	BOOST_TEST((uri_parser("http://g.com")).request() == "");
	BOOST_TEST((uri_parser("http://g.com/")).request() == "/");
	BOOST_TEST((uri_parser("http://g.com/a/b")).request() == "/a/b");
	BOOST_TEST((uri_parser("http://g.com/a/b?c")).params() == "c");
	BOOST_TEST((uri_parser("http://g.com/a/b?c")).request() == "/a/b?c");
	BOOST_TEST((uri_parser("http://g.com/a/b?c=21")).request() == "/a/b?c=21");
}
BOOST_AUTO_TEST_CASE(port)
{
	BOOST_TEST((uri_parser("http://google.com")).port() == 80);
	BOOST_TEST((uri_parser("https://google.com/some/path?a=1#b")).port() == 443);
	BOOST_TEST((uri_parser("http://google.com/some/path?a=1#b")).port() == 80);
	BOOST_TEST((uri_parser("http://google.com:81/some/path?a=1#b")).port() == 81);
	BOOST_TEST((uri_parser("http://user:pass@google.com:81/some/path?a=1#b")).port() == 81);
	BOOST_TEST((uri_parser("https://user:pa$s@google.com:81/some/path?a=1#b")).port() == 81);
}
BOOST_AUTO_TEST_CASE(path)
{
	uri_parser rb("https://google.com/some/path?a=1#b");
	BOOST_TEST(rb.path() == "/some/path");
	rb.uri("https://google.com");
	BOOST_TEST(rb.path() == "/");

	BOOST_TEST((uri_parser("http://google.com")).path() == "/");
	BOOST_TEST((uri_parser("http://google.com/a")).path() == "/a");
}
BOOST_AUTO_TEST_CASE(params)
{
	BOOST_TEST((uri_parser("h://g.c")).params() == "");
	BOOST_CHECK((uri_parser("h://g.c")).param("a") == std::nullopt);
	BOOST_TEST((uri_parser("h://g.c/a?a=2")).params() == "a=2");
	BOOST_TEST((uri_parser("h://g.c/?a=2&b=3")).params() == "a=2&b=3");
	BOOST_TEST((uri_parser("h://g.c/?a=2&b=3")).param("a").value() == "2");
	BOOST_TEST((uri_parser("h://g.c/?a=2a&b=3")).param("a").value() == "2a");
	BOOST_TEST((uri_parser("h://g.c/?a=2&b=3")).param("b").value() == "3");
	BOOST_TEST((uri_parser("h://g.c/?a=2&b")).param("b").value() == "");
	BOOST_TEST((uri_parser("h://g.c/?a&b=2")).param("a").value() == "");
	BOOST_CHECK((uri_parser("h://g.c/?a=2&b")).param("c") == std::nullopt);

	BOOST_TEST((uri_parser("http://g.com/a/b?c")).params() == "c");
	BOOST_TEST((uri_parser("http://g.com/a/b?c")).param("c").value() == "");
}
BOOST_AUTO_TEST_CASE(wrong_url)
{
	BOOST_CHECK((uri_parser("h://g.c/?a=2&=")).param("c") == std::nullopt);
	BOOST_TEST((uri_parser("h://g.c/?a=2&=")).param("a").value() == "2");
	BOOST_CHECK((uri_parser("h://g.c/?a&bc")).param("c") == std::nullopt);
}

BOOST_AUTO_TEST_SUITE(parser)
using uri_parser = http_parser::uri_parser_machine<std::string_view>;
using uri_wparser = http_parser::uri_parser_machine<std::wstring_view>;
BOOST_AUTO_TEST_CASE(full_uri)
{
	uri_parser p, p2;
	p("https://user:pa$s@google.com:81/some/path?a=12#b");
	BOOST_TEST(p.scheme == "https"); BOOST_TEST(p.user == "user");
	BOOST_TEST(p.password == "pa$s");
	BOOST_TEST(p.domain == "google.com");
	BOOST_TEST(p.port == "81");
	BOOST_TEST(p.path == "/some/path");
	BOOST_TEST(p.path_pos() == 31);
	BOOST_TEST(p.query == "a=12");
	BOOST_TEST(p.anchor == "b");

	BOOST_CHECK(p == p);
	BOOST_CHECK(p != p2);
	p2("https://user:pa$s@google.com:81/some/path?a=12");
	BOOST_CHECK(p != p2);
	p2("https://user:pa$s@google.com:81/some/path?a=12#b");
	BOOST_CHECK(p == p2);

	uri_wparser wp;
	wp(L"https://user:pa$s@google.com:81/some/path?a=12#b");
	BOOST_CHECK(wp.scheme == L"https");
	BOOST_CHECK(wp.user == L"user");
}
BOOST_AUTO_TEST_CASE(without_scheme)
{
	uri_parser p, p2;
	p("user:pa$s@google.com:81/some/path?a=12#b");
	BOOST_TEST(p.scheme == "");
	BOOST_TEST(p.user == "user");
	BOOST_TEST(p.password == "pa$s");
	BOOST_TEST(p.domain == "google.com");
	BOOST_TEST(p.port == "81");
	BOOST_TEST(p.path == "/some/path");
	BOOST_TEST(p.query == "a=12");
	BOOST_TEST(p.anchor == "b");
	BOOST_CHECK(p == p2("//user:pa$s@google.com:81/some/path?a=12#b"));
	BOOST_TEST(p2.scheme == "");
	BOOST_TEST(p2.user == "user");
	BOOST_TEST(p2.password == "pa$s");
	BOOST_TEST(p2.domain == "google.com");
}
BOOST_AUTO_TEST_CASE(without_user_pass)
{
	uri_parser p, p2;
	p("google.com:81/some/path?a=12#b");
	BOOST_TEST(p.scheme == "");
	BOOST_TEST(p.user == "");
	BOOST_TEST(p.password == "");
	BOOST_TEST(p.domain == "google.com");
	BOOST_TEST(p.port == "81");
	BOOST_TEST(p.path == "/some/path");
	BOOST_CHECK(p == p2("//google.com:81/some/path?a=12#b"));
}
BOOST_AUTO_TEST_CASE(without_port)
{
	uri_parser p, p2;
	p("google.com/some/path?a=12#b");
	BOOST_TEST(p.scheme == "");
	BOOST_TEST(p.user == "");
	BOOST_TEST(p.password == "");
	BOOST_TEST(p.domain == "google.com");
	BOOST_TEST(p.port == "");
	BOOST_TEST(p.path == "/some/path");
	BOOST_CHECK(p == p2("//google.com/some/path?a=12#b"));
}
BOOST_AUTO_TEST_CASE(without_path)
{
	uri_parser p, p2;
	p("google.com/?a=12#b");
	BOOST_TEST(p.scheme == "");
	BOOST_TEST(p.user == "");
	BOOST_TEST(p.password == "");
	BOOST_TEST(p.domain == "google.com");
	BOOST_TEST(p.port == "");
	BOOST_TEST(p.path == "/");
	BOOST_TEST(p.path_pos() == 10);
	BOOST_TEST(p.query == "a=12");
	BOOST_TEST(p.anchor == "b");
	BOOST_CHECK(p == p2("//google.com/?a=12#b"));
}
BOOST_AUTO_TEST_CASE(without_query)
{
	uri_parser p, p2;
	p("google.com/#b");
	BOOST_TEST(p.scheme == "");
	BOOST_TEST(p.user == "");
	BOOST_TEST(p.password == "");
	BOOST_TEST(p.domain == "google.com");
	BOOST_TEST(p.port == "");
	BOOST_TEST(p.path == "/");
	BOOST_TEST(p.query == "");
	BOOST_TEST(p.anchor == "b");
	BOOST_CHECK(p == p2("//google.com/#b"));

	p("http://google.com:1/#b");
	BOOST_TEST(p.scheme == "http");
	BOOST_TEST(p.user == "");
	BOOST_TEST(p.password == "");
	BOOST_TEST(p.domain == "google.com");
	BOOST_TEST(p.port == "1");
	BOOST_TEST(p.path == "/");
	BOOST_TEST(p.query == "");
	BOOST_TEST(p.anchor == "b");
}
BOOST_AUTO_TEST_CASE(only_domain)
{
	uri_parser p, p2, p3;
	p("google.com");
	BOOST_TEST(p.scheme == "");
	BOOST_TEST(p.user == "");
	BOOST_TEST(p.password == "");
	BOOST_TEST(p.domain == "google.com");
	BOOST_TEST(p.port == "");
	BOOST_TEST(p.path == "");
	BOOST_TEST(p.path_pos() == 0);
	BOOST_TEST(p.query == "");
	BOOST_TEST(p.anchor == "");
	BOOST_CHECK(p == p2("//google.com"));

	p("google.com:1");
	BOOST_TEST(p.scheme == "");
	BOOST_TEST(p.user == "");
	BOOST_TEST(p.password == "");
	BOOST_TEST(p.domain == "google.com");
	BOOST_TEST(p.port == "1");
	BOOST_TEST(p.path == "");
	BOOST_TEST(p.query == "");
	BOOST_TEST(p.anchor == "");

	p3("google.com/");
	BOOST_TEST(p3.scheme == "");
	BOOST_TEST(p3.user == "");
	BOOST_TEST(p3.password == "");
	BOOST_TEST(p3.domain == "google.com");
	BOOST_TEST(p3.port == "");
	BOOST_TEST(p3.path == "/");
	BOOST_TEST(p3.query == "");
	BOOST_TEST(p3.anchor == "");
}
BOOST_AUTO_TEST_CASE(query)
{
	uri_parser p;
	p("http://g.com/a/b?c");
	BOOST_TEST(p.scheme == "http");
	BOOST_TEST(p.user == "");
	BOOST_TEST(p.password == "");
	BOOST_TEST(p.domain == "g.com");
	BOOST_TEST(p.port == "");
	BOOST_TEST(p.path == "/a/b");
	BOOST_TEST(p.path_pos() == 12);
	BOOST_TEST(p.query == "c");
	BOOST_TEST(p.anchor == "");
}
BOOST_AUTO_TEST_CASE(path)
{
	uri_parser p;
	p("http://google.com/a");
	BOOST_TEST(p.scheme == "http");
	BOOST_TEST(p.user == "");
	BOOST_TEST(p.password == "");
	BOOST_TEST(p.domain == "google.com");
	BOOST_TEST(p.port == "");
	BOOST_TEST(p.path == "/a");
	BOOST_TEST(p.path_pos() == 17);
	BOOST_TEST(p.query == "");
	BOOST_TEST(p.anchor == "");
}
BOOST_AUTO_TEST_CASE(only_path)
{
	uri_parser p;
	p("/a/b/c?a=b&c=1&d");
	BOOST_TEST(p.scheme == "");
	BOOST_TEST(p.user == "");
	BOOST_TEST(p.password == "");
	BOOST_TEST(p.domain == "");
	BOOST_TEST(p.port == "");
	BOOST_TEST(p.path == "/a/b/c");
	BOOST_TEST(p.path_pos() == 0);
	BOOST_TEST(p.query == "a=b&c=1&d");
	BOOST_TEST(p.anchor == "");
}
BOOST_AUTO_TEST_CASE(wrong)
{
	uri_parser p;
	BOOST_CHECK_THROW(p("http:/"), std::exception);
	p("");
	BOOST_TEST(p.scheme == "");
	BOOST_TEST(p.user == "");
	BOOST_TEST(p.password == "");
	BOOST_TEST(p.domain == "");
	BOOST_TEST(p.port == "");
	BOOST_TEST(p.path == "");
	BOOST_TEST(p.path_pos() == 0);
	BOOST_TEST(p.query == "");
	BOOST_TEST(p.anchor == "");
}
BOOST_AUTO_TEST_SUITE_END() // parser
BOOST_AUTO_TEST_SUITE_END() // uri
BOOST_AUTO_TEST_SUITE_END() // core

ext: cpp


text:
#include <util/datastream/topk/fss/SpaceSaving.hpp>
#include <util/datastream/topk/cms/TopKCalculator.hpp>
#include <util/datastream/topk/cms/TopKItemEstimation.hpp>
#include <util/datastream/sketch/madoka/sketch.h>
#include <util/datastream/sketch/HyperLogLog.hpp>
#include <util/datastream/sketch/KMV.hpp>
#include <am/leveldb/Table.h>
#include <string>
#include <stdint.h>
#include <iostream>
#include <fstream>
#include <fstream>
#include <boost/lexical_cast.hpp>
#include <map>
#include <time.h>
#include <util/DynamicBloomFilter.h>
#include <log-server/LogAnalysisManager.h>
#include <log-server/StorageManager.cpp>
#include <log-server/LogServerCfg.cpp>

using namespace std;
using namespace sf1r::logserver;
#define MAXCOUNT 400

#define MAX_PRIME 2147483647
#define seed MAX_PRIME

#define TEXT_PROP 0
//test LogAnalysisManager
//write dvleveldb
#define TEXT_LAV  1
//test LogAnalysisManager
//without access to dvleveldb
#define TEXT_LA   0
//test KMV
#define TEXT_KMV  0
//test HyperLogLog
#define TEXT_HLL  0
//test Monitor list
#define TEXT_ML   0

typedef std::list< std::pair<std::string, uint32_t> > TopKT;
typedef std::list< std::map<std::string, std::string> > ValueT;

int main()
{
    if(TEXT_PROP)
    {
        LogAnalysisManager lam("log_server_storage/");
        std::string c = "b5mp";

        std::string prop;
        while(cin>>prop)
        {
            lam.insertPropertyLabel(c, prop, 1);
        }

        ValueT props;
        lam.getPropertyLabel(c, props);
        ValueT::iterator it;
        for(it = props.begin(); it!=props.end(); it++)
        {
            std::map<std::string, std::string>::iterator iter;
            for(iter=it->begin();iter!=it->end();iter++)
                cout <<"[ "<<iter->first<<", "<<iter->second<<" ] ";
            cout <<endl;
        }

    }
    if(TEXT_LAV)
    {
        LogAnalysisManager lam("log_server_storage/");
        std::string s = "user-query-analysis";
        std::string c = "b5mp";
        std::string l_str;

        while(cin >> l_str)
        {
            std::map<std::string, std::string> m;
            m["key"]=l_str;
            lam.insert(s, c, "20130509T000000", l_str, m);
//            lam.insert(s, c, l_str);
        }
        std::map<std::string, std::string> m2;
        m2["end"]="end";

        lam.insert(s, c, "20130510T100000", "end", m2);

        //get distinct value count
        uint64_t count = 0;
        lam.getDVC(s,c, "20130508T000000", "20130509T000000", count);
        cout <<"*****************************"<<endl;
        cout << "Distinct Value Count: "<<count << endl;
        cout <<"*****************************"<<endl;
        cout <<"TopK frequent items: "<<endl;

        for(int j=0;j<1;j++)
        {
            TopKT topk;
            lam.getTopK(s, c, "20130508T000000", "20130509T000000", 20, topk);
            TopKT::iterator iter;
            for(iter=topk.begin();iter!=topk.end();iter++)
                cout << iter->first << "    " << iter->second<<endl;
        }

        ValueT values;
        lam.getAllCollectionData(s, "20130508T000000", values);
        cout << "ok"<<endl;
        ValueT::iterator it;
        for(it=values.begin();it!=values.end();it++)
        {
            std::map<std::string, std::string>::iterator i;
            cout <<"item: ";
            for(i=it->begin();i!=it->end();i++)
                cout <<"["<<i->first<<", "<<i->second<<"]"<<" ";
            cout <<endl;
        }
    }
    if(TEXT_LA)
    {
        LogAnalysisManager lam("storage/");
        std::string s = "test";
        std::string c = "lam_str";
        std::string lam_str;
        while(cin >> lam_str)
        {
            lam.insert(s, c, lam_str);
        }
        uint64_t count = 0;
        lam.getDVC(s, c, count);
        cout << count << endl;

        TopKT topk;
        lam.getTopK(s, c, 400, topk);
        TopKT::iterator iter;
        for(iter=topk.begin();iter!=topk.end();iter++)
            cout << iter->first << "    " << iter->second<<endl;
    }
//test KMV
    if(TEXT_KMV)
    {
        typedef izenelib::util::KMV<uint128_t> KMVT;
        KMVT* kmv = new KMVT(0, 6);
        std::string kmv_str;

        std::map <std::string, int> kmv_map;
        while(cin >> kmv_str)
        {
            kmv_map[kmv_str] = 1;
            kmv->updateSketch(Utilities::md5ToUint128(kmv_str));
        }

        cout << "exact count: " << kmv_map.size() <<endl;
        cout << "distinct value count: " << kmv->getCardinate() << endl;

        ofstream kmv_fout("kmv.out");
        kmv->save(kmv_fout);

        kmv_fout.close();

        ifstream kmv_fin("kmv.out");
        delete kmv;
        kmv = new KMVT(0, 6);
        kmv->load(kmv_fin);
        cout << "distinct value count: "<<kmv->getCardinate() << endl;
    }
//test hll
    if(TEXT_HLL)
    {
        typedef izenelib::util::HyperLL<uint128_t> HyperLLT;
        HyperLLT* hll = new HyperLLT(seed, 6);
        std::string hll_str;

        std::map<std::string, int> hll1_map;
        while(cin >> hll_str)
        {
            hll1_map[hll_str] = 1;
            hll->updateSketch(Utilities::md5ToUint128(hll_str));
        }
        cout << "exact count: " << hll1_map.size() <<endl;
        cout <<"distinct value count: " << hll->getCardinate() << endl;

        //ofstream fout("hll.out");
        //hll->save(fout);

        //ifstream fin("hll.out");
        //delete hll;
        //hll = new HyperLLT(0, 8);
        //hll->load(fin);

        //cout << "distinct value count: "<<hll->getCardinate() << endl;
    }
//test monitored list
    if(TEXT_ML)
    {
        izenelib::util::MonitoredList<uint32_t, uint32_t, uint32_t> ml(MAXCOUNT);

        uint32_t ml_str;
        while(cin >> ml_str)
        {
            ml.insert(ml_str);
        }

        ml.show();
    }
    return 0;
}


text:
/* CirKit: A circuit toolkit
 * Copyright (C) 2009-2015  University of Bremen
 * Copyright (C) 2015-2017  EPFL
 *
 * Permission is hereby granted, free of charge, to any person
 * obtaining a copy of this software and associated documentation
 * files (the "Software"), to deal in the Software without
 * restriction, including without limitation the rights to use,
 * copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following
 * conditions:
 *
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 * OTHER DEALINGS IN THE SOFTWARE.
 */

#include "dbs.hpp"

#include <sstream>
#include <vector>

#include <boost/accumulators/accumulators.hpp>
#include <boost/accumulators/statistics/stats.hpp>
#include <boost/accumulators/statistics/max.hpp>
#include <boost/accumulators/statistics/mean.hpp>
#include <boost/accumulators/statistics/min.hpp>
#include <boost/format.hpp>
#include <boost/range/algorithm.hpp>

#include <alice/rules.hpp>

#include <core/utils/program_options.hpp>
#include <core/utils/string_utils.hpp>
#include <classical/optimization/esop_minimization.hpp>
#include <classical/optimization/exorcism_minimization.hpp>
#include <reversible/circuit.hpp>
#include <reversible/rcbdd.hpp>
#include <reversible/truth_table.hpp>
#include <cli/reversible_stores.hpp>
#include <reversible/synthesis/rcbdd_synthesis.hpp>
#include <reversible/synthesis/young_subgroup_synthesis.hpp>

using namespace boost::program_options;

namespace cirkit
{

/******************************************************************************
 * Types                                                                      *
 ******************************************************************************/

/******************************************************************************
 * Private functions                                                          *
 ******************************************************************************/

std::tuple<int, int, double> compute_stats( const std::vector<int>& sizes )
{
  using namespace boost::accumulators;

  accumulator_set<double, stats<tag::mean, tag::min, tag::max>> acc;
  acc = boost::for_each( sizes, acc );

  return std::make_tuple( min( acc ), max( acc ), mean( acc ) );
}

/******************************************************************************
 * Public functions                                                           *
 ******************************************************************************/

dbs_command::dbs_command( const environment::ptr& env )
  : cirkit_command( env, "Decomposition based synthesis", "[A. De Vos, Y. Van Rentergem, Adv. Math. Commun. 2 (2008), 183-200]\n[M. Soeken, L. Tague, G.W. Dueck, R. Drechsler, J. of Symb. Comp. 73 (2016), 1-26]" )
{
  opts.add_options()
    ( "symbolic,s",                                            "use symbolic variant (works on RCBDDs)" )
    ( "esop_minimizer", value_with_default( &esop_minimizer ), "ESOP minizer (0: built-in, 1: exorcism); only with symbolic approach" )
    ( "new,n",                                                 "add a new entry to the store; if not set, the current entry is overriden" )
    ;

  options_description tt_options( "Options for the truth table variant" );
  tt_options.add_options()
    ( "ordering",       value( &ordering ),                    "complete variable ordering (space separated, only for truth table variant)" )
    ;

  options_description symb_options( "Options for the symbolic variant" );
  symb_options.add_options()
    ( "mode",           value_with_default( &mode ),           "mode (0: default, 1: swap, 2: hamming)" )
    ( "progress,p",                                            "show progress" )
    ;

  opts.add( tt_options );
  opts.add( symb_options );

  be_verbose();
}

command::rules_t dbs_command::validity_rules() const
{
  return {
    { [&]() { return !this->is_set( "symbolic" ) || env->store<rcbdd>().current_index() >= 0; }, "symbolic method require RCBDD in store" },
    { [&]() { return this->is_set( "symbolic" ) || env->store<binary_truth_table>().current_index() >= 0; }, "no truth table in store" }
  };
}

bool dbs_command::execute()
{
  auto& circuits = env->store<circuit>();
  auto& rcbdds   = env->store<rcbdd>();
  auto& specs    = env->store<binary_truth_table>();

  auto settings = make_settings();

  if ( circuits.empty() || is_set( "new" ) )
  {
    circuits.extend();
  }

  circuit circ;

  auto esopmin_settings = std::make_shared<properties>();
  esopmin_settings->set( "verbose", is_verbose() );
  settings->set( "esopmin", esop_minimizer ? dd_based_exorcism_minimization_func( esopmin_settings ) : dd_based_esop_minimization_func( esopmin_settings ) );

  if ( is_set( "symbolic" ) )
  {
    settings->set( "mode", mode );
    settings->set( "progress", is_set( "progress" ) );

    rcbdd_synthesis( circ, rcbdds.current(), settings, statistics );
  }
  else
  {
    if ( !ordering.empty() )
    {
      std::vector<unsigned> vuordering;
      parse_string_list( vuordering, ordering );
      settings->set( "ordering", vuordering );
    }

    young_subgroup_synthesis( circ, specs.current(), settings, statistics );
  }

  circuits.current() = circ;

  std::cout << boost::format( "[i] run-time: %.2f secs" ) % statistics->get<double>( "runtime" ) << std::endl;

  return true;
}

command::log_opt_t dbs_command::log() const
{
  log_map_t map = {
    { "runtime", statistics->get<double>( "runtime" ) }
  };

  if ( is_set( "symbolic" ) )
  {
    const std::vector<int>& node_count = statistics->get<std::vector<int>>( "node_count" );
    auto stats = compute_stats( node_count );
    map["node_count"] = node_count;
    map["min_size"] = std::get<0>( stats );
    map["max_size"] = std::get<1>( stats );
    map["mean_size"] = std::get<2>( stats );

    std::stringstream ss;
    ss << statistics->get<unsigned long long>( "access" );
    map["access"] = ss.str();
  }

  return log_opt_t( map );
}

}

// Local Variables:
// c-basic-offset: 2
// eval: (c-set-offset 'substatement-open 0)
// eval: (c-set-offset 'innamespace 0)
// End:

max_stars_repo_name: eletesta/cirkit

max_issues_repo_name: eletesta/cirkit

max_forks_repo_name: eletesta/cirkit


text:
#ifdef _WIN32
#define _WIN32_WINNT 0x0501
#endif

/// Dynamic linking of boost test
#define BOOST_TEST_DYN_LINK
/// generate main entry points
#define BOOST_TEST_MODULE ts_shared master_test_suite

#ifdef _WIN32
// https://connect.microsoft.com/VisualStudio/feedback/details/737019
// http://social.msdn.microsoft.com/Forums/vstudio/en-US/878f09ff-408f-47a8-913e-15f3a983e237/stdmaketuple-only-allows-5-parameters-with-vc11
#define  _VARIADIC_MAX  6
#endif

#include <iostream>
#include <boost/asio/io_service.hpp>
#include <boost/chrono.hpp>
#include <boost/test/unit_test.hpp>

#ifdef _WIN32
#pragma warning(push)     // disable for this header only
#pragma warning(disable:4251)
// To get around compile error on windows: ERROR macro is defined
#define GLOG_NO_ABBREVIATED_SEVERITIES
#endif
#include <glog/logging.h>
#ifdef _WIN32
#pragma warning(pop)     // restore original warning level
#endif

#include <rtp++/CorePch.h>
#include "CppUtilTest.h"
#include "ExperimentalTest.h"
#include "LossEstimatorTest.h"
#include "MediaTest.h"
#include "MemberEntryTest.h"
#include "MpRtpTest.h"
#include "NetworkTest.h"
#include "Rfc2326Test.h"
#include "Rfc3261Test.h"
#include "Rfc4571Test.h"
#include "Rfc4585Test.h"
#include "Rfc5285Test.h"
#include "Rfc6184Test.h"
#include "RtcpTest.h"
#include "RtoTest.h"
#include "RtpJitterBufferV2Test.h"
#include "RtpPacketGroupTest.h"
#include "RtpPlayoutBufferTest.h"
#include "RtpTimeTest.h"
#include "SctpTest.h"
#include "TransmissionManagerTest.h"

using namespace std;
using namespace boost::chrono;
using namespace rtp_plus_plus::test;

BOOST_AUTO_TEST_CASE( tc_test_MemberEntry )
{
  MemberEntryTest::test();
}

BOOST_AUTO_TEST_CASE( tc_test_RTO )
{
  RtoTest::test();
}

#if 0
#if 0
BOOST_AUTO_TEST_CASE (tc_RtpPacketGroup)
{
  RtpPacketGroupTest::test();
}

// This unit test tests the correct insertion points of RTP packets into the playout buffer
BOOST_AUTO_TEST_CASE( tc_test_RtpJitterBuffer )
{
  RtpJitterBufferTest::test();
}

// This unit test tests the correct insertion points of RTP packets into the playout buffer
BOOST_AUTO_TEST_CASE( tc_test_RtpJitterBufferV2)
{
  RtpJitterBufferV2Test::test();
}

#endif
#endif

#if 0
BOOST_AUTO_TEST_CASE( tc_test_TcpRtpSockets )
{
//  VLOG(5) << "Testing TCP RTP sockets";
  Rfc4571Test::test();
//  VLOG(5) << "Testing TCP RTP sockets - Done";
}
#endif


text:
#pragma once

#include "Tools/NoCopyU.hpp"

#include <unordered_map>
#include "HTTPRequest.hpp"
#include "HTTPResponse.hpp"
#include <boost/regex.hpp>
#include "ScriptParser.hpp"

namespace proZPRd
{
	/**
	*	@file
	*	@version 1.0
	*	@class HTTPRequestProcessor
	*	@brief Klasa służąca do przetwarzania zapytania na odpowiedź.
	*
	*	Zajmuje się dopasowaniem ustawień i zmiennych zapytania i wytworzeniem odpowiedzi
	*/
	class HTTPRequestProcessor : public Tools::NoCopyU
	{
		public:
			/**
			*	Typ mapy opisującej mapping Host: -> Folder
			*/
			typedef std::unordered_map<std::string, std::string> HostMapping_t;

			/**
			*	Typ mapy opisującej mapping Regex -> Ścieżka parsera
			*/
			typedef std::unordered_map<std::string, std::string> ParserMapping_t;

		public:
			/**
			*	Konstruktor
			*	@param HostMapping przyjmuje jako argument std::unordered_map opisującą mapping Host: -> Folder
			*/
			HTTPRequestProcessor(const HostMapping_t & HostMapping, const ParserMapping_t & PM);

		private:
			const HostMapping_t HostMapping;

			/**
			*	Wektor na podstawie którego będziemy dopasowywać.
			*	Każdy element zawiera parę:
			*		.first => skompilowany regex czekający na porównanie
			*		.second => parser obsługujący zapytanie
			*/
			std::vector<std::pair<boost::regex, ScriptParser>> RunningRegexes;
		public:
			/**
			*	Metoda która wytworzy odpowiedź na podstawie zapytania
			*	@param HR Przyjmuje jako parametr HTTPRequest.
			*/
			HTTPResponse::HTTPResponsePtr Process(const HTTPRequest & HR) const;

		private:
			/**
			*	Sprawdza, czy podany URL nie zawiera nieprawidłowych znaków
			*	@return Zwraca true jeśli poprawny, false jeśli nie.
			*/
			static bool IsURLValid(const std::string & URL);
	};
}