copasi API  0.1
Defines | Functions
copasi/utilities/utility.h File Reference
#include <string>
#include <string.h>
#include <stdarg.h>

Go to the source code of this file.

Defines

#define INITIALTEXTSIZE   1024

Functions

std::string ISODateTime (tm *pTime)
std::string LocalTimeStamp ()
std::string UTCTimeStamp ()
bool isNumber (const std::string &str)
std::string StringPrint (const char *format,...)
std::string unQuote (const std::string &name)
std::string quote (const std::string &name, const std::string &additionalEscapes="")
void FixSName (const std::string &original, std::string &fixed)
void FixXHTML (const std::string &original, std::string &fixed)
template<class CType >
CType toEnum (const char *attribute, const char **enumNames, const CType &enumDefault)
std::string utf8ToLocale (const std::string &utf8)
std::string localeToUtf8 (const std::string &locale)
double strToDouble (const char *str, char const **pTail=NULL)

Define Documentation

#define INITIALTEXTSIZE   1024

Function Documentation

void FixSName ( const std::string &  original,
std::string &  fixed 
)
void FixXHTML ( const std::string &  original,
std::string &  fixed 
)
bool isNumber ( const std::string &  str)

Check whether the given string represents a number

Parameters:
conststd::string & str
Returns:
bool isNumber
std::string ISODateTime ( tm *  pTime)

Returns the time pointed to by pTime in ISO format

std::string localeToUtf8 ( const std::string &  locale)

Convert a string in the local used code page to utf8 This only has an effect on Windows as utf8 is the local code page everywhere else

Parameters:
conststd::string & locale
Returns:
std::string utf8
std::string LocalTimeStamp ( )

Returns the current local time in ISO format

std::string quote ( const std::string &  name,
const std::string &  additionalEscapes = "" 
)

Surround a name with quotes if the name contains a space or double quote else the name is returned unmodified. In the quoted name " and \ are escaped. The parameter additionalEscapes forces quotes around names containing any of the character in the parameter.

Parameters:
conststd::string & name
conststd::string & additionalEscapes (default: "")
Returns:
std::string quote
std::string StringPrint ( const char *  format,
  ... 
)

sprintf like function for strings

Parameters:
const char *format sprintf like format string
...
Returns:
"string"
double strToDouble ( const char *  str,
char const **  pTail = NULL 
)

Convert a character sequence to a double

Parameters:
constchar * str
charconst ** pTail (default: NULL)
Returns:
double
template<class CType >
CType toEnum ( const char *  attribute,
const char **  enumNames,
const CType &  enumDefault 
)

Convert an attribute to enum. If attribute is NULL or no matching name is found the parameter enumDefault is returned. Note: enumNames must be zero terminated.

Parameters:
constchar * attribute
constchar ** enumNames
constCType & enumDefault
Returns:
CType enum
std::string unQuote ( const std::string &  name)

Unesacape a quoted name. If the name is surrounded by quotes these are removed and included escape sequences '\.' are reduced to '.' else the name is returned unmodified.

Parameters:
conststd::string & name
Returns:
std::string unQuote
std::string UTCTimeStamp ( )

Returns the current time in ISO format

std::string utf8ToLocale ( const std::string &  utf8)

Convert a utf8 string to the local used code page This only has an effect on Windows as utf8 is the local code page everywhere else

Parameters:
conststd::string & utf8
Returns:
std::string locale
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines