【问题标题】:How to concat various Symbian descriptors如何连接各种 Symbian 描述符
【发布时间】:2011-02-24 09:20:24
【问题描述】:

我在使用 Symbian 描述符时遇到了一些困难。本质上,我想采用各种描述符并将它们组合成一个更大的描述符,也许将它们放入一个 RBuf。此外,程序运行的每种类型的数据都会改变长度,下面是一些我一直在玩但无法构建的骨架代码。

HBufC8 * aVar = someObj.aVarData();
HBufC * anotherVar = someObj.anotherVarData();
HBuf8 * someVar = someObj.someVarData();

//Perform some operation to convert the descriptors to the same type and add them to a RBuf;

RBuf toLog;
toLog.CreateL( _L("Info to Log"));
toLog.Append( aVar );
toLog.Append( anotherVar );
toLog.Append( someVar );

正如您从评论中看到的那样,我无法正确弄清楚如何转换描述符并将其添加到缓冲区。提前致谢。

【问题讨论】:

    标签: mobile symbian descriptor


    【解决方案1】:

    Append() 将 TDesC 的引用作为参数。因此,您的代码应如下所示:

    toLog.Append( *aVar );
    toLog.Append( *anotherVar );
    toLog.Append( *someVar );
    

    【讨论】:

    • 快速提问,为什么你使用 *aVar 而不是 aVar->Des() ?
    • 取消引用 hbufc 描述符(仅)以获取嵌入的 buf 比使用全功能调用 aVar->Des() 更快。这是 symbian 中 hbufc 描述符的基本经验法则(我们在 symbian 组织中明智地遵循了它)。
    【解决方案2】:

    您的代码看起来大致正确。你得到什么错误? 请注意,您正在混合使用 8 位和 16 位描述符类型。

    阅读http://descriptors.blogspot.com/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-31
      • 1970-01-01
      • 1970-01-01
      • 2013-01-13
      • 1970-01-01
      • 2011-03-09
      相关资源
      最近更新 更多