This file is indexed.

/usr/include/CLAM/Flags.hxx is in libclam-dev 1.4.0-6.

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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
/*
 * Copyright (c) 2001-2004 MUSIC TECHNOLOGY GROUP (MTG)
 *                         UNIVERSITAT POMPEU FABRA
 *
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */

#ifndef _Flags_hxx_
#define _Flags_hxx_

#include <bitset>
#include <string>
#include <iosfwd>
#include "Component.hxx"
// TODO: This is provisional to share the IllegalValue exception
#include "Enum.hxx"

namespace CLAM {


/**
* Abstract class from which any Flag<N> instantiation is derived.
* It provides some clever pure virtual functions and shared
* implementations for the symbol managing.
*/
class FlagsBase : public Component {
// Internal Types
public:
	/** The type of the positional indexes */
	typedef unsigned int tValue;
	/** The type of the name table rows */
	typedef struct {tValue value; const char*name;} tFlagValue;

// Attributes
protected:
	/**
	* A pointer to the user specific flag class table of
	* value-symbol pairs for the flag.
	*/
	const tFlagValue * mFlagValues;

// Operations
public:
	/**
	 * @returns the number of flags contained
	 */
	virtual unsigned int GetNFlags() const=0;
	virtual void SetFlag(unsigned int whichOne, bool value)=0;
	virtual bool IsSetFlag(unsigned int whichOne) const =0;
	/**
	* Retrieves the name of the flag at a position
	* @param whichOne The position of the selected flag
	* @returns The symbolic name of the selected flag as stream
	*/
	std::string GetFlagString(unsigned int whichOne) const throw (IllegalValue);

	/**
	* Retrieves the position of the named flag
	* @param whichOne The string containing the simbolic name
	* @returns The symbolic name of the selected flag as stream
	*/
	unsigned int GetFlagPosition(const std::string & whichOne) const throw (IllegalValue);

	/*
	 * Stores component's subitems on the given Storage
	 * @param store The given storage where the subitem will be stored
	 * @see Storage
	 * @todo TODO: This method can throw and IllegalValue exception
	 */
	virtual void StoreOn (Storage & storage) const;

