text:
//               Copyright Ross MacGregor 2013
// 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)

#pragma once
#include <boost/asio.hpp>

#include "AsioExpressError/EcToErrorAdapter.hpp"
#include "AsioExpress/MessagePort/DataBuffer.hpp"
#include "AsioExpress/MessagePort/SendQueue.hpp"
#include "AsioExpress/MessagePort/Tcp/ErrorCodes.hpp"
#include "AsioExpress/MessagePort/Tcp/EndPoint.hpp"
#include "AsioExpress/MessagePort/Tcp/private/SocketPointer.hpp"
#include "AsioExpress/MessagePort/Tcp/private/TcpSetSocketOptions.hpp"

namespace AsioExpress {
namespace MessagePort {
namespace Tcp {

template<typename H, typename ProtocolSender>
class AsyncSendHandler
{
public:
  typedef boost::shared_ptr<bool> BoolPointer;

  AsyncSendHandler(
      SocketPointer socket,
      BoolPointer isSending,
      AsioExpress::MessagePort::SendQueuePointer sendQueue,
      H completionHandler) :
    m_socket(socket),
    m_isSending(isSending),
    m_sendQueue(sendQueue),
    m_completionHandler(completionHandler)
  {
  }

  void operator()(boost::system::error_code ec = boost::system::error_code())
  {
    if (ec)
    {
      // We close the socket if we get any error back.
      m_socket->close();

      if (! m_sendQueue->Empty())
        m_sendQueue->Error(m_socket->get_io_service(), AsioExpress::Error(ec));
    }

    if (! m_sendQueue->Empty())
    {
      AsioExpress::MessagePort::SendQueue::Item item = m_sendQueue->Top();
      m_sendQueue->Pop();

      ProtocolSender sender;
      sender.AsyncRun(
        m_socket,
        item.dataBuffer,
        AsyncSendHandler<AsioExpress::CompletionHandler, ProtocolSender>(
          m_socket,
          m_isSending,
          m_sendQueue,
          item.completionHandler));
    }
    else
    {
      *m_isSending = false;
    }

    m_socket->get_io_service().post(boost::asio::detail::bind_handler(m_completionHandler, AsioExpress::Error(ec)));
  }

private:
   SocketPointer      m_socket;
   BoolPointer        m_isSending;
   SendQueuePointer   m_sendQueue;
   H                  m_completionHandler;
};

template<typename ProtocolSender, typename ProtocolReceiver>
class MessagePort
{
public:
  typedef EndPoint EndPointType;

  MessagePort(boost::asio::io_service & ioService);

  ~MessagePort();

  SocketPointer GetSocket() const;

  void SetMessagePortOptions();

  template<typename H>
  void AsyncConnect(
      EndPointType endPoint,
      H completionHandler);

  template<typename H>
  void AsyncSend(
      AsioExpress::MessagePort::DataBufferPointer buffer,
      H completionHandler);

  template<typename H>
  void AsyncReceive(
      AsioExpress::MessagePort::DataBufferPointer buffer,
      H completionHandler);

  void Disconnect();

  std::string GetAddress() const;

private:
   typedef boost::shared_ptr<bool> BoolPointer;

   SocketPointer      m_socket;
   BoolPointer        m_isSending;
   SendQueuePointer   m_sendQueue;
};

template<typename ProtocolSender, typename ProtocolReceiver>
MessagePort<ProtocolSender, ProtocolReceiver>::MessagePort(
    boost::asio::io_service & ioService) :
  m_socket(new boost::asio::ip::tcp::socket(ioService)),
  m_isSending(new bool(false)),
  m_sendQueue(new SendQueue)
{
}

template<typename ProtocolSender, typename ProtocolReceiver>
MessagePort<ProtocolSender, ProtocolReceiver>::~MessagePort()
{
  Disconnect();
}

template<typename ProtocolSender, typename ProtocolReceiver>
SocketPointer MessagePort<ProtocolSender, ProtocolReceiver>::GetSocket() const
{
  return m_socket;
}

template<typename ProtocolSender, typename ProtocolReceiver>
void MessagePort<ProtocolSender, ProtocolReceiver>::SetMessagePortOptions()
{
  SetSocketOptions(m_socket);
}

template<typename ProtocolSender, typename ProtocolReceiver>
template<typename H>
void MessagePort<ProtocolSender, ProtocolReceiver>::AsyncConnect(
    EndPointType endPoint,
    H completionHandler)
{
  m_socket->async_connect(
    endPoint.GetEndPoint(m_socket->get_io_service()),
    AsioExpress::EcToErrorAdapter<H>(completionHandler));
}

template<typename ProtocolSender, typename ProtocolReceiver>
template<typename H>
void MessagePort<ProtocolSender, ProtocolReceiver>::AsyncSend(
    AsioExpress::MessagePort::DataBufferPointer buffer,
    H completionHandler)
{
  if (*m_isSending)
  {
    m_sendQueue->Push(
      AsioExpress::MessagePort::SendQueue::Item(buffer, completionHandler));
    return;
  }

  *m_isSending = true;

  ProtocolSender sender;
  sender.AsyncRun(
    m_socket,
    buffer,
    AsyncSendHandler<H,ProtocolSender>(
      m_socket,
      m_isSending,
      m_sendQueue,
      completionHandler));
}

template<typename ProtocolSender, typename ProtocolReceiver>
template<typename H>
void MessagePort<ProtocolSender, ProtocolReceiver>::AsyncReceive(
    AsioExpress::MessagePort::DataBufferPointer buffer,
    H completionHandler)
{
  ProtocolReceiver receiver;
  receiver.AsyncRun(
    m_socket,
    buffer,
    AsioExpress::EcToErrorAdapter<H>(completionHandler));
}

template<typename ProtocolSender, typename ProtocolReceiver>
void MessagePort<ProtocolSender, ProtocolReceiver>::Disconnect()
{
  m_socket->close();
}

template<typename ProtocolSender, typename ProtocolReceiver>
std::string MessagePort<ProtocolSender, ProtocolReceiver>::GetAddress() const
{
    return m_socket->remote_endpoint().address().to_string();
}

} // namespace Tcp
} // namespace MessagePort
} // namespace AsioExpress

max_stars_repo_name: suhao/asioexpress

max_issues_repo_name: suhao/asioexpress

max_forks_repo_name: suhao/asioexpress


text: #include <boost/mpl/aux_/preprocessed/gcc/advance_forward.hpp>

ext: hpp

max_stars_repo_name: miathedev/BoostForArduino

max_issues_repo_name: miathedev/BoostForArduino

max_forks_repo_name: miathedev/BoostForArduino


text:
// Copyright (c) 2015-2018 Daniel Cooke
// Use of this source code is governed by the MIT license that can be found in the LICENSE file.

#ifndef input_reads_profiler_hpp
#define input_reads_profiler_hpp

#include <cstddef>
#include <vector>

#include <boost/optional.hpp>

#include "config/common.hpp"
#include "basics/aligned_read.hpp"
#include "io/read/read_manager.hpp"
#include "readpipe/read_pipe.hpp"

namespace octopus {

struct ReadSetProfileConfig
{
    unsigned max_samples_per_sample = 10;
    unsigned max_sample_size = 100'000;
};

struct ReadSetProfile
{
    std::size_t mean_read_bytes, read_bytes_stdev;
    std::size_t mean_depth, median_depth, depth_stdev, median_positive_depth, mean_positive_depth;
    std::vector<std::size_t> sample_mean_depth, sample_median_depth, sample_median_positive_depth, sample_mean_positive_depth;
    std::vector<std::size_t> sample_depth_stdev;
    AlignedRead::NucleotideSequence::size_type max_read_length, median_read_length;
    AlignedRead::MappingQuality max_mapping_quality, median_mapping_quality, rmq_mapping_quality;
};

boost::optional<ReadSetProfile>
profile_reads(const std::vector<SampleName>& samples,
              const InputRegionMap& input_regions,
              const ReadManager& source,
              ReadSetProfileConfig config = ReadSetProfileConfig {});

boost::optional<std::size_t>
estimate_mean_read_size(const std::vector<SampleName>& samples,
                        const InputRegionMap& input_regions,
                        ReadManager& read_manager,
                        unsigned max_sample_size = 1000);

std::size_t default_read_size_estimate() noexcept;

} // namespace octopus

#endif

max_stars_repo_name: gmagoon/octopus

max_issues_repo_name: gmagoon/octopus

max_forks_repo_name: gmagoon/octopus


text:
#pragma once

#include "common.hpp"

#include <tr1/cstdint>
#include <boost/numeric/conversion/converter.hpp>

namespace cindex
{
	// guarded static_cast
	template<typename T, typename S>
	inline T guarded_cast(const S& v)
	{
#ifndef NDEBUG
		return boost::numeric::converter<T, S>::convert(v);
#else
		return static_cast<T>(v);
#endif
	}
}

max_stars_repo_name: ByteHamster/silt

max_issues_repo_name: theopengroup/silt

max_forks_repo_name: theopengroup/silt


text:
/*=============================================================================
  Copyright (c) 2010-2016 Bolero MURAKAMI
  https://github.com/bolero-MURAKAMI/Sprig

  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 SPRIG_CONFIG_LIB_FREETYPE_HPP
#define SPRIG_CONFIG_LIB_FREETYPE_HPP

#ifdef SPRIG_CONFIG_LIB_USERCONFIG
#	include "../../../config/libconfig/freetype.hpp"
#endif	// #ifdef SPRIG_CONFIG_LIB_USERCONFIG

#include <sprig/config/pragma_once.hpp>

#ifdef SPRIG_USING_PRAGMA_ONCE
#	pragma once
#endif	// #ifdef SPRIG_USING_PRAGMA_ONCE

#ifdef SPRIG_CONFIG_LIB_AUTO_LINK

#ifndef SPRIG_LIBCONFIG_FREETYPE_BINARY
#	ifdef SPRIG_LIBCONFIG_FREETYPE_LIB
#		define SPRIG_LIBCONFIG_FREETYPE_BINARY SPRIG_LIBCONFIG_FREETYPE_LIB
#	endif	// #ifdef SPRIG_LIBCONFIG_FREETYPE_LIB
#endif	// #ifndef SPRIG_LIBCONFIG_FREETYPE_BINARY

#include <boost/preprocessor/stringize.hpp>
#include <sprig/config/pragma_comment.hpp>

#ifdef SPRIG_HAS_PRAGMA_COMMENT
#	ifdef SPRIG_LIBCONFIG_FREETYPE_BINARY
#		pragma comment(lib, BOOST_PP_STRINGIZE(SPRIG_LIBCONFIG_FREETYPE_BINARY))
#	endif	// #ifdef SPRIG_LIBCONFIG_FREETYPE_BINARY
#endif	// #ifdef SPRIG_HAS_PRAGMA_COMMENT

#include <sprig/config/pragma_message.hpp>

#ifdef SPRIG_HAS_PRAGMA_MESSAGE
#	pragma message("sprig/config/lib/freetype.hpp")
#	ifdef SPRIG_LIBCONFIG_FREETYPE_BINARY
#		pragma message("    lib=" BOOST_PP_STRINGIZE(SPRIG_LIBCONFIG_FREETYPE_BINARY))
#	endif	// #ifdef SPRIG_LIBCONFIG_FREETYPE_BINARY
#endif	// #ifdef SPRIG_HAS_PRAGMA_MESSAGE

#endif	// #ifdef SPRIG_CONFIG_LIB_AUTO_LINK

#include <sprig/config/libinfo/yamlcpp.hpp>

#endif	// #ifndef SPRIG_CONFIG_LIB_FREETYPE_HPP

max_stars_repo_name: bolero-MURAKAMI/Sprig

max_issues_repo_name: bolero-MURAKAMI/Sprig

max_forks_repo_name: bolero-MURAKAMI/Sprig


text:
//  Copyright (c) 2011 Helge Bahmann
//  Copyright (c) 2013 Tim Blechmann
//
//  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)

// Use the gnu builtin __sync_val_compare_and_swap to build
// atomic operations for 32 bit and smaller.

#ifndef BOOST_ATOMIC_DETAIL_GENERIC_CAS_HPP
#define BOOST_ATOMIC_DETAIL_GENERIC_CAS_HPP

#include <cstddef>
#include <boost/cstdint.hpp>
#include <boost/atomic/detail/config.hpp>

#ifdef BOOST_ATOMIC_HAS_PRAGMA_ONCE
#pragma once
#endif

namespace boost {

#define BOOST_ATOMIC_THREAD_FENCE 2
inline void
atomic_thread_fence(memory_order order)
{
    switch(order) {
        case memory_order_relaxed:
            break;
        case memory_order_release:
        case memory_order_consume:
        case memory_order_acquire:
        case memory_order_acq_rel:
        case memory_order_seq_cst:
            __sync_synchronize();
            break;
    }
}

namespace atomics {
namespace detail {

inline void
platform_fence_before(memory_order)
{
    /* empty, as compare_and_swap is synchronizing already */
}

inline void
platform_fence_after(memory_order)
{
    /* empty, as compare_and_swap is synchronizing already */
}

