本文整理汇总了C++中Context::ClearAllErrors方法的典型用法代码示例。如果您正苦于以下问题:C++ Context::ClearAllErrors方法的具体用法?C++ Context::ClearAllErrors怎么用?C++ Context::ClearAllErrors使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Context
的用法示例。
在下文中一共展示了Context::ClearAllErrors方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AttachToParent
//=================================================================================
bool Node::AttachToParent( Node* parent, Context& context, List::const_iterator* insertBeforeIter /*= 0*/ )
{
context.ClearAllErrors();
if( this->parent )
return context.IssueError( "Cannot attach node to parent, because the given node already has a parent." );
if( this == parent || IsDescendant( parent ) )
return context.IssueError( "Trees cannot have cycles. An attempt to create a cyclical relationship has been detected and prevented." );
if( !parent->children )
parent->children = new List();
if( insertBeforeIter && *insertBeforeIter != parent->children->end() )
{
const Node* beforeNode = **insertBeforeIter;
if( beforeNode->parent != parent )
return context.IssueError( "Cannot insert given node before given iterator, because these do not share the same parent." );
parent->children->insert( *insertBeforeIter, this );
}
else
parent->children->push_back( this );
this->parent = parent;
// This unfortunately changes the time complexity of attachment from O(1) to O(n) in the depth of the tree.
parent->InvalidateIndices();
return true;
}
示例2: WriteToFile
//=================================================================================
bool Node::WriteToFile( const std::string& file, Context& context, std::string* buffer /*= 0*/ ) const
{
bool success = false;
lua_State* L = 0;
context.ClearAllErrors();
try
{
// Create a new Lua state to hold the contents of the file.
L = lua_newstate( &Allocate, 0 );
if( !L )
throw new Error( "Failed to create Lua state in preparation for writing to file \"%s\".", file.c_str() );
// Create the table that represents this node.
lua_newtable( L );
if( !WriteToTable( L, context ) )
throw new Error( "The node \"%s\" of type \"%s\", or one of its children, failed to write its node contents to a Lua table.", name.c_str(), GetType().c_str() );
// Lastly, write the table out to disk.
Writer writer( file, buffer );
if( !writer.Write( L, context ) )
throw new Error( "Failed to write Lua file \"%s\" for root node \"%s\" of type \"%s\".", file.c_str(), name.c_str(), GetType().c_str() );
// Hurrah!
success = true;
}
catch( Error* error )
{
context.IssueError( error );
}
// Be sure to clean up our mess before returning.
if( L )
lua_close( L );
return success;
}
示例3: DetachFromParent
//=================================================================================
bool Node::DetachFromParent( Context& context, List::const_iterator* insertedBeforeIter /*= 0*/ )
{
context.ClearAllErrors();
if( !parent )
return context.IssueError( "Cannot detach root node from its parent, because a root node doesn't have a parent." );
if( !parent->children )
return context.IssueError( "The tree is somehow corrupt, because a child's parent has no record of any of its children." );
// This unfortunately changes the time complexity of detachment from O(1) to O(n) in the depth of the tree.
parent->InvalidateIndices();
// Remember where the child was located if the caller wants that.
if( insertedBeforeIter && ChildLocation( *insertedBeforeIter ) )
( *insertedBeforeIter )++;
// Perform the removal.
parent->children->remove( this );
parent = 0;
return true;
}