EcsDeserializer::EcsDeserializer( const std::string& source_name, std::istream& stream, Entity_manager& m, asset::Asset_manager& assets, Component_filter filter) : sf2::JsonDeserializer( format::Json_reader{stream, create_error_handler(source_name)}, create_error_handler(source_name) ), manager(m), assets(assets), filter(filter) { }
/** * Use an error handler and test it by executing a query that raises an error. */ int cerror_example_2(XQC_Implementation* impl) { XQC_Expression* lExpr; XQC_DynamicContext* lCtx; XQC_ErrorHandler* lErrorHandler = create_error_handler(); XQC_Sequence* lResult; // compile the query impl->prepare(impl, "1 div 0", NULL, &lExpr); // set the error handler for handling errors // during query execution lExpr->create_context(lExpr, &lCtx); lCtx->set_error_handler(lCtx, lErrorHandler); // execute it and iterate results lExpr->execute(lExpr, lCtx, &lResult); while (lResult->next(lResult) == XQC_NO_ERROR); // release all resources lResult->free(lResult); lExpr->free(lExpr); lCtx->free(lCtx); free(lErrorHandler); return gError == XQC_DYNAMIC_ERROR ? 1 : 0; }
int cerror_example_3(XQC_Implementation* impl) { XQC_Error lError = XQC_NO_ERROR; XQC_Expression* lExpr; XQC_StaticContext* lCtx; const char* lStringValue; XQC_Sequence* lResult; XQC_ErrorHandler* lErrorHandler = create_error_handler(); // Assign error handler to the static context impl->create_context(impl, &lCtx); lCtx->set_error_handler(lCtx, lErrorHandler); // compile the query and get the result as a sequence lError = impl->prepare(impl, "for $i in (3, 2, 1, 0) return 3 div $i", lCtx, &lExpr); lExpr->execute(lExpr, NULL, &lResult); // an error is reported during the last for iteration // the error callback function is called and the loop terminates while ( lResult->next(lResult) == XQC_NO_ERROR ) { lResult->string_value(lResult, &lStringValue); printf("%s ", lStringValue); } // release all aquired resources free(lErrorHandler); lResult->free(lResult); lExpr->free(lExpr); lCtx->free(lCtx); return (gError == XQC_DYNAMIC_ERROR && lError == XQC_NO_ERROR) ? 1 : 0; }
/** * Use an error handler and test it by preparing a syntactically wrong query. */ int cerror_example_1(XQC_Implementation* impl) { XQC_Error lError = XQC_NO_ERROR; XQC_Expression* lExpr; XQC_StaticContext* lCtx; XQC_ErrorHandler* lErrorHandler = create_error_handler(); // Assign error handler to the static context impl->create_context(impl, &lCtx); lCtx->set_error_handler(lCtx, lErrorHandler); // compile the query lError = impl->prepare(impl, "for $i in 1, 2, 3", lCtx, &lExpr); // no need to free the query // because it was not successfully created free(lErrorHandler); lCtx->free(lCtx); return (gError == XQC_STATIC_ERROR && lError == XQC_STATIC_ERROR) ? 1 : 0; }