inline void
platform_fence_before_store(memory_order order)
{
    switch(order) {
        case memory_order_relaxed:
        case memory_order_acquire:
        case memory_order_consume:
            break;
        case memory_order_release:
        case memory_order_acq_rel:
        case memory_order_seq_cst:
            __sync_synchronize();
            break;
    }
}

inline void
platform_fence_after_store(memory_order order)
{
    if (order == memory_order_seq_cst)
        __sync_synchronize();
}

inline void
platform_fence_after_load(memory_order order)
{
    switch(order) {
        case memory_order_relaxed:
        case memory_order_release:
            break;
        case memory_order_consume:
        case memory_order_acquire:
        case memory_order_acq_rel:
        case memory_order_seq_cst:
            __sync_synchronize();
            break;
    }
}

template<typename T>
inline bool
platform_cmpxchg32_strong(T & expected, T desired, volatile T * ptr)
{
    T found = __sync_val_compare_and_swap(ptr, expected, desired);
    bool success = (found == expected);
    expected = found;
    return success;
}

class atomic_flag
{
private:
    atomic_flag(const atomic_flag &) /* = delete */ ;
    atomic_flag & operator=(const atomic_flag &) /* = delete */ ;
    uint32_t v_;
public:
    BOOST_CONSTEXPR atomic_flag(void) BOOST_NOEXCEPT : v_(0) {}

    void
    clear(memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT
    {
        atomics::detail::platform_fence_before_store(order);
        const_cast<volatile uint32_t &>(v_) = 0;
        atomics::detail::platform_fence_after_store(order);
    }

    bool
    test_and_set(memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT
    {
        atomics::detail::platform_fence_before(order);
        uint32_t expected = v_;
        do {
            if (expected == 1)
                break;
        } while (!atomics::detail::platform_cmpxchg32(expected, (uint32_t)1, &v_));
        atomics::detail::platform_fence_after(order);
        return expected;
    }
};
#define BOOST_ATOMIC_FLAG_LOCK_FREE 2

}
}
}

#include <boost/atomic/detail/base.hpp>

#if !defined(BOOST_ATOMIC_FORCE_FALLBACK)

#define BOOST_ATOMIC_CHAR_LOCK_FREE 2
#define BOOST_ATOMIC_SHORT_LOCK_FREE 2
#define BOOST_ATOMIC_INT_LOCK_FREE 2
#define BOOST_ATOMIC_LONG_LOCK_FREE (sizeof(long) <= 4 ? 2 : 0)
#define BOOST_ATOMIC_LLONG_LOCK_FREE (sizeof(long long) <= 4 ? 2 : 0)
#define BOOST_ATOMIC_POINTER_LOCK_FREE (sizeof(void *) <= 4 ? 2 : 0)
#define BOOST_ATOMIC_BOOL_LOCK_FREE 2

#include <boost/atomic/detail/cas32strong.hpp>

#endif /* !defined(BOOST_ATOMIC_FORCE_FALLBACK) */

#endif

max_stars_repo_name: danzilio/passenger

max_issues_repo_name: danzilio/passenger

max_forks_repo_name: danzilio/passenger


text:
/*
 * The MIT License (MIT)
 *
 * Copyright (c) 2018 Sylko Olzscher
 *
 */

#include <smf/sml/protocol/reader.h>
#include <smf/sml/obis_db.h>
#include <smf/sml/obis_io.h>
#include <smf/sml/srv_id_io.h>
#include <smf/sml/units.h>
#include <smf/sml/scaler.h>
#include <smf/mbus/defs.h>

#include <cyng/io/io_buffer.h>
#include <cyng/io/io_chrono.hpp>
#include <cyng/io/serializer.h>
#include <cyng/value_cast.hpp>
#include <cyng/numeric_cast.hpp>
#include <cyng/xml.h>
#include <cyng/factory.h>
#include <cyng/vm/generator.h>
#include <cyng/vm/manip.h>
#include <cyng/io/swap.h>

#include <boost/uuid/nil_generator.hpp>
#include <boost/core/ignore_unused.hpp>

namespace node
{
	namespace sml
	{

		reader::reader()
			: rgn_()
			, ro_(rgn_())
		{
			reset();
		}

		void reader::reset()
		{
			ro_.reset(rgn_(), 0);
		}

		cyng::vector_t reader::read(cyng::tuple_t const& msg, std::size_t idx)
		{
			return read_msg(msg.begin(), msg.end(), idx);
		}

		cyng::vector_t reader::read_msg(cyng::tuple_t::const_iterator pos, cyng::tuple_t::const_iterator end, std::size_t idx)
		{
			std::size_t count = std::distance(pos, end);
			BOOST_ASSERT_MSG(count == 5, "SML message");
			if (count!= 5)	return cyng::vector_t{};

			//
			//	instruction vector
			//
			cyng::vector_t prg;

			//
			//	delayed output
			//
			prg << cyng::generate_invoke_unwinded("log.msg.debug"
				, "message #"
				, idx);

			//
			//	reset readout context
			//
			ro_.set_index(idx);

			//
			//	(1) - transaction id
			//	This is typically a printable sequence of 6 up to 9 ASCII values
			//
			cyng::buffer_t buffer;
			ro_.set_trx(cyng::value_cast(*pos++, buffer));

			//
			//	(2) groupNo
			//
			ro_.set_value("groupNo", *pos++);

			//
			//	(3) abortOnError
			//
			ro_.set_value("abortOnError", *pos++);

			//
			//	(4/5) CHOICE - msg type
			//
			cyng::tuple_t choice;
			choice = cyng::value_cast(*pos++, choice);
			prg << cyng::unwinder(read_choice(choice));
			//BOOST_ASSERT_MSG(choice.size() == 2, "CHOICE");
			//if (choice.size() == 2)
			//{
			//	ro_.set_value("code", choice.front());
			//	prg << cyng::unwinder(read_body(choice.front(), choice.back()));
			//}

			//
			//	(6) CRC16
			//
			ro_.set_value("crc16", *pos);

			return prg;
		}

		void reader::set_trx(cyng::buffer_t const& trx)
		{
			ro_.set_trx(trx);
		}

		cyng::vector_t reader::read_choice(cyng::tuple_t const& choice)
		{
			BOOST_ASSERT_MSG(choice.size() == 2, "CHOICE");
			if (choice.size() == 2)
			{
				ro_.set_value("code", choice.front());
				return read_body(choice.front(), choice.back());
			}
			return cyng::vector_t();
		}

		cyng::vector_t reader::read_body(cyng::object type, cyng::object body)
		{
			auto code = cyng::value_cast<std::uint16_t>(type, 0);

			cyng::tuple_t tpl;
			tpl = cyng::value_cast(body, tpl);

			switch (code)
			{
			case BODY_OPEN_REQUEST:
				return read_public_open_request(tpl.begin(), tpl.end());
			case BODY_OPEN_RESPONSE:
				return read_public_open_response(tpl.begin(), tpl.end());
			case BODY_CLOSE_REQUEST:
				return read_public_close_request(tpl.begin(), tpl.end());
			case BODY_CLOSE_RESPONSE:
				return read_public_close_response(tpl.begin(), tpl.end());
			case BODY_GET_PROFILE_PACK_REQUEST:
				//cyng::xml::write(node.append_child("data"), body);
				break;
			case BODY_GET_PROFILE_PACK_RESPONSE:
				//cyng::xml::write(node.append_child("data"), body);
				break;
			case BODY_GET_PROFILE_LIST_REQUEST:
				return read_get_profile_list_request(tpl.begin(), tpl.end());
			case BODY_GET_PROFILE_LIST_RESPONSE:
				return read_get_profile_list_response(tpl.begin(), tpl.end());
			case BODY_GET_PROC_PARAMETER_REQUEST:
				return read_get_proc_parameter_request(tpl.begin(), tpl.end());
			case BODY_GET_PROC_PARAMETER_RESPONSE:
				return read_get_proc_parameter_response(tpl.begin(), tpl.end());
			case BODY_SET_PROC_PARAMETER_REQUEST:
				return read_set_proc_parameter_request(tpl.begin(), tpl.end());
			case BODY_SET_PROC_PARAMETER_RESPONSE:
				//cyng::xml::write(node.append_child("data"), body);
				break;
			case BODY_GET_LIST_REQUEST:
				return read_get_list_request(tpl.begin(), tpl.end());
			case BODY_GET_LIST_RESPONSE:
				//	ToDo: read get list response (0701)
				return read_get_list_response(tpl.begin(), tpl.end());
			case BODY_ATTENTION_RESPONSE:
				return read_attention_response(tpl.begin(), tpl.end());
			default:
				//cyng::xml::write(node.append_child("data"), body);
				break;
			}

			return cyng::generate_invoke("log.msg.fatal"
				, "unknown SML message code"
				, code);
		}

		cyng::vector_t reader::read_public_open_request(cyng::tuple_t::const_iterator pos, cyng::tuple_t::const_iterator end)
		{
			std::size_t count = std::distance(pos, end);
			BOOST_ASSERT_MSG(count == 7, "Public Open Request");
			if (count != 7)	return cyng::vector_t{};

			//	codepage "ISO 8859-15"
			ro_.set_value("codepage", *pos++);

			//
			//	clientId (MAC)
			//	Typically 7 bytes to identify gateway/MUC
			read_client_id(*pos++);

			//
			//	reqFileId
			//
			//ro_.set_value("reqFileId", *pos++);
			read_string("reqFileId", *pos++);

			//
			//	serverId
			//
			read_server_id(*pos++);

			//
			//	username
			//
			read_string("userName", *pos++);

			//
			//	password
			//
			read_string("password", *pos++);

			//
			//	sml-Version: default = 1
			//
			ro_.set_value("SMLVersion", *pos++);

			//
			//	instruction vector
			//
			return cyng::generate_invoke("sml.public.open.request"
				, ro_.pk_
				, ro_.trx_
				, ro_.idx_
				, ro_.client_id_
				, ro_.server_id_
				, ro_.get_value("reqFileId")
				, ro_.get_value("userName")
				, ro_.get_value("password"));

		}

		cyng::vector_t reader::read_public_open_response(cyng::tuple_t::const_iterator pos, cyng::tuple_t::const_iterator end)
		{
			std::size_t count = std::distance(pos, end);
			BOOST_ASSERT_MSG(count == 6, "Public Open Response");
			if (count != 6)	return cyng::vector_t{};

			//	codepage "ISO 8859-15"
			ro_.set_value("codepage", *pos++);

			//
			//	clientId (MAC)
			//	Typically 7 bytes to identify gateway/MUC
			read_client_id(*pos++);

			//
			//	reqFileId
			//
			read_string("reqFileId", *pos++);

			//
			//	serverId
			//
			read_server_id(*pos++);

			//
			//	refTime
			//
			ro_.set_value("refTime", *pos++);

			//	sml-Version: default = 1
			ro_.set_value("SMLVersion", *pos++);

			return cyng::generate_invoke("sml.public.open.response"
				, ro_.pk_
				, ro_.trx_
				, ro_.idx_
				, ro_.client_id_
				, ro_.server_id_
				, ro_.get_value("reqFileId"));
		}

		cyng::vector_t reader::read_public_close_request(cyng::tuple_t::const_iterator pos, cyng::tuple_t::const_iterator end)
		{
			std::size_t count = std::distance(pos, end);
			BOOST_ASSERT_MSG(count == 1, "Public Close Request");
			if (count != 1)	return cyng::vector_t{};

			ro_.set_value("globalSignature", *pos++);

			return cyng::generate_invoke("sml.public.close.request"
				, ro_.pk_
				, ro_.trx_
				, ro_.idx_);
		}

		cyng::vector_t reader::read_public_close_response(cyng::tuple_t::const_iterator pos, cyng::tuple_t::const_iterator end)
		{
			std::size_t count = std::distance(pos, end);
			BOOST_ASSERT_MSG(count == 1, "Public Close Response");
			if (count != 1)	return cyng::vector_t{};

			ro_.set_value("globalSignature", *pos++);

			return cyng::generate_invoke("sml.public.close.response"
				, ro_.pk_
				, ro_.trx_
				, ro_.idx_);
		}

		cyng::vector_t reader::read_get_profile_list_response(cyng::tuple_t::const_iterator pos, cyng::tuple_t::const_iterator end)
		{
			std::size_t count = std::distance(pos, end);
			BOOST_ASSERT_MSG(count == 9, "Get Profile List Response");
			if (count != 9)	return cyng::vector_t{};

			//
			//	serverId
			//
			read_server_id(*pos++);

			//
			//	actTime
			//
			read_time("actTime", *pos++);

			//
			//	regPeriod
			//
			ro_.set_value("regPeriod", *pos++);

			//
			//	parameterTreePath (OBIS)
			//
			std::vector<obis> path = read_param_tree_path(*pos++);

			//
			//	valTime
			//
			read_time("valTime", *pos++);

			//
			//	M-bus status
			//
			ro_.set_value("status", *pos++);

			//	period-List (1)
			//	first we make the TSMLGetProfileListResponse complete, then
			//	the we store the entries in TSMLPeriodEntry.
			cyng::tuple_t tpl;
			tpl = cyng::value_cast(*pos++, tpl);
			read_period_list(path, tpl.begin(), tpl.end());

			//	rawdata
			ro_.set_value("rawData", *pos++);

			//	periodSignature
			ro_.set_value("signature", *pos++);

			return cyng::generate_invoke("db.insert.meta"
				, ro_.pk_
				, ro_.trx_
				, ro_.idx_
				, ro_.get_value("roTime")
				, ro_.get_value("actTime")
				, ro_.get_value("valTime")
				, ro_.client_id_
				, ro_.server_id_
				, ro_.get_value("status"));

		}

