~thopiekar/zypper/libzypp-manual-import

« back to all changes in this revision

Viewing changes to zypp/Capabilities.cc

  • Committer: Thomas-Karl Pietrowski
  • Date: 2014-01-29 22:44:28 UTC
  • Revision ID: thopiekar@googlemail.com-20140129224428-gpcqnsdakby362n8
firstĀ import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*---------------------------------------------------------------------\
 
2
|                          ____ _   __ __ ___                          |
 
3
|                         |__  / \ / / . \ . \                         |
 
4
|                           / / \ V /|  _/  _/                         |
 
5
|                          / /__ | | | | | |                           |
 
6
|                         /_____||_| |_| |_|                           |
 
7
|                                                                      |
 
8
\---------------------------------------------------------------------*/
 
9
/** \file       zypp/sat/Capabilities.cc
 
10
 *
 
11
*/
 
12
#include <iostream>
 
13
#include "zypp/base/LogTools.h"
 
14
 
 
15
#include "zypp/Capabilities.h"
 
16
 
 
17
using std::endl;
 
18
 
 
19
///////////////////////////////////////////////////////////////////
 
20
namespace zypp
 
21
{ /////////////////////////////////////////////////////////////////
 
22
 
 
23
  Capabilities:: Capabilities( const sat::detail::IdType * base_r, sat::detail::IdType skip_r )
 
24
  : _begin( base_r )
 
25
  {
 
26
    if ( ! _begin )
 
27
      return;
 
28
 
 
29
    if ( skip_r )
 
30
    {
 
31
      for ( const sat::detail::IdType * end = _begin; *end; ++end )
 
32
      {
 
33
        if ( *end == skip_r )
 
34
        {
 
35
          _begin = end+1;
 
36
          return;
 
37
        }
 
38
      }
 
39
    }
 
40
    // skipp all ==> empty
 
41
    _begin = 0;
 
42
  }
 
43
 
 
44
 
 
45
  Capabilities::size_type Capabilities::size() const
 
46
  {
 
47
    if ( ! _begin )
 
48
      return 0;
 
49
 
 
50
    // jump over libsolvs internal ids.
 
51
    Capabilities::size_type ret = 0;
 
52
    for ( const sat::detail::IdType * end = _begin; *end; ++end )
 
53
    {
 
54
      if ( ! sat::detail::isDepMarkerId( *end ) )
 
55
        ++ret;
 
56
    }
 
57
    return ret;
 
58
  }
 
59
 
 
60
  /******************************************************************
 
61
  **
 
62
  **    FUNCTION NAME : operator<<
 
63
  **    FUNCTION TYPE : std::ostream &
 
64
  */
 
65
  std::ostream & operator<<( std::ostream & str, const Capabilities & obj )
 
66
  {
 
67
    return dumpRange( str << "(" << obj.size() << ")", obj.begin(), obj.end() );
 
68
  }
 
69
 
 
70
  /////////////////////////////////////////////////////////////////
 
71
} // namespace zypp
 
72
///////////////////////////////////////////////////////////////////