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