PolyBoRi
|
00001 // -*- c++ -*- 00002 //***************************************************************************** 00014 //***************************************************************************** 00015 00016 // get std::vector functionality 00017 #include <vector> 00018 00019 // get std::iterator functionality 00020 #include <iterator> 00021 00022 // include basic definitions 00023 #include "pbori_defs.h" 00024 00025 // get functionals and algorithms 00026 #include "pbori_func.h" 00027 #include "pbori_algo.h" 00028 00029 #include "CStringLiteral.h" 00030 #include "CPrintOperation.h" 00031 00032 #include "CIdxVariable.h" 00033 00034 #ifndef CIdxPath_h_ 00035 #define CIdxPath_h_ 00036 00041 BEGIN_NAMESPACE_PBORI 00042 00043 template <class IdxType = CIdxVariable<CTypes::idx_type>, 00044 class SeparatorType = CStringLiteral<CLiteralCodes::list_separator> > 00045 class CIdxPath: 00046 public std::vector<IdxType> { 00047 00048 public: 00050 00051 typedef IdxType idx_type; 00052 typedef CTypes::ostream_type ostream_type; 00054 00056 typedef std::vector<idx_type> base; 00057 00059 typedef SeparatorType separator_type; 00060 00062 // typedef typename separator_type::result_type sep_value_type ; 00063 00065 typedef CIdxPath<idx_type, separator_type> self; 00066 00068 typedef typename base::size_type size_type; 00069 00071 CIdxPath(): base() {} 00072 00074 CIdxPath(size_type nlen): base(nlen) {}; 00075 00077 CIdxPath(const self& rhs): base(rhs) {}; 00078 00080 ~CIdxPath() {}; 00081 00083 ostream_type& print(ostream_type& os) const { 00084 00085 if (base::begin() == base::end()) { 00086 os << 1; 00087 } 00088 00089 special_first_transform( base::begin(), base::end(), 00090 std::ostream_iterator<idx_type>(os), 00091 CPrintOperation<idx_type, separator_type>(os), 00092 project_ith<1>() ); 00093 00094 return os; 00095 } 00096 00097 }; 00098 00100 template <class IdxType, class SeparatorType> 00101 inline typename CIdxPath<IdxType, SeparatorType>::ostream_type& 00102 operator<<(typename CIdxPath<IdxType, SeparatorType>::ostream_type& os, 00103 const CIdxPath<IdxType, SeparatorType>& storage){ 00104 00105 return storage.print(os); 00106 } 00107 00108 END_NAMESPACE_PBORI 00109 00110 #endif