(C++) Class for reading Windows-INI-like files
Bad news:
My hoster kilu.de got hacked and all user accounts and data has been deleted and couldn't be restored.
The real bad thing is, that I didn't have any local backups of the website so I have to create a new one which will take some time.
Don't worry the projects themselves are backed up
However the hack has its good sites, too.
The new site will be hosted on an root server running only two websites (mine plus another).
So the performance should be very high.
You can reach my site with this url (the old domain doesn't work on the root server... strange)
http://btbsoft.org
My hoster kilu.de got hacked and all user accounts and data has been deleted and couldn't be restored.
The real bad thing is, that I didn't have any local backups of the website so I have to create a new one which will take some time.
Don't worry the projects themselves are backed up
However the hack has its good sites, too.
The new site will be hosted on an root server running only two websites (mine plus another).
So the performance should be very high.
You can reach my site with this url (the old domain doesn't work on the root server... strange)
http://btbsoft.org
Last edited by Sylence on Sat Dec 27, 2008 8:08 pm, edited 1 time in total.
Software documentation is like sex. If it's good you want more. If it's bad it's better than nothing.
-
- Posts: 58
- Joined: Tue Apr 10, 2007 7:49 pm
- Location: Karlsruhe
Hi, i think i found a bug in getValueW:
you're creating a local variable str and returning a pointer to it's content.
But when conrol exits this method, the local variable is destroyed and the
pointer points anywhere.
I fixed it for me this way:
with w_value being a private class variable.
you're creating a local variable str and returning a pointer to it's content.
But when conrol exits this method, the local variable is destroyed and the
pointer points anywhere.
I fixed it for me this way:
Code: Select all
const wchar_t* CIniFileReaderStub::getValueW(const c8* section, const c8* key)
{
w_value = core::stringw(getValue(section,key));
return w_value.c_str();
}
No sorry. I was very busy the last time and I somehow lost the overview of what have to be done with it. Still trying to figure out a way to make it more easily expandable but I just can't figure out a way of dealing with the different Irrlicht types in a more abstract way (and of all the features I want to have in the conversation to irrlicht core types is the number 1)
Either it's now bug-free because there hasn't been a bug report for a while now, or no one is using this anymore...
Either it's now bug-free because there hasn't been a bug report for a while now, or no one is using this anymore...
Software documentation is like sex. If it's good you want more. If it's bad it's better than nothing.
Ok did a coding marathon and made version 0.3 in a few hours
I'm afraid I did more damage than I repaired ^^
Finally fixed that empty line thing at the end of the file =)
Check it out at my site
I'm afraid I did more damage than I repaired ^^
Finally fixed that empty line thing at the end of the file =)
Check it out at my site
Software documentation is like sex. If it's good you want more. If it's bad it's better than nothing.
Half a year later I finally managed to find some time to implement comments.
When you load a file with comments (starting with ; or ##) they will be stored and will be written to the file when saved.
Also you can add / change comments during runtime.
A comment is always associated with the section or key that follows the comment.
Download can be found here
When you load a file with comments (starting with ; or ##) they will be stored and will be written to the file when saved.
Also you can add / change comments during runtime.
A comment is always associated with the section or key that follows the comment.
Download can be found here
Software documentation is like sex. If it's good you want more. If it's bad it's better than nothing.
Dont know if you still visit the site but I tried your IrrIni. I realise this is 2 years old . It still works with the newest version of Irrlicht, so that's nice.
It's good for the most part, but I have some comments.
I'm not sure why you would just convert an unsigned int to a signed one. Values larger than 2,147,483,647 will go into negative.
So instead I changed it to:
I don't think that using random fixed size buffers like that is the best programming practice (eg 20), especially using Irrlicht, where you could just use Irrlicht's stringc. But this matches the behaviour of the other methods.
Also, in CIrrIniStub::addSection() I added if (!getSection(name)). Otherwise, adding a section with the same name again creates multiple sections with the same name, and adding to the section will always just add to the first one found. If you wanted you could make setValue() add the section if it doesn't exist too, I suppose.
Also in your constructor for CIrrIniStub, the first part of the code (the block that uses an IReadFile) you create a file but you never drop the file, this causes a memory leak. Changing it to look like this resolves the issue:
Lastly I wish you had used wide chars, so that values in say Japanese or whatever could be used in the ini files. But I guess that's being picky.
Overall though from my experience so far, it works well and I'll be using it. Saves me time to write my own one. I haven't thoroughly tested it though, I guess I'll post again if I find any other issues.
Cheers.
It's good for the most part, but I have some comments.
I'm not sure why you would just convert an unsigned int to a signed one. Values larger than 2,147,483,647 will go into negative.
Code: Select all
void CIrrIniStub::setValue(const c8* section, const c8* key, u32 value)
{
setValue(section,key,(s32)value);
}
Code: Select all
void CIrrIniStub::setValue(const c8* section, const c8* key, u32 value)
{
c8 buf[20];
sprintf(buf,"%u",value);
setValue(section,key,buf);
}
Also, in CIrrIniStub::addSection() I added if (!getSection(name)). Otherwise, adding a section with the same name again creates multiple sections with the same name, and adding to the section will always just add to the first one found. If you wanted you could make setValue() add the section if it doesn't exist too, I suppose.
Also in your constructor for CIrrIniStub, the first part of the code (the block that uses an IReadFile) you create a file but you never drop the file, this causes a memory leak. Changing it to look like this resolves the issue:
Code: Select all
IReadFile* readFile = fileSystem->createAndOpenFile(file);
if(readFile)
{
s32 size = readFile->getSize();
c8* buffer = new c8[size+2];
readFile->read(buffer,size);
buffer[size+1] = 0x0;
Content = buffer;
delete [] buffer;
readFile->drop(); // <- added this line
}
Overall though from my experience so far, it works well and I'll be using it. Saves me time to write my own one. I haven't thoroughly tested it though, I guess I'll post again if I find any other issues.
Cheers.