text:
/*
    Author: Dr. Ing. Ahmad Kamal Nasir
    Email: dringakn@gmail.com
    Description: Boost start chart example.
        First create events, then states and then the state machine.
        Use CRTP (Curiously Recurring Template Pattern) and forward decleration.
        CRTP is used for compile time polymorphism and state machines.

        The message recieved, invalid, invalid-time period events are generate
        by the message callback. The message callbacke reset the timer before
        timeout occures, otherwise timer callback generates a timeout event.

        Whenver a transitiona occures, the object is destroyed and a new
        instance of the target state is created. So there is no persistance of
        data. Boost states are not meant to store persistant data during
        transistion.
    Note:
        Building:
          In order to visulize the state chart from the executable
          - sudo apt install plantuml
          - git clone https://github.com/kanje/bosce.git
          - mkdir build
          - cd build
          - cmake -DCMAKE_BUILD_TYPE=Release ../../bosce
          - make -j8
        Testing:
        - The executable must be built using -DCMAKE_BUILD_TYPE=Debug
        - cp
          ~/cmu_ws/devel/.private/ros_examples/ros_examples/lib/example_boost_state_machine
          binary
        - ./bosce binary -l (Get the list of state machines)
        - ./bosce binary -s StMachine > uml.pu
        - plantuml uml.pu
        - xdg-open uml.png
*/

#include <ros/ros.h>

#include <boost/statechart/custom_reaction.hpp>  // Custom reactions
#include <boost/statechart/event.hpp>            // Events
#include <boost/statechart/simple_state.hpp>     // State
#include <boost/statechart/state_machine.hpp>    // State machine
#include <boost/statechart/transition.hpp>       // Transistion

using namespace std;
namespace sc = boost::statechart;  // Boost statchart
namespace mpl = boost::mpl;        // Multiple event handler

/*
    Step1: Define events using CRTP
*/
struct EvMessageRecieved : sc::event<EvMessageRecieved> {
  EvMessageRecieved() { cout << "EvMessageRecieved" << endl; }
};
struct EvMessageTimeOut : sc::event<EvMessageTimeOut> {
  EvMessageTimeOut() { cout << "EvMessageTimeOut" << endl; }
};
struct EvInvalidMessage : sc::event<EvInvalidMessage> {
  EvInvalidMessage() { cout << "EvInvalidMessage" << endl; }
};
struct EvInvalidMessageTimePeriod : sc::event<EvInvalidMessageTimePeriod> {
  EvInvalidMessageTimePeriod() { cout << "EvInvalidMessageTimePeriod" << endl; }
};

/*
    Step2: Define state machine
    Because the context of a state must be a complete type (i.e. not forward
    declared), a machine must be defined from "outside to inside". That is, we
    always start with the state machine, followed by outermost states,
    followed by the direct inner states of outermost states and so on. We can
    do so in a breadth-first or depth-first way or employ a mixture of the
    two.

    Note: It's important that state_machine is defined before the states.

*/
struct StActive;   // Forward decleration
struct StStopped;  // Forward decleration
struct StRunning;  // Forward decleration
struct StIdle;     // Forward decleration
struct SmMessage : sc::state_machine<SmMessage, StActive> {};
/*
    Step3: Define states using CRTP
    The simple_state Class template accepts up to four parameters:
    - simple_stae<State, Context, Default Inner State>
    - Stopped and Running both specify Active as their Context, which makes them
      nested inside Active.
    - The third parameter specifies the inner initial state, if there is one.
      Here, only Active has inner states, which is why it needs to pass its
      inner initial state Stopped to its base.
    - The fourth parameter specifies whether and what kind of history is kept.
    - Active is the outermost state and therefore needs to pass the state
      machine Class it belongs to
*/
struct StActive : sc::simple_state<StActive, SmMessage, StStopped> {
  StActive() { cout << "StActive" << endl; }
  typedef sc::transition<EvMessageRecieved, StActive> reactions;
};
struct StStopped : sc::simple_state<StStopped, StActive> {
  StStopped() { cout << "StStopped" << endl; }
  typedef sc::transition<EvMessageTimeOut, StRunning> reactions;
};
struct StRunning : sc::simple_state<StRunning, StActive> {
  StRunning() { cout << "StRunning" << endl; }
  typedef sc::transition<EvMessageTimeOut, StIdle> reactions;
};
struct StIdle : sc::simple_state<StIdle, StActive> {
  StIdle() { cout << "StIdle" << endl; }
  typedef sc::transition<EvInvalidMessage, StStopped> reactions;
};

int main(int argc, char* argv[]) {
  ros::init(argc, argv, "example_boost_state_machine");
  ros::NodeHandle nh;
  SmMessage sm;   // Create the state machine object
  sm.initiate();  // Initialize the state machine
  sm.process_event(EvMessageRecieved());
  sm.process_event(EvMessageTimeOut());
  sm.process_event(EvInvalidMessage());
  ros::spin();
  return 0;
}

max_stars_repo_name: dringakn/ROSExamples

max_issues_repo_name: dringakn/ROSExamples

max_forks_repo_name: dringakn/ROSExamples


text:
#include "../include/dir.h"
#include "dirent.h"
#include <iostream>
#include <string.h>
#include <algorithm>
#define BOOST_NO_CXX11_SCOPED_ENUMS
#include <boost/filesystem.hpp>
#undef BOOST_NO_CXX11_SCOPED_ENUMS
MyDir::dirlist MyDir::getAllSubdirs(string path)
{
  MyDir::dirlist list;
  DIR *dir;
  struct dirent *ent;
  if ((dir = opendir (path.c_str())) != NULL)
  {
    /* print all the files and directories within directory */
    while ((ent = readdir (dir)) != NULL)
    {
      if((ent->d_type == DT_DIR) && (strcmp(ent->d_name,".")!=0) && (strcmp(ent->d_name,"..")!=0) && (strcmp(ent->d_name,"templatebase")!=0))
        list.push_back(ent->d_name);
    }
    closedir (dir);
  }
  else
  {
    cout << "err" << endl;
  }
  sort(list.begin(),list.end(),[](string a, string b) { return a < b; });
  return list;
}
MyDir::dirlist MyDir::getAllFiles(string path)
{
  MyDir::filelist list;
  DIR *dir;
  struct dirent *ent;
  if ((dir = opendir (path.c_str())) != NULL)
  {
    /* print all the files and directories within directory */
    while ((ent = readdir (dir)) != NULL)
    {
      if((ent->d_type != DT_DIR) && (strcmp(ent->d_name,".")!=0) && (strcmp(ent->d_name,"..")!=0) && (strcmp(ent->d_name,"templatebase")!=0))
        list.push_back(ent->d_name);
    }
    closedir (dir);
  }
  else
  {
    cout << "err" << endl;
  }
  sort(list.begin(),list.end(),[](string a, string b) { return a < b; });
  return list;
}

void MyDir::createDir(string s)
{
  boost::filesystem::path dir(s);
  boost::filesystem::create_directory(dir);
}
bool MyDir::bTestExists(string s)
{
  boost::filesystem::path dir(s+"/main.tex");
  cout << s << "/main.tex" << endl;
  return boost::filesystem::exists(s);
}
bool MyDir::bTemlateExists(string s)
{
  boost::filesystem::path dir(s+"/test");
  cout << s << "/main.tex" << endl;
  return boost::filesystem::exists(s);
}

void MyDir::createEmptyTemplate(string s)
{
  MyDir::createDir(s);
  MyDir::createDir(s+"/img");
  fstream _fs;
  _fs.open(s+"/test", ios::out);
  _fs << "#0" << endl;
  _fs.close();
}

void MyDir::copyImages(string source, string dest)
{
  MyDir::createDir(dest);
  MyDir::filelist list=MyDir::getAllFiles(source);
  for(int i=0;i<list.size();i++)
  {

    boost::filesystem::path sdir(source+"/"+list[i]);
    boost::filesystem::path ddir(dest+"/"+list[i]);
    if(boost::filesystem::exists(ddir))
    {
      boost::filesystem::remove(ddir);
      cout << "Warning! Image overwritten!" << endl;
    }

    boost::filesystem::copy_file(sdir, ddir);
  }

}

ext: cc


text:
//  Copyright 2009-2010 Vicente J. Botet Escriba

//  Distributed under the Boost Software License, Version 1.0.
//  See http://www.boost.org/LICENSE_1_0.txt

#ifndef BOOST_CHRONO_DETAIL_SYSTEM_HPP
#define BOOST_CHRONO_DETAIL_SYSTEM_HPP

#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING

#include <boost/system/error_code.hpp>

namespace boost {
namespace chrono {
    inline bool is_throws(system::error_code  & ec) { return (&ec==&boost::throws()); }
}
}

#endif
#endif

ext: hpp

max_stars_repo_name: kindlychung/mediasoup-sfu-cpp

max_issues_repo_name: kindlychung/mediasoup-sfu-cpp

max_forks_repo_name: kindlychung/mediasoup-sfu-cpp


text:
/*
Copyright (c) 2012,2013,2014,2019 Matthew H. Reilly (kb1vc)
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

    Redistributions of source code must retain the above copyright
    notice, this list of conditions and the following disclaimer.
    Redistributions in binary form must reproduce the above copyright
    notice, this list of conditions and the following disclaimer in
    the documentation and/or other materials provided with the
    distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef SODA_THREAD_HDR
#define SODA_THREAD_HDR

#include "SoDaBase.hxx"
#include <string>
#include "Debug.hxx"
#include <boost/thread.hpp>
#include "version.h"
 /**
  * @file SoDaThread.hxx
  * The Baseclass for all SoDa thread objects.  These are used for
  * blocks that wait on messages from the message rings, and act on
  * them.  A SoDaThread subscribes to message rings, and exports
  * a "run" method.
  *
  * @brief SoDa base and commonly used classes
  *
  * @author Matt Reilly (kb1vc)
  *
  */

namespace SoDa {

  class BaseMBox;
  class Command;

  typedef std::map<std::string, BaseMBox *> MailBoxMap;

  /**
   * The Thread baseclass for all SoDa thread objects.
   *
   * @class SoDa::Thread
   *
   * The SoDaThread baseclass simplifies interaction with threads.
   * Since SoDa thread objects aren't created and destroyed very often,
   * we don't need many bells and whistles here.  Just the ability to
   * start a thread a join a thread.
   *
   * All threads, however, must declare a "run" function, and handlers
   * for three types of SoDa::Command objects (GET, SET, and REPort)
   */
  class Thread : public Base, public Debug {
  public:

    /**
     * @brief make the thread object.  Register it by name and
     * store a version string, so we can test it against the current
     * version of the SoDaServer.
     * @param oname The name of the thread.
     * @param version a string of the form "M.m.p" where
     * M is the major version, m is minor, and p is patch.
     *
     * Invoking this thread should *always* leave the version parameter as
     * the default.  This is a hack to get the actual version information from
     * the included file (used for the build) rather than from the shared
     * library.
     */
    Thread(const std::string & oname, const std::string & version = std::string(SoDaRadio_VERSION));

    /**
     * @brief the creator of this thread may offer one or more mailboxes
     * to this object.  The thread may "subscribe" to the mailboxes as it
     * chooses.
     *
     * @param mbox_name The name of the mailbox.  This identifies the purpose
     * of the mailbox, and the thread should be able to infer the the "T" in
     * the actual MultiMBox<T> type from this identifying string.
     * @param mbox_p a pointer to a multimbox.  This should be cast to the
     */
    virtual void subscribeToMailBox(const std::string & mbox_name, BaseMBox * mbox_p) {
    }

    /**
     * @brief the creator of this thread may offer one or more mailboxes
     * to this object.  The thread may "subscribe" to the mailboxes as it
     * chooses.  offerSubscriptionList is a convenience function that allows
     * a thread creator to present a list of mailboxes to which the thread
     * may subscribe.
     *
     * @param subscription_map The name/mailbox pairs. The name identifies the purpose
     * of the mailbox, and the thread should be able to infer the the "T" in
     * the actual MultiMBox<T> type from this identifying string.
     */
    void subscribeToMailBoxList(const MailBoxMap & subscription_map) {
      for(auto p : subscription_map) {
	subscribeToMailBox(p.first, p.second);
      }
    }

