Tools Class Reference

Class that provides tools for programmation. More...

#include <tools.h>

List of all members.

Public Member Functions

 Tools ()
 Constructor.
 ~Tools ()
 Destructor.

Static Public Member Functions

static string asciiToHexa (string)
 Convert an ascii string to an hexadecimal string.
static string hexaToAscii (string)
 Convert an hexadecimal string to an ascii string.
static string intToStr (int)
 Convert a int to a string.
static string doubleToStr (double)
 Convert a double to a string.
static double strToDouble (string)
 Convert a string to a double.
static int strToInt (string)
 Convert a string to a int.
static unsigned int strToUnsignedInt (string)
 Convert a string to an unsigned int.
static unsigned int strtimeToSeconds (string)
 Convert a string time to seconds.
static string to_lower (string)
 Convert a string to lower case.
static string to_upper (string)
 Convert a string to upper case.
static int random (int min, int max)
 Give a random number.
static string vectorToString (vector< string >, string, unsigned int start=0)
 Convert a vector to a string.
static vector< string > stringToVector (string, string, unsigned int start=0)
 Convert a string to a vector.
static vector< string > gatherVectorElements (vector< string >, string, unsigned int)
 Gather vector elements.
static string escapeChar (string, char)
 Escape a char in a string.
static void log (string, string, bool timestamp=true, bool truncate=false)
 Log a string in a file.
static string urlencode (string)
 Encode a string to a URL format.
static string clearAccents (string)
 Clear accents from a sentence.
static string cleanHTML (string)
 Clean HTML code in a string.
static bool isInVector (vector< string >, string)
 Tell if a string is in a vector.
static void delStrFromVector (vector< string > *, string)
 Withdraw a string from a vector.
static string parseQ3Colors (string)
 Parse Quake colors from a string.
static bool ircMaskMatch (string, string)
 Tell if an irc host match to a mask.
static int masksMatch (char *, char *)
 Tell if two masks match.
static bool copyFile (string, string)
 Copy a file.


Detailed Description

Class that provides tools for programmation.

Provide different static methods for regular treatment. Those methods can be used everywhere in the code an doesn't need an object instantiation.

Definition at line 47 of file tools.h.


Constructor & Destructor Documentation

Tools::Tools (  ) 

Constructor.

Constructor

Definition at line 36 of file tools.cpp.

Tools::~Tools (  ) 

Destructor.

Destructor

Definition at line 44 of file tools.cpp.


Member Function Documentation

string Tools::asciiToHexa ( string  asciiStr  )  [static]

Convert an ascii string to an hexadecimal string.

Convert an ascii string to an hexadecimal string

Parameters:
asciiStr String to convert
Returns:
Hexadecimal string

Definition at line 54 of file tools.cpp.

string Tools::cleanHTML ( string  str  )  [static]

Clean HTML code in a string.

Clean all HTML chars in a string : Replace accents marks and delete font marks

Parameters:
str String with no html tags

Definition at line 455 of file tools.cpp.

Referenced by danstonchat(), BZRH::getBugInfos(), BZRH::searchBugs(), tele(), and trad().

string Tools::clearAccents ( string  str  )  [static]

Clear accents from a sentence.

Clear accents from a sentence

Parameters:
str String to clear
Returns:
String with no accents

Definition at line 433 of file tools.cpp.

Referenced by danstonchat(), and tele().

static bool Tools::copyFile ( string  ,
string   
) [static]

Copy a file.

void Tools::delStrFromVector ( vector< string > *  v,
string  str 
) [static]

Withdraw a string from a vector.

Delete a string from a vector

Parameters:
v Vector<string> pointer witch must be delete a string
str string to delete

Definition at line 102 of file tools.cpp.

Referenced by unautoop(), unautovoice(), unprotectmodes(), and unprotecttopic().

string Tools::doubleToStr ( double  number  )  [static]

Convert a double to a string.

Convert a double to a string

Parameters:
number double number to convert
Returns:
String convertion result

Definition at line 134 of file tools.cpp.

