OregonCore  revision 3611e8a-git
Your Favourite TBC server
Field Class Reference

#include <Field.h>

Public Member Functions

 Field ()
 
 ~Field ()
 
enum_field_types GetType () const
 
const char * GetString () const
 
std::string GetCppString () const
 
std::vector< uint8GetBinary () const
 
 GetIntegerDataImpl (GetFloat, MYSQL_TYPE_FLOAT, float, STRTOF(mValue, NULL)) GetIntegerDataImpl(GetDouble
 
 strtod (mValue, NULL)) GetIntegerDataImpl(GetInt8
 
 strtol (mValue, NULL, 10)) GetIntegerDataImpl(GetInt16
 
 strtol (mValue, NULL, 10)) GetIntegerDataImpl(GetInt32
 
 strtol (mValue, NULL, 10)) GetIntegerDataImpl(GetInt64
 
 strtoll (mValue, NULL, 10)) GetIntegerDataImpl(GetUInt8
 
 strtoul (mValue, NULL, 10)) GetIntegerDataImpl(GetUInt16
 
 strtoul (mValue, NULL, 10)) GetIntegerDataImpl(GetUInt32
 
 strtoul (mValue, NULL, 10)) GetIntegerDataImpl(GetUInt64
 
 strtoull (mValue, NULL, 10)) bool GetBool() const
 
void SetBinaryValue (void *value, size_t size, enum_field_types type)
 Used by PreparedQueryResult, we need to copy the original data and free it later. More...
 
void SetType (enum_field_types type)
 Called by QueryResult. More...
 
void SetValue (const char *value)
 Called by QueryResult, no need free this. More...
 

Public Attributes

 MYSQL_TYPE_DOUBLE
 
 double
 
 MYSQL_TYPE_TINY
 
 int8
 
 MYSQL_TYPE_SHORT
 
 int16
 
 MYSQL_TYPE_LONG
 
 int32
 
 MYSQL_TYPE_LONGLONG
 
 int64
 
 uint8
 
 uint16
 
 uint32
 
 uint64
 
void * mRawValue
 
size_t mRawValueSize
 
const char * mValue
 

Private Member Functions

 Field (Field const &)
 
Fieldoperator= (Field const &)
 

Private Attributes

union {
   struct {
      void *   mRawValue
 
      size_t   mRawValueSize
 
   } 
 
   const char *   mValue
 
}; 
 
enum_field_types mType
 The mysql type of this field. More...
 
bool mIsRawValue
 flag whether we have native data (from prepared statements) or not More...
 

Detailed Description

Definition at line 24 of file Field.h.

Constructor & Destructor Documentation

Field::Field ( )
inline

Definition at line 28 of file Field.h.

Referenced by SetValue().

28 : mValue(NULL), mType(MYSQL_TYPE_NULL) {}
const char * mValue
Definition: Field.h:168
enum_field_types mType
The mysql type of this field.
Definition: Field.h:171
Field::~Field ( )
inline

Definition at line 30 of file Field.h.

References mIsRawValue, and mRawValue.

31  {
32  if (mIsRawValue)
33  free (mRawValue);
34  }
bool mIsRawValue
flag whether we have native data (from prepared statements) or not
Definition: Field.h:172
void * mRawValue
Definition: Field.h:162
Field::Field ( Field const &  )
private

Member Function Documentation

std::vector<uint8> Field::GetBinary ( ) const
inline

Definition at line 63 of file Field.h.

References mIsRawValue, mRawValue, and mRawValueSize.

64  {
65  std::vector<uint8> data;
66 
67  if (!mIsRawValue)
68  return data;
69 
70  data.resize(mRawValueSize, 0);
71  std::copy((unsigned char*)mRawValue, ((unsigned char*) mRawValue) + mRawValueSize, data.begin());
72 
73  return data;
74  }
size_t mRawValueSize
Definition: Field.h:163
bool mIsRawValue
flag whether we have native data (from prepared statements) or not
Definition: Field.h:172
void * mRawValue
Definition: Field.h:162
std::string Field::GetCppString ( ) const
inline

Definition at line 52 of file Field.h.

References mIsRawValue, mRawValue, mType, and mValue.

