<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-12650648</id><updated>2011-07-28T05:01:03.766-07:00</updated><category term='translation russian descriptors symbian'/><title type='text'>Descriptors FAQ</title><subtitle type='html'>"Everything about Symbian OS descriptors"</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://descriptors.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://descriptors.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Jo Stichbury</name><uri>http://www.blogger.com/profile/11641972941072027994</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://www.whoshavesthebarber.com/pictures/sose.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>43</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-12650648.post-116449011457651647</id><published>2006-11-25T13:26:00.000-08:00</published><updated>2006-11-25T13:30:40.126-08:00</updated><title type='text'>36. How do I use RBuf to read from a file?</title><content type='html'>This was posted by Simo as a comment &lt;a href="http://descriptors.blogspot.com/2005/06/33-can-you-give-example-of-how-to-use.html"&gt;here&lt;/a&gt;:&lt;br /&gt;&lt;br /&gt;RBuf is also the best choice when reading strings from file. Using RBuf instead of HBufC requires less code. Also, error handling becomes more simpler.&lt;br /&gt;&lt;br /&gt;Here is simple example how to read from RReadStream:&lt;br /&gt;&lt;br /&gt;in .h: RBuf iSomeSetting;&lt;br /&gt;in .cpp: iSomeSetting.CreateL( stream, KMaxTInt );&lt;br /&gt;&lt;br /&gt;the HBufC would be:&lt;br /&gt;in .h: HBufC* iSomeSetting;&lt;br /&gt;in .cpp: iSomeSetting = HBufC::NewL( stream, KMaxTInt );&lt;br /&gt;TPtr tmp( iSomeSetting-&gt;Des() );&lt;br /&gt;stream &gt;&gt; tmp;&lt;br /&gt;&lt;br /&gt;Error handling is also easier because there are no NULL pointer checks required for RBuf.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12650648-116449011457651647?l=descriptors.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://descriptors.blogspot.com/feeds/116449011457651647/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12650648&amp;postID=116449011457651647' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/116449011457651647'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/116449011457651647'/><link rel='alternate' type='text/html' href='http://descriptors.blogspot.com/2006/11/36-how-do-i-use-rbuf-to-read-from-file.html' title='36. How do I use RBuf to read from a file?'/><author><name>Jo Stichbury</name><uri>http://www.blogger.com/profile/11641972941072027994</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://www.whoshavesthebarber.com/pictures/sose.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12650648.post-114824629456262238</id><published>2006-05-21T14:16:00.000-07:00</published><updated>2006-05-22T09:52:13.326-07:00</updated><title type='text'>References to other descriptors resources</title><content type='html'>&lt;p&gt;&lt;/p&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;General Symbian Resources&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Symbian Developer Library on the Symbian site (&lt;span style="font-size:85%;"&gt;&lt;a href="http://www.symbian.com/developer/techlib/index.asp"&gt;www.symbian.com/developer/techlib/index.asp&lt;/a&gt;&lt;/span&gt;)&lt;br /&gt;&lt;br /&gt;Version 9.1: &lt;a href="http://www.symbian.com/developer/techlib/v9.1docs/doc_source/index.html"&gt;www.symbian.com/developer/techlib/v9.1docs/doc_source/index.html&lt;/a&gt;&lt;br /&gt;Version 8.1a: &lt;a href="http://www.symbian.com/developer/techlib/v8.1adocs/doc_source/index.html"&gt;www.symbian.com/developer/techlib/v8.1adocs/doc_source/index.html&lt;/a&gt;&lt;br /&gt;Version 7.0s: &lt;a href="http://www.symbian.com/developer/techlib/v70sdocs/doc_source/index.html"&gt;www.symbian.com/developer/techlib/v70sdocs/doc_source/index.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Developer Communities&lt;/span&gt;&lt;br /&gt;Symbian: &lt;a href="http://www.symbian.com/developer/"&gt;www.symbian.com/developer/&lt;/a&gt;&lt;br /&gt;Forum Nokia: &lt;a href="http://www.forum.nokia.com"&gt;www.forum.nokia.com&lt;/a&gt;&lt;br /&gt;UIQ Developer Community: &lt;a href="http://developer.uiq.com/"&gt;developer.uiq.com/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;My book: "Symbian OS Explained" &lt;a href="http://www.symbian.com/developer/books/sose/sose_info.html"&gt;www.symbian.com/developer/books/sose/sose_info.html&lt;/a&gt; and personal web site &lt;a href="http://www.WhoShavesTheBarber.com"&gt;www.WhoShavesTheBarber.com&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Other Symbian Press titles: &lt;a href="http://www.symbian.com/developer/books/index.html"&gt;www.symbian.com/developer/books/index.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Symbian Developer FAQ and Tech Tips site: &lt;a href="http://www.symbian.com/developer/faq/index.html"&gt;www.symbian.com/developer/faq/index.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;References&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Reference [1]&lt;/span&gt; Descriptors overview from the Symbian Developer Library&lt;br /&gt;&lt;a href="http://www.symbian.com/developer/techlib/v9.1docs/doc_source/guide/Base-subsystem-guide/N10086/BuffersAndStrings/DescriptorsOverview.guide.html#BuffersAndStringsOverview%2eDescriptorsOverview%2emain"&gt;www.symbian.com/developer/techlib/v9.1docs/doc_source/guide/Base-subsystem-guide/N10086/BuffersAndStrings/DescriptorsOverview.guide.html#BuffersAndStringsOverview%2eDescriptorsOverview%2emain&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Reference [2]&lt;/span&gt; &lt;span style="font-family:courier new;"&gt;USER&lt;/span&gt; panic category in the Symbian Developer Library&lt;br /&gt;&lt;a href="http://www.symbian.com/developer/techlib/v9.1docs/doc_source/reference/N10352/UserPanics.html#Panics%2euser"&gt;www.symbian.com/developer/techlib/v9.1docs/doc_source/reference/N10352/UserPanics.html#Panics%2euser&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Reference [3]&lt;/span&gt; Format String Syntax in the Symbian Developer Library&lt;br /&gt;&lt;a href="http://www.symbian.com/developer/techlib/v9.1docs/doc_source/guide/Base-subsystem-guide/N10086/BuffersAndStrings/Descriptors/DescriptorsGuide3/FormatStringSyntax.guide.html#Descriptors%2eFormat%2dstring%2dsyntax"&gt;www.symbian.com/developer/techlib/v9.1docs/doc_source/guide/Base-subsystem-guide/N10086/BuffersAndStrings/Descriptors/DescriptorsGuide3/FormatStringSyntax.guide.html#Descriptors%2eFormat%2dstring%2dsyntax&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Reference [4] &lt;/span&gt;Pointer Descriptors Guide in the Symbian Developer Library&lt;br /&gt;&lt;a href="http://www.symbian.com/developer/techlib/v9.1docs/doc_source/guide/Base-subsystem-guide/N10086/BuffersAndStrings/Descriptors/DescriptorsGuide2/PointerDescriptors.guide.html#DescriptorsGuide2%2epointers"&gt;www.symbian.com/developer/techlib/v9.1docs/doc_source/guide/Base-subsystem-guide/N10086/BuffersAndStrings/Descriptors/DescriptorsGuide2/PointerDescriptors.guide.html#DescriptorsGuide2%2epointers&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Reference [5]&lt;/span&gt; Buffer Descriptors Guide in the Symbian Developer Library&lt;br /&gt;&lt;a href="http://www.symbian.com/developer/techlib/v9.1docs/doc_source/guide/Base-subsystem-guide/N10086/BuffersAndStrings/Descriptors/DescriptorsGuide2/BufferDescriptors.guide.html#DescriptorsGuide2%2ebuffers"&gt;www.symbian.com/developer/techlib/v9.1docs/doc_source/guide/Base-subsystem-guide/N10086/BuffersAndStrings/Descriptors/DescriptorsGuide2/BufferDescriptors.guide.html#DescriptorsGuide2%2ebuffers&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Reference [6]&lt;/span&gt; Documentation for &lt;span style="font-family:courier new;"&gt;RBuf&lt;/span&gt; in the Symbian Developer Library&lt;br /&gt;&lt;a href="http://www.symbian.com/developer/techlib/v9.1docs/doc_source/guide/Base-subsystem-guide/N10086/BuffersAndStrings/Descriptors/DescriptorsGuide2/ResizableBufferDescriptors.guide.html#DescriptorsGuide2%2eresizable"&gt;www.symbian.com/developer/techlib/v9.1docs/doc_source/guide/Base-subsystem-guide/N10086/BuffersAndStrings/Descriptors/DescriptorsGuide2/ResizableBufferDescriptors.guide.html#DescriptorsGuide2%2eresizable&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;"Introducing the &lt;span style="font-family:courier new;"&gt;RBuf&lt;/span&gt; Descriptor" Mark Shackman, Symbian:&lt;br /&gt;&lt;a href="http://www.symbian.com/developer/techlib/papers/rbuf/introduction_to_rbuf_v1.0.pdf"&gt;www.symbian.com/developer/techlib/papers/rbuf/introduction_to_rbuf_v1.0.pdf&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Reference [7]&lt;/span&gt; Forum Nokia: "Symbian OS: Descriptors For Text And Binary Data (With Example) v1.0"&lt;br /&gt;&lt;a href="http://www.forum.nokia.com/info/sw.nokia.com/id/7ad95f0e-d7aa-4acc-90f1-890e21207b75/Symbian_OS_Descriptors_For_Text_And_Binary_Data_With_Example_v1_0.zip.html"&gt;www.forum.nokia.com/info/sw.nokia.com/id/7ad95f0e-d7aa-4acc-90f1-890e21207b75/Symbian_OS_Descriptors_For_Text_And_Binary_Data_With_Example_v1_0.zip.html&lt;br /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Reference [8]&lt;/span&gt; Reverse Polish Notation&lt;br /&gt;&lt;a href="http://www.calculator.org/rpn.html"&gt;www.calculator.org/rpn.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Reference [9]&lt;/span&gt; Reference information about &lt;span style="font-family:courier new;"&gt;TLex&lt;/span&gt; in the Symbian Developer Library&lt;br /&gt;&lt;a href="http://www.symbian.com/developer/techlib/v9.1docs/doc_source/reference/reference-cpp/N101CA/TLex16Class.html#%3a%3aTLex16"&gt;www.symbian.com/developer/techlib/v9.1docs/doc_source/reference/reference-cpp/N101CA/TLex16Class.html#%3a%3aTLex16&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Reference [10]&lt;/span&gt; Lexical analysis and &lt;span style="font-family:courier new;"&gt;TLex&lt;/span&gt; in the Symbian Developer Library&lt;br /&gt;&lt;br /&gt;Lexical analysis overview&lt;br /&gt;&lt;a href="http://www.symbian.com/developer/techlib/v9.1docs/doc_source/guide/Base-subsystem-guide/N10086/BuffersAndStrings/LexicalAnalysisOverview.guide.html#BuffersAndStringsOverview%2eLexicalAnalysisOverview%2emain"&gt;www.symbian.com/developer/techlib/v9.1docs/doc_source/guide/Base-subsystem-guide/N10086/BuffersAndStrings/LexicalAnalysisOverview.guide.html#BuffersAndStringsOverview%2eLexicalAnalysisOverview%2emain&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Using lexical analysis&lt;br /&gt;&lt;a href="http://www.symbian.com/developer/techlib/v9.1docs/doc_source/guide/Base-subsystem-guide/N10086/BuffersAndStrings/LexicalAnalysis/index.html#LexicalAnalysisGuide%2etoc"&gt;www.symbian.com/developer/techlib/v9.1docs/doc_source/guide/Base-subsystem-guide/N10086/BuffersAndStrings/LexicalAnalysis/index.html#LexicalAnalysisGuide%2etoc&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12650648-114824629456262238?l=descriptors.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://descriptors.blogspot.com/feeds/114824629456262238/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12650648&amp;postID=114824629456262238' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/114824629456262238'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/114824629456262238'/><link rel='alternate' type='text/html' href='http://descriptors.blogspot.com/2006/05/references-to-other-descriptors.html' title='References to other descriptors resources'/><author><name>Jo Stichbury</name><uri>http://www.blogger.com/profile/11641972941072027994</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://www.whoshavesthebarber.com/pictures/sose.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12650648.post-114608160202540642</id><published>2006-04-26T12:52:00.000-07:00</published><updated>2006-04-26T19:43:15.243-07:00</updated><title type='text'>10,000 hits!</title><content type='html'>My hit counter (&lt;a href="http://www.statcounter.com"&gt;www.statcounter.com&lt;/a&gt;) informs me that this blog clocked over 10,000 hits today.  Thanks everyone for visiting over the last few months!  &lt;br /&gt;&lt;br /&gt;The blogs have been running for about a year now and are overdue for a makeover.  I'm hoping to make some changes to the format and include more regular updates and new content in the near future.  This will probably include moving them to a new home.  But don't worry, the current content won't be removed and there will be plenty of notice of any changes.&lt;br /&gt;&lt;br /&gt;Besides this blog, I'd just like to flag another descriptors resource on the web.  Take a look at &lt;a href="http://www.symbian.com/developer/tech_papers/papers/cpp_gettingstarted.asp#descriptors"&gt;this presentation&lt;/a&gt; on the Symbian site, for another view of descriptors. &lt;br /&gt;&lt;br /&gt;Best wishes,&lt;br /&gt;&lt;br /&gt;Jo&lt;br /&gt;Vancouver, April 26th 2006&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12650648-114608160202540642?l=descriptors.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://descriptors.blogspot.com/feeds/114608160202540642/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12650648&amp;postID=114608160202540642' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/114608160202540642'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/114608160202540642'/><link rel='alternate' type='text/html' href='http://descriptors.blogspot.com/2006/04/10000-hits.html' title='10,000 hits!'/><author><name>Jo Stichbury</name><uri>http://www.blogger.com/profile/11641972941072027994</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://www.whoshavesthebarber.com/pictures/sose.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12650648.post-112336008550586664</id><published>2005-08-06T13:18:00.000-07:00</published><updated>2006-05-22T09:50:54.333-07:00</updated><title type='text'>35. How do I use TLex?</title><content type='html'>Well firstly, what is &lt;span style="font-family:courier new;"&gt;TLex&lt;/span&gt;?&lt;br /&gt;&lt;br /&gt;It's a lexical analysis class and the lexer example code, which comes with the Symbian OS SDK, gives one example of how to use it. You can find a brief description of the lexer example in the Symbian Developer Library documentation which comes with each SDK; it is also available on the Symbian website (see the &lt;span style="font-style: italic;"&gt;&lt;a href="http://descriptors.blogspot.com/2006/05/references-to-other-descriptors.html"&gt;References&lt;/a&gt;&lt;/span&gt; section for details).&lt;br /&gt;&lt;br /&gt;And, in case you're in some doubt as to what the lexer example is doing - I did - [&lt;a href="http://descriptors.blogspot.com/2006/05/references-to-other-descriptors.html"&gt;&lt;i&gt;reference 8&lt;/i&gt;&lt;/a&gt;] is a very useful resource about Reverse Polish Notation.&lt;br /&gt;&lt;br /&gt;The rest of this article will summarise the main features of &lt;span style="font-family:courier new;"&gt;TLex &lt;/span&gt;into groups of useful API calls. I'd like to create another, simple, example of how to use the class, but am a bit stuck for ideas of what would be useful. &lt;span style="font-weight: bold;"&gt;If anyone's got any thoughts on how best to illustrate the main features, please do add a comment to this post and I'll see what I can do&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;The main class, &lt;span style="font-family:courier new;"&gt;TLex&lt;/span&gt;, is like the descriptors in that two classes are available, &lt;span style="font-family:courier new;"&gt;TLex8&lt;/span&gt; and &lt;span style="font-family:courier new;"&gt;TLex1&lt;/span&gt;6 and the neutral version, &lt;span style="font-family:courier new;"&gt;TLex&lt;/span&gt;, is a typedef to &lt;span style="font-family:courier new;"&gt;TLex16&lt;/span&gt; for today's UNICODE builds of Symbian OS. You can find the Symbian API reference documentation for &lt;span style="font-family:courier new;"&gt;TLex16&lt;/span&gt; in [&lt;a href="http://descriptors.blogspot.com/2006/05/references-to-other-descriptors.html"&gt;&lt;i&gt;reference 9&lt;/i&gt;&lt;/a&gt;].&lt;br /&gt;&lt;br /&gt;As the documentation states, &lt;span style="font-family:courier new;"&gt;TLex &lt;/span&gt;"&lt;span style="font-style: italic;"&gt;...provides general string-parsing functions suitable for numeric format conversions and syntactical-element parsing...An instance of this class stores a string, maintaining an extraction mark to indicate the current lexical element being analysed and a pointer to the next character to be examined...&lt;/span&gt;"&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;TLex &lt;/span&gt;can be constructed with the data for lexical analysis or constructed empty and later assigned the data. Both construction and assignment take either another &lt;span style="font-family:courier new;"&gt;TLex &lt;/span&gt;object, a 16 bit non-modifiable descriptor or a &lt;span style="font-family:courier new;"&gt;TUint16*&lt;/span&gt; pointer to string data.&lt;br /&gt;&lt;br /&gt;At the very simplest level, when the string contains just numerical data, the descriptor contents can be converted to an integer by using the &lt;span style="font-family:courier new;"&gt;Val()&lt;/span&gt; function of &lt;span style="font-family:courier new;"&gt;TLex&lt;/span&gt;. For example:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    _LIT(KTestString1, "54321");&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    TLex lex(KTestString1());&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    TInt value = 0;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    User::LeaveIfError(lex.Val(value));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    ASSERT(value==54321);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The &lt;span style="font-family:courier new;"&gt;Val()&lt;/span&gt; function is overloaded for different signed integer types: &lt;span style="font-family:courier new;"&gt;TInt&lt;/span&gt;, &lt;span style="font-family:courier new;"&gt;TInt8&lt;/span&gt;, &lt;span style="font-family:courier new;"&gt;TInt16&lt;/span&gt;, &lt;span style="font-family:courier new;"&gt;TInt32&lt;/span&gt;, &lt;span style="font-family:courier new;"&gt;TInt64 &lt;/span&gt;- with or without limit checking. Likewise, there are &lt;span style="font-family:courier new;"&gt;Val()&lt;/span&gt; overloads for the unsigned integer types, passing in a radix type (decimal, hexadecimal, binary or octal). There are also overloads of &lt;span style="font-family:courier new;"&gt;Val()&lt;/span&gt; for &lt;span style="font-family:courier new;"&gt;TReal&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;However, there's a lot more you can do with &lt;span style="font-family:courier new;"&gt;TLex&lt;/span&gt;.  The Symbian Developer Library has more information about lexical analysis with TLex - see [&lt;a href="http://descriptors.blogspot.com/2006/05/references-to-other-descriptors.html"&gt;&lt;i&gt;reference 10&lt;/i&gt;&lt;/a&gt;] for more information.&lt;br /&gt;&lt;br /&gt;For example, you can move through the string using the &lt;span style="font-family:courier new;"&gt;Inc()&lt;/span&gt; functions, or just inspect each character using &lt;span style="font-family:courier new;"&gt;Peek()&lt;/span&gt;. Calling &lt;span style="font-family:courier new;"&gt;Get()&lt;/span&gt; will both increment the position and return the character - it can be reversed using &lt;span style="font-family:courier new;"&gt;UnGet()&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;You can skip whitespace using &lt;span style="font-family:courier new;"&gt;SkipSpace()&lt;/span&gt; or characters using &lt;span style="font-family:courier new;"&gt;SkipCharacters()&lt;/span&gt;. The end of the string is hit when &lt;span style="font-family:courier new;"&gt;EoS()&lt;/span&gt; returns &lt;span style="font-family:courier new;"&gt;ETrue&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;You can put an extraction marker at position in the string, using the &lt;span style="font-family:courier new;"&gt;Mark()&lt;/span&gt; overloads. Marking is also useful if you want to reverse (&lt;span style="font-family:courier new;"&gt;UnGetToMark()&lt;/span&gt; or skip using &lt;span style="font-family:courier new;"&gt;SkipAndMark()&lt;/span&gt; or &lt;span style="font-family:courier new;"&gt;SkipSpaceAndMark()&lt;/span&gt;).&lt;br /&gt;&lt;br /&gt;Tokens are used to describe a character string which is deliminated by white space. There are a number of token methods available, such as &lt;span style="font-family:courier new;"&gt;TokenLength()&lt;/span&gt;, &lt;span style="font-family:courier new;"&gt;MarkedToken()&lt;/span&gt; - which extracts a token - and &lt;span style="font-family:courier new;"&gt;NextToken()&lt;/span&gt;. If you don't use tokens, you can use offsets and remainders instead - there are a number of methods for navigating the string in this way.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12650648-112336008550586664?l=descriptors.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://descriptors.blogspot.com/feeds/112336008550586664/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12650648&amp;postID=112336008550586664' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/112336008550586664'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/112336008550586664'/><link rel='alternate' type='text/html' href='http://descriptors.blogspot.com/2005/08/35-how-do-i-use-tlex.html' title='35. How do I use TLex?'/><author><name>Jo Stichbury</name><uri>http://www.blogger.com/profile/11641972941072027994</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://www.whoshavesthebarber.com/pictures/sose.jpg'/></author><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12650648.post-111991813918983401</id><published>2005-06-27T17:20:00.000-07:00</published><updated>2006-05-21T16:33:51.620-07:00</updated><title type='text'>34. Is there a way to get binary data in a _LIT?</title><content type='html'>Check out the answer to FAQ-0814 on Symbian's Developer FAQ &amp; Tech Tips site:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www3.symbian.com/faq.nsf/0/D5889EFF80ED87B780256C290051923C?OpenDocument"&gt;Is there a way to get binary data in a _LIT?&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12650648-111991813918983401?l=descriptors.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://descriptors.blogspot.com/feeds/111991813918983401/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12650648&amp;postID=111991813918983401' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111991813918983401'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111991813918983401'/><link rel='alternate' type='text/html' href='http://descriptors.blogspot.com/2005/06/34-is-there-way-to-get-binary-data-in.html' title='34. Is there a way to get binary data in a _LIT?'/><author><name>Jo Stichbury</name><uri>http://www.blogger.com/profile/11641972941072027994</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://www.whoshavesthebarber.com/pictures/sose.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12650648.post-111983988043376901</id><published>2005-06-26T19:28:00.000-07:00</published><updated>2006-05-18T13:26:48.166-07:00</updated><title type='text'>33. Can you give an example of how to use RBuf?</title><content type='html'>Yes. I was initially reluctant to do so, because there isn't any published example code out there yet. But I'll take the plunge with this example, which shows how to use &lt;span style="font-family:courier new;"&gt;RBuf16&lt;/span&gt;.  I'll leave code to use &lt;span style="font-family:courier new;"&gt;RBuf8&lt;/span&gt;, and to use the non-leaving &lt;span style="font-family:courier new;"&gt;Create()&lt;/span&gt; methods as an exercise for the reader, for now.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;void ExampleRBufCodeL()&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;{&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;__UHEAP_MARK;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 153, 0);font-family:courier new;" &gt;//  RBuf::CreateL&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;    RBuf modifiableBuf;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;    modifiableBuf.CreateL(12);&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;    ASSERT(modifiableBuf.Length()==0);&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;    ASSERT(modifiableBuf.MaxLength()==12);&lt;br /&gt;...&lt;span style="color: rgb(0, 153, 0);font-size:85%;" &gt; &lt;span style="font-size:85%;"&gt;// Do stuff. First push modifiableBuf onto the cleanup stack if a leave may occur&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;    modifiableBuf.Close();&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 153, 0);font-family:courier new;" &gt;//  RBuf::CreateMaxL&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;    modifiableBuf.CreateMaxL(12);&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;    ASSERT(modifiableBuf.Length()==12);&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;    ASSERT(modifiableBuf.MaxLength()==12);&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;...&lt;span style="color: rgb(0, 153, 0);font-size:85%;" &gt; &lt;span style="font-size:85%;"&gt;// Do stuff. First push modifiableBuf onto the cleanup stack if a leave may occur&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;    modifiableBuf.Close();&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 153, 0);font-family:courier new;" &gt;//  RBuf::CreateL passing in a descriptor&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;    _LIT(KHelloWorld, "Hello World");&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;    modifiableBuf.CreateL(KHelloWorld());&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    ASSERT(modifiableBuf.Length()==11);&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;    ASSERT(modifiableBuf.MaxLength()==11);&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;...&lt;span style="color: rgb(0, 153, 0);font-size:85%;" &gt; &lt;span style="font-size:85%;"&gt;// Do stuff. First push modifiableBuf onto the cleanup stack if a leave may occur&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;    modifiableBuf.Close();&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 153, 0);font-family:courier new;" &gt;//  RBuf::CreateL passing in a descriptor and a maximum length&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;modifiableBuf.CreateL(KHelloWorld(), 15);&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;    ASSERT(modifiableBuf.Length()==11);&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;    ASSERT(modifiableBuf.MaxLength()==15);&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;...&lt;span style="color: rgb(0, 153, 0);font-size:85%;" &gt; &lt;span style="font-size:85%;"&gt;// Do stuff. First push modifiableBuf onto the cleanup stack if a leave may occur&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;    modifiableBuf.Close()&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;//  RBuf::CreateL and ReAllocL &amp; modifiable descriptor base class methods&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;_LIT(KHello, "Hello");&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;    _LIT(KWorld, " World");&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;    modifiableBuf.CreateL(5);&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;    modifiableBuf.Copy(KHello());&lt;br /&gt;modifiableBuf.CleanupClosePushL(); &lt;span style="font-size:85%;"&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;// Push onto cleanup stack for leave safety&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;    modifiableBuf.ReAllocL(11);&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;    modifiableBuf.Append(KWorld);&lt;br /&gt;CleanupStack::PopAndDestroy(); &lt;span style="color: rgb(0, 153, 0);"&gt;// Calls modifiableBuf.Close()&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 153, 0);font-family:courier new;" &gt;//  RBuf::Assign&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;HBufC* hBuf = KHello().AllocL();&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;    modifiableBuf.Assign(hBuf);&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;    ASSERT(modifiableBuf.Length()==5);&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;...&lt;span style="color: rgb(0, 153, 0);font-size:85%;" &gt; &lt;span style="font-size:85%;"&gt;// Do stuff. First push modifiableBuf onto the cleanup stack if a leave may occur&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;    modifiableBuf.Close();&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 153, 0);font-family:courier new;" &gt;//  RBuf::Assign, ReAllocL and use of TDes::Append&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;    TUint16* ptr = static_cast&lt;tuint16&gt;(User::AllocL(5*sizeof(TText)));&lt;br /&gt;&lt;/tuint16&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;    modifiableBuf.Assign(ptr,5);&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;    ASSERT(modifiableBuf.Length()==0);&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;    modifiableBuf.Copy(KHello()); &lt;span style="color: rgb(0, 153, 0);"&gt;// Copying any more would panic&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;modifiableBuf.CleanupClosePushL(); &lt;span style="font-size:85%;"&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;// Push onto cleanup stack for leave safety&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;modifiableBuf.ReAllocL(12);&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;    modifiableBuf.Append(KWorld);&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;CleanupStack::PopAndDestroy(); &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;// Calls modifiableBuf.Close()&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt; &lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;    __UHEAP_MARKEND;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;    }&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12650648-111983988043376901?l=descriptors.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://descriptors.blogspot.com/feeds/111983988043376901/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12650648&amp;postID=111983988043376901' title='13 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111983988043376901'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111983988043376901'/><link rel='alternate' type='text/html' href='http://descriptors.blogspot.com/2005/06/33-can-you-give-example-of-how-to-use.html' title='33. Can you give an example of how to use RBuf?'/><author><name>Jo Stichbury</name><uri>http://www.blogger.com/profile/11641972941072027994</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://www.whoshavesthebarber.com/pictures/sose.jpg'/></author><thr:total>13</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12650648.post-111983854094659932</id><published>2005-06-26T18:54:00.000-07:00</published><updated>2006-05-22T13:11:43.346-07:00</updated><title type='text'>32. How do I use RBuf?  What is it?</title><content type='html'>&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;From the Symbian OS 8.1a SDK&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold;font-family:courier new;" &gt;RBuf16&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;16-bit resizable buffer descriptor &lt;span style="font-style: italic;"&gt;[Jo comments - an equivalent 8-bit version, RBuf8, also exists]&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The class provides a buffer that contains, accesses and manipulates &lt;span style="font-family:courier new;"&gt;TUint16&lt;/span&gt; data. The buffer itself is on the heap, and is managed by the class.&lt;br /&gt;&lt;br /&gt;Internally, &lt;span style="font-family:courier new;"&gt;RBuf16&lt;/span&gt; behaves in one of two ways:&lt;br /&gt;&lt;br /&gt;* as a &lt;span style="font-family:courier new;"&gt;TPtr16&lt;/span&gt; descriptor type, where the buffer just contains data,&lt;br /&gt;* as a pointer to a heap descriptor, an &lt;span style="font-family:courier new;"&gt;HBufC16*&lt;/span&gt; type, where the buffer contains both descriptor information and the data.&lt;br /&gt;&lt;br /&gt;Note that the handling of the distinction is hidden from view.&lt;br /&gt;&lt;br /&gt;An &lt;span style="font-family:courier new;"&gt;RBuf16&lt;/span&gt; object can allocate its own buffer. Alternatively, it can take ownership of a pre-existing section of allocated memory, or it can take ownership of a pre-existing heap descriptor. It can also reallocate the buffer to resize it. Regardless of the way in which the buffer has been allocated, the &lt;span style="font-family:courier new;"&gt;RBuf16&lt;/span&gt; object is responsible for freeing memory when the object itself is closed.&lt;br /&gt;&lt;br /&gt;The class is intended for instantiation.&lt;br /&gt;The class is derived from &lt;span style="font-family:courier new;"&gt;TDes16&lt;/span&gt;, which means that data can be both accessed and modified. The base classes provide the functions through which the data is accessed. In addition, an &lt;span style="font-family:courier new;"&gt;RBuf16&lt;/span&gt; object can be passed to any function that is prototyped to take a &lt;span style="font-family:courier new;"&gt;TDes16&lt;/span&gt; or a &lt;span style="font-family:courier new;"&gt;TDesC16&lt;/span&gt; type.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;So what does this mean for me?&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;An &lt;span style="font-family:courier new;"&gt;RBuf&lt;/span&gt; object is rather like an &lt;span style="font-family:courier new;"&gt;HBufC&lt;/span&gt; in that it can be created dynamically by specifying the maximum length required. However, it also benefits from being modifiable, since it derives from &lt;span style="font-family:courier new;"&gt;TDes16&lt;/span&gt;. This means that you don’t have to create a &lt;span style="font-family:courier new;"&gt;TPtr &lt;/span&gt;around the data in order to modify it, which makes it preferable to &lt;span style="font-family:courier new;"&gt;HBufC &lt;/span&gt;when you know you need to dynamically allocate a descriptor, and later modify it.&lt;br /&gt;&lt;br /&gt;You don’t need to worry too much about how it’s represented internally – either as a &lt;span style="font-family:courier new;"&gt;TPtr &lt;/span&gt;or &lt;span style="font-family:courier new;"&gt;HBufC&lt;/span&gt;. In fact, all you need to know is how to create and destroy an &lt;span style="font-family:courier new;"&gt;RBuf&lt;/span&gt;, because calling the other descriptor operations on it should be second nature, given that you have access to all the base class methods of &lt;span style="font-family:courier new;"&gt;TDes16 &lt;/span&gt;and &lt;span style="font-family:courier new;"&gt;TDes16C&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;But you must remember that, although &lt;span style="font-family:courier new;"&gt;RBuf &lt;/span&gt;manages the descriptor buffer by freeing it when you call &lt;span style="font-family:courier new;"&gt;Close()&lt;/span&gt;, it doesn’t manage the size of the buffer and reallocate it when you need more memory for any particular operation.&lt;br /&gt;&lt;br /&gt;So, for example, if you call &lt;span style="font-family:courier new;"&gt;Append() &lt;/span&gt;on a &lt;span style="font-family:courier new;"&gt;RBuf &lt;/span&gt;object for which there is insufficient memory available, a panic will occur – the &lt;span style="font-family:courier new;"&gt;RBuf &lt;/span&gt;object will not automatically reallocate the buffer. This should be clear from the fact that the base class methods are non-leaving, that is, there is no scope for the reallocation to fail in the event of low memory.&lt;br /&gt;&lt;br /&gt;So you still need to manage the memory for descriptor operations that may need to extend the descriptor.&lt;br /&gt;&lt;br /&gt;The &lt;span style="font-family:courier new;"&gt;RBuf &lt;/span&gt;class was first introduced in Symbian OS v8.0, but first documented in the 8.1 SDK and is used extensively in software written for devices based on v9.x.  The RBuf class is ideal for handling &lt;span style="font-family:courier new;"&gt;HBufC &lt;/span&gt;using a stack-based R class object, and may often be preferable to the contortions required to modify an &lt;span style="font-family:courier new;"&gt;HBufC&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;I've created a short example of how to use the class in &lt;a href="http://descriptors.blogspot.com/2005/06/33-can-you-give-example-of-how-to-use.html"&gt;&lt;i&gt;33. Can you give an example of how to use RBuf?&lt;/i&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;I'd like to acknowledge &lt;a href="http://www.pagonis.org/Pagonis.html"&gt;JP&lt;/a&gt;'s help and advice with this post.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12650648-111983854094659932?l=descriptors.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://descriptors.blogspot.com/feeds/111983854094659932/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12650648&amp;postID=111983854094659932' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111983854094659932'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111983854094659932'/><link rel='alternate' type='text/html' href='http://descriptors.blogspot.com/2005/06/32-how-do-i-use-rbuf-what-is-it.html' title='32. How do I use RBuf?  What is it?'/><author><name>Jo Stichbury</name><uri>http://www.blogger.com/profile/11641972941072027994</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://www.whoshavesthebarber.com/pictures/sose.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12650648.post-111964615373197862</id><published>2005-06-24T13:42:00.000-07:00</published><updated>2006-05-21T16:26:52.853-07:00</updated><title type='text'>31. How do I convert between Java strings and descriptors?</title><content type='html'>Check out the answer to FAQ-0277 on Symbian's Developer FAQ &amp; Tech Tips site:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www3.symbian.com/faq.nsf/0/80D8199F9B71BC6180256A570051BA7E?OpenDocument"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family: georgia;"&gt;"&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: georgia;font-family:Arial;font-size:100%;"  &gt;How do I convert between Java strings and Unicode descriptors?"&lt;/span&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12650648-111964615373197862?l=descriptors.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://descriptors.blogspot.com/feeds/111964615373197862/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12650648&amp;postID=111964615373197862' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111964615373197862'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111964615373197862'/><link rel='alternate' type='text/html' href='http://descriptors.blogspot.com/2005/06/31-how-do-i-convert-between-java.html' title='31. How do I convert between Java strings and descriptors?'/><author><name>Jo Stichbury</name><uri>http://www.blogger.com/profile/11641972941072027994</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://www.whoshavesthebarber.com/pictures/sose.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12650648.post-111963942230807890</id><published>2005-06-24T11:52:00.000-07:00</published><updated>2006-05-21T16:25:03.310-07:00</updated><title type='text'>30. How do I convert an 8-bit descriptor to a Java string?</title><content type='html'>Check out the answer to FAQ-0298 on Symbian's Developer FAQ &amp; Tech Tips site:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:100%;"&gt;&lt;a href="http://www3.symbian.com/faq.nsf/0/B2CF51949A6B8AAD80256A570051BA7C?OpenDocument"&gt;&lt;span style="font-family:georgia;"&gt;"&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;a href="http://www3.symbian.com/faq.nsf/0/B2CF51949A6B8AAD80256A570051BA7C?OpenDocument"&gt;&lt;span style=";font-family:Arial;font-size:100%;"  &gt;How do I convert an 8-bit descriptor to a Java string?&lt;/span&gt;&lt;/a&gt;&lt;span style="font-size:100%;"&gt;&lt;a href="http://www3.symbian.com/faq.nsf/0/B2CF51949A6B8AAD80256A570051BA7C?OpenDocument"&gt;&lt;span style="font-family:georgia;"&gt;"&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;These days, it's not necessary to use the Symbian cast macros (eg REINTERPRET_CAST) since these are simply defined as the equivalent C++ standard (eg reinterpret_cast). They're a legacy from when GCC didn't support &lt;/span&gt;the casts.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12650648-111963942230807890?l=descriptors.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://descriptors.blogspot.com/feeds/111963942230807890/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12650648&amp;postID=111963942230807890' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111963942230807890'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111963942230807890'/><link rel='alternate' type='text/html' href='http://descriptors.blogspot.com/2005/06/30-how-do-i-convert-8-bit-descriptor.html' title='30. How do I convert an 8-bit descriptor to a Java string?'/><author><name>Jo Stichbury</name><uri>http://www.blogger.com/profile/11641972941072027994</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://www.whoshavesthebarber.com/pictures/sose.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12650648.post-111904410056936718</id><published>2005-06-17T14:29:00.000-07:00</published><updated>2006-05-21T16:23:40.826-07:00</updated><title type='text'>29. How can I write the most efficient code when using HBufC?</title><content type='html'>&lt;span style="font-weight: bold;"&gt;(1) Spawn &lt;span style="font-family:courier new;"&gt;HBufC &lt;/span&gt;from existing descriptors using &lt;span style="font-family:courier new;"&gt;TDesC::AllocL()&lt;/span&gt; rather than creating and copying into them&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;HBufC &lt;/span&gt;can be spawned from a existing descriptor using the &lt;span style="font-family:courier new;"&gt;Alloc()&lt;/span&gt; or &lt;span style="font-family:courier new;"&gt;AllocL()&lt;/span&gt; overloads of by &lt;span style="font-family:courier new;"&gt;TDesC&lt;/span&gt;.  You can thus replace code like this:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;void SomeFunctionL(const TDesC&amp; aDes)&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;    HBufC* heapBuffer = HBufC::NewL(aDes.Length());&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;    TPtr ptr(heapBuffer-&gt;Des());&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;    ptr.Copy(aDes);&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;    ...&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;With the more efficient single line:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;void SomeFunctionL(const TDesC&amp; aDes)&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;    HBufC* heapBuffer = aDes.AllocL();&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;    ...&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;(2) Don't call &lt;span style="font-family:courier new;"&gt;HBufC::Des()&lt;/span&gt; if you need only non-modifiable access to the data&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;It is clearer and more efficient simply to dereference an &lt;span style="font-family:courier new;"&gt;HBufC &lt;/span&gt;if you need a non modifiable reference to its data.  You only need to call &lt;span style="font-family:courier new;"&gt;Des()&lt;/span&gt; when you need to modify it - &lt;span style="font-family:courier new;"&gt;Des()&lt;/span&gt; will return a &lt;span style="font-family:courier new;"&gt;TPtr&lt;/span&gt;.  That is:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;void Log(const TDesC&amp; aLogBuf); // Forward declaration&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;void Convert(TDes&amp; aBuf);&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;void CMyClass::SomeFunction()&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;{// iHeapBuf is a member of CMyClass&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;//  Get non-modifiable access (TDesC&amp;) to iHeapBuf&lt;br /&gt; &lt;/span&gt;&lt;span style="font-family:courier new;"&gt;Log(*iHeapBuf); // Call a method which takes const TDesC&amp;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;//  Now get modifiable access (TDes&amp;amp;) to iHeapBuf&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt; Convert(iHeapBuf-&gt;Des()); // Call a method which takes TDes&amp;amp;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;By the way, an interesting side-effect of creating a modifiable descriptor from a non-modifiable heap descriptor is discussed in &lt;a href="http://descriptor-tips.blogspot.com/2005/06/tip-9-beware-of-calling-maxlength-on.html"&gt;Tip 9&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12650648-111904410056936718?l=descriptors.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://descriptors.blogspot.com/feeds/111904410056936718/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12650648&amp;postID=111904410056936718' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111904410056936718'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111904410056936718'/><link rel='alternate' type='text/html' href='http://descriptors.blogspot.com/2005/06/29-how-can-i-write-most-efficient-code.html' title='29. How can I write the most efficient code when using HBufC?'/><author><name>Jo Stichbury</name><uri>http://www.blogger.com/profile/11641972941072027994</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://www.whoshavesthebarber.com/pictures/sose.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12650648.post-111903394805324911</id><published>2005-06-17T11:38:00.000-07:00</published><updated>2006-05-21T16:20:17.243-07:00</updated><title type='text'>28. How do I know what the equivalent C string library functions are for descriptors?</title><content type='html'>Just about all the C string library functionality has been implemented by the descriptor base classes, so you can chop them up, rearrange, tokenise and format them just like you have always been able to do with C strings.&lt;br /&gt;&lt;br /&gt;Here's a useful &lt;a href="http://www.whoshavesthebarber.com/descriptors_blog/cstringanddescriptors.html"&gt;table&lt;/a&gt; which compares C string functions with their descriptor equivalents.  I found the information in section 5 of [&lt;a href="http://descriptors.blogspot.com/2006/05/references-to-other-descriptors.html"&gt;&lt;i&gt;reference 7&lt;/i&gt;&lt;/a&gt;]&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12650648-111903394805324911?l=descriptors.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://descriptors.blogspot.com/feeds/111903394805324911/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12650648&amp;postID=111903394805324911' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111903394805324911'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111903394805324911'/><link rel='alternate' type='text/html' href='http://descriptors.blogspot.com/2005/06/28-how-do-i-know-what-equivalent-c.html' title='28. How do I know what the equivalent C string library functions are for descriptors?'/><author><name>Jo Stichbury</name><uri>http://www.blogger.com/profile/11641972941072027994</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://www.whoshavesthebarber.com/pictures/sose.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12650648.post-111870463553504929</id><published>2005-06-13T16:15:00.000-07:00</published><updated>2006-05-21T16:02:10.413-07:00</updated><title type='text'>27. How do I know which kind of descriptor to use?</title><content type='html'>This flowchart may help.  It's taken from my book, Symbian OS Explained (page 76), with some modification:&lt;br /&gt;&lt;br /&gt;&lt;img src="http://www.whoshavesthebarber.com/descriptors_blog/Descriptor_flowchart.jpg" /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12650648-111870463553504929?l=descriptors.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://descriptors.blogspot.com/feeds/111870463553504929/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12650648&amp;postID=111870463553504929' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111870463553504929'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111870463553504929'/><link rel='alternate' type='text/html' href='http://descriptors.blogspot.com/2005/06/27-how-do-i-know-which-kind-of.html' title='27. How do I know which kind of descriptor to use?'/><author><name>Jo Stichbury</name><uri>http://www.blogger.com/profile/11641972941072027994</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://www.whoshavesthebarber.com/pictures/sose.jpg'/></author><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12650648.post-111862790015515670</id><published>2005-06-12T18:49:00.000-07:00</published><updated>2006-05-18T13:24:51.993-07:00</updated><title type='text'>26. How do I convert between 8 bit and 16 bit descriptors?</title><content type='html'>TDes defines a set of &lt;span style="font-family:courier new;"&gt;Copy()&lt;/span&gt; methods to copy data from another descriptor of either width, from a pointer to a block of data of a specified length or from a NULL-terminated string. There are also methods for copying with folding,collation or case adjustment.&lt;br /&gt;&lt;br /&gt;In each case, the data is copied &lt;span style="font-weight: bold;"&gt;*from*&lt;/span&gt; the source specified in the parameter &lt;span style="font-weight: bold;"&gt;*into*&lt;/span&gt; the modifiable, target, descriptor upon which the method is called. If the length of the 'incoming' data is greater than the target descriptor, a USER 11 panic occurs.&lt;br /&gt;&lt;br /&gt;// From the definition of &lt;span style="font-family:courier new;"&gt;TDes16&lt;/span&gt; in e32des16.h&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;IMPORT_C void Copy(const TDesC8&amp; aDes); // Copies an 8 bit descriptor&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;IMPORT_C void Copy(const TDesC16&amp; aDes); // Copies a 16 bit descriptor&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;IMPORT_C void Copy(const TUint16* aBuf, TInt aLength); // Copies aLength characters from the aBuf pointer&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;IMPORT_C void Copy(const TUint16* aString); // Copies the NULL terminated aString&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;IMPORT_C void CopyF(const TDesC16&amp; aDes); // Copies and folds&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;IMPORT_C void CopyC(const TDesC16&amp; aDes); // Copies and collates&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;IMPORT_C void CopyLC(const TDesC16&amp; aDes); // Copies and converts the text to lower case&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;IMPORT_C void CopyUC(const TDesC16&amp; aDes); // Copies and converts the text to upper case&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;IMPORT_C void CopyCP(const TDesC16&amp; aDes); // Copies and capitalizes the text&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Note that, because the &lt;span style="font-family:courier new;"&gt;Copy()&lt;/span&gt; method is overloaded to take either an 8- or 16-bit descriptor, it is possible to copy:&lt;br /&gt;&lt;ul&gt;   &lt;li&gt;a narrow descriptor onto a narrow descriptor (&lt;span style="font-family:courier new;"&gt;TDes8 -&gt; TDes8&lt;/span&gt;), &lt;/li&gt;   &lt;li&gt;a wide descriptor onto a wide descriptor (&lt;span style="font-family:courier new;"&gt;TDes16 -&gt; TDes16&lt;/span&gt;), &lt;/li&gt;   &lt;li&gt;a narrow descriptor onto a wide descriptor (&lt;span style="font-family:courier new;"&gt;TDes8 -&gt; TDes16&lt;/span&gt;),&lt;/li&gt;   &lt;li&gt;a wide descriptor onto a narrow descriptor (&lt;span style="font-family:courier new;"&gt;TDes16 -&gt; TDes8&lt;/span&gt;).&lt;/li&gt; &lt;/ul&gt;&lt;br /&gt;Copying between descriptors of equivalent character widths is fairly self-explanatory, but copying between descriptors of different character widths is worthy of elaboration:&lt;br /&gt;&lt;br /&gt;The &lt;span style="font-family:courier new;"&gt;Copy()&lt;/span&gt; method implemented by &lt;span style="font-family:courier new;"&gt;TDes16&lt;/span&gt; to copy an 8 bit descriptor parameter will pad each incoming character with a trailing zero.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;// Instantiate a wide descriptor&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;_LIT16(KFred, "Fred");&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;TBuf16&lt;4&gt; wideFred(KFred); // Bytewise = F\0R\0E\0D\0&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;// Instantiate a narrow descriptor&lt;/span&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;&lt;br /&gt;_LIT8(KBert, "Bert");&lt;/span&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;&lt;br /&gt;TBuf8&lt;5&gt; narrowBert(KBert); // Bytewise = BERT&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;// Copy the contents of the narrow descriptor into the wide descriptor&lt;/span&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;&lt;br /&gt;wideFred.Copy(narrowBert); // Bytewise = B\0E\0R\0T\0&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;The &lt;span style="font-family:courier new;"&gt;Copy()&lt;/span&gt; method implemented by &lt;span style="font-family:courier new;"&gt;TDes8&lt;/span&gt; to copy an incoming 16-bit descriptor will strip out alternate characters which are assumed to be zeroes. This means that this form of copy will only work if the characters in the wide string do not exceed 255 (decimal).&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;// Instantiate a wide descriptor&lt;/span&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;&lt;br /&gt;_LIT16(KFred, "Fred");&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;TBuf16&lt;4&gt; wideFred(KFred); // Bytewise = F\0R\0E\0D\0&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;// Instantiate a narrow descriptor&lt;/span&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;&lt;br /&gt;_LIT8(KBert, "Bert");&lt;/span&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;&lt;br /&gt;TBuf8&lt;5&gt; narrowBert(KBert); // Bytewise = BERT&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;// Copy the contents of the wide descriptor into the narrow descriptor&lt;/span&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;&lt;br /&gt;narrowBert.Copy(wideFred); // Bytewise = FRED&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;br /&gt;Copy()&lt;/span&gt; thus forms a simple way to copy and convert between narrow and wide descriptors when the character set is encoded by one 8-bit byte per character and the last byte of each wide character is simply a NULL character padding.&lt;br /&gt;&lt;br /&gt;If you need to do a proper conversion between 16-bit Unicode and 8-bit, non-Unicode, character sets (or between Unicode and the UTF-7 and UTF-8 transformation sets), use the Symbian OS conversion library, charconv.lib.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12650648-111862790015515670?l=descriptors.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://descriptors.blogspot.com/feeds/111862790015515670/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12650648&amp;postID=111862790015515670' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111862790015515670'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111862790015515670'/><link rel='alternate' type='text/html' href='http://descriptors.blogspot.com/2005/06/26-how-do-i-convert-between-8-bit-and.html' title='26. How do I convert between 8 bit and 16 bit descriptors?'/><author><name>Jo Stichbury</name><uri>http://www.blogger.com/profile/11641972941072027994</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://www.whoshavesthebarber.com/pictures/sose.jpg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12650648.post-111862454595587801</id><published>2005-06-12T17:59:00.000-07:00</published><updated>2006-05-18T13:24:35.293-07:00</updated><title type='text'>25. What do Length(), MaxLength(), SetLength() and SetMax() do?</title><content type='html'>&lt;span style="font-weight: bold;font-family:courier new;" &gt;TDesC::Length()&lt;/span&gt; returns the number of characters the descriptor contains.&lt;br /&gt;&lt;br /&gt;[While we're on the subject of descriptor length, beware!  Be careful not to confuse &lt;span style="font-family:courier new;"&gt;Size()&lt;/span&gt; and &lt;span style="font-family:courier new;"&gt;Length()&lt;/span&gt;.  They do similar things, but while &lt;span style="font-family:courier new;"&gt;Length()&lt;/span&gt; returns the number of characters the descriptor contains, &lt;span style="font-family:courier new;"&gt;Size()&lt;/span&gt; returns the number of bytes it occupies. For 8-bit descriptors, where each character occupies a byte, this is the same thing. However, on all releases of Symbian OS since v5u, the native character width has been 16 bits, so each character occupies two bytes. Unless you're working with a very old SDK, you'll find that &lt;span style="font-family:courier new;"&gt;Size()&lt;/span&gt; always returns a value which is double that of &lt;span style="font-family:courier new;"&gt;Length()&lt;/span&gt;].&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-family:courier new;" &gt;TDes::MaxLength()&lt;/span&gt; returns the maximum length allowed for a modifiable descriptor.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-family:courier new;" &gt;TDes::SetLength()&lt;/span&gt; can be used to change the descriptor's length to any value between zero and its maximum length.  You can also use &lt;span style="font-family:courier new;"&gt;TDes::Zero()&lt;/span&gt; to set the length to zero.  And &lt;span style="font-weight: bold;font-family:courier new;" &gt;TDes::SetMax()&lt;/span&gt; to set the length to the maximum.&lt;br /&gt;&lt;br /&gt;[&lt;span style="font-family:courier new;"&gt;SetMax()&lt;/span&gt; has a slightly misleading name. It doesn’t allow you to change the maximum length of the descriptor, which would, in effect, allow you to resize its data area].&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12650648-111862454595587801?l=descriptors.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://descriptors.blogspot.com/feeds/111862454595587801/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12650648&amp;postID=111862454595587801' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111862454595587801'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111862454595587801'/><link rel='alternate' type='text/html' href='http://descriptors.blogspot.com/2005/06/25-what-do-length-maxlength-setlength.html' title='25. What do Length(), MaxLength(), SetLength() and SetMax() do?'/><author><name>Jo Stichbury</name><uri>http://www.blogger.com/profile/11641972941072027994</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://www.whoshavesthebarber.com/pictures/sose.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12650648.post-111732713064029816</id><published>2005-05-28T17:36:00.000-07:00</published><updated>2006-05-18T13:24:00.090-07:00</updated><title type='text'>23. Why is the _L literal descriptor macro deprecated?</title><content type='html'>Why is the original _L macro now deprecated in all but test code?  These have the advantage of being used in place rather than declared separately, for example:&lt;br /&gt;&lt;br /&gt;User::Panic(_L("TEST SERVER"), KErrNotOVerflow);&lt;br /&gt;&lt;br /&gt;You will still see them used in test code since they saves typing and thinking up a name for each literal.  It's OK to do so where memory use is not critical, but you should avoid using them in production code.  Why?&lt;br /&gt;&lt;br /&gt;Well, the text, for example "TEST SERVER" is built into ROM as a basic, NULL-terminated C style string, with no initial length member. Because the layout of the stored literal is not like that of a descriptor, it means that when each instance of the literal is used, a temporary TPtrC must be constructed around the data in ROM.  The construction of the temporary, which requires 4 bytes of memory for the length/type data, and instructions to set the pointer, the length and the descriptor type, is an unnecessary overhead when compared to _LIT descriptors which can be used directly because they are stored in ROM to look like descriptors. &lt;br /&gt;&lt;br /&gt;The generation of each temporary results in inline constructor code which may bloat binaries where many string literals are used.  Furthermore, the use of a run-time temporary is safe as long as it is used only during the lifetime of the function in which it is created&lt;br /&gt;&lt;br /&gt;So, in summary, you should use _LIT to _L for your literal descriptors, because _L has an overhead associated with constructing a run-time temporary TPtrC and _LIT does not.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12650648-111732713064029816?l=descriptors.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://descriptors.blogspot.com/feeds/111732713064029816/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12650648&amp;postID=111732713064029816' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111732713064029816'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111732713064029816'/><link rel='alternate' type='text/html' href='http://descriptors.blogspot.com/2005/05/23-why-is-l-literal-descriptor-macro.html' title='23. Why is the _L literal descriptor macro deprecated?'/><author><name>Jo Stichbury</name><uri>http://www.blogger.com/profile/11641972941072027994</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://www.whoshavesthebarber.com/pictures/sose.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12650648.post-111732695814236581</id><published>2005-05-28T17:34:00.000-07:00</published><updated>2006-05-28T14:23:32.643-07:00</updated><title type='text'>22. What are literal descriptors?</title><content type='html'>Literal descriptors are constant descriptors which are compiled into ROM because their contents does not ever change. They are equivalent to static char[] in C.&lt;br /&gt;&lt;br /&gt;There are two types of literal descriptor, _LIT which is the most efficient, and preferred, Symbian OS literal and _L, which is now deprecated in all but test code.&lt;br /&gt;&lt;br /&gt;In the examples I've included in this blog, I've used _LIT throughout, so you've seen it in action already, for example:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;_LIT(KFred, "Fred");&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;On the wide builds of Symbian OS created today, this is equivalent to the following:&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;_LIT16(KFred, "Fred");&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;If an explicitly narrow literal descriptor is required, this can be created using the _LIT8 macro:&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;_LIT8(KFred, "Fred");&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;KFred&lt;/span&gt; can then be used as a constant descriptor, either directly or to initialise a &lt;span style="font-family: courier new;"&gt;TPtrC/TPtr&lt;/span&gt; or &lt;span style="font-family: courier new;"&gt;TBufC/TBuf&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;The macros are defined in the Symbian OS header file e32def.h and create an object of type &lt;span style="font-family: courier new;"&gt;TLitC16&lt;/span&gt; or &lt;span style="font-family: courier new;"&gt;TLitC8&lt;/span&gt; (defined in e32des.h). These classes do not derive from &lt;span style="font-family: courier new;"&gt;TDesC8&lt;/span&gt; or &lt;span style="font-family: courier new;"&gt;TDesC16&lt;/span&gt; but have the same binary layout as &lt;span style="font-family: courier new;"&gt;TBufC8&lt;/span&gt; or &lt;span style="font-family: courier new;"&gt;TBufC16&lt;/span&gt;. This means that the literal object can be used wherever &lt;span style="font-family: courier new;"&gt;TDesC&lt;/span&gt; is used. The literal classes provide &lt;span style="font-family: courier new;"&gt;operator()()&lt;/span&gt; which is very useful to cast the literal object to a &lt;span style="font-family: courier new;"&gt;TDesC&lt;/span&gt;. For example:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;_LIT(KFred, "Fred");&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;HBufC8* theHeapBuffer = KFred().AllocL();&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;To save you additional code, Symbian OS already defines a literal to represent a blank string, defined as follows:&lt;br /&gt;&lt;br /&gt;Build independent: &lt;span style="font-family: courier new;"&gt;_LIT(KNullDesC,"");&lt;/span&gt;&lt;br /&gt;8-bit for non-Unicode strings: &lt;span style="font-family: courier new;"&gt;_LIT8(KNullDesC8,"");&lt;/span&gt;&lt;br /&gt;16-bit for Unicode strings: &lt;span style="font-family: courier new;"&gt;_LIT16(KNullDesC16,"");&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12650648-111732695814236581?l=descriptors.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://descriptors.blogspot.com/feeds/111732695814236581/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12650648&amp;postID=111732695814236581' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111732695814236581'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111732695814236581'/><link rel='alternate' type='text/html' href='http://descriptors.blogspot.com/2005/05/22-what-are-literal-descriptors.html' title='22. What are literal descriptors?'/><author><name>Jo Stichbury</name><uri>http://www.blogger.com/profile/11641972941072027994</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://www.whoshavesthebarber.com/pictures/sose.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12650648.post-111732443163932716</id><published>2005-05-28T16:53:00.000-07:00</published><updated>2006-05-22T09:47:39.543-07:00</updated><title type='text'>21. Why is there no HBuf class?</title><content type='html'>Well, there is and there isn't. Up until Symbian OS v8.0, there was no modifiable heap descriptor class, HBuf, in symmetry with the TBufC and TBuf stack buffers. There were a number of reasons for this:&lt;br /&gt;&lt;br /&gt;(1) The expectation might be that, for a modifiable heap descriptor, the maximum length would expand and contract on the heap as the content was modified. An HBuf class which is modifiable but does not dynamically resize could be considered odd and rather pointless. But to add dynamic resizing to HBuf would be difficult because these methods could leave under low memory conditions and would have to be adjusted accordingly. But, as I’ve previously described, all the modifiable descriptor operations are implemented in the base class, TDes, thus affecting all descriptor types.&lt;br /&gt;&lt;br /&gt;(2) If dynamic reallocation were added to HBuf, the location of the buffer might change as code is reallocated, affecting all TPtr objects referencing that heap buffer's data, as well as compromising the cleanup stack, if the HBuf pointer is stored there.&lt;br /&gt;&lt;br /&gt;(3) Heap buffers were initially intended to allow efficient reading of constant resource strings of variable length. Because they are constant, they save on the additional four bytes required to store a maximum length, which allows them to be as compact as possible. They can still be modified using Des() if necessary, If a separate HBuf class were provided, it would have an extra 4-byte overhead - and may frequently be created unnecessarily, which might add to a significant waste of heap space over time.&lt;br /&gt;&lt;br /&gt;However, this is a somewhat spurious argument since making an HBufC::Des() call is non-trivial and the resultant TPtr itself occupies 12 bytes of stack space. If a modifiable heap descriptor is definitely needed, creating a constant buffer and then an additional, TPtr to update wastes memory *and* processor instructions.&lt;br /&gt;&lt;br /&gt;To this end, Symbian OS 8.0 and 8.1 introduced class RBuf for resizable descriptors.  The Symbian documentation for this class can be found in [&lt;a href="http://descriptors.blogspot.com/2006/05/references-to-other-descriptors.html"&gt;&lt;i&gt;reference 6&lt;/i&gt;&lt;/a&gt;]. &lt;br /&gt;&lt;br /&gt;I discuss class RBuf in more detail in &lt;a href="http://descriptors.blogspot.com/2005/06/32-how-do-i-use-rbuf-what-is-it.html"&gt;&lt;i&gt;32. How do I use RBuf? What is it?&lt;/i&gt;&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12650648-111732443163932716?l=descriptors.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://descriptors.blogspot.com/feeds/111732443163932716/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12650648&amp;postID=111732443163932716' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111732443163932716'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111732443163932716'/><link rel='alternate' type='text/html' href='http://descriptors.blogspot.com/2005/05/21-why-is-there-no-hbuf-class.html' title='21. Why is there no HBuf class?'/><author><name>Jo Stichbury</name><uri>http://www.blogger.com/profile/11641972941072027994</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://www.whoshavesthebarber.com/pictures/sose.jpg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12650648.post-111732190033486935</id><published>2005-05-28T16:05:00.000-07:00</published><updated>2007-09-18T11:44:32.886-07:00</updated><title type='text'>20. How do I use heap-based buffer descriptors?</title><content type='html'>Heap-based descriptors, HBufC&amp;lt;n&amp;gt;, can be used for dynamic allocation of string data whose size is not known at compile time.  It should also be used to store string data too large for the stack.  In effect, HBufC should be used where malloc’d data would be used in C.&lt;br /&gt;&lt;br /&gt;Although the class representing these descriptors is HBufC, these descriptors are always referred to by pointer, HBufC*. The class doesn’t comply with the standard Symbian OS naming conventions, but then, it doesn’t really fit any of the standard Symbian OS types exactly. It is simply prefixed with H to indicate that the data is stored on the heap.&lt;br /&gt;&lt;br /&gt;HBufC can be created using one of the static NewL() functions of the class.  These may leave if there is insufficient memory available (the non-leaving version will return NULL). The heap buffers must be constructed using one of these methods or by using one of the Alloc() or AllocL() methods of the TDesC class to spawn an HBufC copy of any descriptor.&lt;br /&gt;&lt;br /&gt;The ‘C’ suffix in the class name indicates that these descriptors are constant, although, in common with the stack-based non-modifiable buffer descriptors, the class has a set of assignment operators to allow the entire contents of the buffer to be replaced (as long as the new data does not exceed the length of the heap cell originally allocated).  In addition, as with TBufC, the heap-based descriptors can be manipulated at runtime by creating a modifiable pointer descriptor, TPtr over the heap buffer, using the Des() method.  For example:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;_LIT(KFred, "Fred");&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;// Allocate an empty heap descriptor of max length 4&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;HBufC* heapBuf = HBufC::NewL(4);&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;// Copy in the contents of KFred&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;*heapBuf = KFred; // heapBuf now contains "Fred"&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;// Or, a more direct alternative:&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;HBufC* heapBuf = KFred().AllocL();&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;_LIT(KBert, "Bert");&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;TPtr ptr(heapBuf-&gt;Des()); // Modifiable TPtr over heapBuf data area&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;ptr = KBert(); // Copies "Bert" into heapBuf&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;delete heapBuf; // heapBuf deleted - ptr is now invalid&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;The heap descriptors can be created dynamically to the size required, but are not automatically resized when additional data storage is needed.  Instead, you must make sure the buffer has sufficient memory before calling a modification operation.  If necessary, you can reallocate the buffer, to grow it to the desired size, using the set of ReAllocL() methods.  These may potentially move the buffer from its previous memory location.  If there is insufficient memory, they will leave.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;_LIT(KFred, "Fred");&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;// Allocate a heap descriptor of max length 4&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;HBufC* heapBuf = KFred().AllocLC();&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;_LIT(KCyril, "Cyril");&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;TPtr ptr(heapBuf-&gt;Des()); // Modifiable TPtr over heapBuf data area&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;ptr = KCyril(); // This would panic because max length (4) is exceeded&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;// Instead, we need to do a reallocation&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;// Leave on cleanup stack in case the realloc fails and a leave occurs&lt;br /&gt;heapBuf = heapBuf-&gt;ReAllocL(5);&lt;br /&gt;&lt;br /&gt;// Realloc succeeded, but heapBuf pointer may have changed&lt;br /&gt;// We must update the pointer stored on the cleanup stack&lt;br /&gt;CleanupStack::Pop(); // Push it off&lt;br /&gt;// Push it back on again&lt;br /&gt;CleanupStack::PushL(heapBuf);&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;// Since realloc may have changed the location in memory&lt;br /&gt;// we must also reset ptr&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;ptr.Set(heapBuf-&gt;Des());&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;ptr = KCyril(); // Copies "Cyril" into heapBuf&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;CleanupStack::PopAndDestroy(heapBuf); // heapBuf destroyed&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Moral of the story&lt;/span&gt;&lt;br /&gt;Heap descriptors can be created dynamically but are not automatically resized should they need to be extended.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12650648-111732190033486935?l=descriptors.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://descriptors.blogspot.com/feeds/111732190033486935/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12650648&amp;postID=111732190033486935' title='10 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111732190033486935'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111732190033486935'/><link rel='alternate' type='text/html' href='http://descriptors.blogspot.com/2005/05/20-how-do-i-use-heap-based-buffer.html' title='20. How do I use heap-based buffer descriptors?'/><author><name>Jo Stichbury</name><uri>http://www.blogger.com/profile/11641972941072027994</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://www.whoshavesthebarber.com/pictures/sose.jpg'/></author><thr:total>10</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12650648.post-111731795308351067</id><published>2005-05-28T15:05:00.000-07:00</published><updated>2006-05-21T15:48:38.086-07:00</updated><title type='text'>19. How do I use stack-based buffer descriptors?</title><content type='html'>The stack-based buffer descriptor classes are &lt;span style="font-family:courier new;"&gt;TBufC&amp;lt;n&amp;gt; &lt;/span&gt;and &lt;span style="font-family:courier new;"&gt;TBuf&amp;lt;n&amp;gt;&lt;/span&gt;. They are useful for fixed-size or relatively small strings, say up to the length of a 256-character filename (i.e. where n &lt;=256). As I've previously described in &lt;a href="http://descriptors.blogspot.com/2005/05/6-large-stack-based-descriptors.html"&gt;&lt;i&gt;6. Large stack-based descriptors&lt;/i&gt;&lt;/a&gt; and in &lt;a href="http://descriptor-tips.blogspot.com/2005/05/tip-3-need-small-known-length.html"&gt;Tip 3&lt;/a&gt;, because they are stack-based, and stack space is limited on Symbian OS, if you need a larger buffer, you should use the heap (either by using the heap-based buffer descriptors, or having &lt;span style="font-family:courier new;"&gt;TBuf&lt;/span&gt; or &lt;span style="font-family:courier new;"&gt;TBufC&lt;/span&gt; as member variables of C classes). Being stack-based, these descriptors should also only be used when they have a lifetime that coincides with that of their creator.&lt;br /&gt;&lt;br /&gt;The &lt;span style="font-family:courier new;"&gt;TBuf&lt;/span&gt; and &lt;span style="font-family:courier new;"&gt;TBufC&lt;/span&gt; descriptors are somewhat equivalent to &lt;span style="font-family:courier new;"&gt;char[]&lt;/span&gt; in C, but benefit from internal overflow checks. As you've probably guessed by now, they may be constant (&lt;span style="font-family:courier new;"&gt;TBufC&lt;/span&gt;) or modifiable (&lt;span style="font-family:courier new;"&gt;TBuf&lt;/span&gt;).&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;&lt;span style="font-family:courier new;"&gt;TBufC&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;The layout of the buffer descriptors is such that the string data forms part of the descriptor object itself, and follows the length word for &lt;span style="font-family:courier new;"&gt;TBufC&lt;/span&gt; and the maximum length word for &lt;span style="font-family:courier new;"&gt;TBuf&lt;/span&gt;. You can find a diagram in [&lt;a href="http://descriptors.blogspot.com/2006/05/references-to-other-descriptors.html"&gt;&lt;i&gt;reference 5&lt;/i&gt;&lt;/a&gt;].&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;TBufC&lt;/span&gt; is a thin template class which uses the &lt;span style="font-family:courier new;"&gt;TInt&lt;/span&gt; value to fix the size of the data area. The non-modifiable buffer class is used to hold constant string or binary data. It derives from &lt;span style="font-family:courier new;"&gt;TBufCBase&lt;/span&gt; (which derives from &lt;span style="font-family:courier new;"&gt;TDesC&lt;/span&gt;, and only exists as an inheritance convenience. It should not be used directly).  You can find more about thin templates from Chapter 19 of my book, Symbian OS Explained, more details of which are in the &lt;a style="font-style: italic;" href="http://descriptors.blogspot.com/2006/05/references-to-other-descriptors.html"&gt;References&lt;/a&gt; section.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;TBufC&lt;/span&gt; defines constructors that allow it to be created from a copy of any other descriptor or from a zero-terminated string. They can also be created empty and filled later. This may at first seem unintuitive for a constant buffer, but in fact, while the data itself is constant, the contents of the buffer may be replaced by calling the assignment operator of the class. The replacing data must not exceed the length specified when the buffer was created, or a panic will occur, in both debug and release modes.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;TBufC&lt;/span&gt; also has a &lt;span style="font-family:courier new;"&gt;Des()&lt;/span&gt; method which returns a modifiable pointer descriptor for the data represented by the buffer. So, while the contents cannot be altered directly by calling functions such as &lt;span style="font-family:courier new;"&gt;Format()&lt;/span&gt; or &lt;span style="font-family:courier new;"&gt;LowerCase()&lt;/span&gt; upon it, it is possible to change the data indirectly by creating a &lt;span style="font-family:courier new;"&gt;TPtr&lt;/span&gt; around the data in the buffer. When the modification occurs, the length of both the pointer descriptor and the constant buffer descriptor it refers to are changed. But remember, it cannot be extended because the descriptor classes do not provide memory management. So, don't call &lt;span style="font-family:courier new;"&gt;Append()&lt;/span&gt; on the &lt;span style="font-family:courier new;"&gt;TPtr&lt;/span&gt; unless you know there's sufficient space!&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;_LIT(KFred, "Fred");&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;_LIT(KBert, "Bert");&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;TBufC&lt;4&gt; fredBuf(KFred); // Constructed from literal descriptor&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;TPtr ptr(FredBuf.Des()); // max length = 4&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;ptr = KBert; // fredBuf now containts "Bert"&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;_LIT(KCyril, "Cyril");&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;ptr = KCyril; // Panic! KCyril exceeds max length of ptr (=4)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;&lt;span style="font-family:courier new;"&gt;TBuf&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;Like &lt;span style="font-family:courier new;"&gt;TBufC&lt;/span&gt;, the corresponding modifiable buffer class, &lt;span style="font-family:courier new;"&gt;TBuf&amp;lt;n&amp;gt;&lt;/span&gt;, is a thin template class, where &lt;span style="font-family:courier new;"&gt;n&lt;/span&gt; defines the maximum length of the descriptor data area. &lt;span style="font-family:courier new;"&gt;TBuf&lt;/span&gt; derives from &lt;span style="font-family:courier new;"&gt;TBufBase&lt;/span&gt;, which itself derives from &lt;span style="font-family:courier new;"&gt;TDes&lt;/span&gt;. &lt;span style="font-family:courier new;"&gt;TBuf&lt;/span&gt; thus inherits the full range of descriptor operations from &lt;span style="font-family:courier new;"&gt;TDes&lt;/span&gt; and &lt;span style="font-family:courier new;"&gt;TDesC&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;Although the buffer is modifiable, as with all descriptors, memory management of the &lt;span style="font-family:courier new;"&gt;TBuf&lt;/span&gt; is your responsibility and it cannot be extended beyond the initial maximum length set on construction. If it needs to expand, you need to make sure that you either make it large enough at compile time (but not too large to waste valuable stack space) or use a descriptor which you can dynamically allocate at runtime. This means using an &lt;span style="font-family:courier new;"&gt;HBufC&lt;/span&gt; heap descriptor, described in &lt;a href="http://descriptors.blogspot.com/2005/05/20-how-do-i-use-heap-based-buffer.html"&gt;&lt;i&gt;20. How do I use heap-based buffer descriptors?&lt;/i&gt;&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12650648-111731795308351067?l=descriptors.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://descriptors.blogspot.com/feeds/111731795308351067/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12650648&amp;postID=111731795308351067' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111731795308351067'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111731795308351067'/><link rel='alternate' type='text/html' href='http://descriptors.blogspot.com/2005/05/19-how-do-i-use-stack-based-buffer.html' title='19. How do I use stack-based buffer descriptors?'/><author><name>Jo Stichbury</name><uri>http://www.blogger.com/profile/11641972941072027994</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://www.whoshavesthebarber.com/pictures/sose.jpg'/></author><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12650648.post-111730772006883827</id><published>2005-05-28T12:08:00.000-07:00</published><updated>2006-05-22T09:46:31.220-07:00</updated><title type='text'>18. How do I declare a TPtr or TPtr8 for definition later?</title><content type='html'>I want to initialise a &lt;span style="font-family:courier new;"&gt;TPtr&lt;/span&gt; later, but declare it now.  How do I do this?&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;TPtr8 myPtr(NULL, 0);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;or, for member data, in the constructor's initialization list:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;CMyClass::CMyClass() &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;: iPtr(NULL, 0)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;{}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;To assign to it later, use &lt;span style="font-family:courier new;"&gt;Set()&lt;/span&gt; as described in &lt;a style="font-style: italic;" href="http://descriptors.blogspot.com/2005/05/16-what-does-tptrcset-do.html"&gt;16. What does TPtrC::Set() do?&lt;/a&gt;.  For example:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;myTPtr.Set(myHBufC-&gt;Des());&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;iPtr.Set(someExistingBuf);&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12650648-111730772006883827?l=descriptors.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://descriptors.blogspot.com/feeds/111730772006883827/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12650648&amp;postID=111730772006883827' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111730772006883827'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111730772006883827'/><link rel='alternate' type='text/html' href='http://descriptors.blogspot.com/2005/05/18-how-do-i-declare-tptr-or-tptr8-for.html' title='18. How do I declare a TPtr or TPtr8 for definition later?'/><author><name>Jo Stichbury</name><uri>http://www.blogger.com/profile/11641972941072027994</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://www.whoshavesthebarber.com/pictures/sose.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12650648.post-111904356941545597</id><published>2005-05-14T14:00:00.000-07:00</published><updated>2006-05-21T15:35:10.350-07:00</updated><title type='text'>17. What does TPtr::operator=() do?</title><content type='html'>&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;/span&gt;The assignment operator, &lt;span style="font-family:courier new;"&gt;operator=()&lt;/span&gt;, &lt;span style="font-weight: bold; font-style: italic;"&gt;defined for modifiable pointers only&lt;/span&gt;, copies data into the memory already referenced by the pointer.&lt;br /&gt;&lt;br /&gt;If the length of the data to be copied exceeds the length available, the assignment will panic. &lt;span style="font-family:courier new;"&gt;TPtr &lt;/span&gt;also has a &lt;span style="font-family:courier new;"&gt;Set()&lt;/span&gt; method to change the descriptor to point at different data and you should be careful not to confuse them.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;To reiterate:&lt;br /&gt;&lt;/span&gt;As I described in &lt;a href="http://descriptors.blogspot.com/2005/05/16-what-does-tptrcset-do.html"&gt;&lt;i&gt;16. What does TPtrC::Set() do?&lt;/i&gt;&lt;/a&gt;, &lt;span style="font-family:courier new;"&gt;TPtr::Set()&lt;/span&gt; resets either a constant or modifiable pointer descriptor to point at a new data area (with corresponding changes to the length and maximum length members).&lt;br /&gt;&lt;br /&gt;The assignment operator on &lt;span style="font-family:courier new;"&gt;TPtr&lt;/span&gt; copies data into the existing descriptor area if it is large enough, or panics if it is not. It may modify the descriptor length but will not affect its maximum length.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12650648-111904356941545597?l=descriptors.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://descriptors.blogspot.com/feeds/111904356941545597/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12650648&amp;postID=111904356941545597' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111904356941545597'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111904356941545597'/><link rel='alternate' type='text/html' href='http://descriptors.blogspot.com/2005/05/17-what-does-tptroperator-do.html' title='17. What does TPtr::operator=() do?'/><author><name>Jo Stichbury</name><uri>http://www.blogger.com/profile/11641972941072027994</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://www.whoshavesthebarber.com/pictures/sose.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12650648.post-111610457081028730</id><published>2005-05-14T13:59:00.000-07:00</published><updated>2006-05-18T13:21:39.513-07:00</updated><title type='text'>16. What does TPtrC::Set() do?</title><content type='html'>Set() may be called on a constant or modifiable pointer descriptor to change what it points to, that is, to set it to reference different string data.&lt;br /&gt;&lt;br /&gt;For example:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;_LIT(KFred, "Fred");&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;_LIT(KBert, "Bert");&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;TPtrC fred(KFred); // contains 'Fred'&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;TPtrC bert(KBert); // contains 'Bert'&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;bert.Set(fred); // bert now contains 'Fred'&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12650648-111610457081028730?l=descriptors.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://descriptors.blogspot.com/feeds/111610457081028730/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12650648&amp;postID=111610457081028730' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111610457081028730'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111610457081028730'/><link rel='alternate' type='text/html' href='http://descriptors.blogspot.com/2005/05/16-what-does-tptrcset-do.html' title='16. What does TPtrC::Set() do?'/><author><name>Jo Stichbury</name><uri>http://www.blogger.com/profile/11641972941072027994</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://www.whoshavesthebarber.com/pictures/sose.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12650648.post-111610320588088329</id><published>2005-05-14T13:37:00.000-07:00</published><updated>2006-05-21T15:23:58.633-07:00</updated><title type='text'>15. What is the memory layout of pointer descriptors?  How much memory do they occupy besides the data itself?</title><content type='html'>Since pointer descriptors all derive from &lt;span style="font-family: courier new;"&gt;TDesC&lt;/span&gt; (either directly for constant pointer descriptors or from &lt;span style="font-family: courier new;"&gt;TDes&lt;/span&gt;, for modifiable descriptors), the first 4 bytes are used to store the current length of the descriptor data.&lt;br /&gt;&lt;br /&gt;In a constant pointer descriptor (&lt;span style="font-family: courier new;"&gt;TPtrC&lt;/span&gt;), a 4-byte pointer to the data follows the length word, thus the total size of the descriptor object is two words (8 bytes).&lt;br /&gt;&lt;br /&gt;In a modifiable pointer descriptor (&lt;span style="font-family: courier new;"&gt;TPtr&lt;/span&gt;) which derives from &lt;span style="font-family: courier new;"&gt;TDes&lt;/span&gt;, the maximum data length word follows the current length, which is then followed by the data pointer.  Thus, the descriptor object is three words in length (12 bytes).&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;You can find some diagrams which illustrate this in [&lt;a href="http://descriptors.blogspot.com/2006/05/references-to-other-descriptors.html"&gt;&lt;i&gt;reference 4&lt;/i&gt;&lt;/a&gt;].&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12650648-111610320588088329?l=descriptors.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://descriptors.blogspot.com/feeds/111610320588088329/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12650648&amp;postID=111610320588088329' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111610320588088329'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111610320588088329'/><link rel='alternate' type='text/html' href='http://descriptors.blogspot.com/2005/05/15-what-is-memory-layout-of-pointer.html' title='15. What is the memory layout of pointer descriptors?  How much memory do they occupy besides the data itself?'/><author><name>Jo Stichbury</name><uri>http://www.blogger.com/profile/11641972941072027994</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://www.whoshavesthebarber.com/pictures/sose.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12650648.post-111610203520950152</id><published>2005-05-14T13:18:00.000-07:00</published><updated>2006-05-18T13:20:56.766-07:00</updated><title type='text'>14. Do pointer descriptors own and manage the memory they point to?</title><content type='html'>No.  Absolutely not.&lt;br /&gt;&lt;br /&gt;The memory that holds the data referenced by a pointer descriptor is not owned by it, but will have been previously allocated.  Pointer descriptors are agnostic about where the memory they point to is actually stored (in ROM, on the heap or on the stack). &lt;br /&gt;&lt;br /&gt;The string data of a pointer descriptor is separate from the descriptor object itself and pointer descriptors themselves are usually stack-based, although they can be used on the heap, for example as a member variable of a CBase-derived class.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12650648-111610203520950152?l=descriptors.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://descriptors.blogspot.com/feeds/111610203520950152/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12650648&amp;postID=111610203520950152' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111610203520950152'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111610203520950152'/><link rel='alternate' type='text/html' href='http://descriptors.blogspot.com/2005/05/14-do-pointer-descriptors-own-and.html' title='14. Do pointer descriptors own and manage the memory they point to?'/><author><name>Jo Stichbury</name><uri>http://www.blogger.com/profile/11641972941072027994</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://www.whoshavesthebarber.com/pictures/sose.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12650648.post-111568151588292182</id><published>2005-05-09T16:27:00.000-07:00</published><updated>2006-05-21T15:17:08.163-07:00</updated><title type='text'>12. What is the layout of modifiable descriptors?</title><content type='html'>Modifiable descriptors all derive from the base class TDes, which itself is a subclass of TDesC.  TDes has an additional 4-byte member variable, which is used to store the maximum length of data currently allocated to the descriptor. &lt;br /&gt;&lt;br /&gt;TDes defines a range of methods for modifying string data.  Like the non-modifiable descriptors, all the manipulation is inherited by the derived classes, and works regardless of their type. The subclasses only implement specific methods for construction and copy assignment.&lt;br /&gt;&lt;br /&gt;Apart from the allocation methods of the heap buffer descriptors, no descriptor functions allocate any memory.  So any modification which extends the data of the descriptor, eg Append(), will check that there is sufficient memory available before proceeding.  The contents of the descriptor can shrink and expand at will, as long as the length does not exceed the maximum.  If the length of the descriptor contents is less than the maximum length, the end of the block of memory allocated to the descriptor is simply unused.&lt;br /&gt;&lt;br /&gt;Descriptor code uses assertion statements to ensure that the maximum length of the descriptor is sufficient, before proceeding.   The checks are made in both debug and release builds, and panic if an overflow would occur.  This avoids the hard-to-trace memory scribbles and buffer overflows typical of C style strings. &lt;br /&gt;&lt;br /&gt;(See also &lt;a href="http://descriptors.blogspot.com/2005/05/11-what-is-layout-of-non-modifable.html"&gt;&lt;i&gt;11. What is the layout of non-modifiable descriptors?&lt;/i&gt;&lt;/a&gt;)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12650648-111568151588292182?l=descriptors.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://descriptors.blogspot.com/feeds/111568151588292182/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12650648&amp;postID=111568151588292182' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111568151588292182'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111568151588292182'/><link rel='alternate' type='text/html' href='http://descriptors.blogspot.com/2005/05/12-what-is-layout-of-modifiable.html' title='12. What is the layout of modifiable descriptors?'/><author><name>Jo Stichbury</name><uri>http://www.blogger.com/profile/11641972941072027994</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://www.whoshavesthebarber.com/pictures/sose.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12650648.post-111567983577069567</id><published>2005-05-09T15:28:00.000-07:00</published><updated>2006-05-28T14:44:06.276-07:00</updated><title type='text'>11. What is the layout of non-modifable descriptors?</title><content type='html'>First, let’s distinguish between descriptor literals, which are constant and can be built into ROM because their contents is fixed at build time, and non-modifable descriptors, whose contents are constant but not fixed at build time. Symbian OS, literals are treated a bit differently to the other descriptors, and I’ll discuss them separately in &lt;a style="font-style: italic;" href="http://descriptors.blogspot.com/2005/05/22-what-are-literal-descriptors.html"&gt;22. What are literal descriptors?&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;All (non-literal) descriptors derive from the base class TDesC (typedef’d to TDesC16 in e32std.h and defined in e32des16.h). The ‘C’ at the end of the class name indicates that the descriptor is non-modifiable. TDesC class has methods for determining the length of the descriptor and accessing its data, and implements other descriptor methods which access the descriptor data but do not modify it, such as data access, comparison and search functionality.&lt;br /&gt;&lt;br /&gt;It is worth pointing out that all non-modifiable descriptor methods are implemented in this generic base class rather than overridden by each non-modifiable descriptor subclass (TBufC, TPtrC and HBufC). This is for memory efficiency. It’s done this way, rather than by use of virtual functions, because these would require each derived descriptor object to occupy an extra 4 bytes by adding a virtual pointer (vptr) for access to the virtual function table. This memory size overhead is undesirable, particularly for smaller strings, where the 4 bytes becomes a large percentage of the overall size.&lt;br /&gt;&lt;br /&gt;And by keeping the descriptor methods in the base classes, the amount of code to implement a full set of string functionality is minimized too. This reuse is a benefit in terms of ROM size, and an illustration of C++ best practice for testing and maintenance.  The subclasses only implement specific methods for construction and copy assignment.&lt;br /&gt;&lt;br /&gt;The first 4 bytes of every descriptor object is the same: these hold the length of the data it currently contains. Well, actually, only 28 of these 32 bits are used to hold the length of the descriptor data; the top 4 bits are used to indicate the type of descriptor. The use of 4 bits to identify the type limits the number of different types of descriptor to 2^4 (=16), but since only six types have been necessary in all previous releases of Symbian OS (TBufC, TBuf, TPtrC, TPtr, HBufC and RBuf) , it seems unlikely that the range will need to be extended significantly in future. The use of the other 28 bits to store the data length, also means that the maximum number of byes a descriptor may occupy is limited to 2^28 bytes = 256 MB.&lt;br /&gt;&lt;br /&gt;The rest of the layout of a descriptor object depends upon the implementation of each of the subclasses. Access to the descriptor data of each type goes through the (nonvirtual) Ptr() method of the TDesC base class, which uses a switch statement to identify the type of descriptor (using the top 4 bits of the beginning of the descriptor object) and return the correct address for the beginning of its data.&lt;br /&gt;&lt;br /&gt;Of course, this requires that the TDesC base class has knowledge of the memory layout of its subclasses hardcoded into Ptr(). This means that you can’t create your own descriptor class, deriving from TDesC, and expect it to work.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12650648-111567983577069567?l=descriptors.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://descriptors.blogspot.com/feeds/111567983577069567/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12650648&amp;postID=111567983577069567' title='8 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111567983577069567'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111567983577069567'/><link rel='alternate' type='text/html' href='http://descriptors.blogspot.com/2005/05/11-what-is-layout-of-non-modifable.html' title='11. What is the layout of non-modifable descriptors?'/><author><name>Jo Stichbury</name><uri>http://www.blogger.com/profile/11641972941072027994</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://www.whoshavesthebarber.com/pictures/sose.jpg'/></author><thr:total>8</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12650648.post-111565907284743617</id><published>2005-05-09T09:58:00.000-07:00</published><updated>2007-08-24T09:24:33.474-07:00</updated><title type='text'>10. How do I use heap descriptors as return types?</title><content type='html'>&lt;span style="font-weight: bold;"&gt;I want to create a new descriptor in my function.  How do I return it to the caller? &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;You must return an &lt;span style="font-family:courier new;"&gt;HBufC*&lt;/span&gt; as follows:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);font-family:courier new;" &gt;HBufC* CreateSomeDescriptorL()&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);font-family:courier new;" &gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);font-family:courier new;" &gt;    _LIT(KBert, "bert");&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);font-family:courier new;" &gt;    HBufC* newBert = KBert().AllocL();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);font-family:courier new;" &gt;    return (newBert);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);font-family:courier new;" &gt;}&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;The calling function needs to know that it must take ownership of the returned heap-based descriptor and be responsible for deleting it when it has finished with it. Failure to do this is a common cause of memory leaks.&lt;br /&gt;&lt;br /&gt;A similar function, which leaves the created descriptor on the cleanup stack for the caller, would be coded as follows:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;HBufC* CreateSomeDescriptorL&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;C&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;()&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);font-family:courier new;" &gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);font-family:courier new;" &gt;    _LIT(KBert, "bert");&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);font-family:courier new;" &gt;    HBufC* newBert = KBert().AllocL&lt;span style="color: rgb(204, 0, 0);"&gt;C&lt;/span&gt;();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);font-family:courier new;" &gt;    return (newBert);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);font-family:courier new;" &gt;}&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;When should I return a TPtr or TPtrC?  When shouldn't I?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;TPtr&lt;/span&gt; or &lt;span style="font-family:courier new;"&gt;TPtrC &lt;/span&gt;are descriptors which do not own string data; they simply refer to data that exists in another descriptor. So you can use them to return a descriptor which references part of another descriptor argument, &lt;span style="font-weight: bold;"&gt;as long as its lifetime will not extend beyond that descriptor's lifetime&lt;/span&gt;. For example:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;/span&gt;&lt;pre&gt;&lt;span style="color: rgb(0, 0, 0);font-family:courier new;" &gt;&lt;br /&gt;TPtrC LeftChar(const TDesC&amp; aInput)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);font-family:courier new;" &gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);font-family:courier new;" &gt;    if (aInput.Length()&gt;0)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);font-family:courier new;" &gt;        return aInput.Left(1); // Returns the left-most character&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);font-family:courier new;" &gt;    else&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;        return KNullDesC;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:georgia;"&gt;This, however, is not OK because stack-based &lt;span style="font-family: courier new;"&gt;fred&lt;/span&gt; will cease to exist when &lt;span style="font-family:courier new;"&gt;GetFred() &lt;/span&gt;returns:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;TPtrC GetFred()&lt;br /&gt;{  &lt;br /&gt;  _LIT(KFred, "Fred");&lt;br /&gt;  TBufC&lt;4&gt; fred(KFred());&lt;br /&gt;  TPtrC fredPtr(fred);&lt;br /&gt;  return (fredPtr);&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12650648-111565907284743617?l=descriptors.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://descriptors.blogspot.com/feeds/111565907284743617/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12650648&amp;postID=111565907284743617' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111565907284743617'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111565907284743617'/><link rel='alternate' type='text/html' href='http://descriptors.blogspot.com/2005/05/10-how-do-i-use-heap-descriptors-as.html' title='10. How do I use heap descriptors as return types?'/><author><name>Jo Stichbury</name><uri>http://www.blogger.com/profile/11641972941072027994</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://www.whoshavesthebarber.com/pictures/sose.jpg'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12650648.post-111565705651979875</id><published>2005-05-09T09:36:00.000-07:00</published><updated>2006-05-28T14:33:26.440-07:00</updated><title type='text'>9. How do I use descriptors as parameters?</title><content type='html'>The descriptor base classes are described in &lt;a href="http://descriptors.blogspot.com/2005/05/11-what-is-layout-of-non-modifable.html"&gt;11. &lt;i&gt;What is the layout of non-modifiable descriptors?&lt;/i&gt;&lt;/a&gt; and &lt;a href="http://descriptors.blogspot.com/2005/05/12-what-is-layout-of-modifiable.html"&gt;&lt;i&gt;12. What is the layout of non-modifiable descriptors?&lt;/i&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The base classes provide and implement the constant and modifiable descriptor operations regardless of the actual type of the derived descriptor. For consistency, they should be used as arguments to functions, allowing descriptors to be passed without restricting the caller of the function to using a specific type.&lt;br /&gt;&lt;br /&gt;For example, the caller can call the following function with anything derived from &lt;span style="font-family:courier new;"&gt;TDesC &lt;/span&gt;and &lt;span style="font-family:courier new;"&gt;TDes &lt;/span&gt;for the first and second arguments respectively. For example an &lt;span style="font-family:courier new;"&gt;HBufC&lt;/span&gt; and a &lt;span style="font-family:courier new;"&gt;TBuf&lt;8&gt;&lt;/span&gt;, or a &lt;span style="font-family:courier new;"&gt;TPtr &lt;/span&gt;and a &lt;span style="font-family:courier new;"&gt;TBuf&lt;3&gt;&lt;/span&gt;:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;void SomeFunction(const TDesC&amp; aReadOnlyDescriptor, TDes&amp;amp; aReadWriteDescriptor);&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;br /&gt;How do I make a descriptor parameter read-only?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Pass it as a constant reference to a non-modifiable descriptor (&lt;span style="font-family:courier new;"&gt;const TDesC&amp;&lt;/span&gt;).  For example:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;void SomeFunction(const TDesC&amp;amp; aReadOnlyDescriptor);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This function can still be called with a modifiable descriptor like a &lt;span style="font-family:courier new;"&gt;TPtr &lt;/span&gt;as the argument, because these derive from &lt;span style="font-family:courier new;"&gt;TDesC &lt;/span&gt;(a &lt;span style="font-family:courier new;"&gt;TPtr &lt;/span&gt;is a specialised type of &lt;span style="font-family:courier new;"&gt;TDes&lt;/span&gt;).   Inside the function, only the &lt;span style="font-family:courier new;"&gt;TDesC &lt;/span&gt;operations may be performed on the parameter.  Its contents will not be changed, even if you have passed in a modifiable, &lt;span style="font-family:courier new;"&gt;TDes&lt;/span&gt;-derived descriptor.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;How do I make a descriptor parameter read/write?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Pass it as a non-constant reference to a modifiable descriptor (&lt;span style="font-family:courier new;"&gt;TDes&amp;&lt;/span&gt;). For example:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;void  SomeFunction(TDes&amp;amp; aReadWriteDescriptor);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;You cannot call this function with a non-modifiable descriptor, which makes sense because you don’t want a read only descriptor to be modified.&lt;br /&gt;&lt;br /&gt;Inside the function you can both read from and write to the parameter. Remember that the descriptor must already have sufficient space in it for the data to expand into, if necessary. If there isn’t, you’ll get a panic. (Some functions will be coded to check the length of the descriptor before attempting something that may cause a panic and return an overflow error instead. But others will not and the results will be messy).&lt;br /&gt;&lt;br /&gt;[ This is one reason why you should always test your code with "boundary conditions" - that is, passing in parameters to functions at the boundary of their acceptable values, and beyond, to check that resulting errors are handled gracefully.]&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Can I use other descriptor types as function parameters?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Yes you can, but don’t. For example you could specify your function requiring a parameter passed a &lt;span style="font-family:courier new;"&gt;TBuf&lt;10&gt;&amp;&lt;/span&gt;. But what if the caller has got a &lt;span style="font-family:courier new;"&gt;TPtrC&lt;/span&gt;, or an &lt;span style="font-family:courier new;"&gt;HBufC&lt;/span&gt;, or even a &lt;span style="font-family:courier new;"&gt;TBuf&lt;11&gt;&lt;/span&gt;? This means that they won’t be able to call your function without some extra hassle to fit in with exactly what you have specified. &lt;span style="font-family:courier new;"&gt;TDes &lt;/span&gt;and &lt;span style="font-family:courier new;"&gt;TDesC &lt;/span&gt;are the most general types you can use for your function parameters.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;My function uses &lt;/span&gt;&lt;span style="font-weight: bold;font-family:courier new;" &gt;TDes &lt;/span&gt;&lt;span style="font-weight: bold;"&gt;or &lt;/span&gt;&lt;span style="font-weight: bold;font-family:courier new;" &gt;TDesC &lt;/span&gt;&lt;span style="font-weight: bold;"&gt;parameters like you say, but my descriptor passing doesn’t work. Why not?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Oh how much pain has this one caused? Missing out that little &lt;span style="font-family:courier new;"&gt;&amp;&lt;/span&gt; symbol makes all the difference. Your parameter types must be references, not values, ie &lt;span style="font-family:courier new;"&gt;const TDesC&amp;amp;&lt;/span&gt; or &lt;span style="font-family:courier new;"&gt;TDes&amp;&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;The base classes &lt;span style="font-family:courier new;"&gt;TDesC &lt;/span&gt;and &lt;span style="font-family:courier new;"&gt;TDes &lt;/span&gt;contain no string data. If you pass them by value rather than by reference, you are using static binding, which means that polymorphism won’t work, and you'll end up with a data-free base class object. It will all compile OK, but nothing works.&lt;br /&gt;&lt;br /&gt;Never attempt to instantiate or work directly with objects of the base classes TDesC or TDes, as &lt;a href="http://descriptor-tips.blogspot.com/2005/05/tip-1-never-instantiate-tdes-or-tdesc.html"&gt;Tip 1&lt;/a&gt; advises.  They are effectively abstract classes. There is rarely, if ever, a valid reason for instantiating them rather than an object of their deriving classes (&lt;span style="font-family: courier new;"&gt;TBufC&lt;span style="font-family: georgia;"&gt;, &lt;/span&gt;TBuf&lt;span style="font-family: georgia;"&gt;, &lt;/span&gt;TPtrC&lt;span style="font-family: georgia;"&gt;, &lt;/span&gt;TPtr&lt;span style="font-family: georgia;"&gt;, &lt;/span&gt;HBufC&lt;/span&gt; or &lt;span style="font-family: courier new;"&gt;RBuf&lt;/span&gt;).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12650648-111565705651979875?l=descriptors.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://descriptors.blogspot.com/feeds/111565705651979875/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12650648&amp;postID=111565705651979875' title='12 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111565705651979875'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111565705651979875'/><link rel='alternate' type='text/html' href='http://descriptors.blogspot.com/2005/05/9-how-do-i-use-descriptors-as.html' title='9. How do I use descriptors as parameters?'/><author><name>Jo Stichbury</name><uri>http://www.blogger.com/profile/11641972941072027994</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://www.whoshavesthebarber.com/pictures/sose.jpg'/></author><thr:total>12</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12650648.post-111541406476035885</id><published>2005-05-06T14:02:00.000-07:00</published><updated>2006-05-28T14:26:29.926-07:00</updated><title type='text'>8. So how do I create a heap based descriptor? And how do I use it when I've got it?</title><content type='html'>Create an &lt;span style="font-family:courier new;"&gt;HBufC&lt;/span&gt; (or an &lt;span style="font-family:courier new;"&gt;HBufC8&lt;/span&gt; if you explicitly need 8-bit text).&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;HBufC* heapbasedFred=HBufC::NewL(4);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;But how do I then write to a heap descriptor? &lt;span style="font-family:courier new;"&gt;HBufC &lt;/span&gt;is not derived from a modifiable descriptor class?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This is also easy. First you must call &lt;span style="font-family:courier new;"&gt;HBufC::Des()&lt;/span&gt; to get a &lt;span style="font-family:courier new;"&gt;TPtr&lt;/span&gt;, which is modifiable.  You can then use that:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;TPtr fredPtr(heapbasedFred-&gt;Des());&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;_LIT(KFred, “fred”);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;fredPtr.Copy(KFred);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;And how do I read from &lt;span style="font-family:courier new;"&gt;HBufC&lt;/span&gt;?&lt;/span&gt;&lt;br /&gt;You can just dereference the &lt;span style="font-family:courier new;"&gt;HBufC&lt;/span&gt; pointer, like this:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;TBuf&lt;4&gt; stackbasedFred(*heapBasedFred);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;But I’ve seen code which calls &lt;/span&gt;&lt;span style="font-weight: bold;font-family:courier new;" &gt;Des()&lt;/span&gt;&lt;span style="font-weight: bold;"&gt; on an &lt;/span&gt;&lt;span style="font-weight: bold;font-family:courier new;" &gt;HBufC&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;. Why’s that?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This is a common mistake, which fortunately does little harm except to overall efficiency.&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Des()&lt;/span&gt; gives you a modifiable descriptor, &lt;span style="font-family:courier new;"&gt;TDes&lt;/span&gt;, which itself derives from &lt;span style="font-family:courier new;"&gt;TDesC&lt;/span&gt;, so you can use it to call any of the &lt;span style="font-family:courier new;"&gt;TDesC &lt;/span&gt;functions.  But it’s unnecessary.&lt;br /&gt;&lt;br /&gt;Here’s an example of this common mistake:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:85%;"&gt;TBuf&lt;4&gt; stackbasedFred(heapBasedFred-&gt;Des()); // Unnecessary, just use&lt;br /&gt;TBuf&lt;4&gt; stackBasedFred(*heapBasedFred); // More efficient&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12650648-111541406476035885?l=descriptors.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://descriptors.blogspot.com/feeds/111541406476035885/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12650648&amp;postID=111541406476035885' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111541406476035885'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111541406476035885'/><link rel='alternate' type='text/html' href='http://descriptors.blogspot.com/2005/05/8-so-how-do-i-create-heap-based.html' title='8. So how do I create a heap based descriptor? And how do I use it when I&apos;ve got it?'/><author><name>Jo Stichbury</name><uri>http://www.blogger.com/profile/11641972941072027994</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://www.whoshavesthebarber.com/pictures/sose.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12650648.post-111541328900217300</id><published>2005-05-06T14:01:00.000-07:00</published><updated>2006-05-28T14:21:05.976-07:00</updated><title type='text'>7. How do I create a small, stack-based descriptor?</title><content type='html'>If it needs to be modifiable, use a &lt;span style="font-family:courier new;"&gt;TBuf&lt;/span&gt;.  If it's constant, use a &lt;span style="font-family:courier new;"&gt;TBufC&lt;/span&gt;. You'll need to specify the size of stack space allocated for the descriptor's data.&lt;br /&gt;&lt;br /&gt;Here’s an example:&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;_LIT(KFred, “fred”); // A string literal, these will be described later&lt;br /&gt;TBufC&lt;4&gt; constantFred(KFred);&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;In reality, you probably wouldn't do this for a non-modifiable descriptor, since you can use  the literal, &lt;span style="font-family:courier new;"&gt;KFred&lt;/span&gt; directly by calling the &lt;span style="font-family:courier new;"&gt;operator()()&lt;/span&gt;  (as I'll describe separately in &lt;a style="font-style: italic;" href="http://descriptors.blogspot.com/2005/05/22-what-are-literal-descriptors.html"&gt;22. What are literal descriptors?&lt;/a&gt;).  That is, instead of creating &lt;span style="font-family:courier new;"&gt;constantFred&lt;/span&gt;, you could just call &lt;span style="font-family:courier new;"&gt;KFred().&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;However, this approach is still useful for modifiable descriptors, for example, for logging purposes:&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;TInt CMyActiveObject::RunError(TInt aError)&lt;br /&gt;{&lt;br /&gt;_LIT8(KError, "CMyActiveObject::RunError: %d");&lt;br /&gt;TBuf8&lt;35&gt; errorBuf;&lt;br /&gt;errorBuf.Format(KError, aError); // &lt;a href="http://descriptors.blogspot.com/2006/05/references-to-other-descriptors.html"&gt;&lt;i&gt;reference 3&lt;/i&gt;&lt;/a&gt; has more information about TDes::Format()&lt;br /&gt;iLogger.Log(errorBuf); // iLogger is a log object owned by the class&lt;br /&gt;return (KErrNone);&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;What if I want a descriptor to hold ASCII text?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;There are some cases where you do need to hold 8-bit text: MIME types, or binary data, for example. To do this, you should explicitly use the 8 bit descriptors:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;_LIT8(KImageGif, “image/gif”);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;TBufC8&lt;15&gt; mimeType(KImageGif);&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12650648-111541328900217300?l=descriptors.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://descriptors.blogspot.com/feeds/111541328900217300/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12650648&amp;postID=111541328900217300' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111541328900217300'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111541328900217300'/><link rel='alternate' type='text/html' href='http://descriptors.blogspot.com/2005/05/7-how-do-i-create-small-stack-based.html' title='7. How do I create a small, stack-based descriptor?'/><author><name>Jo Stichbury</name><uri>http://www.blogger.com/profile/11641972941072027994</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://www.whoshavesthebarber.com/pictures/sose.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12650648.post-111531829385857436</id><published>2005-05-05T11:17:00.000-07:00</published><updated>2006-05-28T14:17:27.260-07:00</updated><title type='text'>6. Large stack-based descriptors</title><content type='html'>The amount of stack space on Symbian OS is pretty limited (the default is 8 KB). So you should avoid creating large stack-based descriptors when it is unnecessary to do so. Symbian OS sometimes makes it easy to transgress this rule, by defining a number of classes and typedefs that can be used inefficiently on the stack. It pays to be aware of the these and only use them when you know the descriptor you are reading will fill the entire space allocated.&lt;br /&gt;&lt;br /&gt;For example, &lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;TFileName &lt;/span&gt;&lt;/span&gt;is typedef-ed as follows:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;typedef TBuf&amp;lt;KMaxFileName&amp;gt;&lt;kmaxfilename&gt; TFileName;&lt;/kmaxfilename&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;where&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;const TInt KMaxFileName=0x100;  // = 256 decimal&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;But, of course, each character in a descriptor is 2 bytes, since Symbian OS is a wide, UNICODE, build (as described in &lt;a style="font-style: italic;" href="http://descriptors.blogspot.com/2005/05/1-basics.html"&gt;1. The Basics&lt;/a&gt;).  So each &lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;TFileName &lt;/span&gt;&lt;/span&gt;object created on the stack occupies 512 bytes (1/16th of the default stack size), regardless of whether the text occupying it is actually that long!&lt;br /&gt;&lt;br /&gt;Sure, these objects can be very appealing, because they mean you don't have to worry about buffer overrun.  But they come at a price.&lt;br /&gt;&lt;br /&gt;For stack conservation, it's advisable to be aware of the amount of space the following objects consume:&lt;br /&gt;&lt;ul&gt;   &lt;li&gt;&lt;span style="font-family:courier new;"&gt;TFileName&lt;/span&gt;   512 bytes &lt;/li&gt;   &lt;li&gt;&lt;span style="font-family:courier new;"&gt;TEntry&lt;/span&gt;           544 bytes &lt;/li&gt;   &lt;li&gt;&lt;span style="font-family:courier new;"&gt;TFullName&lt;/span&gt;    512 bytes&lt;/li&gt;   &lt;li&gt;&lt;span style="font-family:courier new;"&gt;TName&lt;/span&gt;              256 bytes&lt;/li&gt; &lt;/ul&gt;If you do need to use these objects, it's best to use them on the heap. You can do this simply by making them a member of a heap-based object (ie a C class object) . They don't then need to be created on the heap themselves - just by being a member of the C class, they are automatically heap-based. Alternatively, you can alloc them on the heap using the &lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;new&lt;/span&gt;&lt;/span&gt; operator - but make sure they are leave-safe and destroyed when no longer needed.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12650648-111531829385857436?l=descriptors.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://descriptors.blogspot.com/feeds/111531829385857436/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12650648&amp;postID=111531829385857436' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111531829385857436'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111531829385857436'/><link rel='alternate' type='text/html' href='http://descriptors.blogspot.com/2005/05/6-large-stack-based-descriptors.html' title='6. Large stack-based descriptors'/><author><name>Jo Stichbury</name><uri>http://www.blogger.com/profile/11641972941072027994</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://www.whoshavesthebarber.com/pictures/sose.jpg'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12650648.post-111531686737863646</id><published>2005-05-05T11:10:00.000-07:00</published><updated>2006-05-22T09:43:05.923-07:00</updated><title type='text'>5. Is there any size limit for a descriptor?</title><content type='html'>Sort of.&lt;br /&gt;&lt;br /&gt;Descriptors can be stored on the stack or heap. The normal limitations apply as for other Symbian OS variables:&lt;br /&gt;&lt;ul&gt;   &lt;li&gt;Stack descriptors should be kept small: a 256 byte limit (128 double-byte characters) is a good guide.  See &lt;a href="http://descriptors.blogspot.com/2005/05/6-large-stack-based-descriptors.html"&gt;&lt;i&gt;6. Large stack-based descriptors&lt;/i&gt;&lt;/a&gt; for more information about how to avoid accidentally wasting stack space through use of Symbian OS descriptor typedefs and stack-based classes which encapsulate large descriptors.&lt;br /&gt;&lt;/li&gt;   &lt;li&gt;Heap descriptors can be much larger, depending on the size of heap memory available. But remember, Symbian OS runs on limited memory devices, so allocating a massive descriptor is always unwise. &lt;/li&gt; &lt;/ul&gt; But the layout of a descriptor object (described elsewhere) will limit the maximum size of a descriptor to 2^28 bytes (256 MB).  Since each UNICODE character = 2 bytes, the maximum length of a descriptor is thus 2^27 characters.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12650648-111531686737863646?l=descriptors.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://descriptors.blogspot.com/feeds/111531686737863646/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12650648&amp;postID=111531686737863646' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111531686737863646'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111531686737863646'/><link rel='alternate' type='text/html' href='http://descriptors.blogspot.com/2005/05/5-is-there-any-size-limit-for.html' title='5. Is there any size limit for a descriptor?'/><author><name>Jo Stichbury</name><uri>http://www.blogger.com/profile/11641972941072027994</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://www.whoshavesthebarber.com/pictures/sose.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12650648.post-111531606788097128</id><published>2005-05-05T10:57:00.000-07:00</published><updated>2006-05-21T15:31:40.683-07:00</updated><title type='text'>4. Memory management and descriptors</title><content type='html'>&lt;span style="font-weight: bold;"&gt;Do descriptors automatically resize themselves if I need more memory?&lt;/span&gt;&lt;br /&gt;No. The memory allocated for a descriptor is fixed, and specified on construction. They do not resize themselves dynamically, although you can re-allocate memory for an HBufC heap descriptor. But this has pitfalls of its own as will be described in &lt;a href="http://descriptors.blogspot.com/2005/05/20-how-do-i-use-heap-based-buffer.html"&gt;&lt;i&gt;20. How do I use a heap-based buffer descriptor?&lt;/i&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Why? It would be more useful if it were automatic.&lt;/span&gt;&lt;br /&gt;It would make life easier for the programmer, but it could also make them less efficient, and it would require complex code to be exception-safe. Think of it like this:&lt;br /&gt;&lt;br /&gt;Most descriptor modification methods can potentially require an increase in the amount of memory allocated to the descriptor. If the descriptor classes themselves did this, most of the methods would have to be able to leave, or would be surrounded by less-than-efficient TRAPs. This is quite an overhead when, in the majority of cases, a fixed size string is fine.&lt;br /&gt;&lt;br /&gt;On Symbian OS, efficiency is paramount, so the programmer must take responsibility for memory management.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;What happens if I overrun a descriptor’s allocated space?&lt;/span&gt;&lt;br /&gt;You will get a panic in both debug and release builds.   The panic will be part of the USER category which can be found documented in [&lt;a href="http://descriptors.blogspot.com/2006/05/references-to-other-descriptors.html"&gt;&lt;i&gt;reference 2&lt;/i&gt;&lt;/a&gt;].  It can be assumed that no illegal access of memory has taken place and that no data was moved or corrupted. However, your code will rapidly cease executing, and if you are running in a system thread, you could even reboot the phone.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Isn’t that a bit drastic?&lt;/span&gt;&lt;br /&gt;Drastic maybe, but safe. You will not be overwriting any memory that you shouldn’t be, which avoids the difficult-to-find errors this can cause for C strings.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Do descriptors perform garbage collection?&lt;/span&gt;&lt;br /&gt;No. In the same way that descriptors do not perform allocation or re-allocation, they do not perform garbage collection, because of the extra overhead that would carry.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12650648-111531606788097128?l=descriptors.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://descriptors.blogspot.com/feeds/111531606788097128/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12650648&amp;postID=111531606788097128' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111531606788097128'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111531606788097128'/><link rel='alternate' type='text/html' href='http://descriptors.blogspot.com/2005/05/4-memory-management-and-descriptors.html' title='4. Memory management and descriptors'/><author><name>Jo Stichbury</name><uri>http://www.blogger.com/profile/11641972941072027994</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://www.whoshavesthebarber.com/pictures/sose.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12650648.post-111567633797441413</id><published>2005-05-04T15:04:00.000-07:00</published><updated>2006-05-28T14:18:05.653-07:00</updated><title type='text'>3. What *aren't* descriptors?</title><content type='html'>Because their underlying memory allocation and cleanup must be managed by the programmer, as described in &lt;i&gt;&lt;a href="http://descriptors.blogspot.com/2005/05/4-memory-management-and-descriptors.html"&gt;4. Memory management and descriptors&lt;/a&gt;&lt;/i&gt;, they’re not like standard C++ strings, Java strings or the MFC CString.&lt;br /&gt;&lt;br /&gt;And because they protect against buffer overrun and don’t rely on NULL terminators to determine the length of the string, they are not like C strings either.  See &lt;a style="font-style: italic;" href="http://descriptors.blogspot.com/2005/05/2-why-use-descriptors.html"&gt;2. Why use descriptors?&lt;/a&gt; for why you should prefer to use descriptors rather than familiar, but clunky, C strings.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12650648-111567633797441413?l=descriptors.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://descriptors.blogspot.com/feeds/111567633797441413/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12650648&amp;postID=111567633797441413' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111567633797441413'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111567633797441413'/><link rel='alternate' type='text/html' href='http://descriptors.blogspot.com/2005/05/3-what-arent-descriptors.html' title='3. What *aren&apos;t* descriptors?'/><author><name>Jo Stichbury</name><uri>http://www.blogger.com/profile/11641972941072027994</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://www.whoshavesthebarber.com/pictures/sose.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12650648.post-111523676366781963</id><published>2005-05-04T12:58:00.000-07:00</published><updated>2006-05-28T14:08:37.006-07:00</updated><title type='text'>2. Why use descriptors?</title><content type='html'>&lt;span style="font-weight: bold;"&gt;Can I use standard C arrays to store my text and binary data, and the C string library to manipulate them, like I have always done?&lt;/span&gt;&lt;br /&gt;Yes.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Should I use standard C arrays and the C string library for Symbian OS programming?&lt;/span&gt;&lt;br /&gt;No.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Why not?&lt;/span&gt;&lt;br /&gt;Standard C arrays are unsafe. Why? Because they have no concept of how big they are. Null-terminated strings are clunky and inefficient. What’s more, if you want to write past the end of the allocated space of a standard C string, nothing is going to stop you. This leads to all kinds of mayhem, such as data corruption&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;An API I want to use requires descriptors, but I’ve used C strings. How do I convert between them?&lt;/span&gt;&lt;br /&gt;Quite. Just about every Symbian OS C++ API you come across will use descriptors for transferring text and binary data somewhere, so if you’ve used C strings, you are going to have a problem using these APIs. You’ll have to do the conversion every time you want to use an API call requiring a descriptor, which is inefficient. So you might as well keep reading, and learn how to use descriptors correctly.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12650648-111523676366781963?l=descriptors.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://descriptors.blogspot.com/feeds/111523676366781963/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12650648&amp;postID=111523676366781963' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111523676366781963'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111523676366781963'/><link rel='alternate' type='text/html' href='http://descriptors.blogspot.com/2005/05/2-why-use-descriptors.html' title='2. Why use descriptors?'/><author><name>Jo Stichbury</name><uri>http://www.blogger.com/profile/11641972941072027994</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://www.whoshavesthebarber.com/pictures/sose.jpg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12650648.post-111523573324474652</id><published>2005-05-04T12:37:00.000-07:00</published><updated>2006-05-28T14:07:08.296-07:00</updated><title type='text'>1. The Basics</title><content type='html'>&lt;span style="font-weight: bold;"&gt;What are descriptors?&lt;/span&gt;&lt;br /&gt;Descriptors are Symbian OS strings.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;So why are they called 'descriptors' rather than strings?&lt;/span&gt;&lt;br /&gt;They're known as 'descriptors', because they are &lt;span style="font-style: italic;"&gt;self describing&lt;/span&gt;. Each descriptor object holds the length of the string of data it represents as well as its 'type', which identifies the underlying memory layout of the data it holds.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;So they can be used to store text?&lt;/span&gt;&lt;br /&gt;They can. They can also be used to store binary data.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Do they store text data as ASCII or Unicode?&lt;/span&gt;&lt;br /&gt;Either. There are two types, 8-bit and 16-bit descriptors. The 8-bit variant is used to store ASCII characters and raw binary data. The smallest data unit in these is a “narrow” 8 bit (1 byte) character. The 16-bit type is used to store Unicode characters; for these, the data unit is a “wide” 16-bit (2 byte) character.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;How do I know which I have got?&lt;/span&gt;&lt;br /&gt;Each type ends in 8 or 16, for example TDesC8 or TDesC16.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;What about descriptors without 8 or 16 at the end, such as TDesC?&lt;/span&gt;&lt;br /&gt;These are said to be of ‘neutral’ width because they are built with the platform default character size. In the old days, Symbian OS (or EPOC32 as it was known then) used 8-bit ASCII text, so a neutral descriptor defaulted to the 8-bit variety. Since Symbian OS v5U (also known as ER5U) Symbian OS has used wide strings. &lt;br /&gt;&lt;br /&gt;Thus, unless you're working with a pre-v5U  SDK, the neutral descriptors (TBufC, TPtr, HBufC etc) are implicitly 16-bit and are actually TBufC16, TPtr16, HBufC16 etc.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;How do I find out the character width of my platform?&lt;/span&gt;&lt;br /&gt;As described above - unless you’re working with a version of the OS which pre-dates Symbian OS v5U (used in the Ericsson R380 mobile phone in the year 2000) you’ll be working with the wide, 16-bit platform.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;So which width should I use?&lt;/span&gt;&lt;br /&gt;If you need to use 8-bit data, for example, to call a particular API method (such as the Read() or Write() functions of RFile), for Internet email, or to manipulate ASCII data, you should use the explicitly 8-bit descriptors.&lt;br /&gt;If you want to store a chunk of binary data, use the 8 bit variety too.&lt;br /&gt;&lt;br /&gt;If you need to work with 16-bit text, for example, Java strings, and want to indicate this explicitly, use the 16-bit descriptors.&lt;br /&gt;&lt;br /&gt;But, in general, unless you need to make the data width explicit, use the neutral descriptors. If nothing else, your code is more readable and it may even be portable if the default character width changes on a later platform.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Are they NULL-terminated like C strings?&lt;/span&gt;&lt;br /&gt;No.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;How come?&lt;/span&gt;&lt;br /&gt;Because they're self-describing, descriptors know the length of their internal data.  This means there’s no need for the data to be NULL-terminated to mark where the data ends.&lt;span style=""&gt;  &lt;/span&gt;It also means that binary data can be stored in the same descriptor classes as store text data.&lt;span style=""&gt;  &lt;/span&gt;This isn’t possible with C strings because there’s no way of distinguishing the NULL terminating character from valid binary data.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Are they hard to use?&lt;/span&gt;&lt;br /&gt;Not really. They’re easy to use badly but in fact there are only a few rules, and a few gotchas. They just haven’t been fully explained: until now...&lt;br /&gt;&lt;br /&gt;You can find an overview of descriptors in the Symbian Developer Library which accompanies each Software Development Kit (e.g. for UIQ or S60 phones).  It is also available online as described in the references section (&lt;a style="font-style: italic;" href="http://descriptors.blogspot.com/2006/05/references-to-other-descriptors.html"&gt;References to other descriptors resources&lt;/a&gt;).&lt;br /&gt;&lt;br /&gt;The descriptors overview can be found in [&lt;a href="http://descriptors.blogspot.com/2006/05/references-to-other-descriptors.html"&gt;&lt;i&gt;reference 1&lt;/i&gt;&lt;/a&gt;].&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12650648-111523573324474652?l=descriptors.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://descriptors.blogspot.com/feeds/111523573324474652/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12650648&amp;postID=111523573324474652' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111523573324474652'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111523573324474652'/><link rel='alternate' type='text/html' href='http://descriptors.blogspot.com/2005/05/1-basics.html' title='1. The Basics'/><author><name>Jo Stichbury</name><uri>http://www.blogger.com/profile/11641972941072027994</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://www.whoshavesthebarber.com/pictures/sose.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12650648.post-111522996767413676</id><published>2005-05-04T11:04:00.000-07:00</published><updated>2005-06-17T11:33:38.106-07:00</updated><title type='text'>A Different Approach to Explaining Descriptors</title><content type='html'>Every Symbian OS programming book has a chapter on descriptors, which is usually fairly near the start. They are all quite similar and will show the class hierarchy, a few diagrams with boxes and pointers, and more often than not will give some comparison with an equivalent C string type for each descriptor type. Then there will be a few examples of how to use them, which will all work.&lt;br /&gt;&lt;br /&gt;You will read this not-too-interesting chapter while trying to keep awake; you’ll look at the examples and it will all make sense so you’ll think you can use descriptors. You may still have a few worries in your mind, like “Why doesn’t Ptr() return a TPtr?”, but you move on. Then you do some development for real, which inevitably involves descriptors, and bang. It all goes wrong. You can’t decide which descriptor type to use and, when you think you’ve got it, the darned things won’t compile, or work without crashing or simply work at all. But don’t worry, this happens to many new Symbian OS developers, if not all of them. We’re here to help by taking a new approach to explaining descriptors.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;FAQs Facts, Fax&lt;/span&gt;&lt;br /&gt;The blog will consist of frequently asked questions. It’s difficult to take in information from a long, dry and dull chapter on descriptors. FAQs are different. They are much more interesting to read and present one piece of information at a time.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Good examples, bad examples&lt;/span&gt;&lt;br /&gt;Symbian OS books always give examples that work (or that should work but for bugs introduced during publication). We are usually left to discover how to misuse descriptors at our leisure. Then we have to figure out why they are not working. This is hardly leisure. So this article will give lots of misuse examples too. We’ve made all our mistakes public so you don’t have to make them too.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Repetition&lt;/span&gt;&lt;br /&gt;We say the same things again and again in different ways. We repeat ourselves. This is intentional. Some of these things are so important that you must understand them in order to use descriptors successfully. If repeating and re-describing helps your understanding, it's worth the effort. &lt;br /&gt;&lt;br /&gt;Did we mention that we repeat ourselves?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12650648-111522996767413676?l=descriptors.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://descriptors.blogspot.com/feeds/111522996767413676/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12650648&amp;postID=111522996767413676' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111522996767413676'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111522996767413676'/><link rel='alternate' type='text/html' href='http://descriptors.blogspot.com/2005/05/different-approach-to-explaining_04.html' title='A Different Approach to Explaining Descriptors'/><author><name>Jo Stichbury</name><uri>http://www.blogger.com/profile/11641972941072027994</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://www.whoshavesthebarber.com/pictures/sose.jpg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12650648.post-111522756088046216</id><published>2005-05-04T10:23:00.000-07:00</published><updated>2005-12-08T16:22:24.156-08:00</updated><title type='text'>Welcome to the Descriptor FAQ</title><content type='html'>&lt;p class="MsoNormal"&gt;&lt;span lang="EN-GB"&gt;Someone famous once said that some high percentage of computing was manipulating strings.&lt;span style=""&gt;  &lt;/span&gt;If you believe this to be true,&lt;span style=""&gt;  &lt;/span&gt;then getting the hang of string handling is vital.&lt;span style=""&gt;  &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span lang="EN-GB"&gt;Most programmers come to Symbian OS from some other development environment, and tend to think they’ve already got strings pretty much sussed. After all, there’s not much to C strings to understand, although there are plenty of ways they can go wrong. The Java String and StringBuf classes have about the best combination of power and simplicity that you can get. And the various String and CString classes found in different flavours of C++ environments are usually mastered fairly quickly. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;      &lt;p class="MsoNormal"&gt;&lt;span lang="EN-GB"&gt;But then they encounter Symbian OS descriptors. If there was anything invented to bring a high flying C++ developer firmly back to ground during their first week of Symbian OS development, it’s descriptors. “Good grief, there’s a whole zoo of them” is a typical comment upon the first reading of the descriptor chapter in a Symbian OS programming book.&lt;span style=""&gt;  &lt;/span&gt;They look at the various diagrams showing the C equivalents for each descriptor types. They try the examples. It seems just about to make sense. And then they try using them for real, and it all goes wrong. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;     &lt;p class="MsoNormal"&gt;&lt;span lang="EN-GB"&gt;Descriptors seem designed to restrict you. They don’t compile when you think they should. Or they compile without complaint, but panic when you use them. And if they do compile and run without crashing, they still may just plain refuse to do what you expect them to do.&lt;span style=""&gt;  &lt;/span&gt;At which point it’s tempting to turn to the chapter in the book on using the standard C library and use C strings instead.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;     &lt;p class="MsoNormal"&gt;&lt;span lang="EN-GB"&gt;Well don’t. Stick with them. You don’t really have a choice anyway if you are going to be a Symbian OS developer. There are many good reasons to use descriptors, as will become apparent as we proceed.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;     &lt;p class="MsoNormal"&gt;&lt;span lang="EN-GB"&gt;What is needed is a really good explanation of descriptors in simple language that non-Symbian OS developers can understand.&lt;span style=""&gt;  &lt;/span&gt;It should be detailed, because without the detail you can’t use them successfully. There should be examples of how not to use them, as well as the more typical book examples of how they should be used. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;     &lt;p class="MsoNormal"&gt;&lt;span lang="EN-GB"&gt;All Symbian OS developers will have made the same mistakes of using descriptors incorrectly and not understanding what’s going wrong. This article sets out to short-cut the painful learning curve. The authors have been along it, slowly and painfully. Don’t follow in their footsteps.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12650648-111522756088046216?l=descriptors.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://descriptors.blogspot.com/feeds/111522756088046216/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12650648&amp;postID=111522756088046216' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111522756088046216'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111522756088046216'/><link rel='alternate' type='text/html' href='http://descriptors.blogspot.com/2005/05/welcome-to-descriptor-faq.html' title='Welcome to the Descriptor FAQ'/><author><name>Jo Stichbury</name><uri>http://www.blogger.com/profile/11641972941072027994</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://www.whoshavesthebarber.com/pictures/sose.jpg'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12650648.post-111732277457898497</id><published>2005-05-04T10:15:00.000-07:00</published><updated>2006-05-28T13:52:33.916-07:00</updated><title type='text'>I've got a question or comment not already listed. What do I do?</title><content type='html'>Let me know by adding it as a comment to the most relevant post in the blog (I get notification when a comment is added). Please feel free to add as many questions as you like, though bear in mind it may take me a while to get around to answering them. I'd like this to be the most comprehensive online resource for Symbian OS descriptors available, so your input is really valuable. If you have any descriptor tips you'd like to share, for the &lt;a href="http://descriptor-tips.blogspot.com/"&gt;descriptor tips blog&lt;/a&gt; (descriptor-tips.blogspot.com), please add them as comments to the blog and I'll transfer them - and attribute them to you of course!&lt;br /&gt;&lt;br /&gt;Alternatively, if you have a comment to a particular item, you can post it directly by clicking on the comments link at the bottom of the posting. I'll regularly monitor the comments and make corrections/additions accordingly.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12650648-111732277457898497?l=descriptors.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://descriptors.blogspot.com/feeds/111732277457898497/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12650648&amp;postID=111732277457898497' title='12 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111732277457898497'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111732277457898497'/><link rel='alternate' type='text/html' href='http://descriptors.blogspot.com/2005/05/ive-got-question-or-comment-not.html' title='I&apos;ve got a question or comment not already listed. What do I do?'/><author><name>Jo Stichbury</name><uri>http://www.blogger.com/profile/11641972941072027994</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://www.whoshavesthebarber.com/pictures/sose.jpg'/></author><thr:total>12</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12650648.post-111730980668638310</id><published>2005-05-04T10:14:00.000-07:00</published><updated>2006-05-21T14:07:21.423-07:00</updated><title type='text'>How do I search this blog?</title><content type='html'>You can use the Search bar at the top of the page or the Google site search at the bottom. &lt;br /&gt;&lt;br /&gt;Or simply use the "Find" capability of your browser.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12650648-111730980668638310?l=descriptors.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://descriptors.blogspot.com/feeds/111730980668638310/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12650648&amp;postID=111730980668638310' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111730980668638310'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111730980668638310'/><link rel='alternate' type='text/html' href='http://descriptors.blogspot.com/2005/05/how-do-i-search-this-blog.html' title='How do I search this blog?'/><author><name>Jo Stichbury</name><uri>http://www.blogger.com/profile/11641972941072027994</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://www.whoshavesthebarber.com/pictures/sose.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12650648.post-111600531720163966</id><published>2005-05-04T10:13:00.001-07:00</published><updated>2009-08-05T07:00:27.772-07:00</updated><title type='text'>Who are you?</title><content type='html'>I'm Jo Stichbury, author of a Symbian Press title or two. You can find out more about our books from &lt;a href="http://developer.symbian.com/books"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Some of the FAQs in this blog summarise sections of the Descriptors chapters of my first book, Symbian OS Explained. A lot of the text in the blog was originally written as a FAQ by John Blaiklock, an ex-colleague from Sony Ericsson. I'm very grateful to him for allowing me to publish it to a wider audience.  I'd also like to acknowledge Jarmo Petajaaho for taking the time to review and comment on the clarity of the posts.&lt;br /&gt;&lt;br /&gt;And thanks go to Bill Bonney for his suggestions and modifications to the blog template.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12650648-111600531720163966?l=descriptors.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://descriptors.blogspot.com/feeds/111600531720163966/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12650648&amp;postID=111600531720163966' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111600531720163966'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/111600531720163966'/><link rel='alternate' type='text/html' href='http://descriptors.blogspot.com/2005/05/who-are-you.html' title='Who are you?'/><author><name>Jo Stichbury</name><uri>http://www.blogger.com/profile/11641972941072027994</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://www.whoshavesthebarber.com/pictures/sose.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12650648.post-6606711971465387287</id><published>2004-12-30T02:16:00.000-08:00</published><updated>2008-02-01T02:35:23.294-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='translation russian descriptors symbian'/><title type='text'>Descriptors FAQ is now available in Russian</title><content type='html'>&lt;span style="font-weight: bold;"&gt;1st February 2008&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I'm very pleased to be able to announce that the posts in this blog have been translated into Russian, and are available on the Forum Nokia wiki site (Russian) &lt;a href="http://wiki.forum.nokia.com/index.php/FAQ_%D0%BF%D0%BE_%D0%B4%D0%B5%D1%81%D0%BA%D1%80%D0%B8%D0%BF%D1%82%D0%BE%D1%80%D0%B0%D0%BC?ticket=ST-8427-asi7MbdgyM6eHC9edFLP2z3ZnC646C6pTjc-20"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;I'd like to thank Aleksandr Trufanov for his hard work on the translation, which I'm sure will be much appreciated by its readers.  I was grateful also that Alexsandr contacted me in advance of doing the translation, to check that it was OK to reuse the content.  As you'll appreciate, the blogs took John and I a while to put together (not to mention the time our reviewers put in) and it's good to have acknowledgement when the material is reproduced.&lt;br /&gt;&lt;br /&gt;If anyone is interested in translating parts or the whole of this blog into other languages, please do get in touch!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12650648-6606711971465387287?l=descriptors.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='related' href='http://wiki.forum.nokia.com/index.php/FAQ_%D0%BF%D0%BE_%D0%B4%D0%B5%D1%81%D0%BA%D1%80%D0%B8%D0%BF%D1%82%D0%BE%D1%80%D0%B0%D0%BC?ticket=ST-8427-asi7MbdgyM6eHC9edFLP2z3ZnC646C6pTjc-20' title='Descriptors FAQ is now available in Russian'/><link rel='replies' type='application/atom+xml' href='http://descriptors.blogspot.com/feeds/6606711971465387287/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12650648&amp;postID=6606711971465387287' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/6606711971465387287'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/6606711971465387287'/><link rel='alternate' type='text/html' href='http://descriptors.blogspot.com/2004/12/descriptors-faq-is-now-available-in.html' title='Descriptors FAQ is now available in Russian'/><author><name>Jo Stichbury</name><uri>http://www.blogger.com/profile/11641972941072027994</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://www.whoshavesthebarber.com/pictures/sose.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12650648.post-6066859822680438685</id><published>2004-12-29T09:13:00.001-08:00</published><updated>2008-02-14T09:26:21.151-08:00</updated><title type='text'>More Russian Translations</title><content type='html'>&lt;a href="http://2.bp.blogspot.com/_AkVrvr9TaAI/R7R450906wI/AAAAAAAAABw/P4y9Jc6d8KM/s1600-h/getting_started_russian.bmp"&gt;&lt;img id="BLOGGER_PHOTO_ID_5166887607366642434" style="FLOAT: left; MARGIN: 0px 10px 10px 0px; CURSOR: hand" alt="" src="http://2.bp.blogspot.com/_AkVrvr9TaAI/R7R450906wI/AAAAAAAAABw/P4y9Jc6d8KM/s200/getting_started_russian.bmp" border="0" /&gt;&lt;/a&gt; &lt;strong&gt;14th February 2008&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Following on from my &lt;a href="http://descriptors.blogspot.com/2004/12/descriptors-faq-is-now-available-in.html"&gt;previous&lt;/a&gt; post, Aleksandr Trufanov has now also translated the sister blog to this one, descriptor tips. You can find the Russian version on Forum Nokia &lt;a href="http://wiki.forum.nokia.com/index.php/ÐÑÐ¿Ð¾Ð»ÑÐ·Ð¾Ð²Ð°Ð½Ð¸Ðµ_Ð´ÐµÑÐºÑÐ¸Ð¿ÑÐ¾ÑÐ¾Ð²:_ÑÐ¾Ð²ÐµÑÑ#.D0.98.D1.81.D0.BF.D0.BE.D0.BB.D1.8C.D0.B7.D1.83.D0.B9.D1.82.D0.B5_.D0.BE.D0.BF.D0.B5.D1.80.D0.B0.D1.82.D0.BE.D1.80.D1.8B_.3E.3E_.D0.B8_.3C.3C_.D0.B4.D0.BB.D1.8F_.D1.81.D0.BE.D1.85.D1.80.D0.B0.D0.BD.D0.B5.D0.BD.D0.B8.D1.8F_.D0.B8_.D1.87.D1.82.D0.B5.D0.BD.D0.B8.D1.8F_.D0.B4.D0.B5.D1.81.D0.BA.D1.80.D0.B8.D0.BF.D1.82.D0.BE.D1.80.D0.B0_.D0.B8.D0.B7_.D0.BF.D0.BE.D1.82.D0.BE.D0.BA.D0.B0._.D0.9D.D0.BE_.D0.BF.D0.BE.D0.BC.D0.BD.D0.B8.D1.82.D0.B5.2C_.D1.87.D1.82.D0.BE_.D0.BE.D0.BD.D0.B8_.D0.BC.D0.BE.D0.B3.D1.83.D1.82_.D0.B2.D1.8B.D0.B7.D0.B2.D0.B0.D1.82.D1.8C_.D1.81.D0.B1.D1.80.D0.BE.D1.81.21"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;I'd also like to take the opportunity to publicise the recent translation of the Getting Started on Symbian OS booklet from Symbian Press. It's available &lt;a href="http://developer.symbian.com/main/learning/press/books/pdf/GettingStarted_Russian.pdf"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://developer.symbian.com/main/learning/press/books/pdf/GettingStarted_Russian.pdf"&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12650648-6066859822680438685?l=descriptors.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://descriptors.blogspot.com/feeds/6066859822680438685/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12650648&amp;postID=6066859822680438685' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/6066859822680438685'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12650648/posts/default/6066859822680438685'/><link rel='alternate' type='text/html' href='http://descriptors.blogspot.com/2004/12/more-russian-translations.html' title='More Russian Translations'/><author><name>Jo Stichbury</name><uri>http://www.blogger.com/profile/11641972941072027994</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://www.whoshavesthebarber.com/pictures/sose.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_AkVrvr9TaAI/R7R450906wI/AAAAAAAAABw/P4y9Jc6d8KM/s72-c/getting_started_russian.bmp' height='72' width='72'/><thr:total>0</thr:total></entry></feed>