		cyng::vector_t reader::read_get_profile_list_request(cyng::tuple_t::const_iterator pos, cyng::tuple_t::const_iterator end)
		{
			std::size_t count = std::distance(pos, end);
			BOOST_ASSERT_MSG(count == 9, "Get Profile List Request");
			if (count != 9)	return cyng::vector_t{};

			//
			//	serverId
			//	Typically 7 bytes to identify gateway/MUC
			//
			read_server_id(*pos++);

			//
			//	username
			//
			read_string("userName", *pos++);

			//
			//	password
			//
			read_string("password", *pos++);

			//
			//	rawdata (typically not set)
			//
			ro_.set_value("rawData", *pos++);

			//
			//	start/end time
			//
			read_time("beginTime", *pos++);
			read_time("endTime", *pos++);

			//	parameterTreePath (OBIS)
			//
			std::vector<obis> path = read_param_tree_path(*pos++);
			BOOST_ASSERT(path.size() == 1);

			//
			//	object list
			//
			auto obj_list = *pos++;
			boost::ignore_unused(obj_list);

			//
			//	dasDetails
			//
			auto const das_details = *pos++;
			boost::ignore_unused(das_details);

			//
			//	instruction vector
			//
			if (path.size()) {
				return cyng::generate_invoke("sml.get.profile.list.request"
					, ro_.pk_
					, ro_.trx_
					, ro_.idx_
					, ro_.client_id_
					, ro_.server_id_
					, ro_.get_value("userName")
					, ro_.get_value("password")
					, ro_.get_value("beginTime")
					, ro_.get_value("endTime")
					, path.front().to_buffer());
			}

			return cyng::vector_t{};
		}

		cyng::vector_t reader::read_get_proc_parameter_response(cyng::tuple_t::const_iterator pos, cyng::tuple_t::const_iterator end)
		{
			std::size_t count = std::distance(pos, end);
			BOOST_ASSERT_MSG(count == 3, "Get Proc Parameter Response");
			if (count != 3)	return cyng::vector_t{};

			//
			//	serverId
			//
			read_server_id(*pos++);

			//
			//	parameterTreePath (OBIS)
			//
			std::vector<obis> path = read_param_tree_path(*pos++);
			BOOST_ASSERT(path.size() == 1);

			//
			//	parameterTree
			//
			cyng::tuple_t tpl;
			tpl = cyng::value_cast(*pos++, tpl);

			//
			//	this is a parameter tree
			//	read_param_tree(0, tpl.begin(), tpl.end());
			//
			return read_get_proc_parameter_response(path, 0, tpl.begin(), tpl.end());
		}

		cyng::vector_t reader::read_get_proc_parameter_response(std::vector<obis> path
			, std::size_t depth
			, cyng::tuple_t::const_iterator pos
			, cyng::tuple_t::const_iterator end)
		{
			std::size_t count = std::distance(pos, end);
			BOOST_ASSERT_MSG(count == 3, "SML Tree");
			if (count != 3)	return cyng::vector_t{};

			//
			//	1. parameterName Octet String,
			//
			obis code = read_obis(*pos++);
			if (code == path.back()) {
				//	root
				//std::cout << "root: " << code << std::endl;
				BOOST_ASSERT(depth == 0);
			}
			else {
				BOOST_ASSERT(depth == path.size());
				path.push_back(code);
			}

			//
			//	2. parameterValue SML_ProcParValue OPTIONAL,
			//
			auto attr = read_parameter(*pos++);

			//
			//	program vector
			//
			cyng::vector_t prg;

			if (path.size() == 1 && path.front() == OBIS_CLASS_OP_LOG_STATUS_WORD) {
				//	generate status word

				//to_param_map
				return cyng::generate_invoke("sml.get.proc.status.word"
					, ro_.pk_
					, ro_.trx_
					, ro_.idx_
					, from_server_id(ro_.server_id_)
					, OBIS_CLASS_OP_LOG_STATUS_WORD.to_buffer()	//	same as path.front()
					, cyng::value_cast<std::uint32_t>(attr.second, 0u));	//	[u32] value
			}
			else if (path.size() == 1 && path.front() == OBIS_CODE_ROOT_MEMORY_USAGE) {
				//	get memory usage
				read_get_proc_multiple_parameters(*pos++);
				return cyng::generate_invoke("sml.get.proc.param.memory"
					, ro_.pk_
					, ro_.trx_
					, ro_.idx_
					, from_server_id(ro_.server_id_)
					, OBIS_CODE_ROOT_MEMORY_USAGE.to_buffer()	//	same as path.front()
					, ro_.get_value(OBIS_CODE_ROOT_MEMORY_MIRROR)	//	mirror
					, ro_.get_value(OBIS_CODE_ROOT_MEMORY_TMP));	//	tmp
			}
			else if (path.size() == 1 && path.front() == OBIS_CODE_ROOT_W_MBUS_STATUS) {
				//	get memory usage
				read_get_proc_multiple_parameters(*pos++);
				return cyng::generate_invoke("sml.get.proc.param.wmbus.status"
					, ro_.pk_
					, ro_.trx_
					, ro_.idx_
					, from_server_id(ro_.server_id_)
					, OBIS_CODE_ROOT_W_MBUS_STATUS.to_buffer()	//	same as path.front()
					, ro_.get_string(OBIS_W_MBUS_ADAPTER_MANUFACTURER)	//	Manufacturer (RC1180-MBUS3)
					, ro_.get_value(OBIS_W_MBUS_ADAPTER_ID)	//	Adapter ID (A8 15 34 83 40 04 01 31)
					, ro_.get_string(OBIS_W_MBUS_FIRMWARE)	//	firmware version (3.08)
					, ro_.get_string(OBIS_W_MBUS_HARDWARE)	//	hardware version (2.00)
				);
			}
			else if (path.size() == 1 && path.front() == OBIS_CODE_IF_wMBUS) {
				//	get memory usage
				read_get_proc_multiple_parameters(*pos++);
				return cyng::generate_invoke("sml.get.proc.param.wmbus.config"
					, ro_.pk_
					, ro_.trx_
					, ro_.idx_
					, from_server_id(ro_.server_id_)
					, OBIS_CODE_IF_wMBUS.to_buffer()	//	same as path.front()
					, ro_.get_value(OBIS_W_MBUS_PROTOCOL)	//	protocol
					, ro_.get_value(OBIS_W_MBUS_S_MODE)	//	S2 mode in seconds (30)
					, ro_.get_value(OBIS_W_MBUS_T_MODE)	//	T2 mode in seconds (20)
					, ro_.get_value(OBIS_W_MBUS_REBOOT)	//	automatic reboot in seconds (86400)
					, ro_.get_value(OBIS_W_MBUS_POWER)	//	0
					, ro_.get_value(OBIS_W_MBUS_INSTALL_MODE)	//	installation mode (true)
				);
			}
			else if (path.size() == 1 && path.front() == OBIS_CODE_ROOT_IPT_STATE) {
				//	get IP-T status
				read_get_proc_multiple_parameters(*pos++);
				//	81 49 17 07 00 00 ip address
				//	81 49 1A 07 00 00 local port
				//	81 49 19 07 00 00 remote port
				return cyng::generate_invoke("sml.get.proc.param.ipt.state"
					, ro_.pk_
					, ro_.trx_
					, ro_.idx_
					, from_server_id(ro_.server_id_)
					, OBIS_CODE_ROOT_IPT_STATE.to_buffer()	//	same as path.front()
					, ro_.get_value(OBIS_CODE_ROOT_IPT_STATE_ADDRESS)	//	IP adress
					, ro_.get_value(OBIS_CODE_ROOT_IPT_STATE_PORT_LOCAL)	//	local port
					, ro_.get_value(OBIS_CODE_ROOT_IPT_STATE_PORT_REMOTE)	//	remote port
				);
			}
			else if (path.size() == 2 && path.front() == OBIS_CODE_ROOT_DEVICE_IDENT)
			{
				if (path.back() == OBIS_CODE_DEVICE_CLASS) {
					//
					//	device class
					//	CODE_ROOT_DEVICE_IDENT (81, 81, C7, 82, 01, FF)
					//		CODE_DEVICE_CLASS (81, 81, C7, 82, 02, FF)
					//
#ifdef _DEBUG
					//std::cout << "OBIS_CODE_DEVICE_CLASS: " << cyng::io::to_str(attr.second) << std::endl;
#endif
					return cyng::generate_invoke("sml.get.proc.param.simple"
						, ro_.pk_
						, ro_.trx_
						, ro_.idx_
						, ro_.server_id_
						, path.back().to_buffer()
						, attr.second);	//	value

				}
				else if (path.back() == OBIS_DATA_MANUFACTURER) {
					//
					//	device class
					//
#ifdef _DEBUG
					//std::cout << "OBIS_DATA_MANUFACTURER: " << cyng::io::to_str(attr.second) << std::endl;
#endif
					return cyng::generate_invoke("sml.get.proc.param.simple"
						, ro_.pk_
						, ro_.trx_
						, ro_.idx_
						, ro_.server_id_
						, path.back().to_buffer()
						, attr.second);	//	value
				}
				else if (path.back() == OBIS_CODE_SERVER_ID) {
					//
					//	server ID (81 81 C7 82 04 FF)
					//
#ifdef _DEBUG
					//std::cout << "OBIS_CODE_SERVER_ID: " << cyng::io::to_str(attr.second) << std::endl;
#endif
					return cyng::generate_invoke("sml.get.proc.param.simple"
						, ro_.pk_
						, ro_.trx_
						, ro_.idx_
						, ro_.server_id_
						, path.back().to_buffer()
						, attr.second);	//	value
				}
			}
			else if (path.size() == 2 && path.front() == OBIS_CODE_ROOT_IPT_PARAM) {
				const auto r = path.back().is_matching(0x81, 0x49, 0x0D, 0x07, 0x00);
				if (r.second) {
#ifdef _DEBUG
					std::cout << "OBIS_CODE_ROOT_IPT_PARAM: " << +r.first << std::endl;
#endif
					//	get IP-T params
					read_get_proc_multiple_parameters(*pos++);
					//	81 49 17 07 00 NN ip address/hostname as string - optional
					//	81 49 1A 07 00 NN local port
					//	81 49 19 07 00 NN remote port
					return cyng::generate_invoke("sml.get.proc.param.ipt.param"
						, ro_.pk_
						, ro_.trx_
						, ro_.idx_
						, from_server_id(ro_.server_id_)
						, OBIS_CODE_ROOT_IPT_PARAM.to_buffer()	//	same as path.front()
						, r.first
						, ro_.get_value(make_obis(0x81, 0x49, 0x17, 0x07, 0x00, r.first))	//	IP adress / hostname
						, ro_.get_value(make_obis(0x81, 0x49, 0x1A, 0x07, 0x00, r.first))	//	local port
						, ro_.get_value(make_obis(0x81, 0x49, 0x19, 0x07, 0x00, r.first))	//	remote port
						, ro_.get_string(make_obis(0x81, 0x49, 0x63, 0x3C, 0x01, r.first))	//	device name
						, ro_.get_string(make_obis(0x81, 0x49, 0x63, 0x3C, 0x02, r.first))	//	password
					);
				}
			}
			else if (path.size() == 3 && (path.front() == OBIS_CODE_ROOT_VISIBLE_DEVICES) && path.back().is_matching(0x81, 0x81, 0x10, 0x06)) {

				//
				//	collect meter info
				//	* 81 81 C7 82 04 FF: server ID
				//	* 81 81 C7 82 02 FF: --- (device class)
				//	* 01 00 00 09 0B 00: timestamp
				//
				read_get_proc_multiple_parameters(*pos++);

				return cyng::generate_invoke("sml.get.proc.param.srv.visible"
					, ro_.pk_
					, ro_.trx_
					, ro_.idx_
					, from_server_id(ro_.server_id_)
					, OBIS_CODE_ROOT_VISIBLE_DEVICES.to_buffer()
					, path.back().get_number()	//	4/5
					, ro_.get_value(OBIS_CODE_SERVER_ID)	//	meter ID
					, ro_.get_string(OBIS_CODE_DEVICE_CLASS)	//	device class
					, ro_.get_value(OBIS_CURRENT_UTC));	//	UTC
			}
			else if (path.size() == 3 && (path.front() == OBIS_CODE_ROOT_ACTIVE_DEVICES) && path.back().is_matching(0x81, 0x81, 0x11, 0x06)) {

				//
				//	collect meter info
				//	* 81 81 C7 82 04 FF: server ID
				//	* 81 81 C7 82 02 FF: --- (device class)
				//	* 01 00 00 09 0B 00: timestamp
				//
				read_get_proc_multiple_parameters(*pos++);

				return cyng::generate_invoke("sml.get.proc.param.srv.active"
					, ro_.pk_
					, ro_.trx_
					, ro_.idx_
					, from_server_id(ro_.server_id_)
					, OBIS_CODE_ROOT_ACTIVE_DEVICES.to_buffer()
					, path.back().get_number()	//	4/5
					, ro_.get_value(OBIS_CODE_SERVER_ID)	//	meter ID
					, ro_.get_string(OBIS_CODE_DEVICE_CLASS)	//	device class
					, ro_.get_value(OBIS_CURRENT_UTC));	//	UTC
			}
			else if (path.size() == 3 && (path.front() == OBIS_CODE_ROOT_DEVICE_IDENT) && path.back().is_matching(0x81, 0x81, 0xc7, 0x82, 0x07).second) {

				//	* 81, 81, c7, 82, 08, ff:	CURRENT_VERSION/KERNEL
				//	* 81, 81, 00, 02, 00, 00:	VERSION
				//	* 81, 81, c7, 82, 0e, ff:	activated/deactivated
				read_get_proc_multiple_parameters(*pos++);

#ifdef _DEBUG
				//std::cout << "81 81 c7 82 08 ff: " << cyng::io::to_str(ro_.get_value("81 81 c7 82 08 ff")) << std::endl;
				//std::cout << "81 81 00 02 00 00: " << cyng::io::to_str(ro_.get_value("81 81 00 02 00 00")) << std::endl;
				//std::cout << "81 81 c7 82 0e ff: " << cyng::io::to_str(ro_.get_value("81 81 c7 82 0e ff")) << std::endl;
#endif

				return cyng::generate_invoke("sml.get.proc.param.firmware"
					, ro_.pk_
					, ro_.trx_
					, ro_.idx_
					, from_server_id(ro_.server_id_)
					, OBIS_CODE_ROOT_DEVICE_IDENT.to_buffer()
					, path.back().get_storage()	//	[5] as u32
					, ro_.get_string(OBIS_CODE_DEVICE_KERNEL)	//	root-device-id name/section
					, ro_.get_string(OBIS_CODE_VERSION)	//	version
					, ro_.get_value(OBIS_CODE_DEVICE_ACTIVATED));	//	active/inactive

			}
			else {

				//
				//	OBIS path not implemented yet
				//

				;
			}

			//
			//	3. child_List List_of_SML_Tree OPTIONAL
			//
			return read_tree_list(path, *pos++, ++depth);

		}

