19 return Application::Instance() ;
28 }
catch (std::bad_alloc) {
29 logwriter->
error(
"bad alloc thrown by app()");
40 enum { BUFSIZE = 2048 } ;
47 _vsnprintf(sbuf, BUFSIZE, fmt, args) ;
49 vsprintf(sbuf, fmt, args) ;
61 void writeline(
char repeat,
size_t count,
bool endl_after,
bool endl_before)
66 writelog(std::string(count, repeat));
72 void error(
const std::string& msg)
91 mutex_t Unit::units_mutex;
95 Application::ApplicationDestroy() ;
96 FactoryBase::deleteFactories();
146 void setError(
const std::string& r,
const std::string& msg)
161 doublereal
toSI(
const std::string& unit)
163 doublereal f = Unit::units()->toSI(unit);
167 throw CanteraError(
"toSI",
"unknown unit string: "+unit);
174 doublereal f = Unit::units()->actEnergyToSI(unit);
184 ctroot = getenv(
"CANTERA_ROOT");
186 return string(ctroot);
189 return string(CANTERA_ROOT);
202 static void split_at_pound(
const std::string& src, std::string& file, std::string&
id)
204 string::size_type ipound = src.find(
'#');
206 id = src.substr(ipound+1,src.size());
207 file = src.substr(0,ipound);
216 std::string fname, idstr;
221 "no file name given. file_ID = "+file_ID);
222 db = root->
findID(idstr, 3);
228 if (fname.rfind(
".xml") == fname.size() - 4) {
229 fname.replace(fname.size() - 3, 3,
"cti");
230 }
else if (fname.rfind(
".cti") == fname.size() - 4) {
231 fname.replace(fname.size() - 3, 3,
"xml");
242 "get_XML_File failed trying to open "+fname);
243 db = doc->
findID(idstr, 3);
247 "id tag '"+idstr+
"' not found.");
253 const std::string& file_ID,
256 string fname, idTarget;
274 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.
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.
static std::string fmt(const std::string &r, size_t n)
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.
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.
XML_Node * get_XML_from_string(const std::string &text)
Read a CTI or CTML string and fill up an XML tree.
XML_Node * get_XML_from_string(const std::string &text)
Read a CTI or CTML string and fill up an XML tree.
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.
void error(const std::string &msg)
Write an error message and quit.
Classes providing support for XML data files.
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 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 writelog(const std::string &msg)
Write a message to the screen.
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 ...
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.