This file is indexed.

/usr/include/x86_64-linux-gnu/zypp/UserData.h is in libzypp-dev 15.3.0-1build1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
/*---------------------------------------------------------------------\
|                          ____ _   __ __ ___                          |
|                         |__  / \ / / . \ . \                         |
|                           / / \ V /|  _/  _/                         |
|                          / /__ | | | | | |                           |
|                         /_____||_| |_| |_|                           |
|                                                                      |
\---------------------------------------------------------------------*/
/** \file	zypp/UserData.h
 */
#ifndef ZYPP_USERDATA_H
#define ZYPP_USERDATA_H

#include <iosfwd>
#include <string>
#include <map>
#include <boost/any.hpp>

#include "zypp/base/PtrTypes.h"
#include "zypp/ContentType.h"

///////////////////////////////////////////////////////////////////
namespace zypp
{
  ///////////////////////////////////////////////////////////////////
  namespace callback
  {
    ///////////////////////////////////////////////////////////////////
    /// \class UserData
    /// \brief Typesafe passing of user data via callbacks
    ///
    /// Basically a <tt>std::map<std::string,boost::any></tt> plus
    /// associated \ref ContentType.
    ///
    /// Constness protects non-empty values from being modified.
    /// It is possible to overwrite empty values or to add new ones.
    ///////////////////////////////////////////////////////////////////
    class UserData
    {
      typedef std::map<std::string,boost::any> DataType;
      typedef DataType::size_type size_type;
      typedef DataType::key_type key_type;
      typedef DataType::value_type value_type;
      typedef DataType::const_iterator const_iterator;
    public:
      /** Default ctor. */
      UserData()
      {}

      /** Ctor taking ContentType. */
      explicit UserData( ContentType type_r )
      : _type( std::move(type_r) )
      {}
      /** Ctor taking ContentType. */
      explicit UserData( std::string type_r )
      : UserData( ContentType( std::move(type_r) ) )
      {}
      /** Ctor taking ContentType. */
      UserData( std::string type_r, std::string subtype_r )
      : UserData( ContentType( std::move(type_r), std::move(subtype_r) ) )
      {}

    public:
      /** Get type. */
      const ContentType & type() const
      { return _type; }

      /** Set type. */
      void type( ContentType type_r )
      { _type = std::move(type_r); }

    public:
       /**  Validate object in a boolean context: has data */
      explicit operator bool() const
      { return !empty(); }

      /** Whether \ref data is empty. */
      bool empty() const
      { return !_dataP || _dataP->empty(); }

      /** Size of \ref data. */
      size_type size() const
      { return _dataP ? _dataP->size() : 0;  }

      /** The \ref data. */
      const DataType & data() const
      { return dataRef(); }

      /** Whether \a key_r is in \ref data. */
      bool haskey( const std::string & key_r ) const
      { return _dataP && _dataP->find( key_r ) != _dataP->end(); }

      /** Whether \a key_r is in \ref data and value is not empty. */
      bool hasvalue( const std::string & key_r ) const
      {
	bool ret = false;
	if ( _dataP )
	{
	  const_iterator it = _dataP->find( key_r );
	  if ( it != _dataP->end() && ! it->second.empty() )
	  {
	    ret = true;
	  }
	}
	return ret;
      }

      /** Set the value for key (nonconst version always returns true).
       * Const version is allowed to set empty values or to add new ones only.
       */
      bool set( const std::string & key_r, boost::any val_r )
      { dataRef()[key_r] = std::move(val_r); return true; }
      /** \overload const version */
      bool set( const std::string & key_r, boost::any val_r ) const
      {
	bool ret = false;
	boost::any & val( dataRef()[key_r] );
	if ( val.empty() )
	{
	  val = std::move(val_r);
	  ret = true;
	}
	return ret;
      }

      /** Set an empty value for \a key_r (if possible). */
      bool reset( const std::string & key_r )
      { return set( key_r, boost::any() ); }
      /** \overload const version */
      bool reset( const std::string & key_r ) const
      { return set( key_r, boost::any() ); }

      /** Remove key from data.*/
      void erase( const std::string & key_r )
      { if ( _dataP ) _dataP->erase( key_r ); }

      /** Return the keys boost::any value or an empty value if key does not exist. */
      const boost::any & getvalue( const std::string & key_r ) const
      {
	if ( _dataP )
	{
	  const_iterator it = _dataP->find( key_r );
	  if ( it != _dataP->end() )
	  {
	    return it->second;
	  }
	}
	static const boost::any none;
	return none;
      }

      /** Pass back a <tt>const Tp &</tt> reference to \a key_r value.
       * \throws boost::bad_any_cast if key is not set or value is not of appropriate type
       * \code
       *   UserData data;
       *   std::string value( "defaultvalue" );
       *   try
       *   {
       *     value = data.get<std::string>( "mykey" );
       *   }
       *   catch ( const boost::bad_any_cast & )
       *   {
       *     // no "mykey" or not a std::sting
       *   }
       * \endcode
       */
      template <class Tp>
      const Tp & get( const std::string & key_r ) const
      { return boost::any_cast<const Tp &>( getvalue( key_r ) ); }

      /** Pass back a \a Tp copy of \a key_r value.
       * \throws boost::bad_any_cast if key is not set or value is not of appropriate type
       * \code
       *   UserData data;
       *   std::string value = data.get<std::string>( "mykey", "defaultvalue" );
       * \endcode
       */
      template <class Tp>
      Tp get( const std::string & key_r, const Tp & default_r ) const
      { Tp ret( default_r ); get( key_r, ret ); return ret; }

      /** If the value for \a key_r is of the same type as \a ret_r, pass it back in \a ret_r and return \c true;.
       * \code
       *   UserData data;
       *   std::string value( "defaultvalue" );
       *   if ( ! data.get<std::string>( "mykey", value )
       *   {
       *      // no "mykey" or not a std::sting
       *   }
       * \endcode
       */
      template <class Tp>
      bool get( const std::string & key_r, Tp & ret_r ) const
      {
	bool ret = false;
	if ( _dataP )
	{
	  const_iterator it = _dataP->find( key_r );
	  if ( it != _dataP->end() )
	  {
	    auto ptr = boost::any_cast<const Tp>(&it->second);
	    if ( ptr )
	    {
	      ret_r = *ptr;
	      ret = true;
	    }
	  }
	}
	return ret;
      }

    private:
      DataType & dataRef() const
      { if ( ! _dataP ) _dataP.reset( new DataType ); return *_dataP; }

    private:
      ContentType _type;
      mutable shared_ptr<DataType> _dataP;
    };

    /** \relates UserData Stream output */
    inline std::ostream & operator<<( std::ostream & str, const UserData & obj )
    { return str << "UserData(" << obj.type() << ":" << obj.size() << ")";}

  } // namespace callback
  ///////////////////////////////////////////////////////////////////
} // namespace zypp
///////////////////////////////////////////////////////////////////
#endif // ZYPP_USERDATA_H