    /**
     * Execute the thread's run loop.
     */
    void start() {
      if(th != NULL) return;
      th = new boost::thread(&Thread::outerRun, this);
    }

    /**
     * more properly "Wait for this thread to exit its run loop".
     * returns after the thread has received a STOP message.
     */
    void join() {
      th->join();
    }

    /**
     * wait for the thread to stop running, or the specified time to pass.
     *
     * @param m timeout in milliseconds
     * @return true if the thread has stopped, false otherwise.
     *
     *
     */
    bool waitForJoin(unsigned int m) {
      return th->try_join_for(boost::chrono::milliseconds(m));
    }

    /**
     * Each thread object must define its "run" loop.  This loop
     * exits only when the thread has received a STOP command on
     * one of its command mailboxes.
     */
    virtual void run() = 0;

    /**
     * Execute (dispatch) a message removed from the command stream to one
     * of the basic Command handler functions.
     *
     * This sequence appears in so many of the instances of Thread that it
     * was factored out.
     *
     * @param cmd the command message to be handled
     */
    void execCommand(Command * cmd);

    /**
     * optional method to handle "GET" commands -- commands that request a response
     */
    virtual void execGetCommand(Command * cmd) { (void) cmd; }

    /**
     * optional method to handle "SET" commands -- commands that set internal state in the object.
     */
    virtual void execSetCommand(Command * cmd) { (void) cmd; }

    /**
     * optional method that reports status or the result of some action.
     */
    virtual void execRepCommand(Command * cmd) { (void) cmd; }

    /**
     * optional method that performs cleanup -- may not delete.
     */
    virtual void shutDown() {
      return;
    }

  private:
    /**
     * This is implemented as a boost thread.  We'll transition away
     * from the boost thread model as time proceeds.
     */
    boost::thread * th;

    /**
     * the run method that is called by the boost thread handler.
     * This method wraps the thread objects run loop in an exception
     * handler so that we can do something useful with it.
     *
     * We call the subclass's "run" method inside a wrapper that can
     * give us some limited information about what happened.
     */
    void outerRun();

    static void sigsegHandler(int sig);

    void hookSigSeg();
  };

  /**
   * @brief if the pattern and key match, return true and set "mbox_ptr" to point
   * to the mailbox pointed to by "could_be_pointer".  Otherwise, just return false;
   *
   * @param obj A SoDa object so we have someone to blame for an exception.
   * @param current_ptr if the mailbox has already been connected, then this is it, otherwise, we'll update the mailbox on a match.

   * @param pattern this is the mailbox name we're looking for
   * @param key this is the name of the  mailbox we're being offered
   * @param could_be_pointer this is the mailbox we're being offered.
   * @return true if we find a match
   *
   */
  template<class T> bool connectMailBox(SoDa::Base * obj,
					T * & current_ptr,
					const std::string & pattern,
					const std::string & key,
					SoDa::BaseMBox * could_be_pointer) {
    T * ret;
    if(pattern == key) {
      ret = dynamic_cast<T *>(could_be_pointer);
      if(ret == NULL) {
	throw SoDa::Exception((boost::format("Bad mailbox pointer for mailbox named = [%s]\n")
			     % key).str() , obj);
      }
      else {
	current_ptr = ret;
	return true;
      }
    }
    return false;
  }
}

#endif

ext: hxx


text:
#include <boost/asio.hpp>
#include <memory>
#include <thread>
#include <mutex>
#include <boost/bind.hpp>
#include <boost/lexical_cast.hpp>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <iomanip>

//using namespace std::placeholders; // adds _1, _2, ...
std::mutex global_stream_lock;

void WorkerThread( std::shared_ptr< boost::asio::io_service > io_service )
{
	global_stream_lock.lock();
	std::cout << "[" << std::this_thread::get_id()
		<< "] Thread Start" << std::endl;
	global_stream_lock.unlock();

	while( true )
	{
		try
		{
			boost::system::error_code ec;
			io_service->run( ec );
			if( ec )
			{
				global_stream_lock.lock();
				std::cout << "[" << std::this_thread::get_id()
					<< "] Error: " << ec << std::endl;
				global_stream_lock.unlock();
			}
			break;
		}
		catch( std::exception & ex )
		{
			global_stream_lock.lock();
			std::cout << "[" << std::this_thread::get_id()
				<< "] Exception: " << ex.what() << std::endl;
			global_stream_lock.unlock();
		}
	}

	global_stream_lock.lock();
	std::cout << "[" << std::this_thread::get_id()
		<< "] Thread Finish" << std::endl;
	global_stream_lock.unlock();
}

struct ClientContext : public std::enable_shared_from_this< ClientContext >
{
	boost::asio::ip::tcp::socket m_socket;

	std::vector< std::uint8_t > m_recv_buffer;
	size_t m_recv_buffer_index;

	std::list< std::vector< std::uint8_t > > m_send_buffer;

	ClientContext( boost::asio::io_service & io_service )
		: m_socket( io_service ), m_recv_buffer_index( 0 )
	{
		m_recv_buffer.resize( 4096 );
	}

	~ClientContext()
	{
	}

	void Close()
	{
		boost::system::error_code ec;
		m_socket.shutdown( boost::asio::ip::tcp::socket::shutdown_both, ec );
		m_socket.close( ec );
	}

	void OnSend( const boost::system::error_code & ec, std::list< std::vector< std::uint8_t > >::iterator itr )
	{
		if( ec )
		{
			global_stream_lock.lock();
			std::cout << "[" << std::this_thread::get_id()
				<< "] Error: " << ec << std::endl;
			global_stream_lock.unlock();

			Close();
		}
		else
		{
			global_stream_lock.lock();
			std::cout << "[" << std::this_thread::get_id()
				<< "] Sent " << (*itr).size() << " bytes." << std::endl;
			global_stream_lock.unlock();
		}
		m_send_buffer.erase( itr );

		// Start the next pending send
		if( !m_send_buffer.empty() )
		{
			boost::asio::async_write(
				m_socket,
				boost::asio::buffer( m_send_buffer.front() ),
				boost::bind(
					&ClientContext::OnSend,
					shared_from_this(),
					boost::asio::placeholders::error,
					m_send_buffer.begin()
				)
			);
		}
	}

	void Send( const void * buffer, size_t length )
	{
		bool can_send_now = false;

		std::vector< std::uint8_t > output;
		std::copy( (const std::uint8_t *)buffer, (const std::uint8_t *)buffer + length, std::back_inserter( output ) );

		// Store if this is the only current send or not
		can_send_now = m_send_buffer.empty();

		// Save the buffer to be sent
		m_send_buffer.push_back( output );

		// Only send if there are no more pending buffers waiting!
		if( can_send_now )
		{
			// Start the next pending send
			boost::asio::async_write(
				m_socket,
				boost::asio::buffer( m_send_buffer.front() ),
				boost::bind(
					&ClientContext::OnSend,
					shared_from_this(),
					boost::asio::placeholders::error,
					m_send_buffer.begin()
				)
			);
		}
	}

	void OnRecv( const boost::system::error_code & ec, size_t bytes_transferred )
	{
		if( ec )
		{
			global_stream_lock.lock();
			std::cout << "[" << std::this_thread::get_id()
				<< "] Error: " << ec << std::endl;
			global_stream_lock.unlock();

			Close();
		}
		else
		{
			// Increase how many bytes we have saved up
			m_recv_buffer_index += bytes_transferred;

			// Debug information
			global_stream_lock.lock();
			std::cout << "[" << std::this_thread::get_id()
				<< "] Recv " << bytes_transferred << " bytes." << std::endl;
			global_stream_lock.unlock();

			// Dump all the data
			global_stream_lock.lock();
			for( size_t x = 0; x < m_recv_buffer_index; ++x )
			{
				std::cout << std::hex << std::setfill( '0' ) <<
					std::setw( 2 ) << (int)m_recv_buffer[ x ] << " ";
				if( ( x + 1 ) % 16 == 0 )
				{
					std::cout << std::endl;
				}
			}
			std::cout << std::endl << std::dec;
			global_stream_lock.unlock();

			// Discard all the data (virtually, not physically!)
			m_recv_buffer_index = 0;

			// Start the next recv cycle
			Recv();
		}
	}

	void Recv()
	{
		m_socket.async_read_some(
			boost::asio::buffer(
				&m_recv_buffer[ m_recv_buffer_index ],
				m_recv_buffer.size() - m_recv_buffer_index ),
			boost::bind( &ClientContext::OnRecv, shared_from_this(), _1, _2 )
		);
	}
};

void OnAccept( const boost::system::error_code & ec, std::shared_ptr< ClientContext > client )
{
	if( ec )
	{
		global_stream_lock.lock();
		std::cout << "[" << std::this_thread::get_id()
			<< "] Error: " << ec << std::endl;
		global_stream_lock.unlock();
	}
	else
	{
		global_stream_lock.lock();
		std::cout << "[" << std::this_thread::get_id()
			<< "] Accepted!" << std::endl;
		global_stream_lock.unlock();

		// 2 bytes message size, followed by the message
		client->Send( "\x02\x00Hi", 6 );
		client->Recv();
	}
}

int main( int argc, char * argv[] )
{
	std::shared_ptr< boost::asio::io_service > io_service(
		new boost::asio::io_service
		);
	std::shared_ptr< boost::asio::io_service::work > work(
		new boost::asio::io_service::work( *io_service )
		);
	std::shared_ptr< boost::asio::io_service::strand > strand(
		new boost::asio::io_service::strand( *io_service )
		);

	global_stream_lock.lock();
	std::cout << "[" << std::this_thread::get_id()
		<< "] Press [return] to exit." << std::endl;
	global_stream_lock.unlock();

	// 1 worker thread so we do not have to deal with thread safety issues
	std::thread worker_threads[1];
	for( int x = 0; x < 1; ++x )
	{
		worker_threads[x] = std::thread( std::bind( &WorkerThread, io_service ) );
	}

	std::shared_ptr< boost::asio::ip::tcp::acceptor > acceptor(
		new boost::asio::ip::tcp::acceptor( *io_service )
		);
	std::shared_ptr< ClientContext > client(
		new ClientContext( *io_service )
		);

	try
	{
		boost::asio::ip::tcp::resolver resolver( *io_service );
		boost::asio::ip::tcp::resolver::query query(
			"127.0.0.1",
			boost::lexical_cast< std::string >( 7777 )
			);
		boost::asio::ip::tcp::endpoint endpoint = *resolver.resolve( query );
		acceptor->open( endpoint.protocol() );
		acceptor->set_option( boost::asio::ip::tcp::acceptor::reuse_address( false ) );
		acceptor->bind( endpoint );
		acceptor->listen( boost::asio::socket_base::max_connections );
		acceptor->async_accept( client->m_socket, boost::bind( OnAccept, _1, client ) );

		global_stream_lock.lock();
		std::cout << "Listening on: " << endpoint << std::endl;
		global_stream_lock.unlock();
	}
	catch( std::exception & ex )
	{
		global_stream_lock.lock();
		std::cout << "[" << std::this_thread::get_id()
			<< "] Exception: " << ex.what() << std::endl;
		global_stream_lock.unlock();
	}

	std::cin.get();

	boost::system::error_code ec;
	acceptor->close( ec );

	io_service->stop();

	for( int x = 0; x < 1; ++x )
	{
		worker_threads[x].join();
	}

	return 0;
}

ext: cpp

max_stars_repo_name: steelwil/homepage

max_issues_repo_name: steelwil/homepage

max_forks_repo_name: steelwil/homepage


text:
/*******************************************************************************
procmon, Copyright (c) 2014, The Regents of the University of California,
through Lawrence Berkeley National Laboratory (subject to receipt of any
required approvals from the U.S. Dept. of Energy).  All rights reserved.

If you have questions about your rights to use or distribute this software,
please contact Berkeley Lab's Technology Transfer Department at  TTD@lbl.gov.

The LICENSE file in the root directory of the source code archive describes the
licensing and distribution rights and restrictions on this software.

Author:   Douglas Jacobsen <dmj@nersc.gov>
*******************************************************************************/

#include "config.h"
#include "ProcData.hh"
#include "ProcIO.hh"
#include <signal.h>
#include <string.h>
#include <iostream>
#include <unordered_map>
#include "ProcReducerData.hh"

