adchpp::AdcCommand Class Reference

#include <AdcCommand.h>

Inheritance diagram for adchpp::AdcCommand:
Inheritance graph
[legend]
Collaboration diagram for adchpp::AdcCommand:
Collaboration graph
[legend]

List of all members.

Classes

struct  Type

Public Types

enum  Error {
  ERROR_GENERIC = 0, ERROR_HUB_GENERIC = 10, ERROR_HUB_FULL = 11, ERROR_HUB_DISABLED = 12, ERROR_LOGIN_GENERIC = 20, ERROR_NICK_INVALID = 21,
  ERROR_NICK_TAKEN = 22, ERROR_BAD_PASSWORD = 23, ERROR_CID_TAKEN = 24, ERROR_COMMAND_ACCESS = 25, ERROR_REGGED_ONLY = 26, ERROR_INVALID_PID = 27,
  ERROR_BANNED_GENERIC = 30, ERROR_PERM_BANNED = 31, ERROR_TEMP_BANNED = 32, ERROR_PROTOCOL_GENERIC = 40, ERROR_PROTOCOL_UNSUPPORTED = 41, ERROR_CONNECT_FAILED = 42,
  ERROR_INF_MISSING = 43, ERROR_BAD_STATE = 44, ERROR_FEATURE_MISSING = 45, ERROR_BAD_IP = 46, ERROR_NO_HUB_HASH = 47, ERROR_TRANSFER_GENERIC = 50,
  ERROR_FILE_NOT_AVAILABLE = 51, ERROR_FILE_PART_NOT_AVAILABLE = 52, ERROR_SLOTS_FULL = 53, ERROR_NO_CLIENT_HASH = 54
}
enum  Priority { PRIORITY_NORMAL, PRIORITY_LOW, PRIORITY_IGNORE }
enum  Severity { SEV_SUCCESS = 0, SEV_RECOVERABLE = 1, SEV_FATAL = 2 }

Public Member Functions

 AdcCommand (const BufferPtr &buffer_) throw (ParseException)
 AdcCommand (const std::string &aLine) throw (ParseException)
 AdcCommand (uint32_t cmd, char aType=TYPE_INFO, uint32_t aFrom=HUB_SID)
ADCHPP_DLL AdcCommand (Severity sev, Error err, const std::string &desc, char aType=TYPE_INFO)
ADCHPP_DLL AdcCommand ()
AdcCommandaddParam (const std::string &name, const std::string &value)
AdcCommandaddParam (const std::string &param)
 C (RNT, 'R','N','T')
 C (NAT, 'N','A','T')
 C (CMD, 'C','M','D')
 C (SID, 'S','I','D')
 C (SND, 'S','N','D')
 C (GFI, 'G','F','I')
 C (GET, 'G','E','T')
 C (QUI, 'Q','U','I')
 C (PAS, 'P','A','S')
 C (GPA, 'G','P','A')
 C (RCM, 'R','C','M')
 C (CTM, 'C','T','M')
 C (RES, 'R','E','S')
 C (SCH, 'S','C','H')
 C (MSG, 'M','S','G')
 C (INF, 'I','N','F')
 C (STA, 'S','T','A')
 C (SUP, 'S','U','P')
ADCHPP_DLL bool delParam (const char *name, size_t start)
ADCHPP_DLL const BufferPtrgetBuffer () const
uint32_t getCommand () const
const std::string & getFeatures () const
std::string getFourCC () const
uint32_t getFrom () const
ADCHPP_DLL bool getParam (const char *name, size_t start, std::string &ret) const
 Return a named parameter where the name is a two-letter code.
const std::string & getParam (size_t n) const
const StringListgetParameters () const
StringListgetParameters ()
Priority getPriority () const
uint32_t getTo () const
char getType () const
ADCHPP_DLL bool hasFlag (const char *name, size_t start) const
bool operator== (uint32_t aCmd) const
ADCHPP_DLL void parse (const char *buf, size_t len) throw (ParseException)
void parse (const std::string &str) throw (ParseException)
void resetBuffer ()
void setFrom (uint32_t aFrom)
void setPriority (Priority priority_)
void setTo (uint32_t aTo)
ADCHPP_DLL std::string toString () const