		cyng::vector_t reader::read_tree_list(std::vector<obis> path, cyng::object obj, std::size_t depth)
		{
			cyng::vector_t prg;
			cyng::tuple_t tpl;
			tpl = cyng::value_cast(obj, tpl);
			for (auto const child : tpl)
			{
				cyng::tuple_t tmp;
				tmp = cyng::value_cast(child, tmp);

				prg << cyng::unwinder(read_get_proc_parameter_response(path, depth, tmp.begin(), tmp.end()));
			}
			return prg;
		}

		void reader::read_get_proc_multiple_parameters(cyng::object obj)
		{
			cyng::tuple_t tpl;
			tpl = cyng::value_cast(obj, tpl);
			for (auto const child : tpl)
			{
				read_get_proc_single_parameter(child);
			}

		}

		void reader::read_get_proc_single_parameter(cyng::object obj)
		{
			cyng::tuple_t tmp;
			tmp = cyng::value_cast(obj, tmp);
			read_get_proc_single_parameter(tmp.begin(), tmp.end());
		}

		void reader::read_get_proc_single_parameter(cyng::tuple_t::const_iterator pos
			, cyng::tuple_t::const_iterator end)
		{
			std::size_t count = std::distance(pos, end);
			BOOST_ASSERT_MSG(count == 3, "SML Tree");
			if (count != 3)	return;

			//
			//	1. parameterName Octet String,
			//
			obis code = read_obis(*pos++);

			//
			//	2. parameterValue SML_ProcParValue OPTIONAL,
			//
			auto attr = read_parameter(*pos++);
			ro_.set_value(code, attr.second);

			//std::cerr
			//	<< to_hex(code)
			//	<< " = "
			//	//<< cyng::io::to_str(attr.second)
			//	<< std::endl;

		}

		cyng::vector_t reader::read_get_proc_parameter_request(cyng::tuple_t::const_iterator pos, cyng::tuple_t::const_iterator end)
		{
			std::size_t count = std::distance(pos, end);
			BOOST_ASSERT_MSG(count == 5, "Get Profile List Request");
			if (count != 5)	return cyng::vector_t{};

			//
			//	serverId
			//
			read_server_id(*pos++);

			//
			//	username
			//
			read_string("userName", *pos++);

			//
			//	password
			//
			read_string("password", *pos++);

			//
			//	parameterTreePath == parameter address
			//
			std::vector<obis> path = read_param_tree_path(*pos++);
			BOOST_ASSERT(!path.empty());

			//
			//	attribute/constraints
			//
			//	*pos

			if (path.size() == 1)
			{
				return cyng::generate_invoke("sml.get.proc.parameter.request"
					, ro_.pk_
					, ro_.trx_
					, ro_.idx_
					, ro_.server_id_
					, ro_.get_value("userName")
					, ro_.get_value("password")
					, path.at(0).to_buffer()
					, *pos);

			}

			return cyng::generate_invoke("sml.get.proc.parameter.request"
				, ro_.pk_
				, ro_.trx_
				, ro_.idx_
				, ro_.server_id_
				, ro_.get_value("userName")
				, ro_.get_value("password")
				, to_hex(path.at(0))	//	ToDo: send complete path
				, *pos);	//	attribute
		}

		cyng::vector_t reader::read_set_proc_parameter_request(cyng::tuple_t::const_iterator pos, cyng::tuple_t::const_iterator end)
		{
			std::size_t count = std::distance(pos, end);
			BOOST_ASSERT_MSG(count == 5, "Set Proc Parameter Request");
            if (count != 5) return cyng::vector_t{};

            //
            //	serverId
            //
            read_server_id(*pos++);

            //
            //	username
            //
            read_string("userName", *pos++);

            //
            //	password
            //
            read_string("password", *pos++);

            //
            //	parameterTreePath == parameter address
            //
            std::vector<obis> path = read_param_tree_path(*pos++);

            //
            //	parameterTree
            //
            cyng::tuple_t tpl;
            tpl = cyng::value_cast(*pos++, tpl);

            //
            //	recursiv call to an parameter tree - similiar to read_param_tree()
            //
            return read_set_proc_parameter_request_tree(path, 0, tpl.begin(), tpl.end());
		}

		cyng::vector_t reader::read_set_proc_parameter_request_tree(std::vector<obis> path
			, std::size_t depth
			, cyng::tuple_t::const_iterator pos
			, cyng::tuple_t::const_iterator end)
		{
			cyng::vector_t prg;

			std::size_t count = std::distance(pos, end);
			BOOST_ASSERT_MSG(count == 3, "SML Tree");
            if (count != 3) return cyng::vector_t{};

			//
			//	1. parameterName Octet String,
			//
			obis code = read_obis(*pos++);
			if (code == path.back()) {
				//	root
				//std::cout << "root: " << code << std::endl;
				BOOST_ASSERT(depth == 0);
			}
			else {
				path.push_back(code);
			}

			//
			//	2. parameterValue SML_ProcParValue OPTIONAL,
			//
			auto attr = read_parameter(*pos++);

			if (depth == 0) {

				if (OBIS_CODE_IF_1107 == path.front()) {
					//
					//	root: IEC 62056-21 device
					//

					auto r = code.is_matching(0x81, 0x81, 0xC7, 0x93, 0x09);
					if (r.second) {

						//
						//	add/modify IEC 62056-21 device
						//
						BOOST_ASSERT(path.size() == 3);

						//
						//	collect if 1107 device data
						//
						cyng::tuple_t tpl;
						tpl = cyng::value_cast(*pos, tpl);
						BOOST_ASSERT(tpl.size() <= 5);
						cyng::param_map_t params;
						for (auto obj : tpl) {
							auto const m = read_param_tree(depth + 1, obj);
							params.insert(m.begin(), m.end());	//	preserve existing keys
						}

						return cyng::generate_invoke("sml.set.proc.if1107.device"
							, ro_.pk_
							, ro_.trx_
							, r.first
							, ro_.server_id_
							, ro_.get_value("userName")
							, ro_.get_value("password")
							, params);
							//, ro_.get_value(OBIS_CODE_IF_1107_METER_ID)
							//, ro_.get_value(OBIS_CODE_IF_1107_BAUDRATE)
							//, ro_.get_value(OBIS_CODE_IF_1107_ADDRESS)
							//, ro_.get_value(OBIS_CODE_IF_1107_P1)
							//, ro_.get_value(OBIS_CODE_IF_1107_W5));
					}
					else {

						BOOST_ASSERT(path.size() == 2);

						//
						//	set IEC 62056-21 parameters
						//
						prg << cyng::generate_invoke_unwinded("sml.set.proc.if1107.param"
							, ro_.pk_
							, ro_.trx_
							, ro_.server_id_
							, ro_.get_value("userName")
							, ro_.get_value("password")
							, path.at(1).to_buffer()
							, attr.second);

					}
				}
				else if (OBIS_CODE_ROOT_IPT_PARAM == path.front()) {

					//
					//	set IP-T parameters
					//
					BOOST_ASSERT_MSG(path.size() == 3, "OBIS_CODE_ROOT_IPT_PARAM param tree too short");
					prg << cyng::unwinder(set_proc_param_request_ipt_param(code, attr.second));

				}
				else if (OBIS_CODE_ACTIVATE_DEVICE == path.front()) {

					//
					//	activate device
					//
					BOOST_ASSERT_MSG(path.size() == 3, "OBIS_CODE_ACTIVATE_DEVICE param tree too short");

					cyng::buffer_t tmp;
					tmp = cyng::value_cast(attr.second, tmp);

					auto r = path.at(1).is_matching(0x81, 0x81, 0x11, 0x06, 0xfb);
					if (r.second) {

						prg << cyng::generate_invoke_unwinded("sml.set.proc.activate"
							, ro_.pk_
							, ro_.trx_
							, r.first	//	should be 1
							, ro_.server_id_
							, ro_.get_value("userName")
							, ro_.get_value("password")
							, tmp);
					}

				}
				else if (OBIS_CODE_DEACTIVATE_DEVICE == path.front()) {

					//
					//	deactivate device
					//
					BOOST_ASSERT_MSG(path.size() == 3, "OBIS_CODE_DEACTIVATE_DEVICE parameter tree too short");

					cyng::buffer_t tmp;
					tmp = cyng::value_cast(attr.second, tmp);

					auto r = path.at(1).is_matching(0x81, 0x81, 0x11, 0x06, 0xfc);
					if (r.second) {

						prg << cyng::generate_invoke_unwinded("sml.set.proc.deactivate"
							, ro_.pk_
							, ro_.trx_
							, r.first	//	should be 1
							, ro_.server_id_
							, ro_.get_value("userName")
							, ro_.get_value("password")
							, tmp);
					}
				}
				else if (OBIS_CODE_DELETE_DEVICE == path.front()) {

				//
				//	delete device
				//
				BOOST_ASSERT_MSG(path.size() == 3, "OBIS_CODE_DELETE_DEVICE parameter tree too short");

					cyng::buffer_t tmp;
					tmp = cyng::value_cast(attr.second, tmp);

					auto r = path.at(1).is_matching(0x81, 0x81, 0x11, 0x06, 0xfd);
					if (r.second) {

						prg << cyng::generate_invoke_unwinded("sml.set.proc.delete"
							, ro_.pk_
							, ro_.trx_
							, r.first	//	should be 1
							, ro_.server_id_
							, ro_.get_value("userName")
							, ro_.get_value("password")
							, tmp);
					}
				}
				else if (OBIS_PUSH_OPERATIONS == path.front()) {

					//
					//	set push target
					//
					//	example: push delay
					//	81 81 c7 8a 01 ff => 81 81 c7 8a 01 [01] => 81 81 c7 8a 03 ff
					//	//	std::cout << to_hex(path) << std::endl;
					BOOST_ASSERT_MSG(path.size() == 2, "OBIS_PUSH_OPERATIONS param tree has wro");
					prg << cyng::unwinder(set_proc_param_request_push_op(code, attr.second));

				}
			}

			//
			//	3. child_List List_of_SML_Tree OPTIONAL
			//
			cyng::tuple_t tpl;
			tpl = cyng::value_cast(*pos++, tpl);
			for (auto const child : tpl)
			{
				cyng::tuple_t tmp;
				tmp = cyng::value_cast(child, tmp);

				//
				//	recursive call of read_set_proc_parameter_request_tree()
				//
				prg << cyng::unwinder(read_set_proc_parameter_request_tree(path, depth + 1, tmp.begin(), tmp.end()));
			}
			return prg;
		}

