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


C++ CAccessControlList::IterBegin方法代码示例

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


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

示例1: GetAclRequests

///////////////////////////////////////////////////////////////
//
// CResource::GetAclRequests
//
// Get all acl requests for this resource
//
///////////////////////////////////////////////////////////////
void CResource::GetAclRequests ( std::vector < SAclRequest >& outResultList )
{
    outResultList.clear ();

    CAccessControlList* pAutoAcl = FindAutoAcl ();
    if ( !pAutoAcl )
        return;

    // Get each right
    for ( std::list < CAccessControlListRight* >::const_iterator iter = pAutoAcl->IterBegin () ; iter != pAutoAcl->IterEnd () ; ++iter )
    {
        CAccessControlListRight* pAclRight = *iter;

        // Create SAclRequest from ACL
        SAclRequest request ( CAclRightName ( pAclRight->GetRightType (), pAclRight->GetRightName () ) );
        request.bAccess = StringToBool ( pAclRight->GetAttributeValue ( "access" ) );
        request.bPending = StringToBool ( pAclRight->GetAttributeValue ( "pending" ) );
        request.strWho = pAclRight->GetAttributeValue ( "who" );
        request.strDate = pAclRight->GetAttributeValue ( "date" );

        outResultList.push_back ( request );
    }
}
开发者ID:pombredanne,项目名称:openvice,代码行数:30,代码来源:CResource.AclRequest.cpp

示例2: aclListRights

int CLuaACLDefs::aclListRights ( lua_State* luaVM )
{
//  table aclListRights ( acl theACL )
    CAccessControlList* pACL; SString strType; bool bAll = true; CAccessControlListRight::ERightType eAllowed = (CAccessControlListRight::ERightType)-1;
    
    CScriptArgReader argStream ( luaVM );
    argStream.ReadUserData ( pACL );
    if ( argStream.NextIsString () )
    {
        argStream.ReadString ( strType );

        bAll = false;
        if ( strType == "command" )
            eAllowed = CAccessControlListRight::RIGHT_TYPE_COMMAND;
        else if ( strType == "function" )
            eAllowed = CAccessControlListRight::RIGHT_TYPE_FUNCTION;
        else if ( strType == "resource" )
            eAllowed = CAccessControlListRight::RIGHT_TYPE_RESOURCE;
        else if ( strType == "general" )
            eAllowed = CAccessControlListRight::RIGHT_TYPE_GENERAL;
        else
            bAll = true;
    }
    
    if ( !argStream.HasErrors () )
    {
        // Create a table to return into
        lua_newtable ( luaVM );

        // Loop through ACL
        char szRightName [128];
        CAccessControlListRight::ERightType eType;
        unsigned int uiIndex = 0;
        list <CAccessControlListRight* > ::const_iterator iter = pACL->IterBegin ();
        for ( ; iter != pACL->IterEnd (); ++iter )
        {
            // Type
            eType = (*iter)->GetRightType ();
            if ( !bAll && eType != eAllowed )
                continue;

            switch ( eType )
            {
                case CAccessControlListRight::RIGHT_TYPE_COMMAND:
                strcpy ( szRightName, "command." );
                break;

                case CAccessControlListRight::RIGHT_TYPE_FUNCTION:
                strcpy ( szRightName, "function." );
                break;

                case CAccessControlListRight::RIGHT_TYPE_RESOURCE:
                strcpy ( szRightName, "resource." );
                break;

                case CAccessControlListRight::RIGHT_TYPE_GENERAL:
                strcpy ( szRightName, "general." );
                break;

                default:
                strcpy ( szRightName, "unknown." );
                break;
            }

            // Append right name
            strncat ( szRightName, (*iter)->GetRightName (), NUMELMS( szRightName ) - 1 );

            // Push its name onto the table
            lua_pushnumber ( luaVM, ++uiIndex );
            lua_pushstring ( luaVM, szRightName );
            lua_settable ( luaVM, -3 );
        }

        // Return the table
        return 1;
    }
    else
        m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );

    lua_pushboolean ( luaVM, false );
    return 1;
}
开发者ID:superherohay4,项目名称:mtasa-blue,代码行数:82,代码来源:CLuaACLDefs.cpp


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