Read-only archive of the All About Symbian forum (2001–2013) · About this archive

Problem with Symbian String and descriptors

2 replies · 1,821 views · Started 10 February 2004

So this is probably no problem for experienced C++ developer, but I have little trouble and I am sure it will be something stupid where I am using Symbian descriptors in wrong way.
I have serialized directory that needs to be parsed in this little code. I am having problem of getting substring from this string.
This is my string which is read:

[1]games

01Ftodo.bmp! 01Dvsd![1]kultura

[1]news

01Daaa! 12Dbbs! 23FWINIMAGE.EXE! 12Detc! 23Dna4_files! 34Fbg1.gif! 34FwhatIsNA.css![1]okurky



In debuger I can see that my HBufC8.fulltree contains whole read string (above) that is 144 character long.

do {
myFile.Read(readBuf1);
console->Printf(KDataReceived, readBuf1.Length());
iData->AddDataL(readBuf1); // this is my class containing segmentedbuffer so I can have dynamic descriptor.
} while (readBuf1.Length() != 0 );
HBufC8* fullTree = HBufC8::NewL(144);
fullTreePtr.Set(fullTree->Des());
TInt stat = iData->ReadFully(fullTreePtr, 144); // this method use Read() method of SegmentedBuffer to fill �fullTree�.

At this point I can really see that I have all data in memory and fullTreePtr points to the string above (serialized tree).
When I am trying to get substring 136 - 142 I have error in my debuger. Probably some memory overflow.
fullTreePtr.Mid(136, 142);

Any ideas ????

Originally posted by praefectus
When I am trying to get substring 136 - 142 I have error in my debuger. Probably some memory overflow.
fullTreePtr.Mid(136, 142);

Read the documentation.

The second parameter for a Mid function refers to length and not a position. You should use fullTreePtr.Mid(136, 7).

Originally posted by cmatthee
Read the documentation.

The second parameter for a Mid function refers to length and not a position. You should use fullTreePtr.Mid(136, 7).

Thanks, caught that before you posted -- really appreciate your reply, however.