Referenced by Lamoule::get5first(), Lamoule::getInfosPlayer(), and player().

string Tools::escapeChar ( string  str,
char  c 
) [static]

Escape a char in a string.

Escape a char in a string

Parameters:
str String containing chars
c Char to escape in the string
Returns:
Initial string with escaped chars

Definition at line 358 of file tools.cpp.

vector< string > Tools::gatherVectorElements ( vector< string >  v,
string  separator,
unsigned int  length 
) [static]

Gather vector elements.

Gather vector's elements to make a vector with less elements

Parameters:
v vector for witch gather elements
separator separator for elements
length vector's element length
Returns:
The new vector with gathered elements

Definition at line 336 of file tools.cpp.

Referenced by banlist(), chanlev(), commandsStatus(), listlibs(), listmodules(), onEndOfMOTD(), and superadminlist().

string Tools::hexaToAscii ( string  hexaStr  )  [static]

Convert an hexadecimal string to an ascii string.

Convert an hexadecimal string to an ascii string

Parameters:
hexaStr String to convert
Returns:
Ascii string

Definition at line 68 of file tools.cpp.

string Tools::intToStr ( int  number  )  [static]

bool Tools::ircMaskMatch ( string  request,
string  mask 
) [static]

Tell if an irc host match to a mask.

Check if an IRC host match to a mask

Parameters:
request Irc host
mask mask
Returns:
true if host match to regex, else false

Definition at line 521 of file tools.cpp.

Referenced by banmask(), Admin::getUserLevel(), Moderation::isBanned(), Ignore::isIgnored(), and Admin::isSuperAdmin().

bool Tools::isInVector ( vector< string >  v,
string  str 
) [static]

Tell if a string is in a vector.

Check if a string is in a vector string

Parameters:
v vector to check
str string to check
Returns:
true if present, else false

Definition at line 83 of file tools.cpp.

Referenced by autoop(), autovoice(), LogFactory::cleanLogs(), Moderation::clearOutBans(), Admin::commandOK(), ConfigurationFile::getValue(), LogFactory::hasToBeLogged(), joinHandler(), launchSurvey(), modeHandlerProtect(), protectmodes(), protecttopic(), Plugin::requires(), topicHandler(), unautoop(), unautovoice(), unprotectmodes(), unprotecttopic(), and Survey::vote().

void Tools::log ( string  fileName,
string  str,
bool  timestamp = true,
bool  truncate = false 
) [static]

Log a string in a file.

Log an event in a file, with timestamp

Parameters:
fileName Log file
str Log event
timestamp tell if a timestamp must appear in the log line
truncate tell if the file must be truncated

Definition at line 383 of file tools.cpp.

Referenced by BotKernel::run().

int Tools::masksMatch ( char *  str1,
char *  str2 
) [static]

Tell if two masks match.

Check if two masks match Thanks to "BigBourin" (fr) for this function

Parameters:
str1 first mask
str2 second mask
Returns:
1 if match, else 0

Definition at line 536 of file tools.cpp.

Referenced by Admin::getMaskLevel(), and Admin::maskIsSuperAdmin().

string Tools::parseQ3Colors ( string  raw  )  [static]

Parse Quake colors from a string.

Strip all Quake III Arena color codes from a string

Parameters:
raw String with q3 color codes
Returns:
String with no q3 colors

Definition at line 489 of file tools.cpp.

Referenced by GameServer::parseQ3infos(), GameServer::parseWSWinfos(), q3(), and warsow().

int Tools::random ( int  min,
int  max 
) [static]

Give a random number.

Generate a random int between a min and a max value

Parameters:
min Minimum random value
max Maximum random value
Returns:
radom int

Definition at line 268 of file tools.cpp.

Referenced by Lamoule::generateScore(), Magic8Ball::getRandomAnswer(), Quotes::getRandomQuote(), lamoule(), randomKick(), and Quotes::searchQuote().

vector< string > Tools::stringToVector ( string  str,
string  separator,
unsigned int  start = 0 
) [static]

Convert a string to a vector.