#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>

#include <boost/program_options.hpp>
#define PROCREDUCER_VERSION "2.4"
namespace po = boost::program_options;

/* ProcReducer
    * Takes in procmon data from all sources and only writes the minimal record
    * Writes an HDF5 file for all procdata foreach day
*/

/* global variables - these are global for signal handling */
int cleanUpExitFlag = 0;
int resetOutputFileFlag = 0;

void sig_handler(int signum) {
    /* if we receive any trapped signal, just set the cleanUpFlag
     * this will break the infinite loop and cause the message
     * buffer to get written out
     */
     cleanUpExitFlag = 1;
}

void sighup_handler(int signum) {
    /* if we receive any trapped signal, just set the cleanUpFlag
     * this will break the infinite loop and cause the message
     * buffer to get written out
     */
     resetOutputFileFlag = 1;
}

void version() {
    cout << "ProcReducer " << PROCREDUCER_VERSION;
    cout << endl;
    exit(0);
}

class proc_t {
public:
    proc_t(): statSet(false),dataSet(false) { }
    bool statSet;
    bool dataSet;
    procstat stat;
    procdata data;
    unsigned int statRecord;
    unsigned int dataRecord;
    int nData;
    int nStat;
};

class ProcReducerConfig {
public:
    ProcReducerConfig(int argc, char **argv) {
        /* Parse command line arguments */
        po::options_description basic("Basic Options");
        basic.add_options()
            ("version", "Print version information")
            ("help,h", "Print help message")
            ("verbose,v", "Print extra (debugging) information")
        ;
        po::options_description config("Configuration Options");
        config.add_options()
            ("daemonize,d", "Daemonize the procmon process")
            ("hostname,H",po::value<std::string>(&(this->hostname))->default_value(DEFAULT_REDUCER_HOSTNAME), "identifier for tagging data")
            ("identifier,I",po::value<std::string>(&(this->identifier))->default_value(DEFAULT_REDUCER_IDENTIFIER), "identifier for tagging data")
            ("subidentifier,S",po::value<std::string>(&(this->subidentifier))->default_value(DEFAULT_REDUCER_SUBIDENTIFIER), "secondary identifier for tagging data")
            ("outputhdf5prefix,O",po::value<std::string>(&(this->outputHDF5FilenamePrefix))->default_value(DEFAULT_REDUCER_OUTPUT_PREFIX), "prefix for hdf5 output filename [final names will be prefix.YYYYMMDDhhmmss.h5 (required)")
            ("cleanfreq,c",po::value<int>(&(this->cleanFreq))->default_value(DEFAULT_REDUCER_CLEAN_FREQUENCY), "time between process hash table cleaning runs")
            ("maxage,m",po::value<int>(&(this->maxProcessAge))->default_value(DEFAULT_REDUCER_MAX_PROCESS_AGE), "timeout since last communication from a pid before allowing removal from hash table (cleaning)")
            ("statblock",po::value<int>(&(this->statBlockSize))->default_value(DEFAULT_STAT_BLOCK_SIZE), "number of stat records per block in hdf5 file" )
            ("datablock",po::value<int>(&(this->dataBlockSize))->default_value(DEFAULT_DATA_BLOCK_SIZE), "number of data records per block in hdf5 file" )
            ("pid,q",po::value<string>(&(this->pidfile))->default_value(""), "pid file to write")
            ("debug", "enter debugging mode")
        ;
        po::options_description mqconfig("AMQP Configuration Options");
        mqconfig.add_options()
            ("mqhostname,H", po::value<std::string>(&(this->mqServer))->default_value(DEFAULT_AMQP_HOST), "hostname for AMQP Server")
            ("mqport,P",po::value<unsigned int>(&(this->mqPort))->default_value(DEFAULT_AMQP_PORT), "port for AMQP Server")
            ("mqvhost,V",po::value<std::string>(&(this->mqVHost))->default_value(DEFAULT_AMQP_VHOST), "virtual-host for AMQP Server")
            ("mqexchange,E",po::value<std::string>(&(this->mqExchangeName))->default_value("procmon"), "exchange name for AMQP Server")
            ("mqUser",po::value<std::string>(&(this->mqUser))->default_value(DEFAULT_AMQP_USER), "virtual-host for AMQP Server")
            ("mqPassword",po::value<std::string>(&(this->mqPassword)), "virtual-host for AMQP Server")
            ("mqframe,F",po::value<unsigned int>(&(this->mqFrameSize))->default_value(DEFAULT_AMQP_FRAMESIZE), "maximum frame size for AMQP Messages (bytes)")
        ;

        po::options_description options;
        options.add(basic).add(config).add(mqconfig);
        po::variables_map vm;
        try {
            po::store(po::command_line_parser(argc, argv).options(options).run(), vm);
            po::notify(vm);
            if (vm.count("help")) {
                std::cout << options << std::endl;
                exit(0);
            }
            if (vm.count("version")) {
                version();
                exit(0);
            }
            if (vm.count("daemonize")) {
                daemonize = true;
            } else {
                daemonize = false;
            }
            if (vm.count("debug")) {
                debug = true;
            }
            if (vm.count("mqPassword") == 0) {
                mqPassword = DEFAULT_AMQP_PASSWORD;
            }
        } catch (std::exception &e) {
            std::cout << e.what() << std::endl;
            std::cout << options << std::endl;
            exit(1);
        }
    }
    string mqServer;
    string mqVHost;
    string mqExchangeName;
    string mqUser;
    string mqPassword;
    unsigned int mqPort;
    unsigned int mqFrameSize;
    bool debug;
    bool daemonize;

    string hostname;
    string identifier;
    string subidentifier;

    string pidfile;

    string outputHDF5FilenamePrefix;

    int cleanFreq;
    int maxProcessAge;
    int dataBlockSize;
    int statBlockSize;
    int fdBlockSize;

};

unsigned int get_record_pid(ProcRecordType type, void *data, int n) {
    if (type == TYPE_PROCDATA) {
        procdata *ptr = (procdata*) data;
        return ptr[n].pid;
    } else if (type == TYPE_PROCSTAT) {
        procstat *ptr = (procstat*) data;
        return ptr[n].pid;
    } else if (type == TYPE_PROCFD) {
        procfd *ptr = (procfd*) data;
        return ptr[n].pid;
    }
    return 0;
}

unsigned int set_process_record(ProcRecordType recordType, void *data, int i, ProcessRecord *record, bool newRecord, ProcHDF5IO *outputFile) {
    if (recordType == TYPE_PROCDATA) {
        procdata *ptr = (procdata *) data;
        unsigned int recId = record->set_procdata(&(ptr[i]), newRecord);
        record->set_procdata_id(
            outputFile->write_procdata(&(ptr[i]), recId, 1)
        );
    } else if (recordType == TYPE_PROCSTAT) {
        procstat *ptr = (procstat *) data;
        unsigned int recId = record->set_procstat(&(ptr[i]), newRecord);
        record->set_procstat_id(
            outputFile->write_procstat(&(ptr[i]), recId, 1)
        );
    } else if (recordType == TYPE_PROCFD) {
        procfd *ptr = (procfd *) data;
        try {
            unsigned int recId = record->set_procfd(&(ptr[i]), newRecord);
            record->set_procfd_id(
                outputFile->write_procfd(&(ptr[i]), recId, 1),
                &(ptr[i])
            );
        } catch (ReducerInvalidFDException &e) {
            cerr << "Caught (and ignored) invalid FD exception: " << e.what() << endl;
        }
    }
    return 0;
}

static void daemonize() {
	pid_t pid, sid;

	if (getppid() == 1) {
		return; // already daemonized
	}
	pid = fork();
	if (pid < 0) {
		exit(1); // failed to fork
	}
	if (pid > 0) {
		exit(0); // this is the parent, so exit
	}
	umask(0);

	sid = setsid();
	if (sid < 0) {
		exit(1);
	}

	if ((chdir("/")) < 0) {
		exit(1);
	}

	freopen("/dev/null", "r", stdin);
	freopen("/dev/null", "w", stdout);
	freopen("/dev/null", "w", stderr);
}

/* pidfile start-up routine.
   Should be called after daemonizing, but before any privilege reduction.

   Will check if an existing pid file exists, if it does it will read that
   pid file, check to see if that pid is still running.

   If the pid isn't running, then the existing pidfile will be unlinked

   If the pid is running, then exit()

   Finally, the results of getpid() will be written into the pidfile. If the
   pid file fails to write, then exit()
*/
void pidfile(const string& pidfilename) {
    if (pidfilename.length() == 0) return;

    FILE *pidfile = NULL;
    char buffer[BUFFER_SIZE];
    pid_t my_pid = getpid();

    /* try to open existing pidfile */
    if ((pidfile = fopen(pidfilename.c_str(), "r")) != NULL) {

        /* try to read the pid */
        int readBytes = fread(buffer, sizeof(char), BUFFER_SIZE, pidfile);
        fclose(pidfile);

        if (readBytes > 0) {
            pid_t pid = atoi(buffer);

            if (pid != 0 && pid != my_pid) {
                struct stat st_stat;
                snprintf(buffer, BUFFER_SIZE, "/proc/%d/status", pid);
                if (stat(buffer, &st_stat) == 0) {
                    /* the process still exists! */
                    fprintf(stderr, "Process %d is still running, exiting.\n", pid);
                    exit(0);
                } else {
                    unlink(pidfilename.c_str());
                }
            }
        }
    }
    if ((pidfile = fopen(pidfilename.c_str(), "w")) != NULL) {
        fprintf(pidfile, "%d\n", my_pid);
        fclose(pidfile);
        return;
    }
    fprintf(stderr, "FAILED to write pidfile %s, exiting.", pidfilename.c_str());
    exit(1);
}

