cTAFileParser and gadget mode ?

Everything related to the code /
Tout ce qui touche au code
Post Reply
milipili
Posts: 545
Joined: Thu Nov 02, 2006 8:52 am
Location: Paris (France)
Contact:

cTAFileParser and gadget mode ?

Post by milipili » Wed Jul 16, 2008 6:37 pm

Hi !
does someone know what is gadget mode in cTAFileParser.cpp ? (cf gadget_mode / g_mode)
Damien Gerard
Ta3d & Yuni Developer

User avatar
zuzuf
Administrateur - Site Admin
Posts: 3281
Joined: Mon Oct 30, 2006 8:49 pm
Location: Toulouse, France
Contact:

Post by zuzuf » Wed Jul 16, 2008 7:30 pm

some TA's tdf files use keys named "gadget%d", in many files %d ranges from 0 (or 1 don't remember quite well) to N with all integers between 0 and N. But there are also some files which use nearly random numbers and since those numbers aren't important I wrote a gadget mode that rewrites all the keys with known numbers (from 0 to N like expected).

That way we can easily read the list of primary keys from a TDF file using the hash table structure where we store all the data. Note you can also get the original name of a key using : PullAsString("gadget%d"), it'll return the original name.

This is used by the GUI module to load *.gui/*.tdf files. I think I may have used it too elsewhere I don't remember where exactly ... just to make things easier :D
=>;-D Penguin Powered

milipili
Posts: 545
Joined: Thu Nov 02, 2006 8:52 am
Location: Paris (France)
Contact:

Post by milipili » Fri Jul 18, 2008 12:17 pm

To be sure...

Code: Select all

[pika2] // the first section
{
   key = 42;
}
[gadget42] // another section
{
    key = 11;
    [ nested-section  ]
    {
        foo = bar;
    }
}
...will give ...

Code: Select all

gadget0 = pika2
gadget1 = gadget42
gadget0.key = 42
gadget1.key = 11
gadget1.nested-section.foo = bar
right ?
Damien Gerard
Ta3d & Yuni Developer

User avatar
zuzuf
Administrateur - Site Admin
Posts: 3281
Joined: Mon Oct 30, 2006 8:49 pm
Location: Toulouse, France
Contact:

Post by zuzuf » Fri Jul 18, 2008 1:12 pm

yes it'll give you that result. Only primary keys names are rewritten
=>;-D Penguin Powered

milipili
Posts: 545
Joined: Thu Nov 02, 2006 8:52 am
Location: Paris (France)
Contact:

Post by milipili » Fri Jul 18, 2008 2:36 pm

I have nearly finished a new implementation (with a parser more tolerant to errors and warnings for misplaced '}' and ignored text), which seems promising :

Code: Select all

./ta3d-bin-TA3D-TDFParser  13.10s user 0.51s system 95% cpu 14.303 total
./ta3d-bin-TA3D-UTILS-cTAFileParser  21.18s user 0.61s system 98% cpu 22.085 total
(Core2Duo 2.16GHz)

Code: Select all

for (int i = 0; i < 5000; ++i)
{
    TA3D::UTILS::cTAFileParser p("gui/mdrn_config_display.tdf");
    //TA3D::TDFParser p("gui/mdrn_config_display.tdf");
    if (p.pullAsString("window.object8.name") != "waves")
        LOG_ERROR("Does not match !");
}
I will try it this evening within TA3D and see if it is a bit faster on my PC laptop (and if it works too ^^).
Damien Gerard
Ta3d & Yuni Developer

User avatar
zuzuf
Administrateur - Site Admin
Posts: 3281
Joined: Mon Oct 30, 2006 8:49 pm
Location: Toulouse, France
Contact:

Post by zuzuf » Fri Jul 18, 2008 5:15 pm

Yeah looks really promising :D . It would be great to have such a performance improvement at loading time :shock: !!
=>;-D Penguin Powered

Post Reply

Who is online

Users browsing this forum: No registered users and 38 guests