|
How to save text and image as single image in asp.net 2.0
|
|
|
|
|
Hi Todd,
If I wnat to change the follwoing:
[Section A]
KeyA=ValA
KeyB=ValB
[Section B]
varA=ValC
varB=ValC
to:
[Section A]
KeyA=ValA
KeyB=ValB
[Section B]
varA=ValC
varB=ValC
What would be the easiest way to accomplish this??
Many thanx
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
ANSWER:
<br />
<br />
bool CIniFile::Save(string FileName, vector<Record>& content)<br />
{<br />
ofstream outFile (FileName.c_str()); <br />
if (!outFile.is_open()) return false; <br />
<br />
for (int i=0;i<(int)content.size();i++) <br />
{<br />
outFile << content[i].Comments; <br />
if(content[i].Key == "") <br />
if (i == 0)<br />
outFile << content[i].Commented << "[" <br />
<< content[i].Section << "]" << endl; <br />
else<br />
outFile << content[i].Commented << endl << "[" <br />
<< content[i].Section << "]" << endl; <br />
else<br />
outFile << content[i].Commented << content[i].Key <br />
<< "=" << content[i].Value << endl; <br />
}<br />
<br />
outFile.close(); <br />
return true;<br />
}<br />
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
I haven't worked with this class for a LONG time, and I don't program in C++ anymore, but - off the top of my head, what I would do is a comment to section B which consists of a blank string - i.e. " " and the should give you a space between the sections.
-Todd Davis (toddhd@gmail.com)
|
|
|
|
|
Todd Davis ... thank you very much ... after compiling this into a dll, well let's just say my life has just become alot easier ...
Thanx again
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
What platforms does it support ?
Have you tryed to compile it with g++ on Linux ?
|
|
|
|
|
I am facing the following compilation error. can u give suggestion. I got this error before adding your code itself.
===========
--------------------Configuration: test - Win32 Debug--------------------
Compiling...
IniFile.cpp
IniFile.cpp(155) : warning C4786: 'std::reverse_iterator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const *,std::basic_string<char,std::char_traits<char>,std::allocator<c
har> >,std::basic_string<char,std::char_traits<char>,std::allocator<char> > const &,std::basic_string<char,std::char_traits<char>,std::allocator<char> > const *,int>' : identifier was truncated to '255' characters in the debug information
IniFile.cpp(155) : warning C4786: 'std::reverse_iterator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > *,std::basic_string<char,std::char_traits<char>,std::allocator<char> >
,std::basic_string<char,std::char_traits<char>,std::allocator<char> > &,std::basic_string<char,std::char_traits<char>,std::allocator<char> > *,int>' : identifier was truncated to '255' characters in the debug information
IniFile.cpp(241) : error C2552: 's' : non-aggregates cannot be initialized with initializer list
IniFile.cpp(242) : error C2552: 'r' : non-aggregates cannot be initialized with initializer list
IniFile.cpp(254) : error C2552: 'r' : non-aggregates cannot be initialized with initializer list
IniFile.cpp(504) : error C2552: 's' : non-aggregates cannot be initialized with initializer list
IniFile.obj - 4 error(s), 2 warning(s)
|
|
|
|
|
I don't think this is the good choice to manage your config file.
The *better* choice is CIniFile by Shane Hill.
Two major's reasons:
1) really best writing,
2) the Shane Hill's code is really cross platform.
So the man is not THE MAN.;P
Good coding.
|
|
|
|
|
Hye!!
I'm wondering about how to get the list of keys for each section.
How can i do that?
Thanking you in advance.
|
|
|
|
|
//try this code snipet
//add this to IniFile.h
static vector<string> GetKeyNames(string SectionName, string FileName);
//add this to IniFile.cpp
vector<string> CIniFile::GetKeyNames(string SectionName, string FileName)
{
vector<string> data;
vector<Record> content;
if(Load(FileName, content))
{
for (int i=0;i<(int)content.size();i++)
{
if(((content[i].Section == SectionName) &&(content[i].Key !
= "")) && (content[i].Value != ""))
data.push_back(content[i].Key);
}
}
return data;
}
//usage
vector<string> keyresult = CIniFile::GetKeyNames("DllList",Filename);
cout << "the keys in section DllList in config.ini file are" << endl;
vector<string>::iterator theIterator2;
for (theIterator2 = keyresult.begin(); theIterator2 != keyresult.end();
theIterator2++)
{
cout << *theIterator2 << "=" << endl;
cout << CIniFile::GetValue(*theIterator2,"DllList",Filename)
<<endl;
}
-- modified at 3:54 Wednesday 22nd March, 2006
|
|
|
|
|
Hi!
I have to say thanks! it works great!
a few things I would like to see, if someobdy has time to work on it....
1) ability to have spaces/lines in between items in the INI file....basically making it more readable (spacing before each element in each line), as well as interline spacing (i.e. different sections seperated by one space)
2) comments for the functions (i.e. comments as a whole to say what the function does, pre and post conditions)
other than that, nice!
|
|
|
|
|
That is one of the best slams I have read in response to idiot (oops, I mean befuddled) commenters. You are definitely THE MAN. BTW, good article. It is nice to read educated English on this site, at least occasionally.
|
|
|
|
|
Hi,
Just wanted to say, I like this class a lot.
It is one of the best Ini manipulation class I have seen so far.
One suggestion though, make methods such as GetSections() and GetSection()
return a std::map<> with the KeyName as a key. This would speed even more
retrieval of values with only one disk access. Just my 0.02$ ...
have a nice day,
Alexandre
|
|
|
|
|
i wanted to use your class but all i know about c++ concerns mfc and it seems that CString cannot be automatically converted into std::string so giving CString parameters in your functions cause error. Can you help me?
Thx in advance.
|
|
|
|
|
To convert from CString to std::string or from std::string to CString use the following:
CString -> std::string
<br />
CString csTest = "test";<br />
std::string strTest = static_cast<LPCTSTR>(csTest);<br />
std::string -> CString
<br />
std::string strTest = "Test";<br />
CString csTest = strTest.c_str();<br />
As simple as that.
have a nice day.
Alexandre
|
|
|
|
|
Hmm, don't know which platform you're using, but when I do this (compiling for the PocketPC platform) I get the following error:
error C2440: 'initializing' : cannot convert from 'LPCTSTR' to 'std::basic_string<_Elem,_Traits,_Ax>'
with
[
_Elem=char,
_Traits=std::char_traits<char>,
_Ax=std::allocator<char>
]
No constructor could take the source type, or constructor overload resolution was ambiguous
Still haven't found a solution that works for me though...
|
|
|
|
|
PocketPC projects are Unicode by default, so CString is actually CStringW, and must be converted to std::wstring.
|
|
|
|
|
After converting from CString to std::string it is giving following error,as source code is in UNICODE.
error C2440: 'static_cast' : cannot convert from 'class CString' to 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >'
No constructor could take the source type, or constructor overload resolution was ambiguous
gn
ghn
ghn
ghn
ghn
ghn
ghn
ghn
ghn
ghn
ghn
ghn
ghn
ghn
hn
hn
ghn
ghn
ghn
ghn
ghn
ghn
ghn
gn
hn
hgn
gh
nh
|
|
|
|
|
Hi
I cannot compile your code through VC 6 Prof. it says
--------------------Konfiguration: yabt - Win32 Debug--------------------
Kompilierung läuft...
IniFile.cpp
D:\Projekte\yabt\extern_code\IniFile.cpp(155) : warning C4786: 'std::reverse_iterator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const *,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::basic_s
tring<char,std::char_traits<char>,std::allocator<char> > const &,std::basic_string<char,std::char_traits<char>,std::allocator<char> > const *,int>' : Bezeichner wurde auf '255' Zeichen in den Debug-Informationen reduziert
D:\Projekte\yabt\extern_code\IniFile.cpp(155) : warning C4786: 'std::reverse_iterator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > *,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::basic_string<
char,std::char_traits<char>,std::allocator<char> > &,std::basic_string<char,std::char_traits<char>,std::allocator<char> > *,int>' : Bezeichner wurde auf '255' Zeichen in den Debug-Informationen reduziert
D:\Projekte\yabt\extern_code\IniFile.cpp(241) : error C2552: 's' : Initialisierung nicht zusammengesetzter Typen mit Initialisierungsliste ist nicht moeglich
D:\Projekte\yabt\extern_code\IniFile.cpp(242) : error C2552: 'r' : Initialisierung nicht zusammengesetzter Typen mit Initialisierungsliste ist nicht moeglich
D:\Projekte\yabt\extern_code\IniFile.cpp(254) : error C2552: 'r' : Initialisierung nicht zusammengesetzter Typen mit Initialisierungsliste ist nicht moeglich
D:\Projekte\yabt\extern_code\IniFile.cpp(504) : error C2552: 's' : Initialisierung nicht zusammengesetzter Typen mit Initialisierungsliste ist nicht moeglich
Generieren von Code...
Fehler beim Ausführen von cl.exe.
XnVersion.exe - 4 Fehler, 2 Warnung(en)
Any workaround?
Thy anyway
-------------------
http://www.sanji.tk
|
|
|
|
|
Yeah I get the exact same problem...although I would add that the .exe that you included in the download works fine.
Looks like a nice utility but I'm obviously doing something wrong.
Cheers
Andy
|
|
|
|
|
the faulty code is the struct initialization at lines
241, 242, 254 and 504
change the "{"",' ',SectionName,"",""}" for
s.Comments = "";
s.Commented = ' ';
s.Section = SectionName;
s.Key = "";
s.Value = "";
where s is the Record object;
Somehow VC++ 6.0 does not like the initialization used. I guess
VC++ .NET/2003 does not complain about this.
have a nice day,
Alexandre
|
|
|
|
|
What he means is:
Find lines: 241, 242, 254 and 504
change the "{"",' ',SectionName,"",""}" To:
Record s;
s.Comments = "";
s.Commented = '\0'; //This prevents empty character constant error.
s.Section = SectionName;
s.Key = "";
s.Value = "";
Do the same for the other lines and it should work.
Douglas Saltsman
www.primopdf.com <-- Download my free PDF creator
|
|
|
|
|
I had the same compilation erros, but I have fixed them in another way. Instead of assigning each single attribute, I have created constructors for the struct CIniFile::Record (remember that in C++ "struct" constructions are just like "class" constructions, except by the fact that the former has "public" as default visibility).
The code changes in CIniFile::Record are shown below:
struct Record
{
string Comments;
char Commented;
string Section;
string Key;
string Value;
Record() { Commented = ' '; }
Record(const string& commentsStr, char commented, const string& sectionStr,
const string& keyStr, const string& valueStr)
: Comments(commentsStr), Commented(commented), Section(sectionStr), Key(keyStr), Value(valueStr)
{ }
};
Now, all you have to do is change faulty lines like that:
Record r = {"",' ',SectionName,KeyName,Value};
to the proper use of the new constructor:
Record r ("",' ',SectionName,KeyName,Value);
I hope someone will find it useful...
|
|
|
|
|
after this fix:
--------------------Configuration: Object - Win32 Final--------------------<br />
Compiling...<br />
IniFile.cpp<br />
C:\proj\AVP2\ObjectDLL\IniFile.cpp(132) : warning C4018: '!=' : signed/unsigned mismatch<br />
\lithshared\stl\stl/_algo.c(88) : error C2664: '()' : cannot convert parameter 1 from 'const struct CIniFile::Record' to 'struct CIniFile::Record &'<br />
Conversion loses qualifiers<br />
\lithshared\stl\stl/_algo.c(1152) : see reference to function template instantiation 'const struct CIniFile::Record &__cdecl _STL::__median(const struct CIniFile::Record &,const struct CIniFile::Record &,const struct CIniFile::Record &,struc<br />
t CIniFile::DescendingSectionSort)' being compiled<br />
\lithshared\stl\stl/_algo.c(88) : error C2064: term does not evaluate to a function<br />
\lithshared\stl\stl/_algo.c(1152) : see reference to function template instantiation 'const struct CIniFile::Record &__cdecl _STL::__median(const struct CIniFile::Record &,const struct CIniFile::Record &,const struct CIniFile::Record &,struc<br />
t CIniFile::DescendingSectionSort)' being compiled<br />
\lithshared\stl\stl/_algo.c(89) : error C2664: '()' : cannot convert parameter 1 from 'const struct CIniFile::Record' to 'struct CIniFile::Record &'<br />
Conversion loses qualifiers<br />
\lithshared\stl\stl/_algo.c(1152) : see reference to function template instantiation 'const struct CIniFile::Record &__cdecl _STL::__median(const struct CIniFile::Record &,const struct CIniFile::Record &,const struct CIniFile::Record &,struc<br />
t CIniFile::DescendingSectionSort)' being compiled<br />
\lithshared\stl\stl/_algo.c(89) : error C2064: term does not evaluate to a function<br />
\lithshared\stl\stl/_algo.c(1152) : see reference to function template instantiation 'const struct CIniFile::Record &__cdecl _STL::__median(const struct CIniFile::Record &,const struct CIniFile::Record &,const struct CIniFile::Record &,struc<br />
t CIniFile::DescendingSectionSort)' being compiled<br />
\lithshared\stl\stl/_algo.c(91) : error C2664: '()' : cannot convert parameter 1 from 'const struct CIniFile::Record' to 'struct CIniFile::Record &'<br />
Conversion loses qualifiers<br />
\lithshared\stl\stl/_algo.c(1152) : see reference to function template instantiation 'const struct CIniFile::Record &__cdecl _STL::__median(const struct CIniFile::Record &,const struct CIniFile::Record &,const struct CIniFile::Record &,struc<br />
t CIniFile::DescendingSectionSort)' being compiled<br />
\lithshared\stl\stl/_algo.c(91) : error C2064: term does not evaluate to a function<br />
\lithshared\stl\stl/_algo.c(1152) : see reference to function template instantiation 'const struct CIniFile::Record &__cdecl _STL::__median(const struct CIniFile::Record &,const struct CIniFile::Record &,const struct CIniFile::Record &,struc<br />
t CIniFile::DescendingSectionSort)' being compiled<br />
\lithshared\stl\stl/_algo.c(95) : error C2664: '()' : cannot convert parameter 1 from 'const struct CIniFile::Record' to 'struct CIniFile::Record &'<br />
Conversion loses qualifiers<br />
\lithshared\stl\stl/_algo.c(1152) : see reference to function template instantiation 'const struct CIniFile::Record &__cdecl _STL::__median(const struct CIniFile::Record &,const struct CIniFile::Record &,const struct CIniFile::Record &,struc<br />
t CIniFile::DescendingSectionSort)' being compiled<br />
\lithshared\stl\stl/_algo.c(95) : error C2064: term does not evaluate to a function<br />
\lithshared\stl\stl/_algo.c(1152) : see reference to function template instantiation 'const struct CIniFile::Record &__cdecl _STL::__median(const struct CIniFile::Record &,const struct CIniFile::Record &,const struct CIniFile::Record &,struc<br />
t CIniFile::DescendingSectionSort)' being compiled<br />
\lithshared\stl\stl/_algo.c(97) : error C2664: '()' : cannot convert parameter 1 from 'const struct CIniFile::Record' to 'struct CIniFile::Record &'<br />
Conversion loses qualifiers<br />
\lithshared\stl\stl/_algo.c(1152) : see reference to function template instantiation 'const struct CIniFile::Record &__cdecl _STL::__median(const struct CIniFile::Record &,const struct CIniFile::Record &,const struct CIniFile::Record &,struc<br />
t CIniFile::DescendingSectionSort)' being compiled<br />
\lithshared\stl\stl/_algo.c(97) : error C2064: term does not evaluate to a function<br />
\lithshared\stl\stl/_algo.c(1152) : see reference to function template instantiation 'const struct CIniFile::Record &__cdecl _STL::__median(const struct CIniFile::Record &,const struct CIniFile::Record &,const struct CIniFile::Record &,struc<br />
t CIniFile::DescendingSectionSort)' being compiled<br />
\lithshared\stl\stl/_algo.c(88) : error C2664: '()' : cannot convert parameter 1 from 'const struct CIniFile::Record' to 'struct CIniFile::Record &'<br />
Conversion loses qualifiers<br />
\lithshared\stl\stl/_algo.c(1152) : see reference to function template instantiation 'const struct CIniFile::Record &__cdecl _STL::__median(const struct CIniFile::Record &,const struct CIniFile::Record &,const struct CIniFile::Record &,struc<br />
t CIniFile::AscendingSectionSort)' being compiled<br />
\lithshared\stl\stl/_algo.c(88) : error C2064: term does not evaluate to a function<br />
\lithshared\stl\stl/_algo.c(1152) : see reference to function template instantiation 'const struct CIniFile::Record &__cdecl _STL::__median(const struct CIniFile::Record &,const struct CIniFile::Record &,const struct CIniFile::Record &,struc<br />
t CIniFile::AscendingSectionSort)' being compiled<br />
\lithshared\stl\stl/_algo.c(89) : error C2664: '()' : cannot convert parameter 1 from 'const struct CIniFile::Record' to 'struct CIniFile::Record &'<br />
Conversion loses qualifiers<br />
\lithshared\stl\stl/_algo.c(1152) : see reference to function template instantiation 'const struct CIniFile::Record &__cdecl _STL::__median(const struct CIniFile::Record &,const struct CIniFile::Record &,const struct CIniFile::Record &,struc<br />
t CIniFile::AscendingSectionSort)' being compiled<br />
\lithshared\stl\stl/_algo.c(89) : error C2064: term does not evaluate to a function<br />
\lithshared\stl\stl/_algo.c(1152) : see reference to function template instantiation 'const struct CIniFile::Record &__cdecl _STL::__median(const struct CIniFile::Record &,const struct CIniFile::Record &,const struct CIniFile::Record &,struc<br />
t CIniFile::AscendingSectionSort)' being compiled<br />
\lithshared\stl\stl/_algo.c(91) : error C2664: '()' : cannot convert parameter 1 from 'const struct CIniFile::Record' to 'struct CIniFile::Record &'<br />
Conversion loses qualifiers<br />
\lithshared\stl\stl/_algo.c(1152) : see reference to function template instantiation 'const struct CIniFile::Record &__cdecl _STL::__median(const struct CIniFile::Record &,const struct CIniFile::Record &,const struct CIniFile::Record &,struc<br />
t CIniFile::AscendingSectionSort)' being compiled<br />
\lithshared\stl\stl/_algo.c(91) : error C2064: term does not evaluate to a function<br />
\lithshared\stl\stl/_algo.c(1152) : see reference to function template instantiation 'const struct CIniFile::Record &__cdecl _STL::__median(const struct CIniFile::Record &,const struct CIniFile::Record &,const struct CIniFile::Record &,struc<br />
t CIniFile::AscendingSectionSort)' being compiled<br />
\lithshared\stl\stl/_algo.c(95) : error C2664: '()' : cannot convert parameter 1 from 'const struct CIniFile::Record' to 'struct CIniFile::Record &'<br />
Conversion loses qualifiers<br />
\lithshared\stl\stl/_algo.c(1152) : see reference to function template instantiation 'const struct CIniFile::Record &__cdecl _STL::__median(const struct CIniFile::Record &,const struct CIniFile::Record &,const struct CIniFile::Record &,struc<br />
t CIniFile::AscendingSectionSort)' being compiled<br />
\lithshared\stl\stl/_algo.c(95) : error C2064: term does not evaluate to a function<br />
\lithshared\stl\stl/_algo.c(1152) : see reference to function template instantiation 'const struct CIniFile::Record &__cdecl _STL::__median(const struct CIniFile::Record &,const struct CIniFile::Record &,const struct CIniFile::Record &,struc<br />
t CIniFile::AscendingSectionSort)' being compiled<br />
\lithshared\stl\stl/_algo.c(97) : error C2664: '()' : cannot convert parameter 1 from 'const struct CIniFile::Record' to 'struct CIniFile::Record &'<br />
Conversion loses qualifiers<br />
\lithshared\stl\stl/_algo.c(1152) : see reference to function template instantiation 'const struct CIniFile::Record &__cdecl _STL::__median(const struct CIniFile::Record &,const struct CIniFile::Record &,const struct CIniFile::Record &,struc<br />
t CIniFile::AscendingSectionSort)' being compiled<br />
\lithshared\stl\stl/_algo.c(97) : error C2064: term does not evaluate to a function<br />
\lithshared\stl\stl/_algo.c(1152) : see reference to function template instantiation 'const struct CIniFile::Record &__cdecl _STL::__median(const struct CIniFile::Record &,const struct CIniFile::Record &,const struct CIniFile::Record &,struc<br />
t CIniFile::AscendingSectionSort)' being compiled<br />
\lithshared\stl\stl/_algo.c(88) : error C2664: '()' : cannot convert parameter 1 from 'const struct CIniFile::Record' to 'struct CIniFile::Record &'<br />
Conversion loses qualifiers<br />
\lithshared\stl\stl/_algo.c(1152) : see reference to function template instantiation 'const struct CIniFile::Record &__cdecl _STL::__median(const struct CIniFile::Record &,const struct CIniFile::Record &,const struct CIniFile::Record &,struc<br />
t CIniFile::DescendingRecordSort)' being compiled<br />
\lithshared\stl\stl/_algo.c(88) : error C2064: term does not evaluate to a function<br />
\lithshared\stl\stl/_algo.c(1152) : see reference to function template instantiation 'const struct CIniFile::Record &__cdecl _STL::__median(const struct CIniFile::Record &,const struct CIniFile::Record &,const struct CIniFile::Record &,struc<br />
t CIniFile::DescendingRecordSort)' being compiled<br />
\lithshared\stl\stl/_algo.c(89) : error C2664: '()' : cannot convert parameter 1 from 'const struct CIniFile::Record' to 'struct CIniFile::Record &'<br />
Conversion loses qualifiers<br />
\lithshared\stl\stl/_algo.c(1152) : see reference to function template instantiation 'const struct CIniFile::Record &__cdecl _STL::__median(const struct CIniFile::Record &,const struct CIniFile::Record &,const struct CIniFile::Record &,struc<br />
t CIniFile::DescendingRecordSort)' being compiled<br />
\lithshared\stl\stl/_algo.c(89) : error C2064: term does not evaluate to a function<br />
\lithshared\stl\stl/_algo.c(1152) : see reference to function template instantiation 'const struct CIniFile::Record &__cdecl _STL::__median(const struct CIniFile::Record &,const struct CIniFile::Record &,const struct CIniFile::Record &,struc<br />
t CIniFile::DescendingRecordSort)' being compiled<br />
\lithshared\stl\stl/_algo.c(91) : error C2664: '()' : cannot convert parameter 1 from 'const struct CIniFile::Record' to 'struct CIniFile::Record &'<br />
Conversion loses qualifiers<br />
\lithshared\stl\stl/_algo.c(1152) : see reference to function template instantiation 'const struct CIniFile::Record &__cdecl _STL::__median(const struct CIniFile::Record &,const struct CIniFile::Record &,const struct CIniFile::Record &,struc<br />
t CIniFile::DescendingRecordSort)' being compiled<br />
\lithshared\stl\stl/_algo.c(91) : error C2064: term does not evaluate to a function<br />
\lithshared\stl\stl/_algo.c(1152) : see reference to function template instantiation 'const struct CIniFile::Record &__cdecl _STL::__median(const struct CIniFile::Record &,const struct CIniFile::Record &,const struct CIniFile::Record &,struc<br />
t CIniFile::DescendingRecordSort)' being compiled<br />
\lithshared\stl\stl/_algo.c(95) : error C2664: '()' : cannot convert parameter 1 from 'const struct CIniFile::Record' to 'struct CIniFile::Record &'<br />
Conversion loses qualifiers<br />
\lithshared\stl\stl/_algo.c(1152) : see reference to function template instantiation 'const struct CIniFile::Record &__cdecl _STL::__median(const struct CIniFile::Record &,const struct CIniFile::Record &,const struct CIniFile::Record &,struc<br />
t CIniFile::DescendingRecordSort)' being compiled<br />
\lithshared\stl\stl/_algo.c(95) : error C2064: term does not evaluate to a function<br />
\lithshared\stl\stl/_algo.c(1152) : see reference to function template instantiation 'const struct CIniFile::Record &__cdecl _STL::__median(const struct CIniFile::Record &,const struct CIniFile::Record &,const struct CIniFile::Record &,struc<br />
t CIniFile::DescendingRecordSort)' being compiled<br />
\lithshared\stl\stl/_algo.c(97) : error C2664: '()' : cannot convert parameter 1 from 'const struct CIniFile::Record' to 'struct CIniFile::Record &'<br />
Conversion loses qualifiers<br />
\lithshared\stl\stl/_algo.c(1152) : see reference to function template instantiation 'const struct CIniFile::Record &__cdecl _STL::__median(const struct CIniFile::Record &,const struct CIniFile::Record &,const struct CIniFile::Record &,struc<br />
t CIniFile::DescendingRecordSort)' being compiled<br />
\lithshared\stl\stl/_algo.c(97) : error C2064: term does not evaluate to a function<br />
\lithshared\stl\stl/_algo.c(1152) : see reference to function template instantiation 'const struct CIniFile::Record &__cdecl _STL::__median(const struct CIniFile::Record &,const struct CIniFile::Record &,const struct CIniFile::Record &,struc<br />
t CIniFile::DescendingRecordSort)' being compiled<br />
\lithshared\stl\stl/_algo.c(88) : error C2664: '()' : cannot convert parameter 1 from 'const struct CIniFile::Record' to 'struct CIniFile::Record &'<br />
Conversion loses qualifiers<br />
\lithshared\stl\stl/_algo.c(1152) : see reference to function template instantiation 'const struct CIniFile::Record &__cdecl _STL::__median(const struct CIniFile::Record &,const struct CIniFile::Record &,const struct CIniFile::Record &,struc<br />
t CIniFile::AscendingRecordSort)' being compiled<br />
\lithshared\stl\stl/_algo.c(88) : error C2064: term does not evaluate to a function<br />
\lithshared\stl\stl/_algo.c(1152) : see reference to function template instantiation 'const struct CIniFile::Record &__cdecl _STL::__median(const struct CIniFile::Record &,const struct CIniFile::Record &,const struct CIniFile::Record &,struc<br />
t CIniFile::AscendingRecordSort)' being compiled<br />
\lithshared\stl\stl/_algo.c(89) : error C2664: '()' : cannot convert parameter 1 from 'const struct CIniFile::Record' to 'struct CIniFile::Record &'<br />
Conversion loses qualifiers<br />
\lithshared\stl\stl/_algo.c(1152) : see reference to function template instantiation 'const struct CIniFile::Record &__cdecl _STL::__median(const struct CIniFile::Record &,const struct CIniFile::Record &,const struct CIniFile::Record &,struc<br />
t CIniFile::AscendingRecordSort)' being compiled<br />
\lithshared\stl\stl/_algo.c(89) : error C2064: term does not evaluate to a function<br />
\lithshared\stl\stl/_algo.c(1152) : see reference to function template instantiation 'const struct CIniFile::Record &__cdecl _STL::__median(const struct CIniFile::Record &,const struct CIniFile::Record &,const struct CIniFile::Record &,struc<br />
t CIniFile::AscendingRecordSort)' being compiled<br />
\lithshared\stl\stl/_algo.c(91) : error C2664: '()' : cannot convert parameter 1 from 'const struct CIniFile::Record' to 'struct CIniFile::Record &'<br />
Conversion loses qualifiers<br />
\lithshared\stl\stl/_algo.c(1152) : see reference to function template instantiation 'const struct CIniFile::Record &__cdecl _STL::__median(const struct CIniFile::Record &,const struct CIniFile::Record &,const struct CIniFile::Record &,struc<br />
t CIniFile::AscendingRecordSort)' being compiled<br />
\lithshared\stl\stl/_algo.c(91) : error C2064: term does not evaluate to a function<br />
\lithshared\stl\stl/_algo.c(1152) : see reference to function template instantiation 'const struct CIniFile::Record &__cdecl _STL::__median(const struct CIniFile::Record &,const struct CIniFile::Record &,const struct CIniFile::Record &,struc<br />
t CIniFile::AscendingRecordSort)' being compiled<br />
\lithshared\stl\stl/_algo.c(95) : error C2664: '()' : cannot convert parameter 1 from 'const struct CIniFile::Record' to 'struct CIniFile::Record &'<br />
Conversion loses qualifiers<br />
\lithshared\stl\stl/_algo.c(1152) : see reference to function template instantiation 'const struct CIniFile::Record &__cdecl _STL::__median(const struct CIniFile::Record &,const struct CIniFile::Record &,const struct CIniFile::Record &,struc<br />
t CIniFile::AscendingRecordSort)' being compiled<br />
\lithshared\stl\stl/_algo.c(95) : error C2064: term does not evaluate to a function<br />
\lithshared\stl\stl/_algo.c(1152) : see reference to function template instantiation 'const struct CIniFile::Record &__cdecl _STL::__median(const struct CIniFile::Record &,const struct CIniFile::Record &,const struct CIniFile::Record &,struc<br />
t CIniFile::AscendingRecordSort)' being compiled<br />
\lithshared\stl\stl/_algo.c(97) : error C2664: '()' : cannot convert parameter 1 from 'const struct CIniFile::Record' to 'struct CIniFile::Record &'<br />
Conversion loses qualifiers<br />
\lithshared\stl\stl/_algo.c(1152) : see reference to function template instantiation 'const struct CIniFile::Record &__cdecl _STL::__median(const struct CIniFile::Record &,const struct CIniFile::Record &,const struct CIniFile::Record &,struc<br />
t CIniFile::AscendingRecordSort)' being compiled<br />
\lithshared\stl\stl/_algo.c(97) : error C2064: term does not evaluate to a function<br />
\lithshared\stl\stl/_algo.c(1152) : see reference to function template instantiation 'const struct CIniFile::Record &__cdecl _STL::__median(const struct CIniFile::Record &,const struct CIniFile::Record &,const struct CIniFile::Record &,struc<br />
t CIniFile::AscendingRecordSort)' being compiled<br />
Error executing cl.exe.<br />
<br />
Object.lto - 40 error(s), 1 warning(s)<br />
The following environment variables were not found<br />
$(LT2_DIR)<br />
$(AVP2_BUILD_DIR)
|
|
|
|
|
Hello!
I have some comments to your code, I think it is very expensive to use:
Why are all functions static?
Most of the time I want to load/save the INI File once or only very seldom, at startup or when the user changes the preferences. So, simply make it a normal class, make filename and the content vector a member and thats it.
When I want for some reasons to reload/save the data, I can do it with the Load/Save memberfunctions. But there is no need to enforce that it is done automatically.
Some lesser improvements:
1) Please do not add the line:
using namespace std;
to your header file!
With it you defeat the whole idea behind putting something in a namespace. Everywhere youre header is included, the whole namespace gets included.
2)
Also, in the header you do not need to include e.g. iostream because you only need it in the cpp file. While this is more of an optimization please try to minimize the headers you include in headers.
Everybody who uses a compiler with no precompiled header feature will be grateful.
3) Use const&:
e.g.
static bool AddSection(string SectionName, string FileName);
should get its parameters by const& because there is no need that the strings are copied
4) Errorchecking on streams.
You do no errorchecking if a read access to the inifile fails. While an eror is unlikely you still should protect against it.
Maybe use:
while(!std::getline(inFile, s)))
{ ... }
if (inFile.eof()) return true;
else return false;
This way you could also remove the test for is_open.
5) Do not use endl. For better performance use '\n'. Use endl only if you really intend to flush the stream. You only want this seldom with files.
cu
|
|
|
|
|