int main(int argc, char **argv) {
    cleanUpExitFlag = 0;
    resetOutputFileFlag = 0;

    ProcReducerConfig config(argc, argv);

	if (config.daemonize) {
		daemonize();
	}
    if (config.pidfile.length() > 0) {
        pidfile(config.pidfile);
    }

    ProcAMQPIO *conn = new ProcAMQPIO(config.mqServer, config.mqPort, config.mqVHost, config.mqUser, config.mqPassword, config.mqExchangeName, config.mqFrameSize, FILE_MODE_READ);
    conn->set_context(config.hostname, config.identifier, config.subidentifier);
    ProcHDF5IO* outputFile = NULL;

    time_t currTimestamp = time(NULL);
    time_t lastClean = 0;
    struct tm currTm;
    memset(&currTm, 0, sizeof(struct tm));
    currTm.tm_isdst = -1;
    localtime_r(&currTimestamp, &currTm);
    int last_hour = currTm.tm_hour;
    string hostname, identifier, subidentifier;

    int saveCnt = 0;
    int nRecords = 0;
    string outputFilename;
    int count = 0;
    void* data = NULL;
    size_t data_size = 0;

    char buffer[1024];
    unordered_map<std::string, ProcessList*> processLists;
    processLists.reserve(1000);
    ProcessList* spare_processList = new ProcessList(config.maxProcessAge);

    signal(SIGINT, sig_handler);
    signal(SIGTERM, sig_handler);
    signal(SIGXCPU, sig_handler);
    signal(SIGUSR1, sig_handler);
    signal(SIGUSR2, sig_handler);
    signal(SIGHUP, sighup_handler);

    while (cleanUpExitFlag == 0) {
        currTimestamp = time(NULL);
        localtime_r(&currTimestamp, &currTm);

        if (currTm.tm_hour !=  last_hour || outputFile == NULL || resetOutputFileFlag == 2) {
            /* flush the file buffers and clean up the old references to the old file */
            if (outputFile != NULL) {
                outputFile->flush();
                delete outputFile;
                outputFile = NULL;
            }

            /* dump the hash table - we need a fresh start for a fresh file */
            for (auto iter = processLists.begin(), end = processLists.end(); iter != end; ++iter) {
                ProcessList* list = iter->second;
                list->expire_all_processes();
            }

            /* use the current date and time as the suffix for this file */
            strftime(buffer, 1024, "%Y%m%d%H%M%S", &currTm);
            outputFilename = config.outputHDF5FilenamePrefix + "." + string(buffer) + ".h5";
            outputFile = new ProcHDF5IO(outputFilename, FILE_MODE_WRITE);
            resetOutputFileFlag = 0;
        }
        last_hour = currTm.tm_hour;

        ProcRecordType recordType = conn->read_stream_record(&data, &data_size, &nRecords);
        conn->get_frame_context(hostname, identifier, subidentifier);

        if (data == NULL) {
            continue;
        }
        ProcessList* currList = NULL;
        auto procList_iter = processLists.find(hostname);
        if (procList_iter == processLists.end()) {
            /* new host! */
            currList = new ProcessList(config.maxProcessAge);
            auto insertVal = processLists.insert({hostname, currList});
            if (insertVal.second) {
                procList_iter = insertVal.first;
            } else {
                cout << "couldn't insert new host processlist for: " << hostname << endl;
                delete currList;
                currList = NULL;
            }
        } else {
            currList = procList_iter->second;
        }

        outputFile->set_context(hostname, identifier, subidentifier);
        int last_pid = -1;
        ProcessRecord *last_record = NULL;
        for (int i = 0; i < nRecords; i++) {
            unsigned int recId = 0;
            bool saveNewRec = false;
            unsigned int recID = 0;
            ProcessRecord* record = NULL;

            int pid = get_record_pid(recordType, data, i);
            if (currList != NULL) {
                bool newRecord = false;
                record = currList->find_process_record(pid);
                if (record == NULL) {
                    record = currList->new_process_record(spare_processList);
                    newRecord = true;
                }
                if (record == NULL) {
                    cout << "couldn't get a new record!" << endl;
                } else {
                    set_process_record(recordType, data, i, record, newRecord, outputFile);
                }
            }
        }

        time_t currTime = time(NULL);
        if (currTime - lastClean > config.cleanFreq || cleanUpExitFlag != 0 || resetOutputFileFlag == 1) {
            cout << "Begin Clean; Flushing data to disk..." << endl;
            outputFile->flush();
            outputFile->trim_segments(currTime - config.maxProcessAge);
            cout << "Flush Complete" << endl;

            int before_processes = 0;
            int before_process_capacity = 0;
            int after_processes = 0;
            int after_process_capacity = 0;
            for (auto iter = processLists.begin(), end = processLists.end(); iter != end; ++iter) {
                ProcessList *list = iter->second;
                before_processes += list->get_process_count();
                before_process_capacity += list->get_process_capacity();
                list->find_expired_processes(spare_processList);
                after_processes += list->get_process_count();
                after_process_capacity += list->get_process_capacity();
            }
            time_t nowTime = time(NULL);
            time_t deltaTime = nowTime - currTime;
            cout << "Cleaning finished in " << deltaTime << " seconds" << endl;
            cout << "End Clean: Presently tracking " << after_processes << " processes (removed " << (before_processes - after_processes) << ")" << endl;
            cout << "Capacity for " << after_process_capacity << " processes." << endl;
            cout << "Reserve capacity: " << spare_processList->get_process_capacity() << endl;
            lastClean = currTime;
            if (resetOutputFileFlag == 1) {
                resetOutputFileFlag++;
            }
        }
    }
    free(data);

    /* clean up all the records */
    for (auto iter = processLists.begin(), end = processLists.end(); iter != end; ) {
        ProcessList *record = iter->second;
        delete record;
        processLists.erase(iter++);
    }
    if (outputFile != NULL) {
        outputFile->flush();
        delete outputFile;
        outputFile = NULL;
    }
    if (conn != NULL) {
        delete conn;
        conn = NULL;
    }
    if (spare_processList != NULL) {
        delete spare_processList;
    }
    return 0;
}

max_stars_repo_name: glennklockwood/procmon

max_issues_repo_name: glennklockwood/procmon

max_forks_repo_name: glennklockwood/procmon


text: #include <boost/python/numpy/invoke_matching.hpp>

max_stars_repo_name: miathedev/BoostForArduino

max_issues_repo_name: miathedev/BoostForArduino

max_forks_repo_name: miathedev/BoostForArduino


text:
#ifndef BOOST_UTILITY_EXPLICIT_OPERATOR_BOOL_HPP
#define BOOST_UTILITY_EXPLICIT_OPERATOR_BOOL_HPP

// The header file at this path is deprecated;
// use boost/core/explicit_operator_bool.hpp instead.

#include <boost/core/explicit_operator_bool.hpp>

#endif

max_stars_repo_name: awulkiew/core

max_issues_repo_name: awulkiew/core

max_forks_repo_name: awulkiew/core


text:
#include <functional>
#include <iostream>
#include <boost/coroutine/asymmetric_coroutine.hpp>

using generator_t = typename boost::coroutines::asymmetric_coroutine<int>::pull_type;
using yield_t     = typename boost::coroutines::asymmetric_coroutine<int>::push_type;

void iterator(yield_t& iterator_yield, yield_t& network_yield)
{
 for (auto i = 0; i < 5; ++i)
 {
   if (i % 2 == 0) network_yield(i);
   iterator_yield(i);
 }
}

void loop(yield_t& network_yield)
{
 // bind iterator's second parameter to network_yield function with std::bind
 const auto fn = std::bind(iterator, std::placeholders::_1, std::ref(network_yield));
 // or with a lambda
 // const auto fn = [&](yield_t& iterator_yield){iterator(iterator_yield, network_yield);};
 for (auto i : generator_t{fn})
 {
   std::cout << "loop " << i << '\n';
 }
}

int main()
{
 for (auto i : generator_t{loop}) // loop on network
 {
   std::cout << "main " << i << '\n';
 }
 return 0;
};

max_stars_repo_name: ahamez/snippets

max_issues_repo_name: ahamez/snippets

max_forks_repo_name: ahamez/snippets


text:
/*
 * Copyright 2021 Assured Information Security, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#include "FILE_STREAM_INFORMATION_IMPL.hh"

#include <introvirt/core/exception/BufferTooSmallException.hh>
#include <introvirt/core/exception/InvalidMethodException.hh>
#include <introvirt/util/compiler.hh>

#include <boost/io/ios_state.hpp>

namespace introvirt {
namespace windows {
namespace nt {

void FILE_STREAM_INFORMATION_IMPL::write(std::ostream& os, const std::string& linePrefix) const {
    boost::io::ios_flags_saver ifs(os);
    os << std::dec;

    os << linePrefix << "FileInformationClass: " << FileInformationClass() << '\n';

    for (const auto& entry : *this) {
        os << linePrefix << "\tStreamName: " << entry.StreamName() << '\n';
        os << linePrefix << "\t\tStreamSize: " << entry.StreamSize() << '\n';
        os << linePrefix << "\t\tStreamAllocationSize: " << entry.StreamAllocationSize() << '\n';
    }
}

Json::Value FILE_STREAM_INFORMATION_IMPL::json() const {
    Json::Value result;
    result["FileInformationClass"] = to_string(FileInformationClass());

    Json::Value entries;
    for (const auto& entry : *this) {
        Json::Value json_entry;
        json_entry["StreamName"] = entry.StreamName();
        json_entry["StreamSize"] = entry.StreamSize();
        json_entry["StreamAllocationSize"] = entry.StreamAllocationSize();
        entries.append(std::move(json_entry));
    }

    result["entries"] = std::move(entries);
    return result;
}

FILE_STREAM_INFORMATION_ENTRY_IMPL&
FILE_STREAM_INFORMATION_ENTRY_IMPL::operator=(const FILE_STREAM_INFORMATION_ENTRY& src) {
    const auto& src_impl = static_cast<const FILE_STREAM_INFORMATION_ENTRY_IMPL&>(src);
    *ptr_ = *(src_impl.ptr_);
    StreamName_ = WStr(base_ + offsetof(structs::_FILE_STREAM_INFORMATION, StreamName),
                       src_impl.StreamName_.MaximumLength(), src_impl.StreamName_.Length());

    StreamName_.set(src_impl.StreamName_.utf16());
    return *this;
}

FILE_STREAM_INFORMATION_IMPL::FILE_STREAM_INFORMATION_IMPL(const guest_ptr<void>& ptr,
                                                           uint32_t buffer_size)
    : offset_iterable(
          [](const guest_ptr<void>& ptr, uint32_t buffer_size) {
              return std::make_shared<FILE_STREAM_INFORMATION_ENTRY_IMPL>(ptr);
          },
          ptr, buffer_size) {

    if (unlikely(buffer_size < sizeof(structs::_FILE_STREAM_INFORMATION)))
        throw BufferTooSmallException(sizeof(structs::_FILE_STREAM_INFORMATION), buffer_size);
}

std::shared_ptr<FILE_STREAM_INFORMATION_ENTRY>
FILE_STREAM_INFORMATION_ENTRY::make_shared(const guest_ptr<void>& ptr) {
    return std::make_shared<FILE_STREAM_INFORMATION_ENTRY_IMPL>(ptr);
}

} // namespace nt
} // namespace windows
} // namespace introvirt

max_stars_repo_name: IntroVirt/IntroVirt

max_issues_repo_name: IntroVirt/IntroVirt

max_forks_repo_name: IntroVirt/IntroVirt


text:
#include "lqp_subquery_expression.hpp"

#include <sstream>

#include <boost/container_hash/hash.hpp>

#include "expression_utils.hpp"
#include "logical_query_plan/abstract_lqp_node.hpp"
#include "logical_query_plan/lqp_utils.hpp"
#include "types.hpp"
#include "utils/assert.hpp"

namespace opossum {

LQPSubqueryExpression::LQPSubqueryExpression(
    const std::shared_ptr<AbstractLQPNode>& init_lqp, const std::vector<ParameterID>& init_parameter_ids,
    const std::vector<std::shared_ptr<AbstractExpression>>& parameter_expressions)
    : AbstractExpression(ExpressionType::LQPSubquery, parameter_expressions),
      lqp(init_lqp),
      parameter_ids(init_parameter_ids) {
  Assert(parameter_ids.size() == parameter_expressions.size(),
         "Need exactly as many ParameterIDs as parameter Expressions");
}

size_t LQPSubqueryExpression::parameter_count() const { return parameter_ids.size(); }

std::shared_ptr<AbstractExpression> LQPSubqueryExpression::parameter_expression(const size_t parameter_idx) const {
  Assert(parameter_idx < parameter_count(), "Parameter index out of range");
  return arguments[parameter_idx];
}

std::shared_ptr<AbstractExpression> LQPSubqueryExpression::_on_deep_copy(
    std::unordered_map<const AbstractOperator*, std::shared_ptr<AbstractOperator>>& copied_ops) const {
  const auto lqp_copy = lqp->deep_copy();

  return std::make_shared<LQPSubqueryExpression>(lqp_copy, parameter_ids, expressions_deep_copy(arguments));
}

std::string LQPSubqueryExpression::description(const DescriptionMode mode) const {
  std::stringstream stream;
  stream << "SUBQUERY (LQP, " << lqp.get();

  if (!arguments.empty()) {
    stream << ", Parameters: ";
    for (auto parameter_idx = size_t{0}; parameter_idx < arguments.size(); ++parameter_idx) {
      stream << "[" << arguments[parameter_idx]->description(mode) << ", id=" << parameter_ids[parameter_idx] << "]";
      if (parameter_idx + 1 < arguments.size()) stream << ", ";
    }
  }

  stream << ")";

  return stream.str();
}

DataType LQPSubqueryExpression::data_type() const {
  Assert(lqp->output_expressions().size() == 1,
         "Can only determine the DataType of SubqueryExpressions that return exactly one column");
  return lqp->output_expressions()[0]->data_type();
}

bool LQPSubqueryExpression::_on_is_nullable_on_lqp(const AbstractLQPNode&) const {
  Assert(lqp->output_expressions().size() == 1,
         "Can only determine the nullability of SelectExpressions that return exactly one column");
  return lqp->is_column_nullable(ColumnID{0});
}

bool LQPSubqueryExpression::is_correlated() const { return !arguments.empty(); }

bool LQPSubqueryExpression::_shallow_equals(const AbstractExpression& expression) const {
  DebugAssert(dynamic_cast<const LQPSubqueryExpression*>(&expression),
              "Different expression type should have been caught by AbstractExpression::operator==");
  const auto& subquery_expression = static_cast<const LQPSubqueryExpression&>(expression);
  return *lqp == *subquery_expression.lqp && parameter_ids == subquery_expression.parameter_ids;
}

size_t LQPSubqueryExpression::_shallow_hash() const {
  // Return 0, thus forcing a hash collision for LQPSubqueryExpressions and triggering a full equality check.
  // TODO(moritz) LQP hashing will be introduced with the JoinOrdering optimizer, until then we live with these
  //              collisions
  return AbstractExpression::_shallow_hash();
}

}  // namespace opossum

max_stars_repo_name: mrcl-tst/hyrise

max_issues_repo_name: mrcl-tst/hyrise

max_forks_repo_name: mrcl-tst/hyrise


text:
/**
 * Orthanc - A Lightweight, RESTful DICOM Store
 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
 * Department, University Hospital of Liege, Belgium
 * Copyright (C) 2017-2020 Osimis S.A., Belgium
 *
 * This program is free software: you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation, either version 3 of
 * the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this program. If not, see
 * <http://www.gnu.org/licenses/>.
 **/

