PolyBoRi
CIdxPath.h
Go to the documentation of this file.
1 // -*- c++ -*-
2 //*****************************************************************************
40 //*****************************************************************************
41 
42 // get std::vector functionality
43 #include <vector>
44 
45 // get std::iterator functionality
46 #include <iterator>
47 
48 // include basic definitions
49 #include "pbori_defs.h"
50 
51 // get functionals and algorithms
52 #include "pbori_func.h"
53 #include "pbori_algo.h"
54 
55 #include "CStringLiteral.h"
56 #include "CPrintOperation.h"
57 
58 #include "CIdxVariable.h"
59 
60 #ifndef CIdxPath_h_
61 #define CIdxPath_h_
62 
68 
69 template <class IdxType = CIdxVariable<CTypes::idx_type>,
70  class SeparatorType = CStringLiteral<CLiteralCodes::list_separator> >
71 class CIdxPath:
72  public std::vector<IdxType> {
73 
74 public:
76 
77  typedef IdxType idx_type;
80 
82  typedef std::vector<idx_type> base;
83 
85  typedef SeparatorType separator_type;
86 
88  // typedef typename separator_type::result_type sep_value_type ;
89 
92 
94  typedef typename base::size_type size_type;
95 
97  CIdxPath(): base() {}
98 
100  CIdxPath(size_type nlen): base(nlen) {};
101 
103  CIdxPath(const self& rhs): base(rhs) {};
104 
106  ~CIdxPath() {};
107 
110 
111  if (base::begin() == base::end()) {
112  os << 1;
113  }
114 
115  special_first_transform( base::begin(), base::end(),
116  std::ostream_iterator<idx_type>(os),
118  project_ith<1>() );
119 
120  return os;
121  }
122 
123 };
124 
126 template <class IdxType, class SeparatorType>
128 operator<<(typename CIdxPath<IdxType, SeparatorType>::ostream_type& os,
129  const CIdxPath<IdxType, SeparatorType>& storage){
130 
131  return storage.print(os);
132 }
133 
135 
136 #endif