Home » Developing U++ » UppHub » Simple INI parser (15 mb in 4 s, DualCore 2500 Mhz)
|
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   |
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 #24621 is a reply to message #24589] |
Mon, 25 January 2010 19:05   |
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  |
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.
|
|
|
Goto Forum:
Current Time: Sat Apr 26 15:17:19 CEST 2025
Total time taken to generate the page: 0.01146 seconds
|