/*=========================================================================

  This file is based on portions of the following project:

  Program: DCMTK 3.6.0
  Module:  http://dicom.offis.de/dcmtk.php.en

  Copyright (C) 1994-2011, OFFIS e.V.
  All rights reserved.

  This software and supporting documentation were developed by

  OFFIS e.V.
  R&D Division Health
  Escherweg 2
  26121 Oldenburg, Germany

  Redistribution and use in source and binary forms, with or without
  modification, are permitted provided that the following conditions
  are met:

  - Redistributions of source code must retain the above copyright
  notice, this list of conditions and the following disclaimer.

  - Redistributions in binary form must reproduce the above copyright
  notice, this list of conditions and the following disclaimer in the
  documentation and/or other materials provided with the distribution.

  - Neither the name of OFFIS nor the names of its contributors may be
  used to endorse or promote products derived from this software
  without specific prior written permission.

  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

  =========================================================================*/

#include "../../PrecompiledHeaders.h"
#include <dcmtk/dcmnet/diutil.h>
#include <dcmtk/dcmdata/dcdeftag.h>
#include "GetScp.h"

#include <memory>

#include "../../DicomParsing/FromDcmtkBridge.h"
#include "../../DicomParsing/ToDcmtkBridge.h"
#include "../../Logging.h"
#include "../../OrthancException.h"

#include <boost/lexical_cast.hpp>

namespace Orthanc
{
  namespace
  {
    struct GetScpData
    {
      //  Handle returns void.
      IGetRequestHandler* handler_;
      DcmDataset* lastRequest_;
      T_ASC_Association * assoc_;

      std::string remoteIp_;
      std::string remoteAet_;
      std::string calledAet_;
      int timeout_;

      GetScpData() :
        handler_(NULL),
        lastRequest_(NULL),
        assoc_(NULL),
        timeout_(0)
      {
      };
    };

    static DcmDataset *BuildFailedInstanceList(const std::string& failedUIDs)
    {
      if (failedUIDs.empty())
      {
        return NULL;
      }
      else
      {
        std::unique_ptr<DcmDataset> rspIds(new DcmDataset());

        if (!DU_putStringDOElement(rspIds.get(), DCM_FailedSOPInstanceUIDList, failedUIDs.c_str()))
        {
          throw OrthancException(ErrorCode_InternalError,
                                 "getSCP: failed to build DCM_FailedSOPInstanceUIDList");
        }

        return rspIds.release();
      }
    }

    static void GetScpCallback(
      /* in */
      void *callbackData,
      OFBool cancelled,
      T_DIMSE_C_GetRQ *request,
      DcmDataset *requestIdentifiers,
      int responseCount,
      /* out */
      T_DIMSE_C_GetRSP *response,
      DcmDataset **responseIdentifiers,
      DcmDataset **statusDetail)
    {
      bzero(response, sizeof(T_DIMSE_C_GetRSP));
      *statusDetail = NULL;
      *responseIdentifiers = NULL;

      GetScpData& data = *reinterpret_cast<GetScpData*>(callbackData);
      if (data.lastRequest_ == NULL)
      {
        DicomMap input;
        std::set<DicomTag> ignoreTagLength;
        FromDcmtkBridge::ExtractDicomSummary(input, *requestIdentifiers, 0 /* don't truncate tags */, ignoreTagLength);

        try
        {
          if (!data.handler_->Handle(
                input, data.remoteIp_, data.remoteAet_, data.calledAet_,
                data.timeout_ < 0 ? 0 : static_cast<uint32_t>(data.timeout_)))
          {
            response->DimseStatus = STATUS_GET_Failed_UnableToProcess;
            return;
          }
        }
        catch (OrthancException& e)
        {
          // Internal error!
          LOG(ERROR) << "IGetRequestHandler Failed: " << e.What();
          response->DimseStatus = STATUS_GET_Failed_UnableToProcess;
          return;
        }

        data.lastRequest_ = requestIdentifiers;
      }
      else if (data.lastRequest_ != requestIdentifiers)
      {
        // Internal error!
        LOG(ERROR) << "IGetRequestHandler Failed: Internal error lastRequestIdentifier";
        response->DimseStatus = STATUS_GET_Failed_UnableToProcess;
        return;
      }

      if (data.handler_->GetRemainingCount() == 0)
      {
        response->DimseStatus = STATUS_Success;
      }
      else
      {
        IGetRequestHandler::Status status;

        try
        {
          status = data.handler_->DoNext(data.assoc_);
        }
        catch (OrthancException& e)
        {
          // Internal error!
          LOG(ERROR) << "IGetRequestHandler Failed: " << e.What();
          response->DimseStatus = STATUS_GET_Failed_UnableToProcess;
          return;
        }

        if (status == STATUS_Success)
        {
          if (responseCount < static_cast<int>(data.handler_->GetRemainingCount()))
          {
            response->DimseStatus = STATUS_Pending;
          }
          else
          {
            response->DimseStatus = STATUS_Success;
          }
        }
        else
        {
          response->DimseStatus = STATUS_GET_Failed_UnableToProcess;

          if (data.handler_->GetFailedCount() > 0 ||
              data.handler_->GetWarningCount() > 0)
          {
            response->DimseStatus = STATUS_GET_Warning_SubOperationsCompleteOneOrMoreFailures;
          }

          /*
           * if all the sub-operations failed then we need to generate
           * a failed or refused status.  cf. DICOM part 4, C.4.3.3.1
           * we choose to generate a "Refused - Out of Resources -
           * Unable to perform suboperations" status.
           */
          if ((data.handler_->GetFailedCount() > 0) &&
              ((data.handler_->GetCompletedCount() +
                data.handler_->GetWarningCount()) == 0))
          {
            response->DimseStatus = STATUS_GET_Refused_OutOfResourcesSubOperations;
          }

          *responseIdentifiers = BuildFailedInstanceList(data.handler_->GetFailedUids());
        }
      }

      response->NumberOfRemainingSubOperations = data.handler_->GetRemainingCount();
      response->NumberOfCompletedSubOperations = data.handler_->GetCompletedCount();
      response->NumberOfFailedSubOperations = data.handler_->GetFailedCount();
      response->NumberOfWarningSubOperations = data.handler_->GetWarningCount();
    }
  }

  OFCondition Internals::getScp(T_ASC_Association * assoc,
                                T_DIMSE_Message * msg,
                                T_ASC_PresentationContextID presID,
                                IGetRequestHandler& handler,
                                const std::string& remoteIp,
                                const std::string& remoteAet,
                                const std::string& calledAet,
                                int timeout)
  {
    GetScpData data;
    data.lastRequest_ = NULL;
    data.handler_ = &handler;
    data.assoc_ = assoc;
    data.remoteIp_ = remoteIp;
    data.remoteAet_ = remoteAet;
    data.calledAet_ = calledAet;
    data.timeout_ = timeout;

    OFCondition cond = DIMSE_getProvider(assoc, presID, &msg->msg.CGetRQ,
                                         GetScpCallback, &data,
                                         /*opt_blockMode*/ (timeout ? DIMSE_NONBLOCKING : DIMSE_BLOCKING),
                                         /*opt_dimse_timeout*/ timeout);

    // if some error occured, dump corresponding information and remove the outfile if necessary
    if (cond.bad())
    {
      OFString temp_str;
      LOG(ERROR) << "Get SCP Failed: " << cond.text();
    }

    return cond;
  }
}


text:
#ifndef WEBSERVER_CONNECTION_HPP
#define WEBSERVER_CONNECTION_HPP

#include <boost/asio.hpp>
#include <boost/array.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/enable_shared_from_this.hpp>
#include "request.hpp"
#include "request_handler.hpp"
#include "request_parser.hpp"
#include "response.hpp"

namespace webserver {

#define REQUEST_SIZE 16384 // 2^14

typedef boost::shared_ptr<Connection> connection_ptr;
typedef boost::array<char, REQUEST_SIZE> request_buffer;

class Connection : public boost::enable_shared_from_this<Connection> {
    /* Class representing asynchronous TCP connection.
     *
     * Shared_ptr references are used in order to keep the connection
     * alive. When no new async operation occurs, all connection_ptr disappear
     * and destructor closes th socket.
     * */
public:
    Connection(boost::asio::io_service &io_service,
               RequestHandler request_handler)
            : strand_(io_service)
            , socket_(io_service)
            , request_handler_(request_handler) {
    }

    void start() {
        read_data();
    }

    boost::asio::ip::tcp::socket& socket() {
        return socket_;
    }

private:
    boost::asio::io_service::strand strand_;
    boost::asio::ip::tcp::socket socket_;
    request_buffer buffer_;
    Request request_;
    Response response_;
    RequestParser request_parser_;
    RequestHandler request_handler_;

    void read_data() {
        socket_.async_read_some(boost::asio::buffer(buffer_),
            strand_.wrap(
                boost::bind(&handle_reading_date, shared_from_this(),
                            boost::asio::placeholders::error,
                            boost::asio::placeholders::bytes_transferred))
            );
    }

    void handle_reading_date(boost::system::error_code& e,
                             std::size_t bytes_transferred) {
        /* Handler which parse incoming request and write a response */
        if (e) return;
        parser_state parser_state = request_parser_.parse(
            request_, buffer_,
            buffer_ + bytes_transferred
        );
        switch (parser_state) {
            case completed:
                request_handler_.handle(request_, response_);
                write_response();
                break;
            case unfinished:
                read_data();
                break;
            case failed:
                response_ = Response::response(status::HTTP_400_BAD_REQUEST);
                write_response();
                break;
            default:
                response_ = Response::response(status::HTTP_500_INTERNAL_SERVER_ERROR);
                write_response();
        }
    }

    void write_response() {
        boost::asio::async_write(socket_, response_.as_buffers(),
            strand_.wrap(boost::bind(&shutdown_socket, shared_from_this(),
                                     boost::asio::placeholders::error)));
    }

    void shutdown_socket(boost::system::error_code& e) {
        /* Disable both sending and receiving on the socket */
        if (e) return;
        boost::system::error_code error_code;
        socket_.shutdown(boost::asio::ip::tcp::socket::shutdown_both,
                         error_code);
        // connection_ptr reference disappear destroying the connection object
    }
};

} // namespace webserver

#endif // WEBSERVER_CONNECTION_HPP


text:
//               Copyright Stefan Strasser 2010 - 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)

#ifndef BOOST_TRANSACT_DETAIL_FILE_HPP
#define BOOST_TRANSACT_DETAIL_FILE_HPP

#include <boost/filesystem.hpp>
#include <boost/transact/exception.hpp>

namespace boost {
  namespace transact {

    struct eof_exception : io_failure {
    };

    namespace detail {

#ifdef _WIN32
#include <Windows.h>
#include <WinBase.h>

#include <strsafe.h>

      static void throw_io_failure(char const* function)
      {
        // Retrieve the system error message for the last-error code
        DWORD dw = GetLastError();

        LPVOID lpMsgBuf;
        FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER |
            FORMAT_MESSAGE_FROM_SYSTEM |
            FORMAT_MESSAGE_IGNORE_INSERTS,
            NULL,
            dw,
            MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
            (LPTSTR) &lpMsgBuf,
            0, NULL );