	/*
	 * Loads component's subitems from the given Storage
	 * @param store The given storage where the subitem will be stored
	 * @see Storage
	 * @todo TODO: This method can throw and IllegalValue exception
	 */
	virtual void LoadFrom (Storage & storage);

// Debug
public:
	/**
	* Checks that the object is internally consistent.
	* It tests that: 
	* - the names array is not a NULL pointer (it still could be invalid)
	* - the names array is shorter than the number of flags plus one for the NULL name
	* - a NULL name is present at the end of the names array
	* - the names array has no value replication
	* - the names array has no name replication
	* @todo TODO: Check blanks in names
	*/
	inline bool CheckInvariant();
};

std::istream & operator >> (std::istream & is, FlagsBase & f);
std::ostream & operator << (std::ostream & os, const FlagsBase & f);

/**
* Instances of this class represents objects containing a set
* of booleans values (flags) that can be accessed by their
* symbolic name.
* 
* Because Flags derives from std::bitset<N> it provides all the
* standard operations like bitwise operators and so.
* This interface has been fattened to provide symbolic
* representation (name string) for each flag.
* If symbolic names for flags are not useful to you, consider
* use std::bitset instead which has a pure positional approach.
* 
* - Bitwise operators
* - Several ways to access to individual flags
* - Formated input and output to an std::stream as symbols
* with the insertion (&lt;&lt;) and extraction (&gt;&gt;)
* operators
* - Implements the Component interface: StoreOn, DeepCopy,
* ShallowCopy...
* - Runtime symbolic representation
* - Runtime checking of the values
*
* @section ind Accessing individual flags
* 
* You can acces an individual flag of the Flags object in
* different ways:
* <table border='0'>
* <tr><td>Access by name:</td>	<td>flags.bFlagName</td></tr>
* <tr><td>Access by indexation plus enums:</td>	<td>flags[MyFlagsClass::eFlagName]</td></tr>
* <tr><td>Access by symbol:</td>	<td>flags["FlagName"]</td></tr>
* </table>
*
* You can use references this individual flags like any reference to a boolean.
* Moreover, you can use some extra operations like <tt>flip</tt> that inverses
* the actual value of the flag:
* @code
* 	bool isTrue= flags.bFlagName;
* 	bool isFalse= ~(flags.bFlagName);
* 	flags.bFlagName=true;
* 	flags.bFlagName.flip();
* @endcode
* @section FlagsBitwise Bitwise operations
* @section FlagsNonStandard Non Standard operations
*
* Because older versions of this class didn't derive from bitfield,
* a different interface for a few functions was used. This old interface
* has the advantage that uses the same function name convention as the
* rest of the CLAM classes.
* <table>
* <tr><td>CLAMFlags</td><td>mtg::Flags</td><td>Comments</td></tr>
* <tr><td>Size</td><td>size</td><td>Returns the number of flags</td></tr>
* <tr><td>NSet</td><td>count</td><td>Counts the set flags</td></tr>
* <tr><td>Reset</td><td>reset</td><td></td>Sets to 0 all the flags</tr>
* <tr><td>NFlags</td><td>not present</td><td>Revise This!!!!</td></tr>
* <tr><td>operator int</td><td>operator int</td><td>The interface is unchanged but throws a </td></tr>
* </table>
* @section CustomFlags Creating your own flags
* The way to define a new Flags type is by subclassing
* <tt>Flags<N></tt>.
* The subclass MUST redefine its constructors by
* providing the Flags constructor an array of tFlagsValue's,
* which defines the mapping between numeric and symbolic
* values, and an initialization value, than can be both a
* symbol (char* or std::string) or an integer.
* 
* @code
	// MyFlags.hxx
	class MyFlags : public Flags<5> {
	// Construction/Destruction
	public:
		static tFlagValue sFlagValues[];
		static tValue sDefault;
		virtual Component * Species() const {
			return new MyFlags();
		}
		typedef enum {
			eFlag0=0,
			eFlag1=1,
			eFlag2=2,
			eFlag3=3,
			eFlag4=4
		} tFlag;
		MyFlags () :
			Flags<5>(sFlagValues),
			flag0(operator[](eFlag0)),
			flag1(operator[](eFlag1)),
			flag2(operator[](eFlag2)),
			flag3(operator[](eFlag3)),
			flag4(operator[](eFlag4))
		{
			// The default flag configuration is set here
			flag4=true;
		};
		MyFlags (const MyFlags& someFlags) :
			Flags<5>(sFlagValues,someFlags),
			flag0(operator[](eFlag0)),
			flag1(operator[](eFlag1)),
			flag2(operator[](eFlag2)),
			flag3(operator[](eFlag3)),
			flag4(operator[](eFlag4))
		{};
		template <class T>
		MyFlags(const T &t) :
			Flags<5>(sFlagValues,t),
			flag0(operator[](eFlag0)),
			flag1(operator[](eFlag1)),
			flag2(operator[](eFlag2)),
			flag3(operator[](eFlag3)),
			flag4(operator[](eFlag4))
		{};
		template <class T1, class T2>
		MyFlags(const T1 &t1, const T2 &t2) :
			Flags<5>(sFlagValues,t1,t2),
			flag0(operator[](eFlag0)),
			flag1(operator[](eFlag1)),
			flag2(operator[](eFlag2)),
			flag3(operator[](eFlag3)),
			flag4(operator[](eFlag4))
		{}
		reference flag0;
		reference flag1;
		reference flag2;
		reference flag3;
		reference flag4;
	};
@endcode

@code
	// MyFlags.cxx
	Flags<5>::tFlagValue MyFlags::sFlagValues[] = {
		{MyFlags::eFlag0, "flag0"},
		{MyFlags::eFlag1, "flag1"},
		{MyFlags::eFlag2, "flag2"},
		{MyFlags::eFlag3, "flag3"},
		{MyFlags::eFlag4, "flag4"},
		{0,NULL}
	};
@endcode
*/
template <unsigned int N> class Flags : public FlagsBase, public std::bitset<N>
{
// Construction/Destruction
protected:
	/** The default constructor */
	Flags(tFlagValue * names) : std::bitset<N>() {
		mFlagValues=names;
	};
	/**
	* The derived copy constructor will use this
	*/
	Flags(tFlagValue * names, const Flags<N> &t) : std::bitset<N>() {
		mFlagValues=names;
	};
	/**
	* A lazy way to redefine all unary constructors in bitset 
	* by forwarding it.
	* @see std::bitset To obtain the complete set of available 
	* constructors.
	*/
	template <class T> Flags(tFlagValue * names,const T &t) : std::bitset<N>(t) {
		mFlagValues=names;
	};
	/** 
	* A template binary constructor that fordwards to the
	* matching std::bitset<PRE>&lt;N&gt;</PRE> constructor
	* A lazy way to redefine all binary constructors in bitset 
	* by forwarding it.
	* @see std::bitset To obtain the complete set of available 
	* constructors.
	*/
	template <class T1, class T2> Flags(tFlagValue * names,const T1 &t1,const T2 &t2) : 
		std::bitset<N>(t1, t2)
	{
		mFlagValues=names;
	};
public:
	/** The required virtual destructor */
	virtual ~Flags ()  {};

	/** @todo GetClassName for Flags */
	const char * GetClassName() const {return NULL;}

// Operators
public:
	virtual unsigned int GetNFlags () const {
		return N;
	}
protected:
	virtual bool IsSetFlag(unsigned int whichOne) const {
		return std::bitset<N>::test(whichOne);
	}
	virtual void SetFlag(unsigned int whichOne, bool value=true) {
		this->set(whichOne, value);
	}

// Component Protocol
public:
	/**
	 * Returns a new object of the same class than the receiver
	 * object. To be reimplemented by subclasses.
	 * @returns a new allocated component. The pointer belongs
	 * to the caller.
	 */
	virtual Component * Species () const = 0;

	virtual Component * DeepCopy () const {
		Flags<N> * pe = (Flags<N>*)Species();
		*pe=*this;
		return pe;
	}

	virtual Component * ShallowCopy () const {
		Flags<N> * pe = (Flags<N>*)Species();
		*pe=*this;
		return pe;
	}

};

//MRJ: Why this? There exists a fairly well known issue about
//VC6 support of template base classes, where polymorphism usual assumptions
//don't hold. In this case we introduce two proxy methods that
//just "inform" the compiler about what it has to do next... to promote
//the references to the derived class object into references to the
//base class. Sad but true. In discharge of MS guys this seems to be no
//longer needed in VC++ 7.1. We could have implemented the body of the methods
//inline on the header, but would have prevented us from using the compile-time
//saving usage of the <iosfwd> header.

#ifdef _MSC_VER
template <unsigned int N>
std::istream & operator >> (std::istream & is, Flags<N> & f) {
	return (is >>  static_cast<FlagsBase&>(f) );
}

template <unsigned int N>
std::ostream & operator << (std::ostream & os, const Flags<N> & f){
	return (os << static_cast<const FlagsBase&>(f));
}
#endif //_MSC_VER

}

#endif//_Flags_hxx_