Static Public Member Functions

static void appendSID (std::string &str, uint32_t aSID)
static ADCHPP_DLL void escape (const std::string &s, std::string &out)
static std::string fromField (const uint16_t aField)
static std::string fromFourCC (uint32_t x)
static std::string fromSID (const uint32_t aSID)
static uint32_t toCMD (const char *str)
static uint32_t toCMD (uint8_t a, uint8_t b, uint8_t c)
static uint16_t toField (const char *x)
static uint32_t toFourCC (const char *x)
static uint32_t toSID (const std::string &aSID)

Static Public Attributes

static const uint32_t HUB_SID = static_cast<uint32_t>(-1)
static const uint32_t INVALID_SID = static_cast<uint32_t>(-2)
static const char TYPE_BROADCAST = 'B'
static const char TYPE_CLIENT = 'C'
static const char TYPE_DIRECT = 'D'
static const char TYPE_ECHO = 'E'
static const char TYPE_FEATURE = 'F'
static const char TYPE_HUB = 'H'
static const char TYPE_INFO = 'I'
static const char TYPE_UDP = 'U'

Private Attributes

union {
   uint8_t   cmd [4]
   char   cmdChar [4]
   uint32_t   cmdInt
}; 
BufferPtr buffer
std::string features
uint32_t from
StringList parameters
Priority priority
uint32_t to
char type

Detailed Description

Definition at line 31 of file AdcCommand.h.


Member Enumeration Documentation

Enumerator:
ERROR_GENERIC 
ERROR_HUB_GENERIC 
ERROR_HUB_FULL 
ERROR_HUB_DISABLED 
ERROR_LOGIN_GENERIC 
ERROR_NICK_INVALID 
ERROR_NICK_TAKEN 
ERROR_BAD_PASSWORD 
ERROR_CID_TAKEN 
ERROR_COMMAND_ACCESS 
ERROR_REGGED_ONLY 
ERROR_INVALID_PID 
ERROR_BANNED_GENERIC 
ERROR_PERM_BANNED 
ERROR_TEMP_BANNED 
ERROR_PROTOCOL_GENERIC 
ERROR_PROTOCOL_UNSUPPORTED 
ERROR_CONNECT_FAILED 
ERROR_INF_MISSING 
ERROR_BAD_STATE 
ERROR_FEATURE_MISSING 
ERROR_BAD_IP 
ERROR_NO_HUB_HASH 
ERROR_TRANSFER_GENERIC 
ERROR_FILE_NOT_AVAILABLE 
ERROR_FILE_PART_NOT_AVAILABLE 
ERROR_SLOTS_FULL 
ERROR_NO_CLIENT_HASH 

Definition at line 38 of file AdcCommand.h.

Enumerator:
PRIORITY_NORMAL 

Default priority, command will be sent out normally.

PRIORITY_LOW 

Low priority, command will only be sent if connection isn't saturated.

PRIORITY_IGNORE 

Ignore, command will not be put in send queue.

Definition at line 75 of file AdcCommand.h.

Enumerator:
SEV_SUCCESS 
SEV_RECOVERABLE 
SEV_FATAL 

Definition at line 69 of file AdcCommand.h.


Constructor & Destructor Documentation

adchpp::AdcCommand::AdcCommand (  ) 

Definition at line 39 of file AdcCommand.cpp.

adchpp::AdcCommand::AdcCommand ( Severity  sev,
Error  err,
const std::string &  desc,
char  aType = TYPE_INFO 
) [explicit]

Definition at line 41 of file AdcCommand.cpp.

References addParam(), and adchpp::Util::toString().

Here is the call graph for this function:

adchpp::AdcCommand::AdcCommand ( uint32_t  cmd,
char  aType = TYPE_INFO,
uint32_t  aFrom = HUB_SID 
) [inline, explicit]

Definition at line 132 of file AdcCommand.h.

adchpp::AdcCommand::AdcCommand ( const std::string &  aLine  )  throw (ParseException) [inline, explicit]