        // Display the error message and exit the process
        // TODO - should be incorporated into io_failure what().
        std::cerr << function << " failed with error " << dw << ": " << (char*)lpMsgBuf << std::endl;

        LocalFree(lpMsgBuf);
        throw io_failure();
      }

// low-level ofile representation for WIN32
      template <bool direct_io = false>
      class ofile {
      public:
        typedef unsigned int size_type;
        static const bool has_direct_io = direct_io;

        void* filedes;

        ofile(std::string const &name) : filedes(INVALID_HANDLE_VALUE) {
          unsigned long access = GENERIC_READ | GENERIC_WRITE;
          unsigned long creation_flags = OPEN_ALWAYS;
          unsigned long flags = 0;
          if ( direct_io )
          flags |= FILE_FLAG_NO_BUFFERING | FILE_FLAG_WRITE_THROUGH;

          this->filedes = CreateFileA(name.c_str(), access,
              FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
              0, creation_flags, flags, 0);
          if (this->filedes == INVALID_HANDLE_VALUE )
          throw_io_failure("CreateFileA");

          //make sure the directory entry has reached the disk:
          std::string dirname=filesystem::system_complete(name).parent_path().native();

          creation_flags = OPEN_EXISTING;
          flags = FILE_FLAG_BACKUP_SEMANTICS;
          void *dirfiledes = CreateFileA(dirname.c_str(), access,
              FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
              0, creation_flags, flags, 0);
          if (dirfiledes == INVALID_HANDLE_VALUE )
          throw_io_failure("CreateFileA");
          if(!FlushFileBuffers(dirfiledes))
          throw_io_failure("FlushFileBuffers");
          if(!CloseHandle(dirfiledes))
          throw_io_failure("CloseHandle");
        }

        ~ofile() {
          if(this->filedes != INVALID_HANDLE_VALUE)
          CloseHandle(this->filedes);
        }

        void close(); //TODO
        void reopen(std::string const &name);//TODO

        void seek(size_type const &s) {
          LARGE_INTEGER loc;
          loc.QuadPart = s;
          if(SetFilePointerEx(this->filedes, loc, NULL, FILE_BEGIN) == 0)
          throw_io_failure("SetFilePointerEx");
        }

        size_type write(const char *data, size_type const &size) {
          DWORD written;
          if(WriteFile(this->filedes, data, size, &written, 0) == 0)
          throw_io_failure("WriteFile");
          return (size_type)written;
        }
        void flush() {}
        void sync() {
          if (!direct_io && FlushFileBuffers(this->filedes) == 0)
          throw_io_failure("FlushFileBuffers");
        }
      };

#else

#include <unistd.h>
#include <fcntl.h>

#ifndef _POSIX_SYNCHRONIZED_IO
#error no POSIX synchronized IO available
#endif

// low-level ofile for Linux/Unix
      template<bool direct_io = false> // ignored on Posix API.
      class ofile {
      public:

        typedef unsigned int size_type;
        static const bool has_direct_io = direct_io;

        ofile(std::string const &name) :
            filedes(-1), name(name) {
          this->open_();
          this->sync_directory();
        }

        ~ofile() {
          this->close();
        }

        void seek(size_type const &s) {
          if (::lseek(this->filedes, s, SEEK_SET) != off_t(s)) throw io_failure();
        }

        size_type write(const char *data, size_type const &size) {
          if (::write(this->filedes, data, size) != ssize_t(size)) throw io_failure();
          return size;
        }

        void flush() {
        }

        void sync() {
#ifdef linux
          if (::fdatasync(this->filedes) != 0) throw io_failure();
#else //multiple sources say fdatasync is not safe on other systems
          if(::fsync(this->filedes) != 0) throw io_failure();
#endif
        }

        void close() {
          if (this->filedes != -1) {
            if (::close(this->filedes) != 0) throw io_failure();
          }
          this->filedes = -1;
        }

        void reopen(std::string const &newname) {
          BOOST_ASSERT(this->filedes == -1);
          filesystem::remove(this->name);
          this->name = newname;
          this->open_();
          sync_directory();
        }

        void rename(std::string const &newname) {
          BOOST_ASSERT(this->filedes == -1);
          filesystem::rename(this->name, newname);
          this->name = newname;
          this->open_(0); //do not truncate file!
          sync_directory();
        }

      private:

        void sync_directory() {
          //TODO optimization: directory entries are synced even if syncing is turning off,
          //which is not passed to ofile
          std::string dirname = filesystem::path(this->name).parent_path().native();
          if (dirname.empty()) dirname = ".";
          int dirfd = open(dirname.c_str(), O_RDONLY);
          if (dirfd == -1) throw io_failure();
          int ret = ::fsync(dirfd);
          if (::close(dirfd) != 0 || ret != 0) throw io_failure();
        }

        void open_(int flags = O_CREAT | O_TRUNC) {
          flags |= O_WRONLY;
#ifdef linux
          flags |= O_NOATIME;
#endif
          this->filedes = open(this->name.c_str(), flags, S_IRUSR | S_IWUSR);
          if (this->filedes == -1) throw io_failure();
        }

        int filedes;
        std::string name;
      };

#endif

      typedef ofile<true> direct_ofile;

    }
  }
}

#endif

max_stars_repo_name: galaxyeye/pioneer

max_issues_repo_name: galaxyeye/pioneer

max_forks_repo_name: galaxyeye/pioneer


text:
#include <gtest/gtest.h>

#include "converter/fixml2fix_converter.hxx"
#include "converter/xml_element_helper.hxx"
#include "converter/fix_helper.hxx"
#include "util/fix_env.hxx"
#include "tools/test_util.hxx"

#include <boost/log/trivial.hpp>

#include <quickfix/fix50sp2/AllocationInstructionAck.h>

#include <list>
#include <set>
#include <string>
#include <utility>

using namespace std;
using namespace fix2xml;

