libzypp  15.3.0
Map.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
11 #ifndef ZYPP_SAT_MAP_H
12 #define ZYPP_SAT_MAP_H
13 
14 extern "C"
15 {
16  struct _Map;
17 }
18 #include <iosfwd>
19 #include <string>
20 
21 #include "zypp/base/PtrTypes.h"
22 
24 namespace zypp
25 {
27  namespace sat
28  {
36  class Map
37  {
38  public:
39  typedef unsigned long size_type;
40 
42  struct PoolSizeType {};
44  static constexpr PoolSizeType poolSize = PoolSizeType();
45 
46  public:
48  Map();
49 
51  explicit Map( size_type size_r );
52 
54  Map( PoolSizeType );
55 
57  ~Map();
58 
59  public:
61  bool empty() const;
62 
64  size_type size() const;
65 
67  void grow( size_type size_r );
68 
69  public:
71  void setAll();
72 
74  void clearAll();
75 
77  void assignAll( bool val_r );
78 
82  void set( size_type idx_r );
83 
87  void clear( size_type idx_r );
88 
92  void assign( size_type idx_r, bool val_r );
93 
94  public:
98  bool test( size_type idx_r ) const;
99 
103  bool operator[]( size_type idx_r ) const
104  { return test( idx_r ); }
105 
106  public:
108  std::string asString( const char on_r = '1', const char off_r = '0' ) const;
109 
110  public:
111  operator struct ::_Map *();
112  operator const struct ::_Map *() const
113  { return _pimpl.get(); }
114  private:
116  };
117 
119  inline std::ostream & operator<<( std::ostream & str, const Map & obj )
120  { return str << obj.asString(); }
121 
123  bool operator==( const Map & lhs, const Map & rhs );
124 
126  inline bool operator!=( const Map & lhs, const Map & rhs )
127  { return !( lhs == rhs ); }
128 
129  } // namespace sat
131 
133  template<> struct ::_Map * rwcowClone<struct ::_Map>( const struct ::_Map * rhs );
134 
135  typedef sat::Map Bitmap;
136 
137 } // namespace zypp
139 #endif // ZYPP_SAT_MAP_H
Type to indicate the bitmap should match the current pools capacity.
Definition: Map.h:42
RWCOW_pointer< struct::_Map > _pimpl
Pointer to implementation.
Definition: Map.h:115
void clear(size_type idx_r)
Clear bit idx_r.
Definition: Map.cc:85
bool operator!=(const Map &lhs, const Map &rhs)
Definition: Map.h:126
size_type size() const
Size of the Map.
Definition: Map.cc:59
bool operator==(const Map &lhs, const Map &rhs)
Definition: Map.cc:123
std::ostream & operator<<(std::ostream &str, const Map &obj)
Definition: Map.h:119
void set(size_type idx_r)
Set bit idx_r.
Definition: Map.cc:79
String related utilities and Regular expression matching.
bool test(size_type idx_r) const
Test bit idx_r.
Definition: Map.cc:100
bool operator[](size_type idx_r) const
Test bit idx_r.
Definition: Map.h:103
Map()
Default ctor: empty Map.
Definition: Map.cc:41
const _D * get() const
Definition: PtrTypes.h:503
void clearAll()
Clear all bits.
Definition: Map.cc:68
sat::Map Bitmap
Definition: Bitmap.h:19
~Map()
Dtor.
Definition: Map.cc:53
void setAll()
Set all bits.
Definition: Map.cc:65
unsigned long size_type
Definition: Map.h:39
static constexpr PoolSizeType poolSize
An object indicating the bitmap should match the current pools capacity.
Definition: Map.h:44
void assign(size_type idx_r, bool val_r)
Assign val_r to bit idx_r.
Definition: Map.cc:91
std::string asString(const char on_r= '1', const char off_r= '0') const
String representation.
Definition: Map.cc:106
void grow(size_type size_r)
Grow the Map if necessary.
Definition: Map.cc:62
bool empty() const
Whether Map is empty.
Definition: Map.cc:56
Libsolv (bit)Map wrapper.
Definition: Map.h:36
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
void assignAll(bool val_r)
Assign val_r to all bits.
Definition: Map.cc:71