View unanswered posts | View active topics It is currently Wed Jan 08, 2025 10:16 pm



Reply to topic  [ 28 posts ]  Go to page 1, 2  Next
 Ini Parser Source Code (C++) 
Author Message
User avatar

Joined: Thu Jul 19, 2007 11:31 am
Posts: 249
Location: Sweden, Hallstavik
Reply with quote
Post Ini Parser Source Code (C++)
Current Version: 1.4.0

This is the Cortex Command Ini Parser, it reads a file and puts all parsed data into a tree.

Notice: It won't save comments into the data structure.

How to use it in your code:
This assumes you are not a total newbie at C++.

Requires: Standard Template Library (STL)
Should be in most compilers.

1. Add header AND source file to your project.
2. Add a Parser class to where you want to use it.
Code:
Cortex_Command::Parse::Parser IniFile("File.ini");
or
Cortex_Command::Parse::Parser IniFile();
IniFile.ParseFile("File.ini");

Replace File.ini to whatever you want to parse.
3. Edit the Parse code to suit what you want it to. (Why? Because it is unfinished.)

Additional Info:
Define CC_VARIABLE_OUTPUT if you want in your project if you want it to output variables and comments it found.

Define CC_DEBUG if you want to see additional debugging info.

You can do this in a headerfile if you don't want to define it globally
Code:
#define CC_VARIABLE_OUTPUT
#include "cc_parser.h"


You can read on what the heck it is doing when parsing by looping through the messages vector and printing it. (Add a \n character after each line though.)

Example Output with CC_DEBUG and CC_VARIABLE_OUTPUT defined

Download


Last edited by ChJees on Sun Dec 21, 2008 2:35 pm, edited 10 times in total.



Fri Dec 12, 2008 8:47 pm
Profile WWW
happy carebear mom
User avatar

Joined: Tue Mar 04, 2008 1:40 am
Posts: 7096
Location: b8bbd5
Reply with quote
Post Re: Ini Parser Source Code (C++)
ChJees wrote:
It can parse stuff yes, but you have to handle the data yourself.

...
...
I am very happy.


Fri Dec 12, 2008 9:25 pm
Profile
User avatar

Joined: Wed Dec 27, 2006 9:52 pm
Posts: 688
Location: California
Reply with quote
Post Re: Ini Parser Source Code (C++)
I'm confused as to what you'd use this for.


Fri Dec 12, 2008 9:37 pm
Profile

Joined: Sat Jan 13, 2007 11:04 pm
Posts: 2932
Reply with quote
Post Re: Ini Parser Source Code (C++)
Same here, Chjees tried to explain me but I didnt understand a crap about it.

So what EXACTLY is this app for? Like, in detail and what benefit is there for the user? What does it do?


Fri Dec 12, 2008 9:48 pm
Profile
happy carebear mom
User avatar

Joined: Tue Mar 04, 2008 1:40 am
Posts: 7096
Location: b8bbd5
Reply with quote
Post Re: Ini Parser Source Code (C++)
It reads CC .ini's. You could use it to gather information about a mod, check a mod for errors without opening up CC every five seconds, make a dependency tree, a mod creation program... The list goes on.


Fri Dec 12, 2008 11:27 pm
Profile
User avatar

Joined: Wed Dec 27, 2006 9:52 pm
Posts: 688
Location: California
Reply with quote
Post Re: Ini Parser Source Code (C++)
Hmm, this could be very useful for advanced modders. +5 internets to CHJees.


Sat Dec 13, 2008 6:13 am
Profile

Joined: Thu Dec 11, 2008 5:16 am
Posts: 26
Location: Somewhere close
Reply with quote
Post Re: Ini Parser Source Code (C++)
Perhaps even making a modding program, so that you dont have to hard code everything....


Sun Dec 14, 2008 6:52 pm
Profile
User avatar

Joined: Thu Jul 19, 2007 11:31 am
Posts: 249
Location: Sweden, Hallstavik
Reply with quote
Post Re: Ini Parser Source Code (C++)
A.K.A.Steve wrote:
Perhaps even making a modding program, so that you dont have to hard code everything....


Code:
std::string filename;
std::cin >> filename;

Cortex_Command::Parse::Parser IniFile();
IniFile.ParseFile( filename );