Referenced by InstanceSaveManager::_DelHelper(), Player::_LoadDeclinedNames(), Player::_LoadMail(), CreateDumpString(), Player::DeleteFromDB(), Guild::FillPlayerData(), ChatHandler::getCommandTable(), ChatHandler::GetDeletedCharacterInfoList(), ChatHandler::HandleAccountOnlineListCommand(), WorldSession::HandleCharDeleteOpcode(), ChatHandler::HandleListFreezeCommand(), ChatHandler::HandleListItemCommand(), ChatHandler::HandlePInfoCommand(), WorldSession::HandleTurnInPetitionOpcode(), WorldSession::HandleWhoisOpcode(), ObjectMgr::LoadAccessRequirements(), ArenaTeam::LoadArenaTeamFromDB(), World::LoadAutobroadcasts(), GameEventMgr::LoadFromDB(), SocialMgr::LoadFromDB(), Player::LoadFromDB(), ObjectMgr::LoadGameObjectLocales(), ObjectMgr::LoadGameTele(), ObjectMgr::LoadGossipMenuItems(), ObjectMgr::LoadGossipText(), Guild::LoadGuildBankFromDB(), Guild::LoadGuildFromDB(), ObjectMgr::LoadItemTexts(), ArenaTeam::LoadMembersFromDB(), Guild::LoadMembersFromDB(), ObjectMgr::LoadOregonStrings(), ObjectMgr::LoadPageTextLocales(), Pet::LoadPetFromDB(), Player::LoadPositionFromDB(), Guild::LoadRanksFromDB(), ObjectMgr::LoadReservedPlayersNames(), MapManager::LoadTransports(), CWardenDataStorage::LoadWardenDataResult(), ChatHandler::LookupPlayerSearchCommand(), Quest::Quest(), WorldSession::SendNameQueryOpcodeFromDBCallBack(), WorldSession::SendPetitionQueryOpcode(), and StoreGUID().

53  {
54  if (!mIsRawValue)
55  return mValue ? mValue : ""; // std::string s = 0 have undefine result in C++
56 
57  if (mType != MYSQL_TYPE_STRING || !mRawValue)
58  return "";
59 
60  return reinterpret_cast<char*> (mRawValue);
61  }
const char * mValue
Definition: Field.h:168
enum_field_types mType
The mysql type of this field.
Definition: Field.h:171
bool mIsRawValue
flag whether we have native data (from prepared statements) or not
Definition: Field.h:172
void * mRawValue
Definition: Field.h:162
Field::GetIntegerDataImpl ( GetFloat  ,
MYSQL_TYPE_FLOAT  ,
float  ,
STRTOF(mValue, NULL)   
)
const char* Field::GetString ( ) const
inline

Definition at line 41 of file Field.h.

References mIsRawValue, mRawValue, mType, and mValue.

Referenced by Player::BuildEnumData(), InstanceMap::CreateInstanceData(), ChatHandler::HandleAccountOnlineListCommand(), WorldSocket::HandleAuthSession(), ChatHandler::HandleBanInfoHelper(), ChatHandler::HandleBanListHelper(), ChatHandler::HandleBanListIPCommand(), ChatHandler::HandleWpEventCommand(), ObjectMgr::LoadAreaTriggerScripts(), CreatureTextMgr::LoadCreatureTexts(), World::LoadDBVersion(), DisableMgr::LoadDisables(), TicketMgr::LoadGMTickets(), ObjectMgr::LoadPetNames(), WorldSession::SendExternalMails(), and WorldSession::SendStablePet().

42  {
43  if (!mIsRawValue)
44  return mValue;
45 
46  if (mType != MYSQL_TYPE_STRING)
47  return NULL;
48 
49  return reinterpret_cast<char*> (mRawValue);
50  }
const char * mValue
Definition: Field.h:168
enum_field_types mType
The mysql type of this field.
Definition: Field.h:171
bool mIsRawValue
flag whether we have native data (from prepared statements) or not
Definition: Field.h:172
void * mRawValue
Definition: Field.h:162
enum_field_types Field::GetType ( ) const
inline

Definition at line 36 of file Field.h.

References mType.

37  {
38  return mType;
39  }
enum_field_types mType
The mysql type of this field.
Definition: Field.h:171
Field& Field::operator= ( Field const &  )
private

