当前位置: 首页>>代码示例>>C++>>正文


C++ CScriptArgReader::SetTypeError方法代码示例

本文整理汇总了C++中CScriptArgReader::SetTypeError方法的典型用法代码示例。如果您正苦于以下问题:C++ CScriptArgReader::SetTypeError方法的具体用法?C++ CScriptArgReader::SetTypeError怎么用?C++ CScriptArgReader::SetTypeError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CScriptArgReader的用法示例。


在下文中一共展示了CScriptArgReader::SetTypeError方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: fileWrite

int CLuaFileDefs::fileWrite ( lua_State* luaVM )
{
//  int fileWrite ( file theFile, string string1 [, string string2, string string3 ...])
    CScriptFile* pFile;

    CScriptArgReader argStream ( luaVM );
    argStream.ReadUserData ( pFile );
    
    // Ensure we have atleast one string
    if ( !argStream.NextIsString () )
        argStream.SetTypeError ( "string" );

    if ( !argStream.HasErrors () )
    {
        long lBytesWritten = 0; // Total bytes written
        
        // While we're not out of string arguments
        // (we will always have at least one string because we validated it above)
        while ( argStream.NextIsString () )
        {
            // Grab argument and length
            SString strData;
            argStream.ReadString ( strData );
            unsigned long ulDataLen = strData.length ();

            // Write the data
            long lArgBytesWritten = pFile->Write ( ulDataLen, strData );

            // Did the file mysteriously disappear?
            if ( lArgBytesWritten == -1 )
            {
                m_pScriptDebugging->LogBadPointer ( luaVM, "file", 1 );
                lua_pushnil ( luaVM );
                return 1;
            }

            // Add the number of bytes written to our counter
            lBytesWritten += lArgBytesWritten;
        }

#ifdef MTA_CLIENT
        // Inform file verifier
        if ( lBytesWritten != 0 )
            g_pClientGame->GetResourceManager ()->OnFileModifedByScript ( pFile->GetAbsPath (), "fileWrite" );
#endif
        
        // Return the number of bytes we wrote
        lua_pushnumber ( luaVM, lBytesWritten );
        return 1;
    }
    else
        m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );

    // Error
    lua_pushnil ( luaVM );
    return 1;
}
开发者ID:Jusonex,项目名称:mtasa-blue,代码行数:57,代码来源:CLuaFileDefs.cpp

示例2: MixedReadResourceString

//
// Read next as resource or resource name.  Result output as resource
//
void MixedReadResourceString ( CScriptArgReader& argStream, CResource*& pOutResource )
{
    if ( !argStream.NextIsString () )
    {
        argStream.ReadUserData ( pOutResource );
    }
    else
    {
        SString strResourceName;
        argStream.ReadString ( strResourceName );
        pOutResource = g_pGame->GetResourceManager ()->GetResource ( strResourceName );

        if ( !pOutResource )
            argStream.SetTypeError ( "resource", argStream.m_iIndex - 1 );
    }
}
开发者ID:Anubhav652,项目名称:mtasa-blue,代码行数:19,代码来源:CLuaFunctionParseHelpers.cpp

示例3: fileWrite

int CLuaFileDefs::fileWrite ( lua_State* luaVM )
{
//  int fileWrite ( file theFile, string string1 [, string string2, string string3 ...])
    CScriptFile* pFile;

    CScriptArgReader argStream ( luaVM );
    argStream.ReadUserData ( pFile );
    
    if ( !argStream.NextIsString () )
        argStream.SetTypeError ( "string" );

    if ( !argStream.HasErrors () )
    {
        // While we're not out of string arguments
        long lBytesWritten = 0;
        long lArgBytesWritten = 0;
        
        do
        {
            // Grab argument and length
            SString strData;
            argStream.ReadString ( strData );
            unsigned long ulDataLen = strData.length ();

            // Write it and add the bytes written to our total bytes written
            lArgBytesWritten = pFile->Write ( ulDataLen, strData );
            if ( lArgBytesWritten == -1 )
            {
                m_pScriptDebugging->LogBadPointer ( luaVM, "file", 1 );
                lua_pushnil ( luaVM );
                return 1;
            }
            lBytesWritten += lArgBytesWritten;
        }
        while ( argStream.NextIsString () );
        
        // Return the number of bytes we wrote
        lua_pushnumber ( luaVM, lBytesWritten );
        return 1;
    }
    else
        m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );

    // Error
    lua_pushnil ( luaVM );
    return 1;
}
开发者ID:GDog1985,项目名称:mtasa-blue,代码行数:47,代码来源:CLuaFileDefs.cpp


注:本文中的CScriptArgReader::SetTypeError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。