| Server IP : 20.75.53.88 / Your IP : 216.73.217.72 [ Web Server : Apache System : Linux VMRALP-3 4.4.0-256-generic #290~14.04.1-Ubuntu SMP Thu Jun 20 09:24:50 UTC 2024 x86_64 User : www-data ( 33) PHP Version : 5.5.9-1ubuntu4.29+esm15 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, Domains : 3 Domains MySQL : ON | cURL : OFF | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/include/x86_64-linux-gnu/unicode/ |
Upload File : |
/*
******************************************************************************
*
* Copyright (C) 2012, International Business Machines
* Corporation and others. All Rights Reserved.
*
******************************************************************************
*/
/**
* \file
* \brief C++: internal template EnumSet<>
*/
#ifndef ENUMSET_H
#define ENUMSET_H
#include "unicode/utypes.h"
#if U_SHOW_CPLUSPLUS_API
U_NAMESPACE_BEGIN
/**
* enum bitset for boolean fields. Similar to Java EnumSet<>.
* Needs to range check.
* @internal
*/
template<typename T, uint32_t minValue, uint32_t limitValue>
class EnumSet {
public:
inline EnumSet() : fBools(0) {}
inline EnumSet(const EnumSet<T,minValue,limitValue>& other) : fBools(other.fBools) {}
inline ~EnumSet() {}
inline void clear() { fBools=0; }
inline void add(T toAdd) { set(toAdd, 1); }
inline void remove(T toRemove) { set(toRemove, 0); }
inline int32_t contains(T toCheck) const { return get(toCheck); }
inline void set(T toSet, int32_t v) { fBools=(fBools&(~flag(toSet)))|(v?(flag(toSet)):0); }
inline int32_t get(T toCheck) const { return (fBools & flag(toCheck))?1:0; }
inline UBool isValidEnum(T toCheck) const { return (toCheck>=minValue&&toCheck<limitValue); }
inline UBool isValidValue(int32_t v) const { return (v==0||v==1); }
inline const EnumSet<T,minValue,limitValue>& operator=(const EnumSet<T,minValue,limitValue>& other) {
fBools = other.fBools;
return *this;
}
inline uint32_t getAll() const {
return fBools;
}
private:
inline uint32_t flag(T toCheck) const { return (1<<(toCheck-minValue)); }
private:
uint32_t fBools;
};
U_NAMESPACE_END
#endif /* U_SHOW_CPLUSPLUS_API */
#endif /* ENUMSET_H */