TEST ( AllocationInstructionAck, set_fields)
{

  fixml2fix_converter converter {"../spec/fix/FIX50SP2.xml", "../spec/xsd/fixml-main-5-0-SP2.xsd"};
  auto& fixml_dict = converter.fixml_dico();
  ASSERT_TRUE(converter.init());
  ASSERT_TRUE(converter.parse_fixt_dico("../spec/fix/FIXT11.xml"));
  FIX50SP2::AllocationInstructionAck msg;

  list<multiset<string>> all_values;
  multiset<string> all_compo_names;
  multiset<string> AllocationInstructionAck_0;
  set_field(msg, FIX::AllocID{"STRING_740923793"}, AllocationInstructionAck_0);
  set_field(msg, FIX::AllocIntermedReqType{1}, AllocationInstructionAck_0);
  set_field(msg, FIX::AllocRejCode{99}, AllocationInstructionAck_0);
  set_field(msg, FIX::AllocStatus{6}, AllocationInstructionAck_0);
  set_field(msg, FIX::AllocType{2}, AllocationInstructionAck_0);
  set_field(msg, FIX::EncodedText{"DATA_1637614949"}, AllocationInstructionAck_0);
  set_field(msg, FIX::EncodedTextLen{2031706242}, AllocationInstructionAck_0);
  set_field(msg, FIX::MatchStatus{'0'}, AllocationInstructionAck_0);
  set_field(msg, FIX::Product{13}, AllocationInstructionAck_0);
  set_field(msg, FIX::SecondaryAllocID{"STRING_1677081069"}, AllocationInstructionAck_0);
  set_field(msg, FIX::SecurityType{"STRING_ONITE"}, AllocationInstructionAck_0);
  set_field(msg, FIX::Text{"STRING_476769529"}, AllocationInstructionAck_0);
  set_field(msg, FIX::TradeDate{"LOCALMKTDATE_1571275635"}, AllocationInstructionAck_0);
  set_field(msg, FIX::TransactTime{FIX::UTCTIMESTAMP(6, 17, 30, 23, 9, 2010)}, AllocationInstructionAck_0);
  all_values.push_back(AllocationInstructionAck_0);

  all_compo_names.insert("AllocationInstructionAck");

  // AllocAckGrp
  // Group AllocAckGrp.NoAllocs
  {
    FIX50SP2::AllocationInstructionAck::NoAllocs noAllocs_0_0;
    // AllocAckGrp.NoAllocs
    multiset<string> AllocAckGrp_NoAllocs_0;
    set_field(noAllocs_0_0, FIX::AllocAccount{"STRING_1775859929"}, AllocAckGrp_NoAllocs_0);
    set_field(noAllocs_0_0, FIX::AllocAcctIDSource{1365372011}, AllocAckGrp_NoAllocs_0);
    set_field(noAllocs_0_0, FIX::AllocCustomerCapacity{"STRING_221738740"}, AllocAckGrp_NoAllocs_0);
    set_field(noAllocs_0_0, FIX::AllocPositionEffect{'R'}, AllocAckGrp_NoAllocs_0);
    FIX::AllocPrice AllocPrice_3;
    AllocPrice_3.setString("10719466");
set_field(noAllocs_0_0, AllocPrice_3, AllocAckGrp_NoAllocs_0);
    FIX::AllocQty AllocQty_3;
    AllocQty_3.setString("7592123");
set_field(noAllocs_0_0, AllocQty_3, AllocAckGrp_NoAllocs_0);
    set_field(noAllocs_0_0, FIX::AllocText{"STRING_215017212"}, AllocAckGrp_NoAllocs_0);
    set_field(noAllocs_0_0, FIX::EncodedAllocText{"DATA_449875675"}, AllocAckGrp_NoAllocs_0);
    set_field(noAllocs_0_0, FIX::EncodedAllocTextLen{970135291}, AllocAckGrp_NoAllocs_0);
    set_field(noAllocs_0_0, FIX::IndividualAllocID{"STRING_586700489"}, AllocAckGrp_NoAllocs_0);
    set_field(noAllocs_0_0, FIX::IndividualAllocRejCode{1190799468}, AllocAckGrp_NoAllocs_0);
    set_field(noAllocs_0_0, FIX::IndividualAllocType{1}, AllocAckGrp_NoAllocs_0);
    set_field(noAllocs_0_0, FIX::SecondaryIndividualAllocID{"STRING_1781396953"}, AllocAckGrp_NoAllocs_0);
    all_values.push_back(AllocAckGrp_NoAllocs_0);
    all_compo_names.insert("...NoAllocs");

    // NestedParties
    // Group NestedParties.NoNestedPartyIDs
    {
      FIX50SP2::AllocationInstructionAck::NoAllocs::NoNestedPartyIDs noNestedPartyIDs_0_1_0;
      // NestedParties.NoNestedPartyIDs
      multiset<string> NestedParties_NoNestedPartyIDs_8;
      set_field(noNestedPartyIDs_0_1_0, FIX::NestedPartyID{"STRING_1942846079"}, NestedParties_NoNestedPartyIDs_8);
      set_field(noNestedPartyIDs_0_1_0, FIX::NestedPartyIDSource{'1'}, NestedParties_NoNestedPartyIDs_8);
      set_field(noNestedPartyIDs_0_1_0, FIX::NestedPartyRole{1860770637}, NestedParties_NoNestedPartyIDs_8);
      all_values.push_back(NestedParties_NoNestedPartyIDs_8);
      all_compo_names.insert("...NoAllocs...NoNestedPartyIDs");

      // NstdPtysSubGrp
      // Group NstdPtysSubGrp.NoNestedPartySubIDs
      {
        FIX50SP2::AllocationInstructionAck::NoAllocs::NoNestedPartyIDs::NoNestedPartySubIDs noNestedPartySubIDs_0_0_2_0;
        // NstdPtysSubGrp.NoNestedPartySubIDs
        multiset<string> NstdPtysSubGrp_NoNestedPartySubIDs_21;
        set_field(noNestedPartySubIDs_0_0_2_0, FIX::NestedPartySubID{"STRING_1990615870"}, NstdPtysSubGrp_NoNestedPartySubIDs_21);
        set_field(noNestedPartySubIDs_0_0_2_0, FIX::NestedPartySubIDType{1390368058}, NstdPtysSubGrp_NoNestedPartySubIDs_21);
        all_values.push_back(NstdPtysSubGrp_NoNestedPartySubIDs_21);
        all_compo_names.insert("...NoAllocs...NoNestedPartyIDs...NoNestedPartySubIDs");

        noNestedPartyIDs_0_1_0.addGroup(noNestedPartySubIDs_0_0_2_0);
      }
      noAllocs_0_0.addGroup(noNestedPartyIDs_0_1_0);
    }
    {
      FIX50SP2::AllocationInstructionAck::NoAllocs::NoNestedPartyIDs noNestedPartyIDs_0_1_1;
      // NestedParties.NoNestedPartyIDs
      multiset<string> NestedParties_NoNestedPartyIDs_9;
      set_field(noNestedPartyIDs_0_1_1, FIX::NestedPartyID{"STRING_591245793"}, NestedParties_NoNestedPartyIDs_9);
      set_field(noNestedPartyIDs_0_1_1, FIX::NestedPartyIDSource{'3'}, NestedParties_NoNestedPartyIDs_9);
      set_field(noNestedPartyIDs_0_1_1, FIX::NestedPartyRole{814160045}, NestedParties_NoNestedPartyIDs_9);
      all_values.push_back(NestedParties_NoNestedPartyIDs_9);
      all_compo_names.insert("...NoAllocs...NoNestedPartyIDs");

      // NstdPtysSubGrp
      // Group NstdPtysSubGrp.NoNestedPartySubIDs
      {
        FIX50SP2::AllocationInstructionAck::NoAllocs::NoNestedPartyIDs::NoNestedPartySubIDs noNestedPartySubIDs_0_1_2_0;
        // NstdPtysSubGrp.NoNestedPartySubIDs
        multiset<string> NstdPtysSubGrp_NoNestedPartySubIDs_22;
        set_field(noNestedPartySubIDs_0_1_2_0, FIX::NestedPartySubID{"STRING_142433317"}, NstdPtysSubGrp_NoNestedPartySubIDs_22);
        set_field(noNestedPartySubIDs_0_1_2_0, FIX::NestedPartySubIDType{203748674}, NstdPtysSubGrp_NoNestedPartySubIDs_22);
        all_values.push_back(NstdPtysSubGrp_NoNestedPartySubIDs_22);
        all_compo_names.insert("...NoAllocs...NoNestedPartyIDs...NoNestedPartySubIDs");

        noNestedPartyIDs_0_1_1.addGroup(noNestedPartySubIDs_0_1_2_0);
      }
      {
        FIX50SP2::AllocationInstructionAck::NoAllocs::NoNestedPartyIDs::NoNestedPartySubIDs noNestedPartySubIDs_0_1_2_1;
        // NstdPtysSubGrp.NoNestedPartySubIDs
        multiset<string> NstdPtysSubGrp_NoNestedPartySubIDs_23;
        set_field(noNestedPartySubIDs_0_1_2_1, FIX::NestedPartySubID{"STRING_1814599816"}, NstdPtysSubGrp_NoNestedPartySubIDs_23);
        set_field(noNestedPartySubIDs_0_1_2_1, FIX::NestedPartySubIDType{78987873}, NstdPtysSubGrp_NoNestedPartySubIDs_23);
        all_values.push_back(NstdPtysSubGrp_NoNestedPartySubIDs_23);
        all_compo_names.insert("...NoAllocs...NoNestedPartyIDs...NoNestedPartySubIDs");

        noNestedPartyIDs_0_1_1.addGroup(noNestedPartySubIDs_0_1_2_1);
      }
      noAllocs_0_0.addGroup(noNestedPartyIDs_0_1_1);
    }
    msg.addGroup(noAllocs_0_0);
  }
  {
    FIX50SP2::AllocationInstructionAck::NoAllocs noAllocs_0_1;
    // AllocAckGrp.NoAllocs
    multiset<string> AllocAckGrp_NoAllocs_1;
    set_field(noAllocs_0_1, FIX::AllocAccount{"STRING_970455286"}, AllocAckGrp_NoAllocs_1);
    set_field(noAllocs_0_1, FIX::AllocAcctIDSource{1676827248}, AllocAckGrp_NoAllocs_1);
    set_field(noAllocs_0_1, FIX::AllocCustomerCapacity{"STRING_1544863087"}, AllocAckGrp_NoAllocs_1);
    set_field(noAllocs_0_1, FIX::AllocPositionEffect{'F'}, AllocAckGrp_NoAllocs_1);
    FIX::AllocPrice AllocPrice_4;
    AllocPrice_4.setString("8947156");
set_field(noAllocs_0_1, AllocPrice_4, AllocAckGrp_NoAllocs_1);
    FIX::AllocQty AllocQty_4;
    AllocQty_4.setString("17666018");
set_field(noAllocs_0_1, AllocQty_4, AllocAckGrp_NoAllocs_1);
    set_field(noAllocs_0_1, FIX::AllocText{"STRING_11773442"}, AllocAckGrp_NoAllocs_1);
    set_field(noAllocs_0_1, FIX::EncodedAllocText{"DATA_1966662296"}, AllocAckGrp_NoAllocs_1);
    set_field(noAllocs_0_1, FIX::EncodedAllocTextLen{378330499}, AllocAckGrp_NoAllocs_1);
    set_field(noAllocs_0_1, FIX::IndividualAllocID{"STRING_226790654"}, AllocAckGrp_NoAllocs_1);
    set_field(noAllocs_0_1, FIX::IndividualAllocRejCode{269054323}, AllocAckGrp_NoAllocs_1);
    set_field(noAllocs_0_1, FIX::IndividualAllocType{1}, AllocAckGrp_NoAllocs_1);
    set_field(noAllocs_0_1, FIX::SecondaryIndividualAllocID{"STRING_813491143"}, AllocAckGrp_NoAllocs_1);
    all_values.push_back(AllocAckGrp_NoAllocs_1);
    all_compo_names.insert("...NoAllocs");

    // NestedParties
    // Group NestedParties.NoNestedPartyIDs
    {
      FIX50SP2::AllocationInstructionAck::NoAllocs::NoNestedPartyIDs noNestedPartyIDs_1_1_0;
      // NestedParties.NoNestedPartyIDs
      multiset<string> NestedParties_NoNestedPartyIDs_10;
      set_field(noNestedPartyIDs_1_1_0, FIX::NestedPartyID{"STRING_90943674"}, NestedParties_NoNestedPartyIDs_10);
      set_field(noNestedPartyIDs_1_1_0, FIX::NestedPartyIDSource{'4'}, NestedParties_NoNestedPartyIDs_10);
      set_field(noNestedPartyIDs_1_1_0, FIX::NestedPartyRole{1288918186}, NestedParties_NoNestedPartyIDs_10);
      all_values.push_back(NestedParties_NoNestedPartyIDs_10);
      all_compo_names.insert("...NoAllocs...NoNestedPartyIDs");

      // NstdPtysSubGrp
      // Group NstdPtysSubGrp.NoNestedPartySubIDs
      {
        FIX50SP2::AllocationInstructionAck::NoAllocs::NoNestedPartyIDs::NoNestedPartySubIDs noNestedPartySubIDs_1_0_2_0;
        // NstdPtysSubGrp.NoNestedPartySubIDs
        multiset<string> NstdPtysSubGrp_NoNestedPartySubIDs_24;
        set_field(noNestedPartySubIDs_1_0_2_0, FIX::NestedPartySubID{"STRING_1718932703"}, NstdPtysSubGrp_NoNestedPartySubIDs_24);
        set_field(noNestedPartySubIDs_1_0_2_0, FIX::NestedPartySubIDType{1002205175}, NstdPtysSubGrp_NoNestedPartySubIDs_24);
        all_values.push_back(NstdPtysSubGrp_NoNestedPartySubIDs_24);
        all_compo_names.insert("...NoAllocs...NoNestedPartyIDs...NoNestedPartySubIDs");

        noNestedPartyIDs_1_1_0.addGroup(noNestedPartySubIDs_1_0_2_0);
      }
      noAllocs_0_1.addGroup(noNestedPartyIDs_1_1_0);
    }
    {
      FIX50SP2::AllocationInstructionAck::NoAllocs::NoNestedPartyIDs noNestedPartyIDs_1_1_1;
      // NestedParties.NoNestedPartyIDs
      multiset<string> NestedParties_NoNestedPartyIDs_11;
      set_field(noNestedPartyIDs_1_1_1, FIX::NestedPartyID{"STRING_673654135"}, NestedParties_NoNestedPartyIDs_11);
      set_field(noNestedPartyIDs_1_1_1, FIX::NestedPartyIDSource{'1'}, NestedParties_NoNestedPartyIDs_11);
      set_field(noNestedPartyIDs_1_1_1, FIX::NestedPartyRole{245089585}, NestedParties_NoNestedPartyIDs_11);
      all_values.push_back(NestedParties_NoNestedPartyIDs_11);
      all_compo_names.insert("...NoAllocs...NoNestedPartyIDs");

      // NstdPtysSubGrp
      // Group NstdPtysSubGrp.NoNestedPartySubIDs
      {
        FIX50SP2::AllocationInstructionAck::NoAllocs::NoNestedPartyIDs::NoNestedPartySubIDs noNestedPartySubIDs_1_1_2_0;
        // NstdPtysSubGrp.NoNestedPartySubIDs
        multiset<string> NstdPtysSubGrp_NoNestedPartySubIDs_25;
        set_field(noNestedPartySubIDs_1_1_2_0, FIX::NestedPartySubID{"STRING_1881966677"}, NstdPtysSubGrp_NoNestedPartySubIDs_25);
        set_field(noNestedPartySubIDs_1_1_2_0, FIX::NestedPartySubIDType{1059249631}, NstdPtysSubGrp_NoNestedPartySubIDs_25);
        all_values.push_back(NstdPtysSubGrp_NoNestedPartySubIDs_25);
        all_compo_names.insert("...NoAllocs...NoNestedPartyIDs...NoNestedPartySubIDs");

        noNestedPartyIDs_1_1_1.addGroup(noNestedPartySubIDs_1_1_2_0);
      }
      {
        FIX50SP2::AllocationInstructionAck::NoAllocs::NoNestedPartyIDs::NoNestedPartySubIDs noNestedPartySubIDs_1_1_2_1;
        // NstdPtysSubGrp.NoNestedPartySubIDs
        multiset<string> NstdPtysSubGrp_NoNestedPartySubIDs_26;
        set_field(noNestedPartySubIDs_1_1_2_1, FIX::NestedPartySubID{"STRING_693173466"}, NstdPtysSubGrp_NoNestedPartySubIDs_26);
        set_field(noNestedPartySubIDs_1_1_2_1, FIX::NestedPartySubIDType{2024399994}, NstdPtysSubGrp_NoNestedPartySubIDs_26);
        all_values.push_back(NstdPtysSubGrp_NoNestedPartySubIDs_26);
        all_compo_names.insert("...NoAllocs...NoNestedPartyIDs...NoNestedPartySubIDs");

        noNestedPartyIDs_1_1_1.addGroup(noNestedPartySubIDs_1_1_2_1);
      }
      noAllocs_0_1.addGroup(noNestedPartyIDs_1_1_1);
    }
    {
      FIX50SP2::AllocationInstructionAck::NoAllocs::NoNestedPartyIDs noNestedPartyIDs_1_1_2;
      // NestedParties.NoNestedPartyIDs
      multiset<string> NestedParties_NoNestedPartyIDs_12;
      set_field(noNestedPartyIDs_1_1_2, FIX::NestedPartyID{"STRING_1262998305"}, NestedParties_NoNestedPartyIDs_12);
      set_field(noNestedPartyIDs_1_1_2, FIX::NestedPartyIDSource{'3'}, NestedParties_NoNestedPartyIDs_12);
      set_field(noNestedPartyIDs_1_1_2, FIX::NestedPartyRole{2103387867}, NestedParties_NoNestedPartyIDs_12);
      all_values.push_back(NestedParties_NoNestedPartyIDs_12);
      all_compo_names.insert("...NoAllocs...NoNestedPartyIDs");

      // NstdPtysSubGrp
      // Group NstdPtysSubGrp.NoNestedPartySubIDs
      {
        FIX50SP2::AllocationInstructionAck::NoAllocs::NoNestedPartyIDs::NoNestedPartySubIDs noNestedPartySubIDs_1_2_2_0;
        // NstdPtysSubGrp.NoNestedPartySubIDs
        multiset<string> NstdPtysSubGrp_NoNestedPartySubIDs_27;
        set_field(noNestedPartySubIDs_1_2_2_0, FIX::NestedPartySubID{"STRING_2037116883"}, NstdPtysSubGrp_NoNestedPartySubIDs_27);
        set_field(noNestedPartySubIDs_1_2_2_0, FIX::NestedPartySubIDType{1500767307}, NstdPtysSubGrp_NoNestedPartySubIDs_27);
        all_values.push_back(NstdPtysSubGrp_NoNestedPartySubIDs_27);
        all_compo_names.insert("...NoAllocs...NoNestedPartyIDs...NoNestedPartySubIDs");

        noNestedPartyIDs_1_1_2.addGroup(noNestedPartySubIDs_1_2_2_0);
      }
      noAllocs_0_1.addGroup(noNestedPartyIDs_1_1_2);
    }
    msg.addGroup(noAllocs_0_1);
  }
  // Parties
  // Group Parties.NoPartyIDs
  {
    FIX50SP2::AllocationInstructionAck::NoPartyIDs noPartyIDs_0_0;
    // Parties.NoPartyIDs
    multiset<string> Parties_NoPartyIDs_5;
    set_field(noPartyIDs_0_0, FIX::PartyID{"STRING_784348847"}, Parties_NoPartyIDs_5);
    set_field(noPartyIDs_0_0, FIX::PartyIDSource{'3'}, Parties_NoPartyIDs_5);
    set_field(noPartyIDs_0_0, FIX::PartyRole{83}, Parties_NoPartyIDs_5);
    all_values.push_back(Parties_NoPartyIDs_5);
    all_compo_names.insert("...NoPartyIDs");

    // PtysSubGrp
    // Group PtysSubGrp.NoPartySubIDs
    {
      FIX50SP2::AllocationInstructionAck::NoPartyIDs::NoPartySubIDs noPartySubIDs_0_1_0;
      // PtysSubGrp.NoPartySubIDs
      multiset<string> PtysSubGrp_NoPartySubIDs_12;
      set_field(noPartySubIDs_0_1_0, FIX::PartySubID{"STRING_1498215986"}, PtysSubGrp_NoPartySubIDs_12);
      set_field(noPartySubIDs_0_1_0, FIX::PartySubIDType{1}, PtysSubGrp_NoPartySubIDs_12);
      all_values.push_back(PtysSubGrp_NoPartySubIDs_12);
      all_compo_names.insert("...NoPartyIDs...NoPartySubIDs");

      noPartyIDs_0_0.addGroup(noPartySubIDs_0_1_0);
    }
    {
      FIX50SP2::AllocationInstructionAck::NoPartyIDs::NoPartySubIDs noPartySubIDs_0_1_1;
      // PtysSubGrp.NoPartySubIDs
      multiset<string> PtysSubGrp_NoPartySubIDs_13;
      set_field(noPartySubIDs_0_1_1, FIX::PartySubID{"STRING_872581819"}, PtysSubGrp_NoPartySubIDs_13);
      set_field(noPartySubIDs_0_1_1, FIX::PartySubIDType{3}, PtysSubGrp_NoPartySubIDs_13);
      all_values.push_back(PtysSubGrp_NoPartySubIDs_13);
      all_compo_names.insert("...NoPartyIDs...NoPartySubIDs");

      noPartyIDs_0_0.addGroup(noPartySubIDs_0_1_1);
    }
    {
      FIX50SP2::AllocationInstructionAck::NoPartyIDs::NoPartySubIDs noPartySubIDs_0_1_2;
      // PtysSubGrp.NoPartySubIDs
      multiset<string> PtysSubGrp_NoPartySubIDs_14;
      set_field(noPartySubIDs_0_1_2, FIX::PartySubID{"STRING_1736856751"}, PtysSubGrp_NoPartySubIDs_14);
      set_field(noPartySubIDs_0_1_2, FIX::PartySubIDType{32}, PtysSubGrp_NoPartySubIDs_14);
      all_values.push_back(PtysSubGrp_NoPartySubIDs_14);
      all_compo_names.insert("...NoPartyIDs...NoPartySubIDs");

      noPartyIDs_0_0.addGroup(noPartySubIDs_0_1_2);
    }
    msg.addGroup(noPartyIDs_0_0);
  }
  {
    FIX50SP2::AllocationInstructionAck::NoPartyIDs noPartyIDs_0_1;
    // Parties.NoPartyIDs
    multiset<string> Parties_NoPartyIDs_6;
    set_field(noPartyIDs_0_1, FIX::PartyID{"STRING_790141803"}, Parties_NoPartyIDs_6);
    set_field(noPartyIDs_0_1, FIX::PartyIDSource{'2'}, Parties_NoPartyIDs_6);
    set_field(noPartyIDs_0_1, FIX::PartyRole{18}, Parties_NoPartyIDs_6);
    all_values.push_back(Parties_NoPartyIDs_6);
    all_compo_names.insert("...NoPartyIDs");

    // PtysSubGrp
    // Group PtysSubGrp.NoPartySubIDs
    {
      FIX50SP2::AllocationInstructionAck::NoPartyIDs::NoPartySubIDs noPartySubIDs_1_1_0;
      // PtysSubGrp.NoPartySubIDs
      multiset<string> PtysSubGrp_NoPartySubIDs_15;
      set_field(noPartySubIDs_1_1_0, FIX::PartySubID{"STRING_1755710256"}, PtysSubGrp_NoPartySubIDs_15);
      set_field(noPartySubIDs_1_1_0, FIX::PartySubIDType{19}, PtysSubGrp_NoPartySubIDs_15);
      all_values.push_back(PtysSubGrp_NoPartySubIDs_15);
      all_compo_names.insert("...NoPartyIDs...NoPartySubIDs");

      noPartyIDs_0_1.addGroup(noPartySubIDs_1_1_0);
    }
    {
      FIX50SP2::AllocationInstructionAck::NoPartyIDs::NoPartySubIDs noPartySubIDs_1_1_1;
      // PtysSubGrp.NoPartySubIDs
      multiset<string> PtysSubGrp_NoPartySubIDs_16;
      set_field(noPartySubIDs_1_1_1, FIX::PartySubID{"STRING_1350102044"}, PtysSubGrp_NoPartySubIDs_16);
      set_field(noPartySubIDs_1_1_1, FIX::PartySubIDType{27}, PtysSubGrp_NoPartySubIDs_16);
      all_values.push_back(PtysSubGrp_NoPartySubIDs_16);
      all_compo_names.insert("...NoPartyIDs...NoPartySubIDs");

      noPartyIDs_0_1.addGroup(noPartySubIDs_1_1_1);
    }
    msg.addGroup(noPartyIDs_0_1);
  }
  // header
  multiset<string> header_3;
  set_header_field(msg.getHeader(), FIX::ApplVerID{"STRING_2"}, header_3);
  set_header_field(msg.getHeader(), FIX::BeginString{"STRING_467518325"}, header_3);
  set_header_field(msg.getHeader(), FIX::BodyLength{904774562}, header_3);
  set_header_field(msg.getHeader(), FIX::CstmApplVerID{"STRING_1632930893"}, header_3);
  set_header_field(msg.getHeader(), FIX::DeliverToCompID{"STRING_1160691791"}, header_3);
  set_header_field(msg.getHeader(), FIX::DeliverToLocationID{"STRING_781690909"}, header_3);
  set_header_field(msg.getHeader(), FIX::DeliverToSubID{"STRING_748445551"}, header_3);
  set_header_field(msg.getHeader(), FIX::LastMsgSeqNumProcessed{1520981426}, header_3);
  set_header_field(msg.getHeader(), FIX::MessageEncoding{"STRING_ISO-2022-JP"}, header_3);
  set_header_field(msg.getHeader(), FIX::MsgSeqNum{834415495}, header_3);
  set_header_field(msg.getHeader(), FIX::OnBehalfOfCompID{"STRING_1410614662"}, header_3);
  set_header_field(msg.getHeader(), FIX::OnBehalfOfLocationID{"STRING_90878787"}, header_3);
  set_header_field(msg.getHeader(), FIX::OnBehalfOfSubID{"STRING_1519217006"}, header_3);
  set_header_field(msg.getHeader(), FIX::OrigSendingTime{FIX::UTCTIMESTAMP(10, 52, 36, 12, 5, 2001)}, header_3);
  set_header_field(msg.getHeader(), FIX::PossDupFlag{false}, header_3);
  set_header_field(msg.getHeader(), FIX::PossResend{false}, header_3);
  set_header_field(msg.getHeader(), FIX::SecureData{"DATA_1708541138"}, header_3);
  set_header_field(msg.getHeader(), FIX::SecureDataLen{2050836544}, header_3);
  set_header_field(msg.getHeader(), FIX::SenderCompID{"STRING_617824576"}, header_3);
  set_header_field(msg.getHeader(), FIX::SenderLocationID{"STRING_1034927640"}, header_3);
  set_header_field(msg.getHeader(), FIX::SenderSubID{"STRING_579800805"}, header_3);
  set_header_field(msg.getHeader(), FIX::SendingTime{FIX::UTCTIMESTAMP(21, 29, 37, 27, 3, 2014)}, header_3);
  set_header_field(msg.getHeader(), FIX::TargetCompID{"STRING_1422647825"}, header_3);
  set_header_field(msg.getHeader(), FIX::TargetLocationID{"STRING_1410629318"}, header_3);
  set_header_field(msg.getHeader(), FIX::TargetSubID{"STRING_935324541"}, header_3);
  set_header_field(msg.getHeader(), FIX::XmlData{"DATA_23609728"}, header_3);
  set_header_field(msg.getHeader(), FIX::XmlDataLen{784127096}, header_3);
  all_values.push_back(header_3);
  all_compo_names.insert(".header");

  xml_element elt;
  converter.fix2fixml(msg, elt);
  BOOST_LOG_TRIVIAL(debug) << "The resulting XML is";
  cout << "////////////////////////////////////////////" << endl;
  cout << elt.to_string() << endl;
  cout << "////////////////////////////////////////////" << endl << endl;

  BOOST_LOG_TRIVIAL(debug) << "Quickfix XML representation is";
  cout << "////////////////////////////////////////////" << endl;
  cout << msg.toXML() << endl;
  cout << "////////////////////////////////////////////" << endl << endl;
  list<multiset<string>> elt_lists;
  elt.to_list(elt_lists);
  EXPECT_EQ(elt_lists.size(), all_values.size());

  if (elt_lists.size() != all_values.size())  {
    multiset<string> elt_compo_name;
    elt.all_components(elt_compo_name);
    BOOST_LOG_TRIVIAL(debug) << "XML Elements are:";
    cout << "	[";
    copy(elt_compo_name.begin(), elt_compo_name.end(), ostream_iterator<string>(cout, " "));    cout << "]" << endl;

    BOOST_LOG_TRIVIAL(debug) << "FIX Components are:";
    cout << "	[";
    copy(all_compo_names.begin(), all_compo_names.end(), ostream_iterator<string>(cout, " "));    cout << "]" << endl;

  }
  BOOST_LOG_TRIVIAL(debug) << "All FIX components";
  for (const auto& l : all_values) {
    cout << "	[";
    copy(l.begin(), l.end(), ostream_iterator<string>(cout, " "));
    cout << "]" << endl;
  }
  BOOST_LOG_TRIVIAL(debug) << "All XML components";
  for (const auto& l : elt_lists) {
    cout << "	[";
    copy(l.begin(), l.end(), ostream_iterator<string>(cout, " "));
    cout << "]" << endl;

  }

  for (const auto& xml_l : elt_lists) {
    bool found = false;
    for (const auto& l : all_values) {
      if (includes(l.begin(), l.end(), xml_l.begin(), xml_l.end())) {
        found = true;
        break;
      } // end if includes
    } // end for all_values
    EXPECT_TRUE(found);
    if ( ! found) {
      BOOST_LOG_TRIVIAL(debug) << "[TO CHECK] This XML component was not found in FIX message";
      cout << "	 ---> [";
      copy(xml_l.begin(), xml_l.end(), ostream_iterator<string>(cout, " "));      cout << "]" << endl << endl;
    } // end if ! found
  } // end for elt_lists
}