Descriptors for function interfaces

本文介绍了SymbianOS中描述符在函数接口中的使用方式,对比了传统C语言中字符串和缓冲区的处理方法,并详细阐述了四种主要应用场景:传递常量字符串、可更改字符串、只读二进制数据缓冲区及可更改二进制数据缓冲区。
部署运行你感兴趣的模型镜像

下面的内容摘自Symbian S60 3rd Edition SDK,先把英文原版贴在这里,等时间充足的时候我再把它翻译出来。How to Use Descriptors之Descriptors for function interfaces《函数接口中描述符的使用》

Descriptors for function interfaces

Many interfaces which use or manipulate text strings or general binary data use descriptors to specify the interface. In conventional ‘C’ programming, interfaces are specified using a combination of char*, void* and length values. In Symbian OS, descriptors are always used.

There are four main cases:

  • Passing a constant string

    In ‘C’: StringRead(const char* aString);

    The length of the string is implied by the zero terminator; therefore, the function does not require the length to be explicitly specified.

    In Symbian OS: StringRead(const TDesC& aString);

    The descriptor can access the string and contains its length.

  • Passing a string which can be changed.

    In ‘C’: StringWrite(char* aString, int aMaxLength);

    The length of the passed string is implied by the zero terminator. aMaxLength indicates the maximum length to which the string may be extended.

    In Symbian OS: StringWrite(TDes& aString);

    The descriptor can access the string and contains its length and the maximum length to which the string may be extended.

  • Passing a buffer containing general binary data

    In ‘C’: BufferRead(const void* aBuffer, int aLength);

    Both the address and length of the buffer must be specified.

    In Symbian OS: BufferRead(const TDes8& aBuffer);

    The descriptor has access to the address of the buffer and contains the length of the data. The 8 bit variant is explicitly specified; the buffer is treated as byte data, regardless of the build variant.

  • Passing a buffer containing general binary data which can be changed.

    In ‘C’:BufferWrite(void* aBuffer, int& aLength, int aMaxLength);

    The address of the buffer, the current length of the data and the maximum length of the buffer are specified. The aLength parameter is specified as a reference to allow the function to indicate the length of the data on return.

    In Symbian OS: BufferRead(TDes8& aBuffer);

    The descriptor has access to the adddress of the buffer and contains the length of the data and the maximum length. The 8 bit variant is explicitly specified; the buffer is treated as byte data, regardless of the build variant.

Defining interfaces using the base descriptor classes allows callers to pass all appropriate derived descriptor types.

 

您可能感兴趣的与本文相关的镜像

ACE-Step

ACE-Step

音乐合成
ACE-Step

ACE-Step是由中国团队阶跃星辰(StepFun)与ACE Studio联手打造的开源音乐生成模型。 它拥有3.5B参数量,支持快速高质量生成、强可控性和易于拓展的特点。 最厉害的是,它可以生成多种语言的歌曲,包括但不限于中文、英文、日文等19种语言

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值