Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - Skip Items in CArchive
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Skip Items in CArchive

 Post Reply Post Reply
Author
Message
barobax View Drop Down
Senior Member
Senior Member


Joined: 07 May 2008
Status: Offline
Points: 117
Post Options Post Options   Thanks (0) Thanks(0)   Quote barobax Quote  Post ReplyReply Direct Link To This Post Topic: Skip Items in CArchive
    Posted: 18 October 2008 at 3:15am
Hi,
I have a serialized file and serialized 257244 strings in this file.I want to read string by index(i.e. Index 100 = "add"). I had a file with 200,000 integers and can read indexes by skip 4 bytes for each index(each Integer). I can skip and read Index 1000 with below code:

        int iSkip = (1000 - 1) * 4;
        TCHAR* sLoad = new TCHAR[iSkip];
        archive.Read(sLoad, iSkip);
        free(sLoad);
        sLoad = NULL;
        delete sLoad;
        int iNum;
        archive >> iNum;

if we use sizeof() in runtime we get 4 bytes for int and 4 bytes for string but I can't read string by skipping 4 bytes for each index.I fill the string with thousand characters and I use sizeof() in runtime and sizeof() return 4 bytes.I want to know how can I skip items or strings in CArchive ?


I Ask(GOOGLE) from doctor for non-microsoft written archives and I found CArchiveEx for compressing serialized archives and set password for archives. I Read documents of codejock but I can not found a CArchive Extended class.CodeJock Extended CArchive class or not  ?

Please Help Me,
Thanks in Advance,
Back to Top
znakeeye View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 July 2006
Status: Offline
Points: 1672
Post Options Post Options   Thanks (0) Thanks(0)   Quote znakeeye Quote  Post ReplyReply Direct Link To This Post Posted: 19 October 2008 at 11:32am
If you serialize it like this:
 
ar << _1000characters;
ar << _1000characters;
 
Then you can simply use read:
char buffer[1000], buffer2[1000];
ar.Read(buffer, 1000);
ar.Read(buffer2, 1000);
 
If you use CString you must read the length first (4 bytes). Hmm, I really don't see your problem?
Back to Top
barobax View Drop Down
Senior Member
Senior Member


Joined: 07 May 2008
Status: Offline
Points: 117
Post Options Post Options   Thanks (0) Thanks(0)   Quote barobax Quote  Post ReplyReply Direct Link To This Post Posted: 19 October 2008 at 3:24pm
Hi znakeeye,
Thanks in advance,
I test it but don't work,
My first strings are

1080
12-step

when I skip 4 bytes and Carchive >> a string my string is empty and can't read 12-step !!!!

Thanks znakeeye again for your help,

Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 20 October 2008 at 6:37am
Hi,
You can't skip simple CStrings.
Think its crazy idea to use CArchive for 300000 stings. Migrate to some database.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
barobax View Drop Down
Senior Member
Senior Member


Joined: 07 May 2008
Status: Offline
Points: 117
Post Options Post Options   Thanks (0) Thanks(0)   Quote barobax Quote  Post ReplyReply Direct Link To This Post Posted: 20 October 2008 at 4:37pm
Hi,
Thanks Oleg, I need a portable database. when I use Microsoft Access My Strings size is 90MB and when I export rows in text file My .txt file size is 50MB and when I compress it with WinRAR with Normal Compression in ZIP My Strings size is 10MB.now I need a portable database with compression feature and/or Encryption.If you(Oleg(the king of CodeJock)) have any Idea please tell me.

Thanks from Oleg and znakeeye for responses to My Question.

My work is URGENT.If you have any Idea(PLEASE) tell me.

Thanks in Advance,
Best Regards.
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 21 October 2008 at 2:08am
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
barobax View Drop Down
Senior Member
Senior Member


Joined: 07 May 2008
Status: Offline
Points: 117
Post Options Post Options   Thanks (0) Thanks(0)   Quote barobax Quote  Post ReplyReply Direct Link To This Post Posted: 21 October 2008 at 5:12am
Hi,

Originally posted by oleg oleg wrote:

You can't skip simple CStrings.


which strings we can skip ?!?
Thanks for your database suggestion.

Thanks,
Best Regards.
Back to Top
ABuenger View Drop Down
Newbie
Newbie
Avatar

Joined: 02 February 2006
Status: Offline
Points: 1075
Post Options Post Options   Thanks (0) Thanks(0)   Quote ABuenger Quote  Post ReplyReply Direct Link To This Post Posted: 21 October 2008 at 7:14am
Originally posted by oleg oleg wrote:

Hi,



Or better sqlite for embeddability.

Codejock support
Back to Top
ijwelch View Drop Down
Senior Member
Senior Member


Joined: 20 June 2006
Status: Offline
Points: 262
Post Options Post Options   Thanks (0) Thanks(0)   Quote ijwelch Quote  Post ReplyReply Direct Link To This Post Posted: 21 October 2008 at 8:52am
SQLite com for anyone who needs it. And it's free.
http://www.thecommon.net/2.html



Back to Top
barobax View Drop Down
Senior Member
Senior Member


Joined: 07 May 2008
Status: Offline
Points: 117
Post Options Post Options   Thanks (0) Thanks(0)   Quote barobax Quote  Post ReplyReply Direct Link To This Post Posted: 21 October 2008 at 7:48pm
Hi,
I found this in sqllites site.
"This is a DLL of the SQLite library without the TCL bindings. The only external dependency is MSVCRT.DLL."
it's very very portable.
Thanks ABuenger & ijwelch for your help.

Thanks All,
Best Regards.
Back to Top
barobax View Drop Down
Senior Member
Senior Member


Joined: 07 May 2008
Status: Offline
Points: 117
Post Options Post Options   Thanks (0) Thanks(0)   Quote barobax Quote  Post ReplyReply Direct Link To This Post Posted: 30 October 2008 at 3:29pm
WOW ABuenger && ijwelch,
I work with SQL Lite today and it's nice.

Thaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaanks,
Best Regards,
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.156 seconds.