This file is indexed.

/usr/include/crystalspace-2.0/csutil/nobjvec.h is in libcrystalspace-dev 2.0+dfsg-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
/*
    Crystal Space: Named Object Vector class
    Copyright (C) 1998,1999 by Andrew Zabolotny <bit@eltech.ru>

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public
    License along with this library; if not, write to the Free
    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#ifndef __CS_NOBJVEC_H__
#define __CS_NOBJVEC_H__

//-----------------------------------------------------------------------------
// Note *1*: The explicit "this->" is needed by modern compilers (such as gcc
// 3.4.x) which distinguish between dependent and non-dependent names in
// templates.  See: http://gcc.gnu.org/onlinedocs/gcc/Name-lookup.html
//-----------------------------------------------------------------------------

#include "csextern.h"
#include "csutil/refarr.h"
#include "csutil/weakrefarr.h"
#include "iutil/object.h"

/**\file 
 * Named Object Vector class
 */

/* Workaround for deprecation warnings caused by types used as the template 
 * parameter */
#include "csutil/deprecated_warn_off.h"

/**\addtogroup util_containers
 * @{ */

/**
 * This class implements a typed array that correctly keeps track
 * of reference count and also is able to find by name. Assumes
 * the types used for this implement QueryObject() to get the iObject
 * that has GetName().
 */
template <class T, 
          class Allocator = CS::Container::ArrayAllocDefault,
          class CapacityHandler = CS::Container::ArrayCapacityDefault>
class csRefArrayObject : public csRefArray<T, Allocator, CapacityHandler>
{
public:
  csRefArrayObject (int ilimit = 0,
    const CapacityHandler& ch = CapacityHandler())
  	: csRefArray<T, Allocator, CapacityHandler> (ilimit, ch)
  {
  }

  size_t GetIndexByName (const char* name) const
  {
    size_t i;
    for (i = 0 ; i < this->GetSize () ; i++) // see *1*
    {
      T* o = (*this)[i];
      const char* n = o->QueryObject ()->GetName ();
      if (n && !strcmp (n, name))
        return i;
    }
    return csArrayItemNotFound;
  }

  T* FindByName (const char* name) const
  {
    size_t i = GetIndexByName (name);
    if (i != csArrayItemNotFound)
      return (*this)[i];
    else
      return 0;
  }
};

/** @} */

/**
 * This class implements a typed array that does not keep track
 * of reference count and is able to find by name. Assumes
 * the types used for this implement QueryObject() to get the iObject
 * that has GetName().
 */
template <class T>
class csWeakRefArrayObject : public csWeakRefArray<T>
{
public:
  csWeakRefArrayObject (int ilimit = 0, int ithreshold = 0)
  	: csWeakRefArray<T> (ilimit, ithreshold)
  {
  }

  size_t GetIndexByName (const char* name) const
  {
    size_t i;
    for (i = 0 ; i < this->GetSize () ; i++) // see *1*
    {
      T* o = (*this)[i];
      const char* n = o->QueryObject ()->GetName ();
      if (n && !strcmp (n, name))
        return i;
    }
    return csArrayItemNotFound;
  }

  T* FindByName (const char* name) const
  {
    size_t i = GetIndexByName (name);
    if (i != csArrayItemNotFound)
      return (*this)[i];
    else
      return 0;
  }
};

/** @} */

#include "csutil/deprecated_warn_on.h"

#endif // __CS_NOBJVEC_H__