本文整理汇总了C++中SBMLErrorLog::logError方法的典型用法代码示例。如果您正苦于以下问题:C++ SBMLErrorLog::logError方法的具体用法?C++ SBMLErrorLog::logError怎么用?C++ SBMLErrorLog::logError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SBMLErrorLog
的用法示例。
在下文中一共展示了SBMLErrorLog::logError方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getErrorLog
/*
* Helper to log a common type of error.
*/
void
SBasePlugin::logEmptyString(const std::string &attribute,
const unsigned int sbmlLevel,
const unsigned int sbmlVersion,
const unsigned int pkgVersion,
const std::string& element)
{
if (&attribute == NULL || &element == NULL) return;
std::ostringstream msg;
msg << "Attribute '" << attribute << "' on an "
<< element << " of package \"" << mSBMLExt->getName()
<< "\" version " << pkgVersion << " must not be an empty string.";
//
// (TODO) Additional class such as SBMLExtensionError and SBMLExtensionErrorLog
// may need to be implemented
//
SBMLErrorLog* errlog = getErrorLog();
if (errlog)
{
errlog->logError(NotSchemaConformant, sbmlLevel, sbmlVersion, msg.str());
}
}
示例2: getParentSBMLObject
void
CompSBasePlugin::logInvalidId(const std::string& attribute,
const std::string& wrongattribute)
{
bool knownelement = (getParentSBMLObject() == NULL);
std::ostringstream msg;
msg << "Setting the attribute '" << attribute << "' ";
if (knownelement) {
msg << "of a <" << getParentSBMLObject()->getElementName() << "> ";
}
msg << "in the " << getPackageName()
<< " package (version " << getPackageVersion() << ") to '" << wrongattribute
<< "' is illegal: the string is not a well-formed SId.";
SBMLErrorLog* errlog = getErrorLog();
if (errlog)
{
errlog->logError(NotSchemaConformant, getLevel(), getVersion(), msg.str());
}
}
示例3: xos
/*
* Writes the given SBML document to the output stream.
*
* @return true on success and false if one of the underlying parser
* components fail (rare).
*/
bool
SBMLWriter::writeSBML (const SBMLDocument* d, std::ostream& stream)
{
bool result = false;
try
{
stream.exceptions(ios_base::badbit | ios_base::failbit | ios_base::eofbit);
XMLOutputStream xos(stream, "UTF-8", true, mProgramName,
mProgramVersion);
d->write(xos);
stream << endl;
result = true;
}
catch (ios_base::failure&)
{
SBMLErrorLog *log = (const_cast<SBMLDocument *>(d))->getErrorLog();
log->logError(XMLFileOperationError);
}
return result;
}
示例4: if
//.........这里部分代码省略.........
* bzip2 file.
* File unwritable error will be logged and @c false will be returned if a compressed
* file name is given and underlying libSBML is not linked with the corresponding
* required library.
* SBMLWriter::hasZlib() and SBMLWriter::hasBzip2() can be used to check whether
* underlying libSBML is linked with the library.
*
* @return true on success and false if the filename could not be opened
* for writing.
*/
bool
SBMLWriter::writeSBML (const SBMLDocument* d, const std::string& filename)
{
std::ostream* stream = NULL;
try
{
// open an uncompressed XML file.
if ( string::npos != filename.find(".xml", filename.length() - 4) )
{
stream = new(std::nothrow) std::ofstream(filename.c_str());
}
// open a gzip file
else if ( string::npos != filename.find(".gz", filename.length() - 3) )
{
stream = OutputCompressor::openGzipOStream(filename);
}
// open a bz2 file
else if ( string::npos != filename.find(".bz2", filename.length() - 4) )
{
stream = OutputCompressor::openBzip2OStream(filename);
}
// open a zip file
else if ( string::npos != filename.find(".zip", filename.length() - 4) )
{
std::string filenameinzip = filename.substr(0, filename.length() - 4);
if ( ( string::npos == filenameinzip.find(".xml", filenameinzip.length() - 4) ) &&
( string::npos == filenameinzip.find(".sbml", filenameinzip.length() - 5) )
)
{
filenameinzip += ".xml";
}
#if defined(WIN32) && !defined(CYGWIN)
char sepr = '\\';
#else
char sepr = '/';
#endif
size_t spos = filenameinzip.rfind(sepr, filenameinzip.length() - 1);
if( spos != string::npos )
{
filenameinzip = filenameinzip.substr(spos + 1, filenameinzip.length() - 1);
}
stream = OutputCompressor::openZipOStream(filename, filenameinzip);
}
else
{
stream = new(std::nothrow) std::ofstream(filename.c_str());
}
}
catch ( ZlibNotLinked& )
{
// libSBML is not linked with zlib.
XMLErrorLog *log = (const_cast<SBMLDocument *>(d))->getErrorLog();
std::ostringstream oss;
oss << "Tried to write " << filename << ". Writing a gzip/zip file is not enabled because "
<< "underlying libSBML is not linked with zlib.";
log->add(XMLError( XMLFileUnwritable, oss.str(), 0, 0) );
return false;
}
catch ( Bzip2NotLinked& )
{
// libSBML is not linked with bzip2.
XMLErrorLog *log = (const_cast<SBMLDocument *>(d))->getErrorLog();
std::ostringstream oss;
oss << "Tried to write " << filename << ". Writing a bzip2 file is not enabled because "
<< "underlying libSBML is not linked with bzip2.";
log->add(XMLError( XMLFileUnwritable, oss.str(), 0, 0) );
return false;
}
if ( stream == NULL || stream->fail() || stream->bad())
{
SBMLErrorLog *log = (const_cast<SBMLDocument *>(d))->getErrorLog();
log->logError(XMLFileUnwritable);
delete stream;
return false;
}
bool result = writeSBML(d, *stream);
delete stream;
return result;
}