		cyng::vector_t reader::set_proc_param_request_push_op(obis code, cyng::object obj)
		{
			//if (path.size() > 2) {
			//	auto r = path.at(1).is_matching(0x81, 0x81, 0xc7, 0x8a, 0x01);
			//	if (r.second) {
			//		if (path.at(2) == OBIS_CODE(81, 81, c7, 8a, 02, ff)) {

			//			return cyng::generate_invoke("sml.set.proc.push.interval"
			//				, ro_.pk_
			//				, ro_.trx_
			//				, r.first
			//				, ro_.server_id_
			//				, ro_.get_value("userName")
			//				, ro_.get_value("password")
			//				, std::chrono::seconds(cyng::numeric_cast<std::int64_t>(obj, 900)));

			//		}
			//		else if (path.at(2) == OBIS_CODE(81, 81, c7, 8a, 03, ff)) {

			//			return cyng::generate_invoke("sml.set.proc.push.delay"
			//				, ro_.pk_
			//				, ro_.trx_
			//				, r.first
			//				, ro_.server_id_
			//				, ro_.get_value("userName")
			//				, ro_.get_value("password")
			//				, std::chrono::seconds(cyng::numeric_cast<std::int64_t>(obj, 0)));

			//		}
			//		else if (path.at(2) == OBIS_CODE(81, 47, 17, 07, 00, FF)) {

			//			cyng::buffer_t tmp;
			//			tmp = cyng::value_cast(obj, tmp);

			//			return cyng::generate_invoke("sml.set.proc.push.name"
			//				, ro_.pk_
			//				, ro_.trx_
			//				, r.first
			//				, ro_.server_id_
			//				, ro_.get_value("userName")
			//				, ro_.get_value("password")
			//				, std::string(tmp.begin(), tmp.end()));

			//		}
			//	}
			//}

			//	param tree too short
			return cyng::generate_invoke("log.msg.warning", "param tree too short");

		}

		cyng::vector_t reader::set_proc_param_request_ipt_param(obis code, cyng::object obj)
		{
			//
			//	set IP-T host address
			//
			auto m = code.is_matching(0x81, 0x49, 0x17, 0x07, 0x00);
			if (m.second) {

				BOOST_ASSERT(m.first != 0);
				--m.first;

				//	remove host byte ordering
				//auto num = cyng::swap_num(cyng::numeric_cast<std::uint32_t>(attr.second, 0u));
				//boost::asio::ip::address address = boost::asio::ip::make_address_v4(num);
				return cyng::generate_invoke("sml.set.proc.ipt.param.address"
					, ro_.pk_
					, ro_.trx_
					, m.first
					, obj);

			}

			//
			//	set IP-T target port
			//
			m = code.is_matching(0x81, 0x49, 0x1A, 0x07, 0x00);
			if (m.second) {

				BOOST_ASSERT(m.first != 0);
				--m.first;

				//
				//	set IP-T target port
				//
				auto port = cyng::numeric_cast<std::uint16_t>(obj, 0u);
				return cyng::generate_invoke("sml.set.proc.ipt.param.port.target"
					, ro_.pk_
					, ro_.trx_
					, m.first
					, port);

			}

			//
			//	set IP-T user name
			//
			m = code.is_matching(0x81, 0x49, 0x63, 0x3C, 0x01);
			if (m.second) {

				BOOST_ASSERT(m.first != 0);
				--m.first;

				//
				//	set IP-T user name
				//
				cyng::buffer_t tmp;
				tmp = cyng::value_cast(obj, tmp);

				return cyng::generate_invoke("sml.set.proc.ipt.param.user"
					, ro_.pk_
					, ro_.trx_
					, m.first
					, std::string(tmp.begin(), tmp.end()));
			}

			//
			//	set IP-T password
			//
			m = code.is_matching(0x81, 0x49, 0x63, 0x3C, 0x02);
			if (m.second) {

				BOOST_ASSERT(m.first != 0);
				--m.first;

				//
				//	set IP-T password
				//
				cyng::buffer_t tmp;
				tmp = cyng::value_cast(obj, tmp);

				return cyng::generate_invoke("sml.set.proc.ipt.param.pwd"
					, ro_.pk_
					, ro_.trx_
					, m.first
					, std::string(tmp.begin(), tmp.end()));

			}

			//	param tree too short
			return cyng::generate_invoke("log.msg.warning", "unknown IP-T parameter", code.to_str());
		}

		cyng::vector_t reader::read_get_list_request(cyng::tuple_t::const_iterator pos, cyng::tuple_t::const_iterator end)
		{
			std::size_t count = std::distance(pos, end);
			BOOST_ASSERT_MSG(count == 5, "Get List Request");
			if (count != 5) return cyng::vector_t{};

			//
			//	clientId - MAC address from caller
			//
			read_client_id(*pos++);

			//
			//	serverId - meter ID
			//
			read_server_id(*pos++);

			//
			//	username
			//
			read_string("userName", *pos++);

			//
			//	password
			//
			read_string("password", *pos++);

			//
			//	list name
			//
			obis code = read_obis(*pos++);

			return cyng::generate_invoke("sml.get.list.request"
				, ro_.pk_
				, ro_.trx_
				, ro_.idx_
				, ro_.client_id_
				, ro_.server_id_
				, ro_.get_value("reqFileId")
				, ro_.get_value("userName")
				, ro_.get_value("password")
				, code.to_buffer());
		}

		cyng::vector_t reader::read_get_list_response(cyng::tuple_t::const_iterator pos, cyng::tuple_t::const_iterator end)
		{
			std::size_t count = std::distance(pos, end);
			BOOST_ASSERT_MSG(count == 7, "Get List Response");
			if (count != 7) return cyng::vector_t{};

			//
			//	clientId - optional
			//
			read_client_id(*pos++);

			//
			//	serverId - meter ID
			//
			read_server_id(*pos++);

			//
			//	list name - optional
			//
			obis code = read_obis(*pos++);
			if (code.is_nil()) {
				code = OBIS_CODE(99, 00, 00, 00, 00, 03);	//	last data set
			}

			//
			//	read act. sensor time - optional
			//
			read_time("actSensorTime", *pos++);

			//
			//	valList
			//
			cyng::tuple_t tpl;
			tpl = cyng::value_cast(*pos++, tpl);
			read_sml_list(code, tpl.begin(), tpl.end());

			//
			//	SML_Signature - OPTIONAL
			//
			ro_.set_value("listSignature", *pos++);

			//
			//	SML_Time - OPTIONAL
			//
			read_time("actGatewayTime", *pos++);

			return cyng::generate_invoke("sml.get.list.response"
				, ro_.pk_
				, ro_.trx_
				, ro_.idx_
				, ro_.client_id_	//	mostly empty
				, ro_.server_id_
				, code.to_buffer()
				, ro_.get_value("values")
				, ro_.get_value("actSensorTime")
				, ro_.get_value("actGatewayTime"));
		}

		cyng::vector_t reader::read_attention_response(cyng::tuple_t::const_iterator pos, cyng::tuple_t::const_iterator end)
		{
			std::size_t count = std::distance(pos, end);
			BOOST_ASSERT_MSG(count == 4, "Attention Response");
            if (count != 4) return cyng::vector_t{};

			//
			//	serverId
			//
			read_server_id(*pos++);

			//
			//	attentionNo (OBIS)
			//
			obis code = read_obis(*pos++);

			//
			//	attentionMsg
			//
			ro_.set_value("attentionMsg", *pos++);

			//
			//	attentionDetails (SML_Tree)
			//
			read_param_tree(0, *pos++);

			return cyng::generate_invoke("sml.attention.msg"
				, ro_.pk_
				, ro_.trx_
				, ro_.idx_
				, from_server_id(ro_.server_id_)
				, code.to_buffer()
				, ro_.get_value("attentionMsg"));
		}

		cyng::param_map_t reader::read_param_tree(std::size_t depth, cyng::object obj)
		{
			cyng::tuple_t tpl;
			tpl = cyng::value_cast(obj, tpl);

			return (tpl.size() == 3)
				? read_param_tree(depth, tpl.begin(), tpl.end())
				: cyng::param_map_t()
				;
		}

		cyng::param_map_t reader::read_param_tree(std::size_t depth
			, cyng::tuple_t::const_iterator pos
			, cyng::tuple_t::const_iterator end)
		{
			std::size_t count = std::distance(pos, end);
			BOOST_ASSERT_MSG(count == 3, "SML Tree");
			if (count != 3) return cyng::param_map_t{};

			cyng::param_map_t params;

			//
			//	1. parameterName Octet String,
			//
			obis code = read_obis(*pos++);
			boost::ignore_unused(code);

			//
			//	2. parameterValue SML_ProcParValue OPTIONAL,
			//
			auto attr = read_parameter(*pos++);
			if (attr.first != PROC_PAR_UNDEF) {
				params.emplace(code.to_str(), attr.second);
			}

			//
			//	3. child_List List_of_SML_Tree OPTIONAL
			//
			cyng::tuple_t tpl;
			tpl = cyng::value_cast(*pos++, tpl);
			for (auto const child : tpl)
			{
				cyng::tuple_t tmp;
				tmp = cyng::value_cast(child, tmp);
				auto const m = read_param_tree(depth + 1, tmp.begin(), tmp.end());
				params.insert(m.begin(), m.end());	//	preserve existing keys
			}

			return params;
		}

		void reader::read_sml_list(obis code
			, cyng::tuple_t::const_iterator pos
			, cyng::tuple_t::const_iterator end)
		{
			std::size_t count = std::distance(pos, end);
			boost::ignore_unused(count);	//	release version

			//
			//	list of tuples (period entry)
			//
			std::size_t counter{ 0 };
			while (pos != end)
			{
				cyng::tuple_t tpl;
				tpl = cyng::value_cast(*pos++, tpl);
				read_list_entry(code, counter, tpl.begin(), tpl.end());
				++counter;

			}
		}

		void reader::read_list_entry(obis list_name
			, std::size_t index
			, cyng::tuple_t::const_iterator pos
			, cyng::tuple_t::const_iterator end)
		{
			std::size_t count = std::distance(pos, end);
			BOOST_ASSERT_MSG(count == 7, "List Entry");
			if (count != 7) return;

			//
			//	object name
			//
			obis code = read_obis(*pos++);

			//
			//	status - optional
			//
			ro_.set_value("status", *pos++);

			//
			//	valTime - optional
			//
			auto val_time = read_time("valTime", *pos++);

			//
			//	unit (see sml_unit_enum) - optional
			//
			auto const unit = read_unit("SMLUnit", *pos++);

			//
			//	scaler - optional
			//
			auto const scaler = read_scaler(*pos++);

			//
			//	value - note value with OBIS code
			//
			auto val = read_value(code, scaler, unit, *pos++);
			auto obj = cyng::param_map_factory("unit", unit)("scaler", scaler)("value", val)("valTime", val_time)();
			ro_.set_value(code, "values", obj);

			//
			//	valueSignature
			//
			ro_.set_value("signature", *pos++);

		}

		void reader::read_period_list(std::vector<obis> const& path
			, cyng::tuple_t::const_iterator pos
			, cyng::tuple_t::const_iterator end)
		{
			std::size_t count = std::distance(pos, end);
			boost::ignore_unused(count);	//	release version

			//
			//	list of tuples (period entry)
			//
			std::size_t counter{ 0 };
			while (pos != end)
			{
				cyng::tuple_t tpl;
				tpl = cyng::value_cast(*pos++, tpl);
				read_period_entry(path, counter, tpl.begin(), tpl.end());
				++counter;

			}
		}

		void reader::read_period_entry(std::vector<obis> const& path
			, std::size_t index
			, cyng::tuple_t::const_iterator pos
			, cyng::tuple_t::const_iterator end)
		{
			std::size_t count = std::distance(pos, end);
			BOOST_ASSERT_MSG(count == 5, "Period Entry");
            if (count != 5) return;

			//
			//	object name
			//
			obis code = read_obis(*pos++);

			//
			//	unit (see sml_unit_enum)
			//
			const auto unit = read_unit("SMLUnit", *pos++);

			//
			//	scaler
			//
			const auto scaler = read_scaler(*pos++);

			//
			//	value
			//
			auto val = read_value(code, scaler, unit, *pos++);
			ro_.set_value("value", val);

			//
			//	valueSignature
			//
			ro_.set_value("signature", *pos++);

		}

		cyng::object reader::read_time(std::string const& name, cyng::object obj)
		{
			cyng::tuple_t choice;
			choice = cyng::value_cast(obj, choice);
			if (choice.empty())	return cyng::make_object();

			BOOST_ASSERT_MSG(choice.size() == 2, "TIME");
			if (choice.size() == 2)
			{
				auto code = cyng::value_cast<std::uint8_t>(choice.front(), 0);
				switch (code)
				{
				case TIME_TIMESTAMP:
				{
					const std::uint32_t sec = cyng::value_cast<std::uint32_t>(choice.back(), 0);
					ro_.set_value(name, cyng::make_time_point(sec));
					return cyng::make_time_point(sec);
				}
				break;
				case TIME_SECINDEX:
					ro_.set_value(name, choice.back());
					return choice.back();
				default:
					break;
				}
			}
			return cyng::make_object();
		}

