本文整理汇总了C++中CoreObject::getFalconData方法的典型用法代码示例。如果您正苦于以下问题:C++ CoreObject::getFalconData方法的具体用法?C++ CoreObject::getFalconData怎么用?C++ CoreObject::getFalconData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CoreObject
的用法示例。
在下文中一共展示了CoreObject::getFalconData方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Format_format
/*#
@method format Format
@brief Performs desired formatting on a target item.
@param item The item to be formatted
@optparam dest A string where to store the formatted data.
@return A formatted string
@raise ParamError if a format specifier has not been set yet.
@raise TypeError if the format specifier can't be applied the item because of
incompatible type.
Formats the variable as per the given format descriptor. If the class has been
instantiated without format, and the parse() method has not been called yet,
a ParamError is raised. If the type of the variable is incompatible with the
format descriptor, the method returns nil; a particular format specifier allows
to throw a TypeError in this case.
On success, the method returns a string containing a valid formatted representation
of the variable.
It is possible to provide a pre-allocated string where to store the formatted
result to improve performace and spare memory.
*/
FALCON_FUNC Format_format ( ::Falcon::VMachine *vm )
{
CoreObject *einst = vm->self().asObject();
Format *fmt = dyncast<Format*>( einst->getFalconData() );
Item *param = vm->param( 0 );
Item *dest = vm->param( 1 );
if( param == 0 || ( dest != 0 && ! dest->isString() ) )
{
throw new ParamError( ErrorParam( e_inv_params ).extra( "X,[S]" ) );
}
else
{
CoreString *tgt;
if( dest != 0 )
{
tgt = dest->asCoreString();
}
else {
tgt = new CoreString;
}
if( ! fmt->format( vm, *param, *tgt ) )
vm->retnil();
else
vm->retval( tgt );
}
}
示例2: Format_parse
/*#
@method parse Format
@brief Initializes the Format instance with an optional value.
@param fmtspec Format specifier
@raise ParseError if the format specifier is not correct.
Sets or changes the format specifier for this Format instance.
If the format string is not correct, a ParseError is raised.
*/
FALCON_FUNC Format_parse ( ::Falcon::VMachine *vm )
{
CoreObject *einst = vm->self().asObject();
Format *fmt = (Format *) einst->getFalconData();
Item *param = vm->param( 0 );
if ( param != 0 )
{
if( ! param->isString() )
{
throw new ParamError( ErrorParam( e_inv_params ).extra( "[S]" ) );
}
else {
fmt->parse( *param->asString() );
if( ! fmt->isValid() )
{
throw new ParseError( ErrorParam( e_param_fmt_code ) );
}
}
}
}