libzypp  10.5.0
Capabilities.cc
Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                          ____ _   __ __ ___                          |
00003 |                         |__  / \ / / . \ . \                         |
00004 |                           / / \ V /|  _/  _/                         |
00005 |                          / /__ | | | | | |                           |
00006 |                         /_____||_| |_| |_|                           |
00007 |                                                                      |
00008 \---------------------------------------------------------------------*/
00012 #include <iostream>
00013 #include "zypp/base/LogTools.h"
00014 
00015 #include "zypp/Capabilities.h"
00016 
00017 using std::endl;
00018 
00020 namespace zypp
00021 { 
00022 
00023   Capabilities:: Capabilities( const sat::detail::IdType * base_r, sat::detail::IdType skip_r )
00024   : _begin( base_r )
00025   {
00026     if ( ! _begin )
00027       return;
00028 
00029     if ( skip_r )
00030     {
00031       for ( const sat::detail::IdType * end = _begin; *end; ++end )
00032       {
00033         if ( *end == skip_r )
00034         {
00035           _begin = end+1;
00036           return;
00037         }
00038       }
00039     }
00040     // skipp all ==> empty
00041     _begin = 0;
00042   }
00043 
00044 
00045   Capabilities::size_type Capabilities::size() const
00046   {
00047     if ( ! _begin )
00048       return 0;
00049 
00050     // jump over libsolvs internal ids.
00051     Capabilities::size_type ret = 0;
00052     for ( const sat::detail::IdType * end = _begin; *end; ++end )
00053     {
00054       if ( ! sat::detail::isDepMarkerId( *end ) )
00055         ++ret;
00056     }
00057     return ret;
00058   }
00059 
00060   /******************************************************************
00061   **
00062   **    FUNCTION NAME : operator<<
00063   **    FUNCTION TYPE : std::ostream &
00064   */
00065   std::ostream & operator<<( std::ostream & str, const Capabilities & obj )
00066   {
00067     return dumpRange( str << "(" << obj.size() << ")", obj.begin(), obj.end() );
00068   }
00069 
00071 } // namespace zypp