|
Add the line:
using namespace std;
Either add it in the iniFile.h file (after the includes). I think you can also add it just prior to including the .h file in your program.
Adam Clauss
cabadam@tamu.edu
|
|
|
|
|
I now get this
-------------------Configuration: MovieBase - Win32 Debug--------------------
Compiling...
MainFrm.cpp
c:\program files\microsoft visual studio\myprojects\moviebase\inifile.h(115) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
c:\program files\microsoft visual studio\vc98\include\vector(60) : 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_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
c:\program files\microsoft visual studio\vc98\include\vector(58) : while compiling class-template member function '__thiscall std::vector<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<c
har,std::char_traits<char>,std::allocator<char> > > >::~std::vector<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >(void)'
c:\program files\microsoft visual studio\vc98\include\vector(60) : 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
c:\program files\microsoft visual studio\vc98\include\vector(58) : while compiling class-template member function '__thiscall std::vector<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<c
har,std::char_traits<char>,std::allocator<char> > > >::~std::vector<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >(void)'
MovieBase.cpp
c:\program files\microsoft visual studio\myprojects\moviebase\inifile.h(115) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
c:\program files\microsoft visual studio\vc98\include\vector(60) : 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_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
c:\program files\microsoft visual studio\vc98\include\vector(58) : while compiling class-template member function '__thiscall std::vector<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<c
har,std::char_traits<char>,std::allocator<char> > > >::~std::vector<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >(void)'
c:\program files\microsoft visual studio\vc98\include\vector(60) : 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
c:\program files\microsoft visual studio\vc98\include\vector(58) : while compiling class-template member function '__thiscall std::vector<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<c
har,std::char_traits<char>,std::allocator<char> > > >::~std::vector<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >(void)'
MovieBaseDoc.cpp
c:\program files\microsoft visual studio\myprojects\moviebase\inifile.h(115) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
c:\program files\microsoft visual studio\vc98\include\vector(60) : 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_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
c:\program files\microsoft visual studio\vc98\include\vector(58) : while compiling class-template member function '__thiscall std::vector<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<c
har,std::char_traits<char>,std::allocator<char> > > >::~std::vector<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >(void)'
c:\program files\microsoft visual studio\vc98\include\vector(60) : 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
c:\program files\microsoft visual studio\vc98\include\vector(58) : while compiling class-template member function '__thiscall std::vector<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<c
har,std::char_traits<char>,std::allocator<char> > > >::~std::vector<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >(void)'
MovieBaseView.cpp
c:\program files\microsoft visual studio\myprojects\moviebase\inifile.h(115) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
c:\program files\microsoft visual studio\vc98\include\vector(60) : 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_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
c:\program files\microsoft visual studio\vc98\include\vector(58) : while compiling class-template member function '__thiscall std::vector<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<c
har,std::char_traits<char>,std::allocator<char> > > >::~std::vector<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >(void)'
c:\program files\microsoft visual studio\vc98\include\vector(60) : 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
c:\program files\microsoft visual studio\vc98\include\vector(58) : while compiling class-template member function '__thiscall std::vector<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<c
har,std::char_traits<char>,std::allocator<char> > > >::~std::vector<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >(void)'
NewDatabaseDlg.cpp
c:\program files\microsoft visual studio\myprojects\moviebase\inifile.h(115) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
c:\program files\microsoft visual studio\vc98\include\vector(60) : 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_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
c:\program files\microsoft visual studio\vc98\include\vector(58) : while compiling class-template member function '__thiscall std::vector<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<c
har,std::char_traits<char>,std::allocator<char> > > >::~std::vector<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >(void)'
c:\program files\microsoft visual studio\vc98\include\vector(60) : 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
c:\program files\microsoft visual studio\vc98\include\vector(58) : while compiling class-template member function '__thiscall std::vector<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<c
har,std::char_traits<char>,std::allocator<char> > > >::~std::vector<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >(void)'
iniFile.cpp
c:\program files\microsoft visual studio\myprojects\moviebase\inifile.cpp(32) : warning C4005: 'iniEOL' : macro redefinition
c:\program files\microsoft visual studio\myprojects\moviebase\inifile.cpp(30) : see previous definition of 'iniEOL'
c:\program files\microsoft visual studio\myprojects\moviebase\inifile.cpp(488) : fatal error C1010: unexpected end of file while looking for precompiled header directive
Generating Code...
Error executing cl.exe.
MovieBase.exe - 1 error(s), 16 warning(s)
|
|
|
|
|
For the warnings - these are a known issue with the STL. They don't really mean anything. See:
http://www.codeguru.com/forum/showthread.php?s=438df56fb6990cc9dfb4fa38be92c5d5&threadid=232164
For the error at the end, you can do one of two things.
Either add:
#include "stdafx.h" as the first include in iniFile.cpp OR
In File View (or Solution Explorer if you are using VC.NET) right click on iniFile.cpp and go to properties. Turn off precompiled headers for this file (will not affect the rest of the project).
I typically do the second method.
Adam Clauss
cabadam@tamu.edu
|
|
|
|
|
jobs a goodin
|
|
|
|
|
I am using VC.NET and cant find "Turn off precompiled headers for this file (will not affect the rest of the project)."
why. is there anything wrong with my compiler?
|
|
|
|
|
In Solution Explorer, right click on iniFile.cpp and go to properties. On the left, click the folder for C/C++ and then select Precompiled Headers. Now on the right, change where it says "Use Precompiled Header" to "Not Using Precompiled Header".
Adam Clauss
cabadam@tamu.edu
|
|
|
|
|
I submitted an update that should be posted here in a couple days. There has been enough interest in the non-MFC version of this class that I have decided to post it here.
Adam Clauss
cabadam@tamu.edu
|
|
|
|
|
The update looks good. I have been using the MFC version of the class for a while. It is very nice and I have actually ended up using it for a log of my projects as well... The one feature I felt was missing was the ability to store lists of values. I ended up modifying the class slightly to include SetValueList, and GetValueList functions. A list would be identified by a key name, and the values in the list would just appear in the ini file as n0, n1, n2, ... Is this an update that has been considered?
jonathan
|
|
|
|
|
No, I hadn't really considered doing that. I guess I figured it would be just as easy to either parse the string value returned. I've also seen other programs use a format similar to this (not with my class, though it could easily be done):
[SomeKeyName]
ListCount=5
Value1=...
Value2=...
Value3=...
Value4=...
Value5=...
Adam Clauss
cabadam@tamu.edu
|
|
|
|
|
Great class.. Thanks for sharing it with us!
Rob
|
|
|
|
|
Truely great class! In your demo, though, there is one simple bug in the OnInitDialog(). You had:
<code>age.SetWindowText(inifile.GetValue("Info","Age"));
This wouldn't load the age. The code for age is:
<code>age.SetWindowText(inifile.GetValue("Info<big>1</big>","Age"));
Again, not a big deal, but in case anyone was questioning the ability of your class, it was just a coding mistake.
Thanks a lot (I've been needing a class like this for a LONG time),
~ Selevercin
If you have a problem with my spelling, just remember that's not my fault. I [as well as everyone
else who learned to spell after 1976] blame it on
Robert A. Kolpek for U.S. Patent 4,136,395.
|
|
|
|
|
How can I get the text inputted into the ini file and save it to a CStirng?
Appreciate it ,
NightBlade
|
|
|
|
|
SetValue/GetValue?
Not sure if this is what you were asking, if it isn't please explain.
HTH,
Adam Clauss
cabadam@tamu.edu
|
|
|
|
|
I tried doing the example:
CString GetValue(CString, CString)
but it gives me the error that "GetValue" is an undeclared identifer. I'm not sure why its doing that, thats my i asked. All the other functions work fine. So if there is somthing that I am not doing, I can't catch it
Thanks
NightBlade
|
|
|
|
|
Adam I am looking to change it so that it can access random ini keys ie
i am writing an app which records company account codes in a ini file for report purposes
ie it needs to load the account codes to setup a select statement to produce the reports
[codes]
acc1=syscode1
acc2=syscode2
acc3=syscode3
problem is the account code will vary and the syscode will vary
so i cant write something which pickup all the keys for a given section ,i can however count them.
I will email u if i can get it adjusted to cope !!
|
|
|
|
|
Hi,
I'm using your class with NT 4.0. It works very well.
I've got problems with my software running with Windows 95. Is CIniFile can work with Win95 ?
|
|
|
|
|
Hmm... I can't say I've personally tested it with Windows 95. I also haven't even used 95 in a long time.
What kind of problems are you experiencing?
Adam Clauss
cabadam@tamu.edu
|
|
|
|
|
Yes no problem. I've used it with every 32 bit version of windows except Windows .net server and Windows nt 3.x
|
|
|
|
|
#include <windows.h><br />
::GetPrivateProfileString<br />
::GetPrivateProfileInt<br />
::WritePrivateProfileString<br />
::GetPrivateProfileSection<br />
::GetPrivateProfileSectionNames
Above API functions are not MFC dependent and are able to be directly used in all Win32 applications without any compatible issues. And the ini file path\\name can be referred to any file on your disks.
We may, of course, write some API wrap-class to wrap those API calls and make them look more OOP-ish, but a lot less works are required actually. Just in case you didn't know.
|
|
|
|
|
I had thought that a thread regarding this had occured before... but maybe I'm just losing it
When using these API calls, all your settings (for EVERY program that uses them) is stored in one huge "community" ini file. There is only one section per application, which can make keeping things "orderly" difficult.
And what if you want to move from one machine to the next, and keep settings?
You would have to go dig through the ini file and locate the section pertaining to the app in question.
With this class, the programmer has complete control over the ini file and its location. No clutter, no mess, no other programs getting in the way. If you want to move, no problem, just take the ini file and move the entire thing. No need to search through it for the section you want.
And if the MFC dependency is an issue, there is also a non-MFC dependent version of this class available. Email me (cabadam@tamu.edu) if interested.
Hope this helps!
Adam Clauss
cabadam@tamu.edu
|
|
|
|
|
*Notices the 'next' button*
*Mental note to self, do not attempt to answer questions right after you wake up...*
Adam Clauss
cabadam@tamu.edu
|
|
|
|
|
When using these API calls, all your settings (for EVERY program that uses them) is stored in one huge "community" ini file. There is only one section per application, which can make keeping things "orderly" difficult.
That is untrue.
Using the APIs I listed in original reply will store information in a separate INI file, path and name of the INI can be any valid file name, and it does not require information to be stored in one section block...
As was implied by "private profile", the entire INI file is private and only belongs to your application, thus you may store information in it in anyway you want. And, might be important to many developers, none of those methods require MFC.
If you would like to see the detailed implementation please email me, and I will send you a copy of my INI file wrapping class, I've been using it for long time with no problem encountered.
|
|
|
|
|
I do have a verson of my class that does not use MFC, uses the STL instead (see my post below).
It has no dependencies even on the Win32 API, making it portable and useable on whatever OS you want.
Adam Clauss
cabadam@tamu.edu
|
|
|
|
|
Ah, I missed that, sorry.
|
|
|
|
|
Hehe, its ok.
I suppose mostly whether you use a clas like mine or the Win32 API is just a personal preference. If you only develop on Win32 (which is true in my case), it really doesn't matter much which one you use. Either will get the job done.
When I originally wrote this class, I wrote it more of as an excercise for myself. I was not at all familiar with the STL yet, only MFC. After writing it, I realized it was actually a fairly useful class and decided to post it here.
Adam Clauss
cabadam@tamu.edu
|
|
|
|
|