hey... I just made my own class to handle tagToken's...
#ifndef TAGTOKEN_H
#define TAGTOKEN_H
#include <QtCore>
class tagToken
{
public:
tagToken();
private:
QString nameOftagToken;
//line # of file token was on
int rowNumber = 0;
//colNumber token started at
int colNumber = 0;
//Either an identifier such as Object:
//or What is specified after Object: such as creature
QString objectInstance ="";
//is tagToken "Object:" ?
bool objectIdentifier = 0;
struct tokenInfo
{
bool openBrace = 0;
bool closingBrace = 0;
bool whiteSpace = 0;
//it's a comment if there is no nearby [ or ]
bool comment = 0;
//are there newLines in this token?
bool newLines = 0;
};
};
#endif // TAGTOKEN_H
this code I planned on doing more with, but as I parsed the file, I could backupdate new data structures since I keep track of the parent object. I could do further matching on token names, and identify subclasses of tagToken's, such as Caste, and check dependencies.
Also tokens could hold information regarding their line position, but I don't think that's too important, but knowing whitespace can help preserve the same format when rewritten so as to avoid excessive contextual differences between two files.
I set it up, so I could load up a comment with new lines as a tagToken as well as regular tag's, so when outputted, it could reference the boolean flags in the object to see if it needs to rewrite brackets or not (or leave as a comment) and hopefully leave the correct whitespace and/or tab's...
remember, this is a primitive mockup. I started thinking about it last night and coding it today, but I haven't implemented it yet beyond creating a qvector so I can keep track of each and every tag.
Then I would probably derive a patch file based on the ordinal differences between tag positions of two objects.
Yes, I am aware I have no accessor functions setup atm. I just noted the private vars I think I would need.
Update:
So... made some good progress for a newb today.
I have my environment setup to start parsing the entire file, whatever it may be.
Step 2 is to read all the tokens in a qvector.
Step 3 is to create individual objects and their respective tokens.
Step 4 is to compare the differences between two objects from two different files