		std::vector<obis> reader::read_param_tree_path(cyng::object obj)
		{
			std::vector<obis> result;

			cyng::tuple_t tpl;
			tpl = cyng::value_cast(obj, tpl);
			for (auto obj : tpl)
			{

				const obis object_type = read_obis(obj);
				result.push_back(object_type);

			}
			return result;
		}

		obis reader::read_obis(cyng::object obj)
		{
			cyng::buffer_t tmp;
			tmp = cyng::value_cast(obj, tmp);

			return (tmp.empty())
				? obis()
				: obis(tmp)
				;

		}

		std::uint8_t reader::read_unit(std::string const& name, cyng::object obj)
		{
			std::uint8_t unit = cyng::value_cast<std::uint8_t>(obj, 0);
			ro_.set_value(name, obj);
			return unit;
		}

		std::string reader::read_string(std::string const& name, cyng::object obj)
		{
			cyng::buffer_t buffer;
			buffer = cyng::value_cast(obj, buffer);
			const auto str = cyng::io::to_ascii(buffer);
			ro_.set_value(name, cyng::make_object(str));
			return str;
		}

		std::string reader::read_server_id(cyng::object obj)
		{
			ro_.server_id_ = cyng::value_cast(obj, ro_.server_id_);
			return from_server_id(ro_.server_id_);
		}

		std::string reader::read_client_id(cyng::object obj)
		{
			ro_.client_id_ = cyng::value_cast(obj, ro_.client_id_);
			return from_server_id(ro_.client_id_);
		}

		std::int8_t reader::read_scaler(cyng::object obj)
		{
			std::int8_t scaler = cyng::numeric_cast<std::int8_t>(obj, 0);
			return scaler;
		}

		cyng::object reader::read_value(obis code, std::int8_t scaler, std::uint8_t unit, cyng::object obj)
		{
			//
			//	write value
			//
			if (OBIS_DATA_MANUFACTURER == code)
			{
				cyng::buffer_t buffer;
				buffer = cyng::value_cast(obj, buffer);
				const auto manufacturer = cyng::io::to_ascii(buffer);
				return cyng::make_object(manufacturer);
			}
			else if (OBIS_CURRENT_UTC == code)
			{
				if (obj.get_class().tag() == cyng::TC_TUPLE)
				{
					read_time(get_name(code), obj);
				}
				else
				{
					const auto tm = cyng::value_cast<std::uint32_t>(obj, 0);
					const auto tp = std::chrono::system_clock::from_time_t(tm);
					return cyng::make_object(tp);
				}
			}
			else if (OBIS_ACT_SENSOR_TIME == code)
			{
				const auto tm = cyng::value_cast<std::uint32_t>(obj, 0);
				const auto tp = std::chrono::system_clock::from_time_t(tm);
				ro_.set_value(get_name(code), cyng::make_object(tp));
			}
			else if (OBIS_SERIAL_NR == code)
			{
				cyng::buffer_t buffer;
				buffer = cyng::value_cast(obj, buffer);
				const auto serial_nr = cyng::io::to_hex(buffer);
				return cyng::make_object(serial_nr);
			}
			else if (OBIS_SERIAL_NR_SECOND == code)
			{
				cyng::buffer_t buffer;
				buffer = cyng::value_cast(obj, buffer);
				//std::reverse(buffer.begin(), buffer.end());
				const auto serial_nr = cyng::io::to_hex(buffer);
				ro_.set_value(get_name(code), cyng::make_object(serial_nr));
				if (buffer.size() == 8)
				{
					//
					//	extract manufacturer name
					//	example: [2d2c]688668691c04
					//
					const auto manufacturer = decode(buffer.at(0), buffer.at(1));
					return cyng::make_object(manufacturer);
				}
			}
			else if (OBIS_MBUS_STATE == code) {
				auto const state = cyng::numeric_cast<std::int32_t>(obj, 0);
				return cyng::make_object(state);
			}

			if (scaler != 0)
			{
				switch (obj.get_class().tag())
				{
				case cyng::TC_INT64:
				{
					const std::int64_t value = cyng::value_cast<std::int64_t>(obj, 0);
					const auto str = scale_value(value, scaler);
					return cyng::make_object(str);
				}
				break;
				case cyng::TC_INT32:
				{
					const std::int32_t value = cyng::value_cast<std::int32_t>(obj, 0);
					const auto str = scale_value(value, scaler);
					return cyng::make_object(str);
				}
				break;
				case cyng::TC_UINT64:
				{
					const std::uint64_t value = cyng::value_cast<std::uint64_t>(obj, 0);
					const auto str = scale_value(value, scaler);
					return cyng::make_object(str);
				}
				break;
				case cyng::TC_UINT32:
				{
					const std::uint32_t value = cyng::value_cast<std::uint32_t>(obj, 0);
					const auto str = scale_value(value, scaler);
					return cyng::make_object(str);
				}
				break;
				default:
					break;
				}
			}
			return  obj;
		}

		cyng::attr_t reader::read_parameter(cyng::object obj)
		{
			cyng::tuple_t tpl;
			tpl = cyng::value_cast(obj, tpl);
			if (tpl.size() == 2)
			{
				const auto type = cyng::value_cast<std::uint8_t>(tpl.front(), 0);
				switch (type)
				{
				case PROC_PAR_VALUE:		return cyng::attr_t(type, tpl.back());
				case PROC_PAR_PERIODENTRY:	return cyng::attr_t(type, tpl.back());
				case PROC_PAR_TUPELENTRY:	return cyng::attr_t(type, tpl.back());
				case PROC_PAR_TIME:			return cyng::attr_t(type, read_time("parTime", tpl.back()));
				default:
					break;
				}
			}
			return cyng::attr_t(PROC_PAR_UNDEF, cyng::make_object());
		}
	}	//	sml
}

ext: cpp

max_stars_repo_name: solosTec/node

max_issues_repo_name: solosTec/node

max_forks_repo_name: solosTec/node


text:
/* Copyright 2003-2008 Joaquin M Lopez Munoz.
 * 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://www.boost.org/libs/multi_index for library home page.
 */

#ifndef BOOST_MULTI_INDEX_DETAIL_MSVC_INDEX_SPECIFIER_HPP
#define BOOST_MULTI_INDEX_DETAIL_MSVC_INDEX_SPECIFIER_HPP

#if defined(_MSC_VER)&&(_MSC_VER>=1200)
#pragma once
#endif

#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
#include <boost/detail/workaround.hpp>

#if BOOST_WORKAROUND(BOOST_MSVC,<1310)
/* Workaround for a problem in MSVC with dependent template typedefs
 * when accesing index specifiers.
 * Modeled after <boost/mpl/aux_/msvc_dtw.hpp> (thanks, Aleksey!)
 */

#include <boost/mpl/aux_/msvc_never_true.hpp>

namespace boost{

namespace multi_index{

namespace detail{

template<typename IndexSpecifier>
struct msvc_index_specifier
{
  template<bool> struct fake_index_type:IndexSpecifier{};
  template<> struct fake_index_type<true>
  {
    template<typename Super>
    struct node_class{};

    template<typename Super>
    struct index_class{};
  };

  template<typename Super>
  struct result_node_class:
    fake_index_type<mpl::aux::msvc_never_true<IndexSpecifier>::value>::
      template node_class<Super>
  {
  };

  template<typename Super>
  struct result_index_class:
    fake_index_type<mpl::aux::msvc_never_true<IndexSpecifier>::value>::
      template index_class<Super>
  {
  };
};

} /* namespace multi_index::detail */

} /* namespace multi_index */

} /* namespace boost */

#endif /* workaround */

#endif

max_stars_repo_name: randolphwong/mcsema

max_issues_repo_name: randolphwong/mcsema

max_forks_repo_name: randolphwong/mcsema


text:
//==================================================================================================
/**
  Copyright 2016 NumScale SAS

  Distributed under the Boost Software License, Version 1.0.
  (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
**/
//==================================================================================================
#ifndef BOOST_SIMD_ARCH_COMMON_SIMD_FUNCTION_LOOKUP_HPP_INCLUDED
#define BOOST_SIMD_ARCH_COMMON_SIMD_FUNCTION_LOOKUP_HPP_INCLUDED

#include <boost/simd/detail/overload.hpp>
#include <boost/simd/meta/cardinal_of.hpp>
#include <boost/simd/function/bitwise_cast.hpp>
#include <boost/simd/function/extract.hpp>

namespace boost { namespace simd { namespace ext
{
  namespace bd = boost::dispatch;
  namespace bs = boost::simd;

  BOOST_DISPATCH_OVERLOAD_IF( lookup_
                            , (typename A0, typename A1, typename X, typename Y)
                            , (nsm::equal_to<cardinal_of<A0>,cardinal_of<A1>>)
                            , bd::cpu_
                            , bs::pack_<bd::unspecified_<A0>, X>
                            , bs::pack_<bd::integer_<A1>, Y>
                            )
  {
    BOOST_FORCEINLINE A0 operator()(const A0& a0, const A1&  a1) const BOOST_NOEXCEPT
    {
      return do_(a0,a1, typename A0::traits::element_range{});
    }

    template<typename... N> BOOST_FORCEINLINE
    A0 do_(const A0& a0, const A1& a1, nsm::list<N...> const&) const BOOST_NOEXCEPT
    {
      return A0( a0[extract<N::value>(a1)]... );
    }
  };
} } }

#endif

max_stars_repo_name: SylvainCorlay/pythran

max_issues_repo_name: SylvainCorlay/pythran

max_forks_repo_name: SylvainCorlay/pythran


text:
/*
 * Copyright (c) 2016 Dmitri
 *
 * 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.
 */

#ifndef IPC_HEADER__HPP
#define IPC_HEADER__HPP

#include <boost/endian/conversion.hpp>
#include "types.hpp"

namespace IPC {

constexpr uint32_t HEADER_SIZE = 8;

/*
 * First 8 bytes of an IPC message
 * 0x01 - architecture used for encoding the message, big endian (0) or little endian (1)
 * 0x00 - message type (0 - async, 1 - sync, 2 - response)
 * 0x00 - non-compressed (0), compressed less than 4GB (1), compressed more than 4GB (2)
 * 0x00 - part of message length (for kdb 3.4)
 * 0x0d 00 00 00 - message length (13)
 */
class Header {
private:
  static constexpr message_size_t MESSAGE_SIZE_OFFSET = 4;
public:
  Header() = default;
  Header(Header&& other) {
    std::memcpy(h, other.h, sizeof(h));
    std::memset(other.h, '\0', sizeof(other.h));
  }
  char* get() {return h;}
  const char* get() const {return h;}
  static message_size_t size() {return sizeof(h);}
  operator char*() {return h;}
  operator const char*() const {return h;}
  message_size_t getBodySize() const {
    typedef message_size_t(*Converter)(message_size_t);
    // header[0] - big endian (0) or little endian (1)
    Converter c = (h[0] ?
      (Converter)&boost::endian::little_to_native :
      (Converter)&boost::endian::big_to_native);

    return c(*(reinterpret_cast<const message_size_t*>(h + MESSAGE_SIZE_OFFSET))) - HEADER_SIZE;
  }
private:
  char h[HEADER_SIZE];
};

} // namespace IPC

#endif /* IPC_HEADER__HPP */

max_stars_repo_name: dmitritt/lb

max_issues_repo_name: dmitritt/lb

max_forks_repo_name: dmitritt/qlb


text:
#include <scorum/blockchain_history/blockchain_history_api.hpp>
#include <scorum/blockchain_history/blockchain_history_plugin.hpp>
#include <scorum/blockchain_history/schema/operation_objects.hpp>
#include <scorum/app/application.hpp>
#include <scorum/chain/services/dynamic_global_property.hpp>
#include <scorum/common_api/config_api.hpp>
#include <scorum/protocol/operations.hpp>

#include <fc/static_variant.hpp>

#include <boost/lambda/lambda.hpp>

namespace scorum {
namespace blockchain_history {

namespace detail {

class blockchain_history_api_impl
{
public:
    scorum::app::application& _app;
    std::shared_ptr<chain::database> _db;

private:
    template <typename ObjectType> applied_operation get_filtered_operation(const ObjectType& obj) const
    {
        return _db->get(obj.op);
    }

    applied_operation get_operation(const filtered_not_virt_operations_history_object& obj) const
    {
        return get_filtered_operation(obj);
    }

    applied_operation get_operation(const filtered_virt_operations_history_object& obj) const
    {
        return get_filtered_operation(obj);
    }

    applied_operation get_operation(const filtered_market_operations_history_object& obj) const
    {
        return get_filtered_operation(obj);
    }

    applied_operation get_operation(const operation_object& obj) const
    {
        applied_operation temp;
        temp = obj;
        return temp;
    }

    inline uint32_t get_head_block() const
    {
        return _db->obtain_service<dbs_dynamic_global_property>().get().head_block_number;
    }

public:
    blockchain_history_api_impl(scorum::app::application& app)
        : _app(app)
        , _db(_app.chain_database())
    {
    }