Referenced by SetValue().

void Field::SetBinaryValue ( void *  value,
size_t  size,
enum_field_types  type 
)
inline

Used by PreparedQueryResult, we need to copy the original data and free it later.

Definition at line 131 of file Field.h.

References mIsRawValue, mRawValue, mRawValueSize, mType, and value.

132  {
133  mRawValue = value;
134  mRawValueSize = size;
135  mType = type;
136  mIsRawValue = true;
137  }
size_t mRawValueSize
Definition: Field.h:163
etc mysql my cnf *Then change max_allowed_packet to a bigger value
enum_field_types mType
The mysql type of this field.
Definition: Field.h:171
bool mIsRawValue
flag whether we have native data (from prepared statements) or not
Definition: Field.h:172
void * mRawValue
Definition: Field.h:162
void Field::SetType ( enum_field_types  type)
inline

Called by QueryResult.

Definition at line 140 of file Field.h.

References mType.

141  {
142  mType = type;
143  }
enum_field_types mType
The mysql type of this field.
Definition: Field.h:171
void Field::SetValue ( const char *  value)
inline

Called by QueryResult, no need free this.

Definition at line 146 of file Field.h.

References Field(), mIsRawValue, operator=(), and value.

147  {
148  mValue = value;
149  mIsRawValue = false;
150  };
const char * mValue
Definition: Field.h:168
etc mysql my cnf *Then change max_allowed_packet to a bigger value
bool mIsRawValue
flag whether we have native data (from prepared statements) or not
Definition: Field.h:172
Field::strtod ( mValue  ,
NULL   
)
Field::strtol ( mValue  ,
NULL  ,
10   
)
Field::strtol ( mValue  ,
NULL  ,
10   
)
Field::strtol ( mValue  ,
NULL  ,
10   
)
Field::strtoll ( mValue  ,
NULL  ,
10   
)
Field::strtoul ( mValue  ,
NULL  ,
10   
)
Field::strtoul ( mValue  ,
NULL  ,
10   
)
Field::strtoul ( mValue  ,
NULL  ,
10   
)
Field::strtoull ( mValue  ,
NULL  ,
10   
) const
inline

Definition at line 120 of file Field.h.

126  {
127  return GetUInt8() == 1;
128  }

Member Data Documentation

union { ... }
Field::double

Definition at line 112 of file Field.h.

Field::int16

Definition at line 114 of file Field.h.

Field::int32

Definition at line 115 of file Field.h.

Field::int64

Definition at line 116 of file Field.h.

Field::int8

Definition at line 113 of file Field.h.

bool Field::mIsRawValue
private

flag whether we have native data (from prepared statements) or not

Definition at line 172 of file Field.h.

Referenced by GetBinary(), GetCppString(), GetString(), SetBinaryValue(), SetValue(), and ~Field().

void* Field::mRawValue

Definition at line 162 of file Field.h.

Referenced by GetBinary(), GetCppString(), GetString(), SetBinaryValue(), and ~Field().

size_t Field::mRawValueSize

Definition at line 163 of file Field.h.

Referenced by GetBinary(), and SetBinaryValue().

enum_field_types Field::mType
private

The mysql type of this field.

Definition at line 171 of file Field.h.

Referenced by GetCppString(), GetString(), GetType(), SetBinaryValue(), and SetType().

const char* Field::mValue

data from regular query, we don't own this data, mysql_free_result will free these

Definition at line 168 of file Field.h.

Referenced by GetCppString(), and GetString().

Field::MYSQL_TYPE_DOUBLE

Definition at line 112 of file Field.h.

Field::MYSQL_TYPE_LONG

Definition at line 115 of file Field.h.

Field::MYSQL_TYPE_LONGLONG

Definition at line 116 of file Field.h.

Field::MYSQL_TYPE_SHORT

Definition at line 114 of file Field.h.

Field::MYSQL_TYPE_TINY

Definition at line 113 of file Field.h.

Field::uint16

Definition at line 118 of file Field.h.

Field::uint32

Definition at line 119 of file Field.h.

Field::uint64

Definition at line 120 of file Field.h.

Field::uint8

Definition at line 117 of file Field.h.


The documentation for this class was generated from the following file: