Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Developing U++ » UppHub » Simple INI parser (15 mb in 4 s, DualCore 2500 Mhz)
Simple INI parser (15 mb in 4 s, DualCore 2500 Mhz) [message #24458] Mon, 18 January 2010 10:11 Go to next message
Sc0rch is currently offline  Sc0rch
Messages: 99
Registered: February 2008
Location: Russia, Rubtsovsk
Member

Simple INI parser

Test-log:
15 mb random INI-file

START LOADING at 01/18/2010 14:59:33
::MemoryUsedKb() = 536
COMPLETE LOADING at 01/18/2010 14:59:37
::MemoryUsedKb() = 94292
COMPLETE_SAVING at 01/18/2010 14:59:39

I hope it can be useful somehow. Example included.
Re: Simple INI parser (15 mb in 4 s, DualCore 2500 Mhz) [message #24511 is a reply to message #24458] Thu, 21 January 2010 18:55 Go to previous messageGo to next message
Sc0rch is currently offline  Sc0rch
Messages: 99
Registered: February 2008
Location: Russia, Rubtsovsk
Member

IniFile 1.0 - Simple INI parser

Example of ini-file:
[Test]

Title = "Test \"Title\""

Name1 = "Value 1"
"Name 2" = Value2
Number = 1
Characters = \\\"\[\]\,\=
"Name with \\\"\[\]\,\=" = Value

["Section with \\\"\[\]\,\="]
Name = Value


Example of usage:
IniFile p;
p.Add("Test", "Name1", "Value 1");
p.Add("Test", "Name 2", "Value2");
p.AddInt("Test", "Number", 1);

p.Add("Test", "Characters", "\\\"[],=");
p.Add("Test", "Name with \\\"[],=", "Value");
p.Add("Section with \\\"[],=", "Name", "Value");

DUMP(p.Get("Test", "Name1")); // "Value 1" as result
DUMP(p.GetInt("Test", "Number")); // 1 as result
DUMP(p.Get("Test", "Characters")); // \"[],= as result

LOG(p.Dump());
p.Save(ConfigFile("Test1.ini", CHARSET_CP1251));
p.Clear();

p.Load(ConfigFile("Test1.ini", CHARSET_CP1251));
p.Save(ConfigFile("Test2.ini")); // CHARSET_DEFAULT


Version 1.0:
* bugfixes (most of them)
+ charsets support (Load("file...", CHARSET_CP1251) and Save)
+ added \ support to use the chars []=,\

Best regards!
Re: Simple INI parser (15 mb in 4 s, DualCore 2500 Mhz) [message #24589 is a reply to message #24458] Mon, 25 January 2010 11:03 Go to previous messageGo to next message
Sc0rch is currently offline  Sc0rch
Messages: 99
Registered: February 2008
Location: Russia, Rubtsovsk
Member

hmm, bug with ','
trying to fix...
if somebody has an idea about reasons, help me. I'm a little slow today =)

[Updated on: Mon, 25 January 2010 11:04]

Report message to a moderator

Re: Simple INI parser (15 mb in 4 s, DualCore 2500 Mhz) [message #24621 is a reply to message #24589] Mon, 25 January 2010 19:05 Go to previous messageGo to next message
Sc0rch is currently offline  Sc0rch
Messages: 99
Registered: February 2008
Location: Russia, Rubtsovsk
Member

Sc0rch wrote on Mon, 25 January 2010 16:03

hmm, bug with ','

Not only with ',' found. Fixed.

Quick fix:
	String GetText()
	{
		if (Text.GetCount() == 1 && Text[0] == '\"')
			return "";
		else if (Text.GetCount())
		{
			String t = Text;

			if (Text[0] == '\"' && Text[Text.GetCount() - 1] == '\"')
				t = Text.Mid(1, Text.GetCount()-2);

			if (t.Find("\\\"") >= 0) ::ReplaceString(t, "\\\"", "\"");
			if (t.Find("\\[" ) >= 0) ::ReplaceString(t, "\\[", "[");
			if (t.Find("\\]" ) >= 0) ::ReplaceString(t, "\\]", "]");
			if (t.Find("\\=" ) >= 0) ::ReplaceString(t, "\\=", "=");
			if (t.Find("\\," ) >= 0) ::ReplaceString(t, "\\,", ",");
			if (t.Find("\\\\") >= 0) ::ReplaceString(t, "\\\\", "\\");
			return t;
		}
		return Text;
	}


New version of IniParser:

[Updated on: Mon, 25 January 2010 19:09]

Report message to a moderator

Re: Simple INI parser (15 mb in 4 s, DualCore 2500 Mhz) [message #41608 is a reply to message #24621] Sun, 05 January 2014 12:28 Go to previous message
vicxtor is currently offline  vicxtor
Messages: 4
Registered: November 2013
Junior Member
c:\upp\uppsrc\core\Topt.h(137) : error C2558: struct 'IniName' : no copy constructor available or copy constructor is declared 'explicit'
c:\upp\uppsrc\core\Vcont.h(45) : see reference to function template instantiation 'T &Upp::DeepCopyConstruct<T>(void *,const T &)' being compiled
with
[
T=IniName
]
c:\upp\uppsrc\core\Vcont.h(45) : while compiling class template member function 'IniName &Upp::Vector<T>::Add(const T &)'
with
[
T=IniName
]
c:\myapps\iniconfig\IniConfig.h(186) : see reference to class template instantiation 'Upp::Vector<T>' being compiled
with
[
T=IniName
]

I get these messages when compiled with MSVC10.
No problem with mingw,
Same messages for IniSection.

How to fix this issue ?

Thank you.
Previous Topic: Very Simple Report Generator (Use QTF format)
Next Topic: GraphCtrl/GraphDraw Candidat to bazaar upload
Goto Forum:
  


Current Time: Thu Mar 28 16:37:12 CET 2024

Total time taken to generate the page: 0.01276 seconds