Definition at line 133 of file AdcCommand.h.

References parse().

Here is the call graph for this function:

adchpp::AdcCommand::AdcCommand ( const BufferPtr buffer_  )  throw (ParseException) [inline, explicit]

Definition at line 134 of file AdcCommand.h.

References buffer, and parse().

Here is the call graph for this function:


Member Function Documentation

AdcCommand& adchpp::AdcCommand::addParam ( const std::string &  name,
const std::string &  value 
) [inline]

Definition at line 150 of file AdcCommand.h.

References addParam().

Here is the call graph for this function:

AdcCommand& adchpp::AdcCommand::addParam ( const std::string &  param  )  [inline]

Definition at line 145 of file AdcCommand.h.

References parameters.

Referenced by AdcCommand(), addParam(), and adchpp::Entity::getSUP().

Here is the caller graph for this function:

static void adchpp::AdcCommand::appendSID ( std::string &  str,
uint32_t  aSID 
) [inline, static]

Definition at line 119 of file AdcCommand.h.

Referenced by toString().

Here is the caller graph for this function:

adchpp::AdcCommand::C ( RNT  ,
'R'  ,
'N'  ,
'T'   
)
adchpp::AdcCommand::C ( NAT  ,
'N'  ,
'A'  ,
'T'   
)
adchpp::AdcCommand::C ( CMD  ,
'C'  ,
'M'  ,
'D'   
)
adchpp::AdcCommand::C ( SID  ,
'S'  ,
'I'  ,
'D'   
)
adchpp::AdcCommand::C ( SND  ,
'S'  ,
'N'  ,
'D'   
)
adchpp::AdcCommand::C ( GFI  ,
'G'  ,
'F'  ,
'I'   
)
adchpp::AdcCommand::C ( GET  ,
'G'  ,
'E'  ,
'T'   
)
adchpp::AdcCommand::C ( QUI  ,
'Q'  ,
'U'  ,
'I'   
)
adchpp::AdcCommand::C ( PAS  ,
'P'  ,
'A'  ,
'S'   
)
adchpp::AdcCommand::C ( GPA  ,
'G'  ,
'P'  ,
'A'   
)
adchpp::AdcCommand::C ( RCM  ,
'R'  ,
'C'  ,
'M'   
)
adchpp::AdcCommand::C ( CTM  ,
'C'  ,
'T'  ,
'M'   
)
adchpp::AdcCommand::C ( RES  ,
'R'  ,
'E'  ,
'S'   
)
adchpp::AdcCommand::C ( SCH  ,
'S'  ,
'C'  ,
'H'   
)
adchpp::AdcCommand::C ( MSG  ,
'M'  ,
'S'  ,
'G'   
)
adchpp::AdcCommand::C ( INF  ,
'I'  ,
'N'  ,
'F'   
)
adchpp::AdcCommand::C ( STA  ,
'S'  ,
'T'  ,
'A'   
)
adchpp::AdcCommand::C ( SUP  ,
'S'  ,
'U'  ,
'P'   
)
bool adchpp::AdcCommand::delParam ( const char *  name,
size_t  start 
)

Definition at line 239 of file AdcCommand.cpp.

References getParameters(), resetBuffer(), and toField().

Here is the call graph for this function:

void adchpp::AdcCommand::escape ( const std::string &  s,
std::string &  out 
) [static]

Definition at line 46 of file AdcCommand.cpp.

Referenced by toString().

Here is the caller graph for this function:

static std::string adchpp::AdcCommand::fromField ( const uint16_t  aField  )  [inline, static]

Definition at line 125 of file AdcCommand.h.

Referenced by adchpp::Entity::getAllFields().

Here is the caller graph for this function:

static std::string adchpp::AdcCommand::fromFourCC ( uint32_t  x  )  [inline, static]

Definition at line 128 of file AdcCommand.h.

Referenced by adchpp::Entity::getSUP(), and adchpp::Entity::getSupportList().

Here is the caller graph for this function:

static std::string adchpp::AdcCommand::fromSID ( const uint32_t  aSID  )  [inline, static]
const BufferPtr & adchpp::AdcCommand::getBuffer (  )  const