There, no longer hard coded.


Sun Dec 14, 2008 8:18 pm
Profile WWW

Joined: Thu Dec 11, 2008 5:16 am
Posts: 26
Location: Somewhere close
Reply with quote
Post Re: Ini Parser Source Code (C++)
lol, yes of course, its so simple.
I meant a mod making program, the parser is the first step and opens the door but doesnt have the interface(yet), sorry for any misconceptions. :grin:
Correct if im wrong but right now the only way to make mods is to type it out in the document by hand.
If someone were to take the parser and create a graphical modder, modding would be much easier.
Ie.
    Start a new mod
    Create effect
      Bring up effect editor(graphical display coupled with text boxes for editing the effect properties)
      Modify default settings
      name and save
    Create emitter
      Bring up emitter editor(graphical display coupled with text boxes for editing the emitter properties)
      Modify default settings, add effects
      name and save
    Create craft
      Bring up craft editor(graphical display coupled with text boxes and grid for part positioning)
      Modify default values, add emitter, add parts
      Name and save

If the preview was real time you could see exactly what each variable does, currently CC only has a gib editor, so a third party modder would provide for an easy alternative until one is added.

Personally I would love to make something along these lines but all i know is basic C++/Java/Basic, when it comes to any graphical displays I quickly get shot down by the complications. Curse you DirectX and all of your jargon.


Sun Dec 14, 2008 10:04 pm
Profile
happy carebear mom
User avatar

Joined: Tue Mar 04, 2008 1:40 am
Posts: 7096
Location: b8bbd5
Reply with quote
Post Re: Ini Parser Source Code (C++)
One thing I worry about if modding gets an easy-to-use GUI is an overwhelming tide of SMG shotcannons.
Then again, if they suddenly become so easy to make they might not be made... Anyone a psychologist here?


Sun Dec 14, 2008 10:21 pm
Profile
User avatar

Joined: Fri Apr 27, 2007 4:55 pm
Posts: 1178
Location: America!
Reply with quote
Post Re: Ini Parser Source Code (C++)
Duh102 wrote:
One thing I worry about if modding gets an easy-to-use GUI is an overwhelming tide of SMG shotcannons.
Then again, if they suddenly become so easy to make they might not be made... Anyone a psychologist here?


You don't have to release a mod if you make it.
Some people just want to make SMG shotcannons to mess around with in their own games.


Sun Dec 14, 2008 10:45 pm
Profile
User avatar

Joined: Thu Jul 19, 2007 11:31 am
Posts: 249
Location: Sweden, Hallstavik
Reply with quote
Post Re: Ini Parser Source Code (C++)
I has made some considerable progress now, it is not far until i will release a fully functional version :).

The final version will include a "Tree" structure in which all parsed data is in. And a much cleaner and self documenting interface :P.

I will eventually make a new "Mod Loader" for Cortex Command as well as a "Quick Mod Test" application. All in UI.


Sun Dec 14, 2008 10:48 pm
Profile WWW
User avatar

Joined: Sun May 18, 2008 8:30 am
Posts: 732
Reply with quote
Post Re: Ini Parser Source Code (C++)
Does that mean it makes sure all of the filepaths and instances are valid?


Mon Dec 15, 2008 12:25 am
Profile
User avatar

Joined: Sat Sep 22, 2007 7:28 pm
Posts: 298
Location: Right here.
Reply with quote
Post Re: Ini Parser Source Code (C++)
Hey! Stop breaking CC!!


Mon Dec 15, 2008 6:25 am
Profile
User avatar

Joined: Thu Jul 19, 2007 11:31 am
Posts: 249
Location: Sweden, Hallstavik
Reply with quote
Post Re: Ini Parser Source Code (C++)
New Source Release!

This features all things which i wanted to achieve!

Reading Cortex Command Ini Files and put them into a tree structure!

Example Output with CC_DEBUG and CC_VARIABLE_OUTPUT defined

Download

Will now continue to work on the Rte Inspector :3.
If you use my code, then credit me. And Data of course for making this awesome game.


Mon Dec 15, 2008 5:36 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 28 posts ]  Go to page 1, 2  Next

Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.030s | 14 Queries | GZIP : Off ]