本文整理汇总了C++中CoreObject::setProperty方法的典型用法代码示例。如果您正苦于以下问题:C++ CoreObject::setProperty方法的具体用法?C++ CoreObject::setProperty怎么用?C++ CoreObject::setProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CoreObject
的用法示例。
在下文中一共展示了CoreObject::setProperty方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ConfParser_read
FALCON_FUNC ConfParser_read( ::Falcon::VMachine *vm )
{
CoreObject *self = vm->self().asObject();
ConfigFile *cfile = (ConfigFile *) self->getUserData();
Item *i_stream = vm->param(0);
bool bRes;
if( i_stream == 0 )
{
vm->idle();
bRes = cfile->load();
vm->unidle();
}
else {
bool bValid = false;
if ( i_stream->isObject() )
{
CoreObject *streamObj = i_stream->asObject();
if ( streamObj->derivedFrom( "Stream" ) )
{
Stream *base = (Stream *) streamObj->getUserData();
bRes = cfile->load( base );
bValid = true;
}
}
if ( ! bValid )
{
throw new ParamError( ErrorParam( e_inv_params, __LINE__ ).extra( "Stream" ) );
return;
}
}
if ( ! bRes )
{
// is this an I/O or a parsing error?
if ( cfile->fsError() != 0 )
{
throw new IoError( ErrorParam( e_loaderror, __LINE__ ).
sysError( cfile->fsError() ).
extra( cfile->errorMessage() ) );
}
else {
String msg = cfile->errorMessage() + " at ";
msg.writeNumber( (int64) cfile->errorLine() );
self->setProperty( "error", cfile->errorMessage() );
self->setProperty( "errorLine", (int64) cfile->errorLine() );
throw new ParseError( ErrorParam( FALCP_ERR_INVFORMAT, __LINE__ )
.desc( FAL_STR(cp_msg_invformat) )
.extra( msg ) );
}
}
}
示例2: ConfParser_write
/*#
@method write ConfParser
@brief Write the INI file.
@optparam stream An optional output stream on which to write the configuration file.
@raise IoError on write error.
Writes the content of a modified or entirely generated configuration file on the
given stream, that must be a valid Falcon stream opened for output. If a stream
is not given, then the file name provided to the ConfParser constructor is
opened for writing. In case the name has not been given in the constructor, the
method raises an error.
*/
FALCON_FUNC ConfParser_write( ::Falcon::VMachine *vm )
{
CoreObject *self = vm->self().asObject();
ConfigFile *cfile = (ConfigFile *) self->getUserData();
Item *i_stream = vm->param(0);
bool bRes;
if( i_stream == 0 )
{
bRes = cfile->save();
}
else {
bool bValid = false;
if ( i_stream->isObject() )
{
CoreObject *streamObj = i_stream->asObject();
if ( streamObj->derivedFrom( "Stream" ) )
{
Stream *base = (Stream *) streamObj->getUserData();
bRes = cfile->save( base );
bValid = true;
}
}
if ( ! bValid )
{
throw new ParamError( ErrorParam( e_inv_params, __LINE__ ).extra( "Stream" ) );
return;
}
}
if ( ! bRes )
{
// is this a file error?
if ( cfile->fsError() )
{
throw new IoError( ErrorParam( e_file_output, __LINE__ ).
sysError( cfile->fsError() ).
extra( cfile->errorMessage() ) );
}
else
{
// no -- it's a configuration file.d
self->setProperty( "error", cfile->errorMessage() );
self->setProperty( "errorLine", (int64) cfile->errorLine() );
throw new ParseError( ErrorParam( FALCP_ERR_STORE, __LINE__ ).
desc( FAL_STR(cp_msg_errstore) ).extra( cfile->errorMessage() ) );
}
}
}
示例3: mth_dictFind
FALCON_FUNC mth_dictFind( ::Falcon::VMachine *vm )
{
Item *i_dict, *i_key;
if( vm->self().isMethodic() )
{
i_dict = &vm->self();
i_key = vm->param(0);
}
else {
i_dict = vm->param(0);
i_key = vm->param(1);
}
if( i_dict == 0 || ! i_dict->isDict() || i_key == 0 )
{
throw new ParamError( ErrorParam( e_inv_params, __LINE__ )
.origin( e_orig_runtime )
.extra( vm->self().isMethodic() ? "X" : "D,X" ) );
}
CoreDict *dict = i_dict->asDict();
Iterator iter( &dict->items() );
if ( ! dict->findIterator( *i_key, iter ) )
vm->retnil();
else
{
// find the iterator class, we'll need it
Item *i_iclass = vm->findWKI( "Iterator" );
fassert( i_iclass != 0 );
CoreObject *ival = i_iclass->asClass()->createInstance( new Iterator( iter ) );
ival->setProperty( "_origin", *i_dict );
vm->retval( ival );
}
}
示例4: CmdlineParser_terminate
FALCON_FUNC CmdlineParser_terminate( ::Falcon::VMachine *vm )
{
CoreObject *self = vm->self().asObject();
self->setProperty( "_request", (int64) 2 );
}
示例5: CmdlineParser_parse
/*#
@method parse CmdlineParser
@brief Starts command line parsing.
@optparam args A specific string array that will be used as arguments to be parsed.
@return true if the parsing is complete, false on error.
Start the parsing process. If args parameter is not provided, the method gets
the content of the @a args global vector defined in the Core module.
Returns true if the parsing was complete, and false on error (for example,
if some element in the array wasn't a string).
*/
FALCON_FUNC CmdlineParser_parse( ::Falcon::VMachine *vm )
{
CoreObject *self = vm->self().asObject();
Item *i_params = vm->param( 0 );
if ( i_params == 0 )
{
// get the parameters from the VM args object
i_params = vm->findGlobalItem( "args" );
if ( i_params == 0 || ! i_params->isArray() ) {
throw new CodeError( ErrorParam( e_undef_sym ).extra( "args" ).hard() );
}
}
else if ( ! i_params->isArray() )
{
throw new ParamError( ErrorParam( e_inv_params ).extra( "( A )" ) );
}
CoreArray *args = i_params->asArray();
// zero request.
self->setProperty( "_request", Item((int64) 0) );
self->setProperty( "lastParsed", Item((int64) 0) );
// status.
typedef enum {
t_none,
t_waitingValue,
t_allFree
} t_states;
t_states state = t_none ;
String currentOption;
Item i_method;
Item i_passMM;
self->getProperty( "passMinusMinus", i_passMM );
bool passMM = i_passMM.isTrue();
Item _request;
String subParam;
uint32 i;
for ( i = 0; i < args->length(); i++ )
{
Item &i_opt = args->at( i );
if ( !i_opt.isString() )
{
throw new ParamError( ErrorParam( e_param_type ).
extra( vm->moduleString( rtl_cmdp_0 ) ) );
}
String &opt = *i_opt.asString();
// if we were expecting a value, we MUST consider ANYTHING as it was a value.
if ( state == t_waitingValue )
{
self->getProperty( "onValue", i_method );
if ( i_method.methodize( self ) )
{
vm->pushParam( new CoreString(currentOption) );
vm->pushParam( i_opt );
vm->callItemAtomic( i_method, 2 );
state = t_none;
}
else
{
vm->retval( false );
self->setProperty( "lastParsed", i );
return;
}
}
else if( opt.length() == 0 || (opt.getCharAt( 0 ) != '-' || opt.length() == 1) || state == t_allFree )
{
self->getProperty( "onFree", i_method );
if ( i_method.methodize( self ) )
{
vm->pushParam( i_opt );
vm->callItemAtomic( i_method, 1 );
}
else
{
vm->retval( false );
self->setProperty( "lastParsed", i );
return;
}
}
else if ( opt == "--" && ! passMM )
{
state = t_allFree;
//.........这里部分代码省略.........