    using result_type = std::map<uint32_t, applied_operation>;

    template <typename IndexType> result_type get_ops_history(uint32_t from_op, uint32_t limit) const
    {
        FC_ASSERT(limit > 0, "Limit must be greater than zero");
        FC_ASSERT(limit <= get_api_config(API_BLOCKCHAIN_HISTORY).max_blockchain_history_depth,
                  "Limit of ${l} is greater than maxmimum allowed ${2}",
                  ("l", limit)("2", get_api_config(API_BLOCKCHAIN_HISTORY).max_blockchain_history_depth));
        FC_ASSERT(from_op >= limit, "From must be greater than limit");

        if (from_op != std::numeric_limits<decltype(from_op)>::max())
        {
            --from_op;
        }

        result_type result;

        const auto& idx = _db->get_index<IndexType, by_id>();
        if (idx.empty())
            return result;

        // move to last operation object
        auto itr = idx.lower_bound(from_op);
        if (itr == idx.end())
            --itr;

        auto start = (int64_t(itr->id._id) - limit);
        auto end = itr->id._id;
        auto range = idx.range(start < boost::lambda::_1, boost::lambda::_1 <= end);

        for (auto it = range.first; it != range.second; ++it)
        {
            auto id = it->id;
            FC_ASSERT(id._id >= 0, "Invalid operation_object id");
            result[(uint32_t)id._id] = get_operation(*it);
        }

        return result;
    }

    template <typename IndexType>
    result_type get_ops_history_by_time(const fc::time_point_sec& from,
                                        const fc::time_point_sec& to,
                                        uint32_t from_op,
                                        uint32_t limit) const
    {
        FC_ASSERT(from <= to, "'From' is greater than 'to'");
        FC_ASSERT((to - from).to_seconds() <= get_api_config(API_BLOCKCHAIN_HISTORY).max_timestamp_range_in_s,
                  "Timestamp range can't be more then ${t} seconds",
                  ("t", get_api_config(API_BLOCKCHAIN_HISTORY).max_timestamp_range_in_s));
        FC_ASSERT(limit > 0, "Limit must be greater than zero");
        FC_ASSERT(limit <= get_api_config(API_BLOCKCHAIN_HISTORY).max_blockchain_history_depth,
                  "Limit of ${l} is greater than maxmimum allowed ${2}",
                  ("l", limit)("2", get_api_config(API_BLOCKCHAIN_HISTORY).max_blockchain_history_depth));
        FC_ASSERT(from_op >= limit, "From must be greater than limit");

        result_type result;

        const auto& idx = _db->get_index<IndexType, by_timestamp>();
        if (idx.empty())
            return result;

        auto range = idx.range(::boost::lambda::_1 >= std::make_tuple(from, 0),
                               ::boost::lambda::_1 <= std::make_tuple(to, ALL_IDS));

        for (auto it = range.first; limit && it != range.second; ++it)
        {
            auto id = it->id;
            FC_ASSERT(id._id >= 0, "Invalid operation_object id");
            const operation_object& op = (*it);
            if (id > from_op)
                continue;

            --limit;
            result[(uint32_t)id._id] = get_operation(op);
        }

        return result;
    }

    template <typename Filter> result_type get_ops_in_block(uint32_t block_num, Filter operation_filter) const
    {
        const auto& idx = _db->get_index<operation_index>().indices().get<by_location>();

        result_type result;

        auto range = idx.equal_range(block_num);

        for (auto it = range.first; it != range.second; ++it)
        {
            auto id = it->id;
            applied_operation temp = *it;
            if (operation_filter(temp.op))
            {
                FC_ASSERT(id._id >= 0, "Invalid operation_object id");
                result[(uint32_t)id._id] = temp;
            }
        }

        return result;
    }

    // Blocks and transactions
    annotated_signed_transaction get_transaction(transaction_id_type id) const
    {

#ifdef SKIP_BY_TX_ID
        FC_ASSERT(false, "This node's operator has disabled operation indexing by transaction_id");
#else
        FC_ASSERT(!_app.is_read_only(), "get_transaction is not available in read-only mode.");

        const auto& idx = _db->get_index<operation_index>().indices().get<by_transaction_id>();
        auto itr = idx.lower_bound(id);
        if (itr != idx.end() && itr->trx_id == id)
        {
            auto blk = _db->fetch_block_by_number(itr->block);
            FC_ASSERT(blk.valid());
            FC_ASSERT(blk->transactions.size() > itr->trx_in_block);
            annotated_signed_transaction result = blk->transactions[itr->trx_in_block];
            result.block_num = itr->block;
            result.transaction_num = itr->trx_in_block;
            return result;
        }
        FC_ASSERT(false, "Unknown Transaction ${t}", ("t", id));
#endif
    }

    optional<signed_block> get_block(uint32_t block_num) const
    {
        return _db->fetch_block_by_number(block_num);
    }

    template <typename T> std::map<uint32_t, T> get_blocks_history_by_number(uint32_t block_num, uint32_t limit) const
    {
        FC_ASSERT(limit <= get_api_config(API_BLOCKCHAIN_HISTORY).max_blockchain_history_depth,
                  "Limit of ${l} is greater than maxmimum allowed ${2}",
                  ("l", limit)("2", get_api_config(API_BLOCKCHAIN_HISTORY).max_blockchain_history_depth));
        FC_ASSERT(limit > 0, "Limit must be greater than zero");
        FC_ASSERT(block_num >= limit, "block_num must be greater than limit");

        try
        {
            uint32_t head_block_num = get_head_block();
            if (block_num > head_block_num)
            {
                block_num = head_block_num;
            }

            uint32_t from_block_num = (block_num > limit) ? block_num - limit : 0;

            std::map<uint32_t, T> result;
            optional<signed_block> b;
            while (from_block_num != block_num)
            {
                b = _db->fetch_block_by_number(block_num);
                if (b.valid())
                    result[block_num] = *b; // convert from signed_block to type T
                --block_num;
            }

            return result;
        }
        FC_LOG_AND_RETHROW()
    }

    std::vector<block_api_object> get_blocks(uint32_t block_num, uint32_t limit) const
    {
        FC_ASSERT(limit <= get_api_config(API_BLOCKCHAIN_HISTORY).max_blockchain_history_depth,
                  "Limit of ${l} is greater than maxmimum allowed ${2}",
                  ("l", limit)("2", get_api_config(API_BLOCKCHAIN_HISTORY).max_blockchain_history_depth));
        FC_ASSERT(limit > 0, "Limit must be greater than zero");
        FC_ASSERT(block_num >= limit, "block_num must be greater than limit");

        try
        {
            uint32_t head_block_num = get_head_block();
            if (block_num > head_block_num)
            {
                block_num = head_block_num;
            }

            uint32_t from_block_num = (block_num > limit) ? block_num - limit : 0;

            std::vector<block_api_object> result;
            optional<signed_block> b;
            while (from_block_num != block_num)
            {
                b = _db->fetch_block_by_number(block_num);

                if (b.valid())
                {
                    block_api_object block(static_cast<signed_block_header>(*b));
                    block.block_num = block_num;

                    auto operations = this->get_ops_in_block(block_num, [&](const operation&) { return true; });

                    for (auto pair : operations)
                    {
                        block.operations.push_back(pair.second);
                    }

                    result.push_back(block);
                }
                --block_num;
            }

            return result;
        }
        FC_LOG_AND_RETHROW()
    }
};

} // namespace detail

blockchain_history_api::blockchain_history_api(const scorum::app::api_context& ctx)
    : _impl(new detail::blockchain_history_api_impl(ctx.app))
{
}

blockchain_history_api::~blockchain_history_api()
{
}

void blockchain_history_api::on_api_startup()
{
}

std::map<uint32_t, applied_operation> blockchain_history_api::get_ops_history(
    uint32_t from_op, uint32_t limit, applied_operation_type type_of_operation) const
{
    return _impl->_app.chain_database()->with_read_lock([&]() {
        switch (type_of_operation)
        {
        case applied_operation_type::not_virt:
            return _impl->get_ops_history<filtered_not_virt_operations_history_index>(from_op, limit);
        case applied_operation_type::virt:
            return _impl->get_ops_history<filtered_virt_operations_history_index>(from_op, limit);
        case applied_operation_type::market:
            return _impl->get_ops_history<filtered_market_operations_history_index>(from_op, limit);
        default:;
        }

        return _impl->get_ops_history<operation_index>(from_op, limit);
    });
}

std::map<uint32_t, applied_operation> blockchain_history_api::get_ops_history_by_time(const fc::time_point_sec& from,
                                                                                const fc::time_point_sec& to,
                                                                                uint32_t from_op,
                                                                                uint32_t limit) const
{
    return _impl->_app.chain_database()->with_read_lock(
        [&]() { return _impl->get_ops_history_by_time<operation_index>(from, to, from_op, limit); });
}

std::map<uint32_t, applied_operation>
blockchain_history_api::get_ops_in_block(uint32_t block_num, applied_operation_type type_of_operation) const
{
    return _impl->_app.chain_database()->with_read_lock([&]() {
        switch (type_of_operation)
        {
        case applied_operation_type::market:
            return _impl->get_ops_in_block(block_num, is_market_operation);
        case applied_operation_type::virt:
            return _impl->get_ops_in_block(block_num, is_virtual_operation);
        case applied_operation_type::not_virt:
            return _impl->get_ops_in_block(block_num, [&](const operation& op) { return !is_virtual_operation(op); });
        default:;
        }

        return _impl->get_ops_in_block(block_num, [&](const operation& op) { return true; });
    });
}

annotated_signed_transaction blockchain_history_api::get_transaction(transaction_id_type id) const
{
    return _impl->_app.chain_database()->with_read_lock([&]() { return _impl->get_transaction(id); });
}

//////////////////////////////////////////////////////////////////////
// Blocks and transactions                                          //
//////////////////////////////////////////////////////////////////////

optional<block_header> blockchain_history_api::get_block_header(uint32_t block_num) const
{
    return _impl->_db->with_read_lock([&]() { return _impl->get_block(block_num); });
}

optional<signed_block_api_obj> blockchain_history_api::get_block(uint32_t block_num) const
{
    return _impl->_db->with_read_lock([&]() { return _impl->get_block(block_num); });
}

std::map<uint32_t, block_header> blockchain_history_api::get_block_headers_history(uint32_t block_num,
                                                                                uint32_t limit) const
{
    FC_ASSERT(!_impl->_app.is_read_only(), "Disabled for read only mode");
    return _impl->_db->with_read_lock(
        [&]() { return _impl->get_blocks_history_by_number<block_header>(block_num, limit); });
}

std::map<uint32_t, signed_block_api_obj> blockchain_history_api::get_blocks_history(uint32_t block_num,
                                                                                uint32_t limit) const
{
    FC_ASSERT(!_impl->_app.is_read_only(), "Disabled for read only mode");
    return _impl->_db->with_read_lock(
        [&]() { return _impl->get_blocks_history_by_number<signed_block_api_obj>(block_num, limit); });
}

std::vector<block_api_object> blockchain_history_api::get_blocks(uint32_t from, uint32_t limit) const
{
    return _impl->_db->with_read_lock([&]() { return _impl->get_blocks(from, limit); });
}

} // namespace blockchain_history
} // namespace scorum

max_stars_repo_name: scorum/scorum

max_issues_repo_name: Scorum/Scorum

max_forks_repo_name: Scorum/Scorum


text:
// Boost.Geometry

// Copyright (c) 2020, Oracle and/or its affiliates.

// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle

// Licensed under the Boost Software License version 1.0.
// http://www.boost.org/users/license.html

#ifndef BOOST_GEOMETRY_STRATEGIES_INDEX_GEOGRAPHIC_HPP
#define BOOST_GEOMETRY_STRATEGIES_INDEX_GEOGRAPHIC_HPP

#include <boost/geometry/strategies/index/services.hpp>
#include <boost/geometry/strategies/relate/geographic.hpp>

// TEMP - move to strategy
#include <boost/geometry/strategies/geographic/distance.hpp>
#include <boost/geometry/strategies/geographic/distance_andoyer.hpp>
#include <boost/geometry/strategies/geographic/distance_cross_track.hpp>
#include <boost/geometry/strategies/geographic/distance_cross_track_box_box.hpp>
#include <boost/geometry/strategies/geographic/distance_cross_track_point_box.hpp>
#include <boost/geometry/strategies/geographic/distance_segment_box.hpp>
#include <boost/geometry/strategies/geographic/distance_thomas.hpp>
#include <boost/geometry/strategies/geographic/distance_vincenty.hpp>

