19 #if DEBUG_MODE_ENABLED == 1
29 return Application::Instance() ;
38 }
catch (std::bad_alloc) {
39 logwriter->
error(
"bad alloc thrown by app()");
50 enum { BUFSIZE = 2048 } ;
57 _vsnprintf(sbuf, BUFSIZE, fmt, args) ;
59 vsprintf(sbuf, fmt, args) ;
71 void error(
const std::string& msg)
95 void addLogEntry(
const std::string& tag,
const std::string& value)
125 #endif // WITH_HTML_LOGS
130 mutex_t Unit::units_mutex;
134 Application::ApplicationDestroy() ;
135 FactoryBase::deleteFactories();
181 void setError(
const std::string& r,
const std::string& msg)
196 doublereal
toSI(
const std::string& unit)
198 doublereal f = Unit::units()->toSI(unit);
202 throw CanteraError(
"toSI",
"unknown unit string: "+unit);
209 doublereal f = Unit::units()->actEnergyToSI(unit);
219 ctroot = getenv(
"CANTERA_ROOT");
221 return string(ctroot);
224 return string(CANTERA_ROOT);
237 static void split_at_pound(
const std::string& src, std::string& file, std::string&
id)
239 string::size_type ipound = src.find(
'#');
241 id = src.substr(ipound+1,src.size());
242 file = src.substr(0,ipound);
251 std::string fname, idstr;
256 "no file name given. file_ID = "+file_ID);
257 db = root->
findID(idstr, 3);
261 "get_XML_File failed trying to open "+fname);
262 db = doc->
findID(idstr, 3);
266 "id tag '"+idstr+
"' not found.");
272 const std::string& file_ID,
275 string fname, idTarget;
293 std::vector<FactoryBase*> FactoryBase::s_vFactoryRegistry;
XML_Node * get_XML_Node(const std::string &file_ID, XML_Node *root)
This routine will locate an XML node in either the input XML tree or in another input file specified ...
void addError(const std::string &r, const std::string &msg)
Set an error condition in the application class without throwing an exception.
XML_Node * findNameID(const std::string &nameTarget, const std::string &idTarget) const
This routine carries out a recursive search for an XML node based on both the xml element name and th...
XML_Node * get_XML_File(const std::string &file, int debug)
Return a pointer to the XML tree for a Cantera input file.
void writelogendl()
Write an endl to the screen and flush output.
Base class for 'loggers' that write text messages to log files.
void popError()
Discard the last error message.
Class to hold global data.
void beginLogGroup(const std::string &title, int loglevel)
Create a new group for log messages.
string lastErrorMessage()
Retrieve the last error message in a string.
doublereal actEnergyToSI(const std::string &unit)
Return the conversion factor to convert activation energy unit std::string 'unit' to Kelvin...
std::string lastErrorMessage()
Retrieve the last error message in a string.
doublereal toSI(const std::string &unit)
Return the conversion factor to convert unit std::string 'unit' to SI units.
void thread_complete()
Delete and free memory allocated per thread in multithreaded applications.
const size_t npos
index returned by functions to indicate "no position"
void setLogger(Logger *logwriter)
Install a logger.
void setError(const std::string &r, const std::string &msg)
Set an error condition in the application class without throwing an exception.
static Application * app()
Return a pointer to the application object.
Class XML_Node is a tree-based representation of the contents of an XML file.
void showErrors()
Prints all of the error messages using writelog.
void warn_deprecated(const std::string &method, const std::string &extra)
Print a warning indicating that method is deprecated.
void beginLogGroup(const std::string &title, int loglevel)
Create a new group for log messages.
void addLogEntry(const std::string &tag, const std::string &value)
Add an entry to an HTML log file.
This file contains definitions for utility functions and text for modules, inputfiles, logs, textlogs, HTML_logs (see Input File Handling, Diagnostic Output, Writing messages to the screen and Writing HTML Logfiles).
virtual void error(const std::string &msg)
Write an error message and quit.
void writelog(const std::string &msg)
Write a message to the screen.
void logerror(const std::string &msg)
Write an error message and quit.
void close_XML_File(const std::string &file)
Close an XML File.
void writelogf(const char *fmt,...)
Write a formatted message to the screen.
const int g_DEBUG_MODE
Definition of whether the DEBUG_MODE environment is turned on within Cantera.
void error(const std::string &msg)
Write an error message and quit.
Classes providing support for XML data files.
void endLogGroup(const std::string &title)
Close the current group of log messages.
Base class for exceptions thrown by Cantera classes.
void suppress_deprecation_warnings()
Globally disable printing of deprecation warnings.
void warn_deprecated(const std::string &method, const std::string &extra="")
Print a warning indicating that method is deprecated.
Header for units conversion utilities, which are used to translate user input from input files (See I...
void appdelete()
Delete and free all memory associated with the application.
void popError()
Discard the last error message.
XML_Node * get_XML_File(const std::string &file, int debug=0)
Return a pointer to the XML tree for a Cantera input file.
void endLogGroup(const std::string &title)
Close the current group of log messages.
void thread_complete()
Delete and free memory allocated per thread in multithreaded applications.
void writelogendl()
Write an end of line character to the screen and flush output.
void logErrors()
Prints all of the error messages using writelog.
void getErrors(std::ostream &f)
Prints all of the error messages to an ostream.
void suppress_deprecation_warnings()
Globally disable printing of deprecation warnings.
XML_Node * findID(const std::string &id, const int depth=100) const
This routine carries out a recursive search for an XML node based on the xml element attribute...
void write_logfile(const std::string &file)
Write the HTML log file.
void write_logfile(const std::string &file)
Write the HTML log file.
void writelog(const std::string &msg)
Write a message to the screen.
void addLogEntry(const std::string &msg)
Add an entry to an HTML log file.
int nErrors()
Return the number of errors that have been encountered so far.
int getErrorCount()
Return the number of errors that have been encountered so far.
XML_Node * get_XML_NameID(const std::string &nameTarget, const std::string &file_ID, XML_Node *root)
This routine will locate an XML node in either the input XML tree or in another input file specified ...
Definitions for the classes that are thrown when Cantera experiences an error condition (also contain...
File contains the FactoryBase class declarations.
static void split_at_pound(const std::string &src, std::string &file, std::string &id)
split a string at a '#' sign. Used to separate a file name from an id string.
void setLogger(Logger *logwriter)
Install a logger.
void close_XML_File(const std::string &file)
Close an XML File.