Core/Utilities: Do not expose internal store structure in Tokens and rename it to Tokenizer

This commit is contained in:
Spp committed 2012-10-02 11:54:41 +02:00
1 parent d44ec4b7da
commit f8846cdeaf
21 files changed
+187 -269

No files matched your search

+2 -1
View File
@@ -20,8 +20,9 @@
#define TRINITY_UNITAI_H
#include "Define.h"
#include <list>
#include "Unit.h"
#include "Containers.h"
#include <list>
class Unit;
class Player;
+2 -5
View File
@@ -16,8 +16,8 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "DatabaseEnv.h"
#include "AccountMgr.h"
#include "DatabaseEnv.h"
#include "ObjectAccessor.h"
#include "Player.h"
#include "Util.h"
@@ -274,10 +274,7 @@ std::string CalculateShaPassHash(std::string& name, std::string& password)
sha.UpdateData(password);
sha.Finalize();
std::string encoded;
hexEncodeByteArray(sha.GetDigest(), sha.GetLength(), encoded);
return encoded;
return ByteArrayToHexStr(sha.GetDigest(), sha.GetLength());
}
bool IsPlayerAccount(uint32 gmlevel)
+2 -2
View File
@@ -69,8 +69,8 @@ Channel::Channel(const std::string& name, uint32 channel_id, uint32 Team)
if (db_BannedList)
{
Tokens tokens(db_BannedList, ' ');
Tokens::iterator iter;
Tokenizer tokens(db_BannedList, ' ');
Tokenizer::const_iterator iter;
for (iter = tokens.begin(); iter != tokens.end(); ++iter)
{
uint64 banned_guid = atol(*iter);
+2 -2
View File
@@ -100,14 +100,14 @@ void LoadDisables()
if (flags & SPELL_DISABLE_MAP)
{
Tokens tokens(params_0, ',');
Tokenizer tokens(params_0, ',');
for (uint8 i = 0; i < tokens.size(); )
data.params[0].insert(atoi(tokens[i++]));
}
if (flags & SPELL_DISABLE_AREA)
{
Tokens tokens(params_1, ',');
Tokenizer tokens(params_1, ',');
for (uint8 i = 0; i < tokens.size(); )
data.params[1].insert(atoi(tokens[i++]));
}
+1 -1
View File
@@ -18,7 +18,7 @@
#include "Common.h"
#include "SharedDefines.h"
#include "DBCStores.h"
#include "Containers.h"
#include "DisableMgr.h"
#include "ObjectMgr.h"
#include "SocialMgr.h"
+1 -1
View File
@@ -424,7 +424,7 @@ bool Item::LoadFromDB(uint32 guid, uint64 owner_guid, Field* fields, uint32 entr
need_save = true;
}
Tokens tokens(fields[4].GetString(), ' ', MAX_ITEM_PROTO_SPELLS);
Tokenizer tokens(fields[4].GetString(), ' ', MAX_ITEM_PROTO_SPELLS);
if (tokens.size() == MAX_ITEM_PROTO_SPELLS)
for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
SetSpellCharges(i, atoi(tokens[i]));
+1 -1
View File
@@ -772,7 +772,7 @@ void Object::_LoadIntoDataField(char const* data, uint32 startOffset, uint32 cou
if (!data)
return;
Tokens tokens(data, ' ', count);
Tokenizer tokens(data, ' ', count);
if (tokens.size() != count)
return;
+10 -10
View File
@@ -192,10 +192,10 @@ void PlayerTaxi::InitTaxiNodesForLevel(uint32 race, uint32 chrClass, uint8 level
void PlayerTaxi::LoadTaxiMask(const char* data)
{
Tokens tokens(data, ' ');
Tokenizer tokens(data, ' ');
uint8 index;
Tokens::iterator iter;
Tokenizer::const_iterator iter;
for (iter = tokens.begin(), index = 0;
(index < TaxiMaskSize) && (iter != tokens.end()); ++iter, ++index)
{
@@ -222,9 +222,9 @@ bool PlayerTaxi::LoadTaxiDestinationsFromString(const std::string& values, uint3
{
ClearTaxiDestinations();
Tokens tokens(values, ' ');
Tokenizer tokens(values, ' ');
for (Tokens::iterator iter = tokens.begin(); iter != tokens.end(); ++iter)
for (Tokenizer::const_iterator iter = tokens.begin(); iter != tokens.end(); ++iter)
{
uint32 node = uint32(atol(*iter));
AddTaxiDestination(node);
@@ -1975,7 +1975,7 @@ bool Player::BuildEnumData(PreparedQueryResult result, WorldPacket* data)
*data << uint32(petLevel);
*data << uint32(petFamily);
Tokens equipment(fields[19].GetString(), ' ');
Tokenizer equipment(fields[19].GetString(), ' ');
for (uint8 slot = 0; slot < INVENTORY_SLOT_BAG_END; ++slot)
{
uint32 visualBase = slot * 2;
@@ -16691,7 +16691,7 @@ void Player::SetHomebind(WorldLocation const& /*loc*/, uint32 /*area_id*/)
CharacterDatabase.Execute(stmt);
}
uint32 Player::GetUInt32ValueFromArray(Tokens const& data, uint16 index)
uint32 Player::GetUInt32ValueFromArray(Tokenizer const& data, uint16 index)
{
if (index >= data.size())
return 0;
@@ -16699,7 +16699,7 @@ uint32 Player::GetUInt32ValueFromArray(Tokens const& data, uint16 index)
return (uint32)atoi(data[index]);
}
float Player::GetFloatValueFromArray(Tokens const& data, uint16 index)
float Player::GetFloatValueFromArray(Tokenizer const& data, uint16 index)
{
float result;
uint32 temp = Player::GetUInt32ValueFromArray(data, index);
@@ -17742,9 +17742,9 @@ Item* Player::_LoadItem(SQLTransaction& trans, uint32 zoneId, uint32 timeDiff, F
if (PreparedQueryResult result = CharacterDatabase.Query(stmt))
{
std::string strGUID = (*result)[0].GetString();
Tokens GUIDlist(strGUID, ' ');
Tokenizer GUIDlist(strGUID, ' ');
AllowedLooterSet looters;
for (Tokens::iterator itr = GUIDlist.begin(); itr != GUIDlist.end(); ++itr)
for (Tokenizer::const_iterator itr = GUIDlist.begin(); itr != GUIDlist.end(); ++itr)
looters.insert(atol(*itr));
item->SetSoulboundTradeable(looters);
AddTradeableItem(item);
@@ -19604,7 +19604,7 @@ void Player::SavePositionInDB(uint32 mapid, float x, float y, float z, float o,
CharacterDatabase.Execute(stmt);
}
void Player::SetUInt32ValueInArray(Tokens& tokens, uint16 index, uint32 value)
void Player::SetUInt32ValueInArray(Tokenizer& tokens, uint16 index, uint32 value)
{
char buf[11];
snprintf(buf, 11, "%u", value);
+5 -5
View File
@@ -34,7 +34,7 @@
#include "QuestDef.h"
#include "ReputationMgr.h"
#include "Unit.h"
#include "Util.h" // for Tokens typedef
#include "Util.h" // for Tokenizer typedef
#include "WorldSession.h"
// for template
@@ -1518,8 +1518,8 @@ class Player : public Unit, public GridObject<Player>
bool isBeingLoaded() const { return GetSession()->PlayerLoading();}
void Initialize(uint32 guid);
static uint32 GetUInt32ValueFromArray(Tokens const& data, uint16 index);
static float GetFloatValueFromArray(Tokens const& data, uint16 index);
static uint32 GetUInt32ValueFromArray(Tokenizer const& data, uint16 index);
static float GetFloatValueFromArray(Tokenizer const& data, uint16 index);
static uint32 GetZoneIdFromDB(uint64 guid);
static uint32 GetLevelFromDB(uint64 guid);
static bool LoadPositionFromDB(uint32& mapid, float& x, float& y, float& z, float& o, bool& in_flight, uint64 guid);
@@ -1534,8 +1534,8 @@ class Player : public Unit, public GridObject<Player>
void SaveInventoryAndGoldToDB(SQLTransaction& trans); // fast save function for item/money cheating preventing
void SaveGoldToDB(SQLTransaction& trans);
static void SetUInt32ValueInArray(Tokens& data, uint16 index, uint32 value);
static void SetFloatValueInArray(Tokens& data, uint16 index, float value);
static void SetUInt32ValueInArray(Tokenizer& data, uint16 index, uint32 value);
static void SetFloatValueInArray(Tokenizer& data, uint16 index, float value);
static void Customize(uint64 guid, uint8 gender, uint8 skin, uint8 face, uint8 hairStyle, uint8 hairColor, uint8 facialHair);
static void SavePositionInDB(uint32 mapid, float x, float y, float z, float o, uint32 zone, uint64 guid);
+5 -5
View File
@@ -6654,7 +6654,7 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere
Player* Member = itr->getSource();
// check if it was heal by paladin which casted this beacon of light
if (Aura const * aura = Member->GetAura(53563, victim->GetGUID()))
if (Member->GetAura(53563, victim->GetGUID()))
{
// do not proc when target of beacon of light is healed
if (Member == this)
@@ -14132,14 +14132,14 @@ void CharmInfo::LoadPetActionBar(const std::string& data)
{
InitPetActionBar();
Tokens tokens(data, ' ');
Tokenizer tokens(data, ' ');
if (tokens.size() != (ACTION_BAR_INDEX_END-ACTION_BAR_INDEX_START) * 2)
return; // non critical, will reset to default
uint8 index;
Tokens::iterator iter;
for (iter = tokens.begin(), index = ACTION_BAR_INDEX_START; index < ACTION_BAR_INDEX_END; ++iter, ++index)
uint8 index = ACTION_BAR_INDEX_START;
Tokenizer::const_iterator iter = tokens.begin();
for (; index < ACTION_BAR_INDEX_END; ++iter, ++index)
{
// use unsigned cast to avoid sign negative format use at long-> ActiveStates (int) conversion
ActiveStates type = ActiveStates(atol(*iter));
+4 -4
View File
@@ -525,10 +525,10 @@ void ObjectMgr::LoadCreatureTemplateAddons()
creatureAddon.bytes2 = fields[4].GetUInt32();
creatureAddon.emote = fields[5].GetUInt32();
Tokens tokens(fields[6].GetString(), ' ');
Tokenizer tokens(fields[6].GetString(), ' ');
uint8 i = 0;
creatureAddon.auras.resize(tokens.size());
for (Tokens::iterator itr = tokens.begin(); itr != tokens.end(); ++itr)
for (Tokenizer::const_iterator itr = tokens.begin(); itr != tokens.end(); ++itr)
{
SpellInfo const* AdditionalSpellInfo = sSpellMgr->GetSpellInfo(uint32(atol(*itr)));
if (!AdditionalSpellInfo)
@@ -907,10 +907,10 @@ void ObjectMgr::LoadCreatureAddons()
creatureAddon.bytes2 = fields[4].GetUInt32();
creatureAddon.emote = fields[5].GetUInt32();
Tokens tokens(fields[6].GetString(), ' ');
Tokenizer tokens(fields[6].GetString(), ' ');
uint8 i = 0;
creatureAddon.auras.resize(tokens.size());
for (Tokens::iterator itr = tokens.begin(); itr != tokens.end(); ++itr)
for (Tokenizer::const_iterator itr = tokens.begin(); itr != tokens.end(); ++itr)
{
SpellInfo const* AdditionalSpellInfo = sSpellMgr->GetSpellInfo(uint32(atol(*itr)));
if (!AdditionalSpellInfo)
@@ -2021,7 +2021,7 @@ void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recv_data)
{
const uint32 ktcount = KNOWN_TITLES_SIZE * 2;
uint32 knownTitles[ktcount];
Tokens tokens(knownTitlesStr, ' ', ktcount);
Tokenizer tokens(knownTitlesStr, ' ', ktcount);
if (tokens.size() != ktcount)
return;
+1
View File
@@ -17,6 +17,7 @@
*/
#include "PoolMgr.h"
#include "Containers.h"
#include "ObjectMgr.h"
#include "Log.h"
#include "MapManager.h"
+2 -2
View File
@@ -39,12 +39,12 @@ public:
{ "complete", SEC_ADMINISTRATOR, false, &HandleQuestComplete, "", NULL },
{ "remove", SEC_ADMINISTRATOR, false, &HandleQuestRemove, "", NULL },
{ "reward", SEC_ADMINISTRATOR, false, &HandleQuestReward, "", NULL },
{ NULL, 0, false, NULL, "", NULL }
{ NULL, SEC_PLAYER, false, NULL, "", NULL }
};
static ChatCommand commandTable[] =
{
{ "quest", SEC_ADMINISTRATOR, false, NULL, "", questCommandTable },
{ NULL, 0, false, NULL, "", NULL }
{ NULL, SEC_PLAYER, false, NULL, "", NULL }
};
return commandTable;
}
+2 -2
View File
@@ -408,9 +408,9 @@ public:
if (!*args)
return false;
Tokens entries(std::string(args), ' ');
Tokenizer entries(std::string(args), ' ');
for (Tokens::const_iterator itr = entries.begin(); itr != entries.end(); ++itr)
for (Tokenizer::const_iterator itr = entries.begin(); itr != entries.end(); ++itr)
{
uint32 entry = uint32(atoi(*itr));
+1 -1
View File
@@ -41,7 +41,7 @@ struct MySQLConnectionInfo
MySQLConnectionInfo() {}
MySQLConnectionInfo(const std::string& infoString)
{
Tokens tokens(infoString, ';');
Tokenizer tokens(infoString, ';');
if (tokens.size() != 5)
return;
+4 -4
View File
@@ -88,8 +88,8 @@ void Log::CreateAppenderFromConfig(const char* name)
std::string options = "Appender.";
options.append(name);
options = ConfigMgr::GetStringDefault(options.c_str(), "");
Tokens tokens(options, ',');
Tokens::iterator iter = tokens.begin();
Tokenizer tokens(options, ',');
Tokenizer::const_iterator iter = tokens.begin();
if (tokens.size() < 2)
{
@@ -181,8 +181,8 @@ void Log::CreateLoggerFromConfig(const char* name)
return;
}
Tokens tokens(options, ',');
Tokens::iterator iter = tokens.begin();
Tokenizer tokens(options, ',');
Tokenizer::const_iterator iter = tokens.begin();
if (tokens.size() != 3)
{
+2 -2
View File
@@ -24,12 +24,12 @@
*/
#include "Define.h"
#include<algorithm>
#include <algorithm>
namespace ByteConverter
{
template<size_t T>
inline void convert(char *val)
inline void convert(char *val)
{
std::swap(*val, *(val + T - 1));
convert<T - 2>(val + 1);
+2 -5
View File
@@ -21,7 +21,7 @@
#include "Define.h"
#include<map>
#include <map>
// Note. All times are in milliseconds here.
@@ -29,9 +29,7 @@ class BasicEvent
{
public:
BasicEvent() { to_Abort = false; }
virtual ~BasicEvent() // override destructor to perform some actions on event removal
{
};
virtual ~BasicEvent() {} // override destructor to perform some actions on event removal
// this method executes when the event is triggered
// return false if event does not want to be deleted
@@ -68,4 +66,3 @@ class EventProcessor
bool m_aborting;
};
#endif
+18 -26
View File
@@ -56,13 +56,13 @@ double rand_chance(void)
return sfmtRand->Random() * 100.0;
}
Tokens::Tokens(const std::string &src, const char sep, uint32 vectorReserve)
Tokenizer::Tokenizer(const std::string &src, const char sep, uint32 vectorReserve)
{
m_str = new char[src.length() + 1];
memcpy(m_str, src.c_str(), src.length() + 1);
if (vectorReserve)
reserve(vectorReserve);
m_storage.reserve(vectorReserve);
char* posold = m_str;
char* posnew = m_str;
@@ -71,17 +71,17 @@ Tokens::Tokens(const std::string &src, const char sep, uint32 vectorReserve)
{
if (*posnew == sep)
{
push_back(posold);
m_storage.push_back(posold);
posold = posnew + 1;
*posnew = 0x00;
*posnew = '\0';
}
else if (*posnew == 0x00)
else if (*posnew == '\0')
{
// Hack like, but the old code accepted these kind of broken strings,
// so changing it would break other things
if (posold != posnew)
push_back(posold);
m_storage.push_back(posold);
break;
}
@@ -471,29 +471,21 @@ void vutf8printf(FILE* out, const char *str, va_list* ap)
#endif
}
void hexEncodeByteArray(uint8* bytes, uint32 arrayLen, std::string& result)
std::string ByteArrayToHexStr(uint8 const* bytes, uint32 arrayLen, bool reverse /* = false */)
{
std::ostringstream ss;
for (uint32 i=0; i<arrayLen; ++i)
{
for (uint8 j=0; j<2; ++j)
{
unsigned char nibble = 0x0F & (bytes[i]>>((1-j)*4));
char encodedNibble;
if (nibble < 0x0A)
encodedNibble = '0'+nibble;
else
encodedNibble = 'A'+nibble-0x0A;
ss << encodedNibble;
}
}
result = ss.str();
}
int32 init = 0;
int32 end = arrayLen;
int8 op = 1;
if (reverse)
{
init = arrayLen - 1;
end = -1;
op = -1;
}
std::string ByteArrayToHexStr(uint8* bytes, uint32 length)
{
std::ostringstream ss;
for (uint32 i = 0; i < length; ++i)
for (int32 i = init; i != end; i += op)
{
char buffer[4];
sprintf(buffer, "%02X ", bytes[i]);
+119 -189
View File
@@ -19,27 +19,48 @@
#ifndef _UTIL_H
#define _UTIL_H
#include "Common.h"
#include "Containers.h"
#include "Define.h"
#include <string>
#include <vector>
#include <list>
// Searcher for map of structs
template<typename T, class S> struct Finder
{
T val_;
T S::* idMember_;
Finder(T val, T S::* idMember) : val_(val), idMember_(idMember) {}
bool operator()(const std::pair<int, S> &obj) { return obj.second.*idMember_ == val_; }
};
struct Tokens: public std::vector<char*>
class Tokenizer
{
Tokens(const std::string &src, const char sep, uint32 vectorReserve = 0);
~Tokens() { delete[] m_str; }
public:
typedef std::vector<char const *> StorageType;
typedef StorageType::size_type size_type;
typedef StorageType::const_iterator const_iterator;
typedef StorageType::reference reference;
typedef StorageType::const_reference const_reference;
public:
Tokenizer(const std::string &src, char const sep, uint32 vectorReserve = 0);
~Tokenizer() { delete[] m_str; }
const_iterator begin() const { return m_storage.begin(); }
const_iterator end() const { return m_storage.end(); }
size_type size() const { return m_storage.size(); }
reference operator [] (size_type i) { return m_storage[i]; }
const_reference operator [] (size_type i) const { return m_storage[i]; }
private:
char* m_str;
StorageType m_storage;
};
void stripLineInvisibleChars(std::string &src);
@@ -49,27 +70,29 @@ uint32 TimeStringToSecs(const std::string& timestring);
std::string TimeToTimestampStr(time_t t);
/* Return a random number in the range min..max; (max-min) must be smaller than 32768. */
int32 irand(int32 min, int32 max);
int32 irand(int32 min, int32 max);
/* Return a random number in the range min..max (inclusive). For reliable results, the difference
* between max and min should be less than RAND32_MAX. */
uint32 urand(uint32 min, uint32 max);
uint32 urand(uint32 min, uint32 max);
/* Return a random number in the range 0 .. RAND32_MAX. */
int32 rand32();
int32 rand32();
/* Return a random number in the range min..max */
float frand(float min, float max);
/* Return a random number in the range min..max */
float frand(float min, float max);
/* Return a random double from 0.0 to 1.0 (exclusive). Floats support only 7 valid decimal digits.
* A double supports up to 15 valid decimal digits and is used internally (RAND32_MAX has 10 digits).
* With an FPU, there is usually no difference in performance between float and double. */
double rand_norm(void);
* With an FPU, there is usually no difference in performance between float and double.
*/
double rand_norm(void);
/* Return a random double from 0.0 to 99.9999999999999. Floats support only 7 valid decimal digits.
* A double supports up to 15 valid decimal digits and is used internally (RAND32_MAX has 10 digits).
* With an FPU, there is usually no difference in performance between float and double. */
double rand_chance(void);
* With an FPU, there is usually no difference in performance between float and double.
*/
double rand_chance(void);
/* Return true if a random roll fits in the specified chance (range 0-100). */
inline bool roll_chance_f(float chance)
@@ -355,8 +378,7 @@ void vutf8printf(FILE* out, const char *str, va_list* ap);
bool IsIPAddress(char const* ipaddress);
uint32 CreatePIDFile(const std::string& filename);
void hexEncodeByteArray(uint8* bytes, uint32 arrayLen, std::string& result);
std::string ByteArrayToHexStr(uint8* bytes, uint32 length);
std::string ByteArrayToHexStr(uint8 const* bytes, uint32 length, bool reverse = false);
#endif
//handler for operations on large flags
@@ -404,232 +426,140 @@ class flag96
{
private:
uint32 part[3];
public:
flag96(uint32 p1=0, uint32 p2=0, uint32 p3=0)
flag96(uint32 p1 = 0, uint32 p2 = 0, uint32 p3 = 0)
{
part[0]=p1;
part[1]=p2;
part[2]=p3;
part[0] = p1;
part[1] = p2;
part[2] = p3;
}
flag96(uint64 p1, uint32 p2)
{
part[0]=PAIR64_LOPART(p1);
part[1]=PAIR64_HIPART(p1);
part[2]=p2;
part[0] = PAIR64_LOPART(p1);
part[1] = PAIR64_HIPART(p1);
part[2] = p2;
}
inline bool IsEqual(uint32 p1=0, uint32 p2=0, uint32 p3=0) const
inline bool IsEqual(uint32 p1 = 0, uint32 p2 = 0, uint32 p3 = 0) const
{
return (
part[0]==p1 &&
part[1]==p2 &&
part[2]==p3);
};
inline bool HasFlag(uint32 p1=0, uint32 p2=0, uint32 p3=0) const
{
return (
part[0]&p1 ||
part[1]&p2 ||
part[2]&p3);
};
inline void Set(uint32 p1=0, uint32 p2=0, uint32 p3=0)
{
part[0]=p1;
part[1]=p2;
part[2]=p3;
};
template<class type>
inline bool operator < (type & right)
{
for (uint8 i=3; i > 0; --i)
{
if (part[i-1]<right.part[i-1])
return 1;
else if (part[i-1]>right.part[i-1])
return 0;
}
return 0;
return (part[0] == p1 && part[1] == p2 && part[2] == p3);
}
template<class type>
inline bool operator < (type & right) const
inline bool HasFlag(uint32 p1 = 0, uint32 p2 = 0, uint32 p3 = 0) const
{
return (part[0] & p1 || part[1] & p2 || part[2] & p3);
}
inline void Set(uint32 p1 = 0, uint32 p2 = 0, uint32 p3 = 0)
{
part[0] = p1;
part[1] = p2;
part[2] = p3;
}
inline bool operator <(const flag96 &right) const
{
for (uint8 i = 3; i > 0; --i)
{
if (part[i-1]<right.part[i-1])
return 1;
else if (part[i-1]>right.part[i-1])
return 0;
if (part[i - 1] < right.part[i - 1])
return true;
else if (part[i - 1] > right.part[i - 1])
return false;
}
return 0;
}
template<class type>
inline bool operator != (type & right)
{
if (part[0]!=right.part[0]
|| part[1]!=right.part[1]
|| part[2]!=right.part[2])
return true;
return false;
}
template<class type>
inline bool operator != (type & right) const
inline bool operator ==(const flag96 &right) const
{
if (part[0]!=right.part[0]
|| part[1]!=right.part[1]
|| part[2]!=right.part[2])
return true;
return false;
}
template<class type>
inline bool operator == (type & right)
{
if (part[0]!=right.part[0]
|| part[1]!=right.part[1]
|| part[2]!=right.part[2])
return false;
return true;
}
template<class type>
inline bool operator == (type & right) const
{
if (part[0]!=right.part[0]
|| part[1]!=right.part[1]
|| part[2]!=right.part[2])
return false;
return true;
}
template<class type>
inline void operator = (type & right)
{
part[0]=right.part[0];
part[1]=right.part[1];
part[2]=right.part[2];
}
template<class type>
inline flag96 operator & (type & right)
{
flag96 ret(part[0] & right.part[0], part[1] & right.part[1], part[2] & right.part[2]);
return
ret;
(
part[0] == right.part[0] &&
part[1] == right.part[1] &&
part[2] == right.part[2]
);
}
template<class type>
inline flag96 operator & (type & right) const
inline bool operator !=(const flag96 &right) const
{
flag96 ret(part[0] & right.part[0], part[1] & right.part[1], part[2] & right.part[2]);
return
ret;
return !this->operator ==(right);
}
template<class type>
inline void operator &= (type & right)
inline flag96 & operator =(const flag96 &right)
{
*this=*this & right;
part[0] = right.part[0];
part[1] = right.part[1];
part[2] = right.part[2];
return *this;
}
template<class type>
inline flag96 operator | (type & right)
inline flag96 operator &(const flag96 &right) const
{
flag96 ret(part[0] | right.part[0], part[1] | right.part[1], part[2] | right.part[2]);
return
ret;
return flag96(part[0] & right.part[0], part[1] & right.part[1],
part[2] & right.part[2]);
}
template<class type>
inline flag96 operator | (type & right) const
inline flag96 & operator &=(const flag96 &right)
{
flag96 ret(part[0] | right.part[0], part[1] | right.part[1], part[2] | right.part[2]);
return
ret;
part[0] &= right.part[0];
part[1] &= right.part[1];
part[2] &= right.part[2];
return *this;
}
template<class type>
inline void operator |= (type & right)
inline flag96 operator |(const flag96 &right) const
{
*this=*this | right;
return flag96(part[0] | right.part[0], part[1] | right.part[1],
part[2] | right.part[2]);
}
inline void operator ~ ()
inline flag96 & operator |=(const flag96 &right)
{
part[2]=~part[2];
part[1]=~part[1];
part[0]=~part[0];
};
template<class type>
inline flag96 operator ^ (type & right)
{
flag96 ret(part[0] ^ right.part[0], part[1] ^ right.part[1], part[2] ^ right.part[2]);
return
ret;
part[0] |= right.part[0];
part[1] |= right.part[1];
part[2] |= right.part[2];
return *this;
}
template<class type>
inline flag96 operator ^ (type & right) const
inline flag96 operator ~() const
{
flag96 ret(part[0] ^ right.part[0], part[1] ^ right.part[1], part[2] ^ right.part[2]);
return
ret;
return flag96(~part[0], ~part[1], ~part[2]);
}
template<class type>
inline void operator ^= (type & right)
inline flag96 operator ^(const flag96 &right) const
{
*this=*this^right;
return flag96(part[0] ^ right.part[0], part[1] ^ right.part[1],
part[2] ^ right.part[2]);
}
inline flag96 & operator ^=(const flag96 &right)
{
part[0] ^= right.part[0];
part[1] ^= right.part[1];
part[2] ^= right.part[2];
return *this;
}
inline operator bool() const
{
return(
part[0] != 0 ||
part[1] != 0 ||
part[2] != 0);
};
return (part[0] != 0 || part[1] != 0 || part[2] != 0);
}
inline operator bool()
inline bool operator !() const
{
return(
part[0] != 0 ||
part[1] != 0 ||
part[2] != 0);
};
return !this->operator bool();
}
inline bool operator ! () const
inline uint32 & operator [](uint8 el)
{
return(
part[0] == 0 &&
part[1] == 0 &&
part[2] == 0);
};
return part[el];
}
inline bool operator ! ()
inline const uint32 & operator [](uint8 el) const
{
return(
part[0] == 0 &&
part[1] == 0 &&
part[2] == 0);
};
inline uint32 & operator[](uint8 el)
{
return (part[el]);
};
inline uint32 operator[](uint8 el) const
{
return (part[el]);
};
return part[el];
}
};
#endif