Results 1 to 2 of 2

Thread: Reading a Lua File into QHashes

  1. #1
    Join Date
    Jan 2006
    Posts
    44
    Thanks
    9
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11

    Red face Reading a Lua File into QHashes

    I'm working on an app that needs to read some "data" files written out in Lua (from World of Warcraft addons).

    For reference the beginning of one of the file is here:
    Qt Code:
    1. AucDbData = {
    2. ["bids"] = {
    3. ["US/Executus-Alliance"] = {
    4. },
    5. ["US/Aggramar-Alliance"] = {
    6. [1255128075] = "36909:0:0:0:823116736:20:Saggiebottom:180000:200000:0:4:list:200000;36909:0:0:0:1421360512:20:Saggiebottom:180000:200000:0:4:list:200000",
    7. [1255166575] = "36907:0:0:0:727092128:7:Dionisis:57176:66528:0:4:list:66528;36907:0:0:0:897729472:13:Macamar:121550:124800:0:4:list:124800",
    8. [1255128605] = "36909:0:0:0:513886800:20:Saggiebottom:180000:200000:0:4:list:200000;36909:0:0:0:495964656:20:Saggiebottom:180000:200000:0:4:list:200000",
    9. [1255166698] = "36901:0:0:0:-2029754892:1:Hellstormi:4900:4900:0:4:list:4900;36901:0:0:0:1483235840:5:Dionisis:33725:33725:0:4:list:33725",
    10. },
    11. },
    12. ["count"] = {
    13. ["US/Aggramar-Alliance"] = {
    14. ["42411:0"] = {
    15. [14526] = "83655:5:2880",
    16. },
    17. ["41100:0"] = {
    18. [14526] = "22862:1:2880",
    19. },
    20. ["40922:0"] = {
    21. [14526] = "13761:1:2880",
    22. },
    23. ["12820:0"] = {
    24. [14526] = "37600:2:1440",
    25. },
    26. ["33461:0"] = {
    27. [14526] = "2178:1:2880",
    28. },
    29. ["43376:0"] = {
    30. [14526] = "25643:1:2880",
    31. },
    32. ["42910:0"] = {
    33. [14526] = "19404:1:2880;19404:1:2880",
    34. },
    35. ["43467:0"] = {
    36. [14526] = "7821:1:2880",
    37. },
    38. },
    39. },
    40. ["scans"] = {
    41. ["US/Executus-Alliance"] = {
    42. },
    43. ["US/Aggramar-Alliance"] = {
    44. [1255124278] = "12820:0:0:0:794027136:1:Azeract:17300:18400:0:4;12820:0:0:0:1143618432:2:Thldruid:30100:30200:0:4",
    45. (more lines like that one and it closes out)
    46. ....
    To copy to clipboard, switch view to plain text mode 

    Now it seems to me I have a few options. I could go the route of embedding a Lua interpreter and trying to access the data that way. I've looked but everything seems to be more about using Lua to access/control C++. I don't need to *do* anything in Lua, I'm just needing to read (only) in this data and then do stuff in Qt with it.

    Which leads me to the option of writing a parser to read this data in and convert it to a nested QHash or custom object. I've seen references to QLALR that might be able to do the job but the only mentions of it are a couple years old and there is zero documentation.

    Has anyone done something along either of these lines and be able to give references or pointers, or even just some advice as to routes to take? I've not written any parsers that do this soort of thing so it is a bit new to me. (But give me a log file ...). Theoretically I *could* use regexes but that doesn't smell right.
    --
    The Real Bill

  2. #2
    Join Date
    Nov 2009
    Location
    US, Midwest
    Posts
    215
    Thanks
    62
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Reading a Lua File into QHashes

    Look at boost::spirit, may be it is what you are looking for.

Similar Threads

  1. Reading and rereading a file with QXmlStreamReader
    By TheRonin in forum Qt Programming
    Replies: 14
    Last Post: 30th April 2015, 14:04
  2. reading bytes out of a file
    By priceey in forum Qt Programming
    Replies: 7
    Last Post: 6th October 2009, 16:55
  3. help in reading XML file
    By cshiva_in in forum Qt Programming
    Replies: 1
    Last Post: 24th March 2008, 13:55
  4. QTextStream loses position while reading file
    By bjh in forum Qt Programming
    Replies: 2
    Last Post: 13th February 2008, 15:47
  5. Replies: 3
    Last Post: 18th October 2007, 18:07

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.