print_container.hpp 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // (C) Copyright Ion Gaztanaga 2004-2012. Distributed under the Boost
  4. // Software License, Version 1.0. (See accompanying file
  5. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. //
  7. // See http://www.boost.org/libs/interprocess for documentation.
  8. //
  9. //////////////////////////////////////////////////////////////////////////////
  10. #ifndef BOOST_INTERPROCESS_TEST_PRINTCONTAINER_HPP
  11. #define BOOST_INTERPROCESS_TEST_PRINTCONTAINER_HPP
  12. #include <boost/interprocess/detail/config_begin.hpp>
  13. #include <iostream>
  14. namespace boost{
  15. namespace interprocess{
  16. namespace test{
  17. template<class Container>
  18. void PrintContents(const Container &cont, const char *contName)
  19. {
  20. std::cout<< "Printing contents of " << contName << std::endl;
  21. typename Container::iterator b(cont.begin()), e(cont.end());
  22. for(; b != e; ++b){
  23. std::cout << *b << " ";
  24. }
  25. std::cout<< std::endl << std::endl;
  26. }
  27. //Function to dump data
  28. template<class MyShmCont, class MyStdCont>
  29. void PrintContainers(MyShmCont *shmcont, MyStdCont *stdcont)
  30. {
  31. typename MyShmCont::iterator itshm = shmcont->begin(), itshmend = shmcont->end();
  32. typename MyStdCont::iterator itstd = stdcont->begin(), itstdend = stdcont->end();
  33. std::cout << "MyShmCont" << std::endl;
  34. for(; itshm != itshmend; ++itshm){
  35. std::cout << *itshm << std::endl;
  36. }
  37. std::cout << "MyStdCont" << std::endl;
  38. for(; itstd != itstdend; ++itstd){
  39. std::cout << *itstd << std::endl;
  40. }
  41. }
  42. } //namespace test{
  43. } //namespace interprocess{
  44. } //namespace boost{
  45. #include <boost/interprocess/detail/config_end.hpp>
  46. #endif //#ifndef BOOST_INTERPROCESS_TEST_PRINTCONTAINER_HPP