⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sdpattributeparser.cpp

📁 symbian平台蓝牙程序,功能实现:搜索设备,指定时间间隔搜索,对指定的设备发送信息,也可指定时间间隔发送,日志操作,可通过mms,红外,蓝牙发送日志等
💻 CPP
字号:
/* Copyright (c) 2002, Nokia Mobile Phones. All rights reserved */

#include "Bt_Sock.h"
#include "SdpAttributeParser.h"
#include "SdpAttributeParser.pan"
#include "SdpAttributeNotifier.h"



TSdpAttributeParser::TSdpAttributeParser(
    TSdpAttributeList& aNodeList, 
    MSdpAttributeNotifier& aObserver
) 
:   iObserver(aObserver),
    iNodeList(aNodeList),
    iCurrentNodeIndex(0)
    {
    // no implementation required
    }

TBool TSdpAttributeParser::HasFinished() const
    {
    return CurrentNode().iCommand == EFinished;
    }

void TSdpAttributeParser::VisitAttributeValueL(CSdpAttrValue& aValue, TSdpElementType aType)
    {
    switch(CurrentNode().iCommand)
        {
        case ECheckType:
            CheckTypeL(aType);
            break;

        case ECheckValue:
            CheckTypeL(aType);
            CheckValueL(aValue);
            break;

        case ECheckEnd:
            User::Leave(KErrGeneral);   //  list element contains too many items
            break;

        case ESkip:
            break;  // no checking required

        case EReadValue:
            CheckTypeL(aType);
            ReadValueL(aValue);
            break;

        case EFinished:
            User::Leave(KErrGeneral);   // element is after value should have ended
            return;

        default:
            Panic(ESdpAttributeParserInvalidCommand);
        }

    AdvanceL();
    }

void TSdpAttributeParser::StartListL(CSdpAttrValueList& /*aList*/)
    {
    // no checks done here
    }

void TSdpAttributeParser::EndListL()
    {
    // check we are at the end of a list
    if (CurrentNode().iCommand != ECheckEnd)
        {
        User::Leave(KErrGeneral);
        }

    AdvanceL();
    }

void TSdpAttributeParser::CheckTypeL(TSdpElementType aElementType) const
    {
    if (CurrentNode().iType != aElementType)
        {
        User::Leave(KErrGeneral);
        }
    }

void TSdpAttributeParser::CheckValueL(CSdpAttrValue& aValue) const
    {
    switch(aValue.Type())
        {
        case ETypeNil:
            Panic(ESdpAttributeParserNoValue);
            break;

        case ETypeUint:
            if (aValue.Uint() != (TUint)CurrentNode().iValue)
                {
                User::Leave(KErrArgument);
                }
            break;

        case ETypeInt:
            if (aValue.Int() != CurrentNode().iValue)
                {
                User::Leave(KErrArgument);
                }
            break;

        case ETypeBoolean:
            if (aValue.Bool() != CurrentNode().iValue)
                {
                User::Leave(KErrArgument);
                }
            break;

        case ETypeUUID:
            if (aValue.UUID() != TUUID(CurrentNode().iValue))
                {
                User::Leave(KErrArgument);
                }
            break;

        // these are lists, so have to check contents
        case ETypeDES:
        case ETypeDEA:
            Panic(ESdpAttributeParserValueIsList);
            break;

        // these aren't supported - use EReadValue and leave on error
        //case ETypeString:
        //case ETypeURL:
        //case ETypeEncoded:
        default:
            Panic(ESdpAttributeParserValueTypeUnsupported);
            break;
        }
    }

void TSdpAttributeParser::ReadValueL(CSdpAttrValue& aValue) const
    {
    iObserver.FoundElementL(CurrentNode().iValue, aValue);
    }

const TSdpAttributeParser::SSdpAttributeNode& TSdpAttributeParser::CurrentNode() const
    {
    return  iNodeList[iCurrentNodeIndex];
    }

void TSdpAttributeParser::AdvanceL()
    {
    // check not at end
    if (CurrentNode().iCommand == EFinished)
        {
        User::Leave(KErrEof);
        }

    // move to the next item
    ++iCurrentNodeIndex;
    }


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -