device.hpp 881 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /*
  2. Copyright 2010 Intel Corporation
  3. Use, modification and distribution are subject to the Boost Software License,
  4. Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  5. http://www.boost.org/LICENSE_1_0.txt).
  6. */
  7. //device.hpp
  8. #ifndef BOOST_POLYGON_TUTORIAL_DEVICE_HPP
  9. #define BOOST_POLYGON_TUTORIAL_DEVICE_HPP
  10. #include <string>
  11. #include <vector>
  12. #include <iostream>
  13. struct device {
  14. std::string type;
  15. std::vector<std::string> terminals;
  16. };
  17. inline std::ostream& operator << (std::ostream& o, const device& r)
  18. {
  19. o << r.type << " ";
  20. for(std::size_t i = 0; i < r.terminals.size(); ++i) {
  21. o << r.terminals[i] << " ";
  22. }
  23. return o;
  24. }
  25. inline std::istream& operator >> (std::istream& i, device& r)
  26. {
  27. i >> r.type;
  28. r.terminals = std::vector<std::string>(3, std::string());
  29. i >> r.terminals[0] >> r.terminals[1] >> r.terminals[2];
  30. return i;
  31. }
  32. #endif