/usr/include/Wt/WFlags is in libwt-dev 3.1.10-1ubuntu2.
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 356 357 358 | // This may look like C code, but it's really -*- C++ -*-
/*
* Copyright (C) 2008 Emweb bvba, Kessel-Lo, Belgium.
*
* See the LICENSE file for terms of use.
*/
#ifndef WFLAGS_H_
#define WFLAGS_H_
#include <Wt/WDllDefs.h>
#define WFLAGS_USE_TYPESAFE_MASKS
namespace Wt {
/*! \class WFlags Wt/WFlags Wt/WFlags
* \brief Utility class for type-safe combinations of enumeration flags.
*
* This type is used in %Wt API whenever one or more flag options are
* expected, instead of an <tt>int</tt>. The class provides type
* safety, in the sense that it checks that the correct combination of
* enum values is bound to the argument, and does not cost any
* run-time overhead (internally it uses only an <tt>int</tt> to
* represent the combination of flags.
*/
template<typename EnumType>
class WFlags
{
class Zero_ {};
typedef Zero_ *Zero;
#ifdef WFLAGS_USE_TYPESAFE_MASKS
typedef const WFlags<EnumType>& MaskType;
#else
typedef unsigned MaskType;
#endif
public:
typedef EnumType enum_type;
/*! \brief Default constructor.
*/
inline WFlags(Zero zero = 0);
/*! \brief Construct from a single enum value.
*/
inline WFlags(EnumType flag);
/*! \brief Copy constructor.
*/
inline WFlags(const WFlags<EnumType>& other);
/*! \brief Assignment operator.
*/
inline WFlags<EnumType>& operator=(const WFlags<EnumType>& other);
/*! \brief Assignment operator.
*/
inline WFlags<EnumType>& operator=(const EnumType other);
/*! \brief Returns whether a flag is set.
*/
inline bool testFlag(EnumType flag) const;
/*! \brief Clears a flag.
*/
inline WFlags<EnumType>& clear(EnumType value);
/*! \brief Cast to the enum type.
*
* The internal <tt>int</tt> representation is simply cast to the
* enum type, without any additional checks.
*/
inline operator EnumType() const;
inline int bitCount() const;
/*! \brief Negation operator.
*
* Returns whether different from 0.
*/
inline bool operator!() const;
/*! \brief Bitwise AND operator.
*
* Returns flags that are the bitwise AND of this and \p mask.
*/
inline WFlags<EnumType> operator&(EnumType mask) const;
/*! \brief Bitwise AND operator.
*
* Returns flags that are the bitwise AND of this and \p mask.
*/
inline WFlags<EnumType> operator&(MaskType mask) const;
/*! \brief Modifying bitwise AND operator.
*
* Sets as value the bitwise AND of this and \p mask.
*/
inline WFlags<EnumType>& operator&=(EnumType mask);
/*! \brief Modifying bitwise AND operator.
*
* Sets as value the bitwise AND of this and \p mask.
*/
inline WFlags<EnumType>& operator&=(MaskType mask);
/*! \brief Bitwise XOR operator.
*
* Returns flags that are the bitwise XOR of this and \p other.
*/
inline WFlags<EnumType> operator^(WFlags<EnumType> other) const;
/*! \brief Bitwise XOR operator.
*
* Returns flags that are the bitwise XOR of this and \p other.
*/
inline WFlags<EnumType> operator^(EnumType other) const;
/*! \brief Modifying bitwise XOR operator.
*
* Sets as value the bitwise XOR of this and \p other.
*/
inline WFlags<EnumType>& operator^=(WFlags<EnumType> other);
/*! \brief Modifying bitwise XOR operator.
*
* Sets as value the bitwise XOR of this and \p other.
*/
inline WFlags<EnumType>& operator^=(EnumType other);
/*! \brief Bitwise OR operator.
*
* Returns flags that are the bitwise OR of this and \p other.
*/
inline WFlags<EnumType> operator|(WFlags<EnumType> other) const;
/*! \brief Bitwise OR operator.
*
* Returns flags that are the bitwise OR of this and \p other.
*/
inline WFlags<EnumType> operator|(EnumType other) const;
/*! \brief Modifying bitwise OR operator.
*
* Sets as value the bitwise OR of this and \p other.
*/
inline WFlags<EnumType>& operator|=(WFlags<EnumType> other);
/*! \brief Modifying bitwise OR operator.
*
* Sets as value the bitwise OR of this and \p other.
*/
inline WFlags<EnumType>& operator|=(EnumType other);
/*! \brief Inversion operator.
*
* Returns flags that are the inverted of this.
*/
inline WFlags<EnumType> operator~() const;
#ifdef WT_TARGET_JAVA
inline bool operator==(WFlags<EnumType> other) const;
inline bool operator==(EnumType other) const;
inline bool operator==(int zero) const;
inline bool operator!=(WFlags<EnumType> other) const;
inline bool operator!=(EnumType other) const;
inline bool operator!=(int zero) const;
#endif
inline int value() const { return flags_; }
private:
unsigned int flags_;
WFlags(int flags, bool): flags_(flags) {}
inline static WFlags<EnumType> createFromInt(int flags) {
return WFlags(flags, false);
}
};
#ifndef DOXYGEN_ONLY
template<typename EnumType>
WFlags<EnumType>::WFlags(const WFlags<EnumType>& other):
flags_(other.flags_)
{
}
template<typename EnumType>
WFlags<EnumType>::WFlags(enum_type flag):
flags_(flag)
{
}
template<typename EnumType>
WFlags<EnumType>::WFlags(typename WFlags<EnumType>::Zero):
flags_(0)
{
}
template<typename EnumType>
bool WFlags<EnumType>::testFlag(enum_type flag) const
{
return flags_ & flag;
}
template<typename EnumType>
WFlags<EnumType>& WFlags<EnumType>::clear(enum_type flag)
{
flags_ &= ~flag;
return *this;
}
template<typename EnumType>
WFlags<EnumType>::operator EnumType() const
{
return static_cast<EnumType>(flags_);
}
template<typename EnumType>
int WFlags<EnumType>::bitCount() const
{
unsigned n = flags_;
int retval = 0;
while (n) {
retval ++;
n &= n - 1;
}
return retval;
}
template<typename EnumType>
bool WFlags<EnumType>::operator!() const
{
return !flags_;
}
template<typename EnumType>
WFlags<EnumType> WFlags<EnumType>::operator&(EnumType mask) const
{
return WFlags<EnumType>::createFromInt(flags_ & (unsigned)mask);
}
template<typename EnumType>
WFlags<EnumType> WFlags<EnumType>::operator&(MaskType mask) const
{
return WFlags<EnumType>::createFromInt(flags_ & (unsigned)mask);
}
template<typename EnumType>
WFlags<EnumType> &WFlags<EnumType>::operator&=(MaskType mask)
{
flags_ &= (unsigned)mask;
return *this;
}
template<typename EnumType>
WFlags<EnumType> &WFlags<EnumType>::operator&=(EnumType mask)
{
flags_ &= (unsigned)mask;
return *this;
}
template<typename EnumType>
WFlags<EnumType>& WFlags<EnumType>::operator=(const WFlags<EnumType>& other)
{
flags_ = other.flags_;
return *this;
}
template<typename EnumType>
WFlags<EnumType>& WFlags<EnumType>::operator=(const EnumType other)
{
flags_ = other;
return *this;
}
template<typename EnumType>
WFlags<EnumType> WFlags<EnumType>::operator^(WFlags<EnumType> other) const
{
return WFlags<EnumType>::createFromInt(flags_ ^ other.flags_);
}
template<typename EnumType>
WFlags<EnumType> WFlags<EnumType>::operator^(EnumType other) const
{
return WFlags<EnumType>::createFromInt(flags_ ^ other);
}
template<typename EnumType>
WFlags<EnumType>& WFlags<EnumType>::operator^=(WFlags<EnumType> other)
{
flags_ ^= other.flags_;
return *this;
}
template<typename EnumType>
WFlags<EnumType>& WFlags<EnumType>::operator^=(EnumType other)
{
flags_ ^= other;
return *this;
}
template<typename EnumType>
WFlags<EnumType> WFlags<EnumType>::operator|(WFlags<EnumType> other) const
{
return WFlags<EnumType>::createFromInt(flags_ | other.flags_);
}
template<typename EnumType>
WFlags<EnumType> WFlags<EnumType>::operator|(EnumType other) const
{
return WFlags<EnumType>::createFromInt(flags_ | other);
}
template<typename EnumType>
WFlags<EnumType>& WFlags<EnumType>::operator|=(WFlags<EnumType> other)
{
flags_ |= other.flags_;
return *this;
}
template<typename EnumType>
WFlags<EnumType>& WFlags<EnumType>::operator|=(EnumType other)
{
flags_ |= other;
return *this;
}
template<typename EnumType>
WFlags<EnumType> WFlags<EnumType>::operator~() const
{
return WFlags<EnumType>::createFromInt(~flags_);
}
#ifndef WT_TARGET_JAVA
#define W_DECLARE_OPERATORS_FOR_FLAGS(EnumType) \
inline Wt::WFlags<EnumType> operator|(EnumType l, EnumType r) { \
Wt::WFlags<EnumType> retval(l); \
retval |= r; \
return retval; \
} \
inline Wt::WFlags<EnumType> operator|(EnumType l, \
Wt::WFlags<EnumType> r) { \
return r | l; \
}
#else
#define W_DECLARE_OPERATORS_FOR_FLAGS(EnumType) \
Wt::WFlags<EnumType> operator|(EnumType l, EnumType r); \
Wt::WFlags<EnumType> operator|(EnumType l, Wt::WFlags<EnumType> r); \
bool operator==(EnumType l, Wt::WFlags<EnumType> r); \
bool operator==(EnumType l, int zero);
#endif
}
#endif // DOXYGEN_ONLY
#endif // WFLAGS_H_
|