Split a string in elements inserted in a vector

Parameters:
str String to split
separator Delimitor for string
start Index of the first element to split
Returns:
A vector containing strings

Definition at line 304 of file tools.cpp.

Referenced by autoop(), autovoice(), danstonchat(), LogFactory::getLoggedChannels(), Fedorafr::getWikiLinks(), LogFactory::hasToBeLogged(), hl(), joinHandler(), launchSurvey(), ConfigurationFile::load(), FedoraProject::loadFasFile(), BotKernel::loadPlugins(), modeHandlerProtect(), onEndOfMOTD(), GameServer::parseQ3infos(), GameServer::parseWSWinfos(), protectmodes(), protecttopic(), q3(), BotKernel::run(), Message::setMessage(), topicHandler(), unautoop(), unautovoice(), unprotectmodes(), unprotecttopic(), and warsow().

unsigned int Tools::strtimeToSeconds ( string  strtime  )  [static]

Convert a string time to seconds.

Convert a 'string time' to seconds. Exemple : 2d6h2m1s = 194521 seconds d for 'days' h for 'hours' m for 'minuts' s for 'seconds'

Parameters:
strtime String time to convert
Returns:
seconds convertion

Definition at line 211 of file tools.cpp.

References strToUnsignedInt().

Referenced by addad(), addIgnore(), addtempsuperadmin(), ban(), banmask(), launchSurvey(), and slapme().

double Tools::strToDouble ( string  str  )  [static]

Convert a string to a double.

Convert a string to a double if operation fails, result is 0.0

Parameters:
str string to convert
Returns:
Double convertion result

Definition at line 147 of file tools.cpp.

Referenced by Lamoule::get5first(), Lamoule::getInfosPlayer(), Lamoule::increaseScore(), player(), and Lamoule::sort().

int Tools::strToInt ( string  str  )  [static]

unsigned int Tools::strToUnsignedInt ( string  str  )  [static]

Convert a string to an unsigned int.

Convert a string to an unsigned int if operation fails, result is 0

Parameters:
str string to convert
Returns:
Int convertion result

Definition at line 187 of file tools.cpp.

Referenced by BotKernel::addCountDown(), bannedHandler(), danstonchat(), getMyFirstNick(), launchSurvey(), rejoinChan(), RemoteControl::RemoteControl(), BZRH::searchBugs(), secondaryNick(), strtimeToSeconds(), and topicInfos().

string Tools::to_lower ( string  str  )  [static]

string Tools::to_upper ( string  str  )  [static]

Convert a string to upper case.

Put an entire string to upper case

Parameters:
str string to convert
Returns:
string converted to upper case

Definition at line 252 of file tools.cpp.

string Tools::urlencode ( string  str  )  [static]

Encode a string to a URL format.

Convert special chars from a string to be compatible to URL format

Parameters:
str String to encode
Returns:
String compatible to URL format

Definition at line 411 of file tools.cpp.

Referenced by BZRH::getBugInfos(), planet(), BZRH::searchBugs(), trad(), FedoraProject::whoowns(), and wiki().

string Tools::vectorToString ( vector< string >  vec,
string  separator,
unsigned int  start = 0 
) [static]

Convert a vector to a string.

Convert a vector<string> to a string

Parameters:
vec Vector to convert
separator Elements separator in generated string
start Indice for starting conversion
Returns:
A string containing vector values

Definition at line 280 of file tools.cpp.

Referenced by addad(), addQuote(), ban(), banmask(), bzsearch(), fas(), greplog(), hl(), kick(), kickHandler(), launchSurvey(), leaveChannel(), notice(), partHandler(), planet(), privmsgHandler(), q3(), quitHandler(), raw(), searchQuote(), sendHandler(), slapUser(), tell(), topic(), topicHandler(), topicJoin(), trad(), unautoop(), unautovoice(), unprotectmodes(), unprotecttopic(), warsow(), and wiki().


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

Generated on Sun Aug 16 15:29:00 2009 for trustyRC by  doxygen 1.5.8