Definition at line 186 of file AdcCommand.cpp.

References buffer, and toString().

Referenced by adchpp::Entity::getINF(), adchpp::Entity::getSUP(), and adchpp::Entity::send().

Here is the call graph for this function:

Here is the caller graph for this function:

uint32_t adchpp::AdcCommand::getCommand (  )  const [inline]

Definition at line 138 of file AdcCommand.h.

References cmdInt.

Referenced by adchpp::CommandHandler< ClientManager >::dispatch(), adchpp::PluginManager::CommandDispatch::operator()(), and adchpp::Entity::updateFields().

Here is the caller graph for this function:

const std::string& adchpp::AdcCommand::getFeatures (  )  const [inline]

Definition at line 160 of file AdcCommand.h.

References features.

std::string adchpp::AdcCommand::getFourCC (  )  const [inline]

Definition at line 140 of file AdcCommand.h.

References cmd, and type.

uint32_t adchpp::AdcCommand::getFrom (  )  const [inline]

Definition at line 176 of file AdcCommand.h.

References from.

bool adchpp::AdcCommand::getParam ( const char *  name,
size_t  start,
std::string &  ret 
) const

Return a named parameter where the name is a two-letter code.

Definition at line 229 of file AdcCommand.cpp.

References getParameters(), and toField().

Here is the call graph for this function:

const std::string& adchpp::AdcCommand::getParam ( size_t  n  )  const [inline]

Definition at line 154 of file AdcCommand.h.

References adchpp::Util::emptyString, and getParameters().

Here is the call graph for this function:

const StringList& adchpp::AdcCommand::getParameters (  )  const [inline]

Definition at line 142 of file AdcCommand.h.

References parameters.

StringList& adchpp::AdcCommand::getParameters (  )  [inline]

Definition at line 141 of file AdcCommand.h.

References parameters.

Referenced by delParam(), getParam(), hasFlag(), adchpp::PluginManager::CommandDispatch::operator()(), toString(), and adchpp::Entity::updateFields().

Here is the caller graph for this function:

Priority adchpp::AdcCommand::getPriority (  )  const [inline]

Definition at line 179 of file AdcCommand.h.

References priority.

uint32_t adchpp::AdcCommand::getTo (  )  const [inline]

Definition at line 174 of file AdcCommand.h.

References to.

char adchpp::AdcCommand::getType (  )  const [inline]

Definition at line 139 of file AdcCommand.h.

References type.

bool adchpp::AdcCommand::hasFlag ( const char *  name,
size_t  start 
) const

Definition at line 250 of file AdcCommand.cpp.

References getParameters(), and toField().

Here is the call graph for this function:

bool adchpp::AdcCommand::operator== ( uint32_t  aCmd  )  const [inline]

Definition at line 168 of file AdcCommand.h.

References cmdInt.

void adchpp::AdcCommand::parse ( const char *  buf,
size_t  len 
) throw (ParseException)

Definition at line 59 of file AdcCommand.cpp.

References adchpp::Text::validateUtf8().

Here is the call graph for this function:

void adchpp::AdcCommand::parse ( const std::string &  str  )  throw (ParseException) [inline]

Definition at line 136 of file AdcCommand.h.

References parse().

Referenced by AdcCommand(), and parse().

Here is the call graph for this function:

Here is the caller graph for this function:

void adchpp::AdcCommand::resetBuffer (  )  [inline]

Definition at line 158 of file AdcCommand.h.

References buffer.

Referenced by delParam().

Here is the caller graph for this function:

void adchpp::AdcCommand::setFrom ( uint32_t  aFrom  )  [inline]

Definition at line 177 of file AdcCommand.h.

References from.

void adchpp::AdcCommand::setPriority ( Priority  priority_  )  [inline]

Definition at line 180 of file AdcCommand.h.

References priority.

Referenced by adchpp::PluginManager::CommandDispatch::operator()().

Here is the caller graph for this function:

void adchpp::AdcCommand::setTo ( uint32_t  aTo  )  [inline]

Definition at line 175 of file AdcCommand.h.

