QNetworkString Namespace Reference


Detailed Description

collection of utility functions used with network strings

Author:
sergio.didomizio@ge.infn.it The purpose of the functions contained in this namespace is to encapsulate the details of the network protocol used in client/server communication


Functions

void FixNewLines (std::string &message)
 substitute all newline characters with special token '$'.
void RestoreNewLines (std::string &message)
 restore newline characters in network message
bool SplitCommandAndParams (std::string cmdStr, std::string &cmdName, std::string &params)
 split command string into command name (and possible modifier) and parameters string
bool GetParameter (const std::string &srcString, const std::string &parName, std::string &parVal, const char separator=DEFAULT_SEPARATOR)
 extract parameter from network string
bool GetIntParameter (const std::string &srcString, const std::string &parName, int &val, const char separator=DEFAULT_SEPARATOR)
 get integer parameter from network string
bool GetCharParameter (const std::string &srcString, const std::string &parName, char &val, const char separator=DEFAULT_SEPARATOR)
 get char parameter from network string


Function Documentation

void QNetworkString::FixNewLines ( std::string &  message  ) 

substitute all newline characters with special token '$'.

Parameters:
message string to be parsed

References QStringHandler::Escape(), and QStringHandler::Replace().

Referenced by QNwMessageBuilder::BuildMessage().

bool QNetworkString::GetCharParameter ( const std::string &  srcString,
const std::string &  parName,
char &  val,
const char  separator = DEFAULT_SEPARATOR 
)

get char parameter from network string

Parameters:
srcString string from which parameter is to be extracted
parName parameter to be extracted
val destination char
Returns:
true on success, false on failure
this is a wrapper function that calls in sequence GetParameter() and GetChar() functions

References GetParameter(), and QStringHandler::StringToChar().

bool QNetworkString::GetIntParameter ( const std::string &  srcString,
const std::string &  parName,
int &  val,
const char  separator = DEFAULT_SEPARATOR 
)

get integer parameter from network string

Parameters:
srcString string from which parameter is to be extracted
parName parameter to be extracted
val destination int
separator character used in srcString to separate different parName=parVal pieces (defaults to DEFAULT_SEPARATOR)
Returns:
true on success, false on failure
this is a wrapper function that calls in sequence GetParameter() and GetInt() functions

References GetParameter(), and QStringHandler::StringToInt().

bool QNetworkString::GetParameter ( const std::string &  srcString,
const std::string &  parName,
std::string &  parVal,
const char  separator = DEFAULT_SEPARATOR 
)

extract parameter from network string

Parameters:
srcString string from which parameter is to be extracted
parName parameter to be extracted
parVal string filled with value of requested parameter
separator character used in srcString to separate different parName=parVal pieces (defaults to DEFAULT_SEPARATOR)
Returns:
true on success, false on failure. In case of failure the value of parVal is undefined.
srcString must follow the syntax: par1=val1 par2=val2 ... where the space between different par=val fields can be replaced with the specified separator

Referenced by GetCharParameter(), and GetIntParameter().

void QNetworkString::RestoreNewLines ( std::string &  message  ) 

restore newline characters in network message

Parameters:
message string to be parsed

References QStringHandler::Replace(), and QStringHandler::UnEscape().

Referenced by QBaseCmdParser::ParseParameters(), and QBaseClient::ProcessAnswer().

bool QNetworkString::SplitCommandAndParams ( std::string  cmdStr,
std::string &  cmdName,
std::string &  params 
)

split command string into command name (and possible modifier) and parameters string

Parameters:
cmdStr source string to be parsed
cmdName is filled with command name (and possibly modifier)
params is filled with the parameters part of the command string
Returns:
true on success, false if parsing fails. In case of failure the content of cmdName and params is not modified
The expected syntax in cmdString is command[/modifier] params
Therefore this method simply splits cmdStr into two parts wher the first space is found.
This function fails only if cmdStr contains only spaces.
This function removes trailing spaces at the beginning and at the end of the cmdName and params strings.

References QStringHandler::DoubleSwallowSpaces().

Referenced by QBaseCmdParser::Parse(), and QBaseClient::ProcessAnswer().


Generated on Tue Nov 16 10:50:09 2010 for CUORE Software by  doxygen 1.5.6