namespace boost { namespace geometry { namespace strategies { namespace index
{

template
<
    typename FormulaPolicy = strategy::andoyer,
    // TODO: Is SeriesOrder argument needed here?
    std::size_t SeriesOrder = strategy::default_order<FormulaPolicy>::value,
    typename Spheroid = srs::spheroid<double>,
    typename CalculationType = void
>
class geographic
    : public relate::geographic<FormulaPolicy, SeriesOrder, Spheroid, CalculationType>
{
    typedef relate::geographic<FormulaPolicy, SeriesOrder, Spheroid, CalculationType> base_t;

public:
    geographic()
        : base_t()
    {}

    explicit geographic(Spheroid const& spheroid)
        : base_t(spheroid)
    {}

    template <typename Geometry1, typename Geometry2>
    auto comparable_distance(Geometry1 const&, Geometry2 const&,
                             std::enable_if_t
                                <
                                    util::is_pointlike<Geometry1>::value
                                    && util::is_pointlike<Geometry2>::value
                                > * = nullptr) const
    {
        return geometry::strategy::distance::geographic
            <
                FormulaPolicy, Spheroid, CalculationType
            >(base_t::m_spheroid);
    }

    template <typename Geometry1, typename Geometry2>
    auto comparable_distance(Geometry1 const&, Geometry2 const&,
                             std::enable_if_t
                                <
                                    (util::is_pointlike<Geometry1>::value
                                    && util::is_segment<Geometry2>::value)
                                    || (util::is_segment<Geometry1>::value
                                    && util::is_pointlike<Geometry2>::value)
                                > * = nullptr) const
    {
        return geometry::strategy::distance::geographic_cross_track
            <
                FormulaPolicy, Spheroid, CalculationType
            >(base_t::m_spheroid);
    }

    template <typename Geometry1, typename Geometry2>
    auto comparable_distance(Geometry1 const&, Geometry2 const&,
                             std::enable_if_t
                                <
                                    (util::is_pointlike<Geometry1>::value
                                    && util::is_box<Geometry2>::value)
                                    || (util::is_box<Geometry1>::value
                                    && util::is_pointlike<Geometry2>::value)
                                > * = nullptr) const
    {
        return geometry::strategy::distance::geographic_cross_track_point_box
            <
                FormulaPolicy, Spheroid, CalculationType
            >(base_t::m_spheroid);
    }

    template <typename Geometry1, typename Geometry2>
    auto comparable_distance(Geometry1 const&, Geometry2 const&,
                             std::enable_if_t
                                <
                                    (util::is_segment<Geometry1>::value
                                    && util::is_box<Geometry2>::value)
                                    || (util::is_box<Geometry1>::value
                                        && util::is_segment<Geometry2>::value)
                                > * = nullptr) const
    {
        return geometry::strategy::distance::geographic_segment_box
            <
                FormulaPolicy, Spheroid, CalculationType
            >(base_t::m_spheroid);
    }

    template <typename Geometry1, typename Geometry2>
    auto comparable_distance(Geometry1 const&, Geometry2 const&,
                             std::enable_if_t
                                <
                                    util::is_segment<Geometry1>::value
                                    && util::is_segment<Geometry2>::value
                                > * = nullptr) const
    {
        return geometry::strategy::distance::geographic_cross_track
            <
                FormulaPolicy, Spheroid, CalculationType
            >(base_t::m_spheroid);
    }
};

namespace services
{

template <typename Geometry>
struct default_strategy<Geometry, geographic_tag>
{
    using type = strategies::index::geographic<>;
};

// TEMP - needed in distance until umbrella strategies are supported
template <typename FormulaPolicy, typename Spheroid, typename CalculationType>
struct strategy_converter<strategy::distance::geographic_cross_track<FormulaPolicy, Spheroid, CalculationType>>
{
    static auto get(strategy::distance::geographic_cross_track<FormulaPolicy, Spheroid, CalculationType> const& strategy)
    {
        return strategies::index::geographic
            <
                FormulaPolicy,
                strategy::default_order<FormulaPolicy>::value,
                Spheroid,
                CalculationType
            >(strategy.model());
    }
};
// TEMP - needed in distance until umbrella strategies are supported
template <typename FormulaPolicy, typename Spheroid, typename CalculationType, bool Bisection, bool EnableClosestPoint>
struct strategy_converter<strategy::distance::detail::geographic_cross_track<FormulaPolicy, Spheroid, CalculationType, Bisection, EnableClosestPoint>>
{
    typedef strategies::index::geographic
        <
            FormulaPolicy,
            strategy::default_order<FormulaPolicy>::value,
            Spheroid,
            CalculationType
        > base_strategy;

    struct altered_strategy : base_strategy
    {
        explicit altered_strategy(Spheroid const& spheroid)
            : base_strategy(spheroid)
        {}

        // It seems that this declaration is needed because comparable_distance
        // is not static function.
        using base_strategy::comparable_distance;

        template <typename Geometry1, typename Geometry2>
        auto comparable_distance(Geometry1 const&, Geometry2 const&,
                                 std::enable_if_t
                                    <
                                        (util::is_pointlike<Geometry1>::value
                                        && util::is_segment<Geometry2>::value)
                                        || (util::is_segment<Geometry1>::value
                                        && util::is_pointlike<Geometry2>::value)
                                    > * = nullptr) const
        {
            return geometry::strategy::distance::detail::geographic_cross_track
                <
                    FormulaPolicy, Spheroid, CalculationType, Bisection, EnableClosestPoint
                >(base_strategy::m_spheroid);
        }

        template <typename Geometry1, typename Geometry2>
        auto comparable_distance(Geometry1 const&, Geometry2 const&,
                                 std::enable_if_t
                                    <
                                        util::is_segment<Geometry1>::value
                                        && util::is_segment<Geometry2>::value
                                    > * = nullptr) const
        {
            return geometry::strategy::distance::detail::geographic_cross_track
                <
                    FormulaPolicy, Spheroid, CalculationType, Bisection, EnableClosestPoint
                >(base_strategy::m_spheroid);
        }
    };

    static auto get(strategy::distance::detail::geographic_cross_track<FormulaPolicy, Spheroid, CalculationType, Bisection, EnableClosestPoint> const& strategy)
    {
        return altered_strategy(strategy.model());
    }
};
// TEMP - needed in distance until umbrella strategies are supported
template <typename FormulaPolicy, typename Spheroid, typename CalculationType>
struct strategy_converter<strategy::distance::geographic<FormulaPolicy, Spheroid, CalculationType>>
{
    static auto get(strategy::distance::geographic<FormulaPolicy, Spheroid, CalculationType> const& strategy)
    {
        return strategies::index::geographic
            <
                FormulaPolicy,
                strategy::default_order<FormulaPolicy>::value,
                Spheroid,
                CalculationType
            >(strategy.model());
    }
};
// TEMP - needed in distance until umbrella strategies are supported
template <typename Spheroid, typename CalculationType>
struct strategy_converter<strategy::distance::andoyer<Spheroid, CalculationType>>
{
    static auto get(strategy::distance::andoyer<Spheroid, CalculationType> const& strategy)
    {
        return strategies::index::geographic
            <
                strategy::andoyer,
                strategy::default_order<strategy::andoyer>::value,
                Spheroid,
                CalculationType
            >(strategy.model());
    }
};
// TEMP - needed in distance until umbrella strategies are supported
template <typename Spheroid, typename CalculationType>
struct strategy_converter<strategy::distance::thomas<Spheroid, CalculationType>>
{
    static auto get(strategy::distance::thomas<Spheroid, CalculationType> const& strategy)
    {
        return strategies::index::geographic
            <
                strategy::thomas,
                strategy::default_order<strategy::thomas>::value,
                Spheroid,
                CalculationType
            >(strategy.model());
    }
};
// TEMP - needed in distance until umbrella strategies are supported
template <typename Spheroid, typename CalculationType>
struct strategy_converter<strategy::distance::vincenty<Spheroid, CalculationType>>
{
    static auto get(strategy::distance::vincenty<Spheroid, CalculationType> const& strategy)
    {
        return strategies::index::geographic
            <
                strategy::vincenty,
                strategy::default_order<strategy::vincenty>::value,
                Spheroid,
                CalculationType
            >(strategy.model());
    }
};

} // namespace services

}}}} // namespace boost::geometry::strategy::index

#endif // BOOST_GEOMETRY_STRATEGIES_INDEX_GEOGRAPHIC_HPP


text:
/**
 * \ file main.pp
 * Runner file for ATK Special
 */

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

max_stars_repo_name: D-J-Roberts/AudioTK

max_forks_repo_name: D-J-Roberts/AudioTK


text:
/* Copyright 2003-2015 Joaquin M Lopez Munoz.
 * 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://www.boost.org/libs/multi_index for library home page.
 */

#ifndef BOOST_MULTI_INDEX_ORDERED_INDEX_HPP
#define BOOST_MULTI_INDEX_ORDERED_INDEX_HPP

#if defined(_MSC_VER)
#pragma once
#endif

#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
#include <boost/multi_index/detail/ord_index_impl.hpp>
#include <boost/multi_index/ordered_index_fwd.hpp>

namespace lslboost{

namespace multi_index{

namespace detail{

/* no augment policy for plain ordered indices */

struct null_augment_policy
{
  template<typename OrderedIndexImpl>
  struct augmented_interface
  {
    typedef OrderedIndexImpl type;
  };

  template<typename OrderedIndexNodeImpl>
  struct augmented_node
  {
    typedef OrderedIndexNodeImpl type;
  };

  template<typename Pointer> static void add(Pointer,Pointer){}
  template<typename Pointer> static void remove(Pointer,Pointer){}
  template<typename Pointer> static void copy(Pointer,Pointer){}
  template<typename Pointer> static void rotate_left(Pointer,Pointer){}
  template<typename Pointer> static void rotate_right(Pointer,Pointer){}

#if defined(BOOST_MULTI_INDEX_ENABLE_INVARIANT_CHECKING)
  /* invariant stuff */

  template<typename Pointer> static bool invariant(Pointer){return true;}

#endif
};

} /* namespace multi_index::detail */

/* ordered_index specifiers */

template<typename Arg1,typename Arg2,typename Arg3>
struct ordered_unique
{
  typedef typename detail::ordered_index_args<
    Arg1,Arg2,Arg3>                                index_args;
  typedef typename index_args::tag_list_type::type tag_list_type;
  typedef typename index_args::key_from_value_type key_from_value_type;
  typedef typename index_args::compare_type        compare_type;

  template<typename Super>
  struct node_class
  {
    typedef detail::ordered_index_node<detail::null_augment_policy,Super> type;
  };

  template<typename SuperMeta>
  struct index_class
  {
    typedef detail::ordered_index<
      key_from_value_type,compare_type,
      SuperMeta,tag_list_type,detail::ordered_unique_tag,
      detail::null_augment_policy>                        type;
  };
};

template<typename Arg1,typename Arg2,typename Arg3>
struct ordered_non_unique
{
  typedef detail::ordered_index_args<
    Arg1,Arg2,Arg3>                                index_args;
  typedef typename index_args::tag_list_type::type tag_list_type;
  typedef typename index_args::key_from_value_type key_from_value_type;
  typedef typename index_args::compare_type        compare_type;

  template<typename Super>
  struct node_class
  {
    typedef detail::ordered_index_node<detail::null_augment_policy,Super> type;
  };

  template<typename SuperMeta>
  struct index_class
  {
    typedef detail::ordered_index<
      key_from_value_type,compare_type,
      SuperMeta,tag_list_type,detail::ordered_non_unique_tag,
      detail::null_augment_policy>                            type;
  };
};

} /* namespace multi_index */

} /* namespace lslboost */

#endif

max_stars_repo_name: samuelpowell/liblsl

max_issues_repo_name: samuelpowell/liblsl

max_forks_repo_name: samuelpowell/liblsl


text:
// Copyright Kevlin Henney, 2000, 2001. All rights reserved.
// Copyright Antony Polukhin, 2013-2021.
//
// 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)

// what:  unit tests for variant type boost::any
// who:   contributed by Kevlin Henney
// when:  July 2001, 2013, 2014
// where: tested with BCC 5.5, MSVC 6.0, and g++ 2.95

#include <boost/any.hpp>

#include "basic_test.hpp"

static const std::string& returning_string1()
{
    static const std::string ret("foo");
    return ret;
}

static std::string returning_string2()
{
    static const std::string ret("foo");
    return ret;
}

static void test_with_func()
{
    std::string s;
    s = boost::any_cast<std::string>(returning_string1());
    s = boost::any_cast<const std::string&>(returning_string1());

    s = boost::any_cast<std::string>(returning_string2());
    s = boost::any_cast<const std::string&>(returning_string2());

#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
#if !defined(__INTEL_COMPILER) && !defined(__ICL) && (!defined(_MSC_VER) || _MSC_VER != 1600)
    // Intel compiler thinks that it must choose the `any_cast(const any&)` function
    // instead of the `any_cast(const any&&)`.
    // Bug was not reported because of missing premier support account + annoying
    // registrations requirements.

    // MSVC-10 had a bug:
    //
    // any.hpp(291) : error C2440: 'return' : cannot convert.
    // Conversion loses qualifiers
    // any_test.cpp(304) : see reference to function template instantiation
    //
    // This issue was fixed in MSVC-11.

    s = boost::any_cast<std::string&&>(returning_string1());
#endif

    s = boost::any_cast<std::string&&>(returning_string2());
#endif
}

int main() {
    test_with_func();

    return any_tests::basic_tests<boost::any>::run_tests();
}