References to.

static uint32_t adchpp::AdcCommand::toCMD ( const char *  str  )  [inline, static]

Definition at line 122 of file AdcCommand.h.

References toCMD().

Referenced by toCMD().

Here is the call graph for this function:

Here is the caller graph for this function:

static uint32_t adchpp::AdcCommand::toCMD ( uint8_t  a,
uint8_t  b,
uint8_t  c 
) [inline, static]

Definition at line 121 of file AdcCommand.h.

static uint16_t adchpp::AdcCommand::toField ( const char *  x  )  [inline, static]

Definition at line 124 of file AdcCommand.h.

Referenced by delParam(), adchpp::Entity::getField(), getParam(), adchpp::Entity::hasField(), hasFlag(), and adchpp::Entity::setField().

Here is the caller graph for this function:

static uint32_t adchpp::AdcCommand::toFourCC ( const char *  x  )  [inline, static]
static uint32_t adchpp::AdcCommand::toSID ( const std::string &  aSID  )  [inline, static]

Definition at line 117 of file AdcCommand.h.

string adchpp::AdcCommand::toString (  )  const

Definition at line 193 of file AdcCommand.cpp.

References appendSID(), buffer, cmdChar, escape(), features, from, getParameters(), to, type, TYPE_BROADCAST, TYPE_DIRECT, TYPE_ECHO, and TYPE_FEATURE.

Referenced by adchpp::CommandHandler< ClientManager >::dispatch(), and getBuffer().

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

union { ... } [private]

Definition at line 186 of file AdcCommand.h.

Referenced by AdcCommand(), getBuffer(), resetBuffer(), and toString().

Definition at line 190 of file AdcCommand.h.

Referenced by getFourCC().

Definition at line 189 of file AdcCommand.h.

Referenced by toString().

Definition at line 191 of file AdcCommand.h.

Referenced by getCommand(), and operator==().

std::string adchpp::AdcCommand::features [private]

Definition at line 184 of file AdcCommand.h.

Referenced by getFeatures(), and toString().

uint32_t adchpp::AdcCommand::from [private]

Definition at line 195 of file AdcCommand.h.

Referenced by getFrom(), setFrom(), and toString().

const uint32_t adchpp::AdcCommand::HUB_SID = static_cast<uint32_t>(-1) [static]
const uint32_t adchpp::AdcCommand::INVALID_SID = static_cast<uint32_t>(-2) [static]

Definition at line 115 of file AdcCommand.h.

Referenced by adchpp::ClientManager::getEntity().

Definition at line 183 of file AdcCommand.h.

Referenced by addParam(), and getParameters().

Definition at line 194 of file AdcCommand.h.

Referenced by getPriority(), and setPriority().

uint32_t adchpp::AdcCommand::to [private]

Definition at line 196 of file AdcCommand.h.

Referenced by getTo(), setTo(), and toString().

char adchpp::AdcCommand::type [private]

Definition at line 197 of file AdcCommand.h.

Referenced by getFourCC(), getType(), and toString().

const char adchpp::AdcCommand::TYPE_BROADCAST = 'B' [static]
const char adchpp::AdcCommand::TYPE_CLIENT = 'C' [static]

Definition at line 82 of file AdcCommand.h.

const char adchpp::AdcCommand::TYPE_DIRECT = 'D' [static]
const char adchpp::AdcCommand::TYPE_ECHO = 'E' [static]
const char adchpp::AdcCommand::TYPE_FEATURE = 'F' [static]
const char adchpp::AdcCommand::TYPE_HUB = 'H' [static]

Definition at line 87 of file AdcCommand.h.

Referenced by adchpp::ClientManager::onReceive().

const char adchpp::AdcCommand::TYPE_INFO = 'I' [static]

Definition at line 86 of file AdcCommand.h.

Referenced by adchpp::Entity::getINF(), and adchpp::Entity::getSUP().

const char adchpp::AdcCommand::TYPE_UDP = 'U' [static]

Definition at line 88 of file AdcCommand.h.

Generated on Sat Nov 27 23:38:24 2010 for adchpp by  doxygen 1.6.3