private:
bool getvar(const cstring &,const cstring &,cstring &);
bool setvar(const cstring &,const cstring &,const cstring &,const int itype = 1);
int searchline(const cstring &,const cstring &);
private:
// vector filecontainer;
carray filecontainer;
bool bfileexsit;
cstdiofile stffile;
cstring strinifilename;
#endif
int iline = searchline(strsection,strvarname);
if(iline > 0)
return false;
}bool cinifile::getvarstr(const cstring & strsection,const cstring & strvarname,cstring &strreturnvalue)
bool cinifile::getvarint(const cstring & strsection,const cstring & strvarname,int & ivalue)
return true;
}bool cinifile::setvar(const cstring & strsection,const cstring & strvarname,const cstring & strvar,const int itype)
int i = 0;
int ifilelines = filecontainer.getsize();
//for(pinterator;pinterator != filecontainer.end();++pinterator)
//if(strsectionlist.find("[",0)>=0)//在原來檔案的section中,沒有相應的變數需要新增而且,這種情況下,下邊還有別的section
//*/
strparam = strvarname + "=" + strvar;
filecontainer.setat(i-1,strparam);
return true;
}if(i == ifilelines && itype == 0)}}
}if(itype == 0)
return true;
}bool cinifile::setvarstr(const cstring & strsection,const cstring & strvarname,const cstring & strvalue,const int itype)
bool cinifile::setvarint(const cstring & strsection,const cstring & strvarname,const int & ivalue,const int itype)
int cinifile::searchline(const cstring & strsection,const cstring & strvarname)
if(strsectionlist.find("[",0) >= 0)//另外乙個段落出現,尋找失敗}}
}}return -1;
}
ini配置檔案讀取類 C
using system using system.io using system.runtime.interopservices using system.text using system.collections using system.collections.specialized publ...
python讀取ini配置的類封裝
coding utf 8 import configparser import os class inicfg def init self self.conf configparser.configparser self.cfgpath def checksection self,section t...
C 讀取Ini配置檔案類
配置檔案 為filename.ini 的檔案 第一行必須為空,不然讀不出值 section1 key value key2 value section2 key value key2 value 如下 using system using system.runtime.interopservices...