COPASI API
4.16.103
|
#include <algorithm>
#include <cmath>
#include <limits>
#include <string>
#include <sstream>
#include <iostream>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "copasi.h"
#include "utility.h"
#include "CCopasiMessage.h"
Go to the source code of this file.
Macros | |
#define | toBeEscaped "\\\"" |
Functions | |
void | FixSName (const std::string &original, std::string &fixed) |
bool | isNumber (const std::string &str) |
std::string | ISODateTime (tm *pTime) |
std::string | LocalTimeStamp () |
std::string | nameToSbmlId (const std::string &name) |
std::string | pointerToString (const void *pVoid) |
std::string | quote (const std::string &name, const std::string &additionalEscapes) |
std::string | StringPrint (const char *format,...) |
bool | stringReplace (std::string &str, const std::string &target, const std::string &replacement) |
void * | stringToPointer (const std::string str) |
double | strToDouble (const char *str, char const **pTail) |
C_INT32 | strToInt (const char *str, char const **pTail) |
unsigned C_INT32 | strToUnsignedInt (const char *str, char const **pTail) |
std::string | unQuote (const std::string &name) |
std::string | UTCTimeStamp () |
#define toBeEscaped "\\\"" |
Referenced by quote().
void FixSName | ( | const std::string & | original, |
std::string & | fixed | ||
) |
Definition at line 188 of file utility.cpp.
bool isNumber | ( | const std::string & | str | ) |
Check whether the given string represents a number
const | std::string & str |
Definition at line 75 of file utility.cpp.
References strToDouble().
Referenced by COptItem::compileLowerBound(), COptItem::compileUpperBound(), ConverterASTNode::ConverterASTNode(), CMetabNameInterface::getDisplayName(), CQFittingItemWidget::loadSelection(), CQFittingItemWidget::saveSelection(), COptItem::setLowerBound(), CQFittingItemWidget::setTableText(), COptItem::setUpperBound(), CQFittingItemWidget::slotCheckLowerInf(), CQFittingItemWidget::slotCheckUpperInf(), CQFittingItemWidget::slotLowerLostFocus(), CQFittingItemWidget::slotStartLostFocus(), CQFittingItemWidget::slotUpperLostFocus(), and CChemEqInterface::writeElement().
std::string ISODateTime | ( | tm * | pTime | ) |
Returns the time pointed to by pTime in ISO format
Definition at line 31 of file utility.cpp.
Referenced by LocalTimeStamp(), and UTCTimeStamp().
std::string LocalTimeStamp | ( | ) |
Returns the current local time in ISO format
Definition at line 53 of file utility.cpp.
References ISODateTime().
Referenced by CCopasiMessage::handler().
std::string nameToSbmlId | ( | const std::string & | name | ) |
Convert a utf8 encoded name to a XmlId
const | std::string & name |
Definition at line 437 of file utility.cpp.
Referenced by CSBMLExporter::createUniqueId().
std::string pointerToString | ( | const void * | pVoid | ) |
Convert a void pointer to a string
const | void * pVoid |
Definition at line 423 of file utility.cpp.
References fatalError.
Referenced by CEvaluationNodeObject::CEvaluationNodeObject(), and CEvaluationNodeObject::setObjectValuePtr().
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.
const | std::string & name |
const | std::string & additionalEscapes (default: "") |
Definition at line 144 of file utility.cpp.
References toBeEscaped.
Referenced by CChemEqInterface::addModifier(), CEvaluationNodeCall::CEvaluationNodeCall(), CEvaluationNodeCall::getBerkeleyMadonnaString(), CEvaluationNodeCall::getCCodeString(), CEvaluationNodeCall::getData(), CMetabNameInterface::getDisplayName(), CEvaluationNodeCall::getDisplayString(), CEvaluationNodeCall::getInfix(), CEvaluationNodeCall::getMMLString(), CEvaluationNodeCall::getXPPString(), CEvaluationNodeCall::setData(), and CMetabNameInterface::splitDisplayName().
std::string StringPrint | ( | const char * | format, |
... | |||
) |
sprintf like function for strings
const char * | format sprintf like format string |
... |
Definition at line 87 of file utility.cpp.
References C_INT32, and INITIALTEXTSIZE.
Referenced by CExperimentSet::addExperiment(), CExperiment::elevateChildren(), CExperimentObjectMap::getDefaultScale(), CExperimentObjectMap::getName(), CExperimentObjectMap::getObjectCN(), CExperimentObjectMap::getRole(), CExperimentObjectMap::getScale(), CCopasiTimeVariable::LL2String(), CQExperimentData::load(), CReaction::loadOld(), CReaction::loadOneRole(), CExperimentObjectMap::setNumCols(), CExperimentObjectMap::setObjectCN(), CExperimentObjectMap::setRole(), CExperimentObjectMap::setScale(), CVersion::setString(), CQExperimentData::slotFileAdd(), and CCopasiXMLParser::ParameterDescriptionElement::start().
bool stringReplace | ( | std::string & | str, |
const std::string & | target, | ||
const std::string & | replacement | ||
) |
Replaces the all occurrences of target string in str with the replacement and returns true if the target string was replaced
std::string | & str |
const | std::string & target |
const | std::string & replacement |
Definition at line 165 of file utility.cpp.
Referenced by CModel::convert2NonReversible().
void* stringToPointer | ( | const std::string | str | ) |
Convert a character sequence to a void pointer
const | std::string str |
Definition at line 414 of file utility.cpp.
Referenced by CEvaluationNodeObject::compile(), CMathExpression::compile(), and CMathExpression::copy().
double strToDouble | ( | const char * | str, |
char const ** | pTail = NULL |
||
) |
Convert a character sequence to a double
const | char * str |
char | const ** pTail (default: NULL) |
Definition at line 325 of file utility.cpp.
Referenced by CEvaluationNodeNumber::CEvaluationNodeNumber(), COptItem::compileLowerBound(), COptItem::compileUpperBound(), CReadConfig::getVariable(), isNumber(), CMiaseParser::newSimulation(), operator>>(), COptItem::setLowerBound(), COptItem::setUpperBound(), CCopasiXMLParser::RectangleElement::start(), CCopasiXMLParser::EllipseElement::start(), CCopasiXMLParser::TextElement::start(), CCopasiXMLParser::RenderCurveElement::start(), CCopasiXMLParser::PolygonElement::start(), CCopasiXMLParser::GroupElement::start(), test000087::test_simulate_reaction_flux_reference_1(), CEvaluationNodeNumber::toAST(), and CChemEqParserBase::yyparse().
C_INT32 strToInt | ( | const char * | str, |
char const ** | pTail = NULL |
||
) |
Convert a character sequence to a double
const | char * str |
char | const ** pTail (default: NULL) |
Definition at line 354 of file utility.cpp.
References C_INT32.
Referenced by CCopasiXMLParser::ParameterElement::start(), and CCopasiXMLParser::COPASIElement::start().
unsigned C_INT32 strToUnsignedInt | ( | const char * | str, |
char const ** | pTail = NULL |
||
) |
Convert a character sequence to a double
const | char * str |
char | const ** pTail (default: NULL) |
Definition at line 384 of file utility.cpp.
References C_INT32.
Referenced by CCopasiParameterGroup::getObject(), CCopasiXMLParser::CompartmentElement::start(), CCopasiXMLParser::ParameterElement::start(), CCopasiXMLParser::ReportElement::start(), CCopasiXMLParser::ParameterDescriptionElement::start(), and CCopasiXMLParser::SliderElement::start().
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.
const | std::string & name |
Definition at line 120 of file utility.cpp.
Referenced by CEvaluationNodeCall::CEvaluationNodeCall(), CModel::findMetabByName(), CEvaluationNodeCall::getData(), CCopasiVectorN< CReportDefinition >::getIndex(), CEvaluationNodeCall::setData(), and CChemEqParser::yylex().
std::string UTCTimeStamp | ( | ) |
Returns the current time in ISO format
Definition at line 64 of file utility.cpp.
References ISODateTime().
Referenced by createParameterSetsForExperiment(), CCopasiXML::save(), and CConfigurationFile::CXML::save().