📄 testini.cpp
字号:
// TestIni.cpp : Defines the entry point for the console application.
#include "TIniFile.h"
int main(int argc, char* argv[])
{
TIniFile PIni("test.ini");
//------------------test ReadString()------------------------
string strvalue = PIni.ReadString("sect2", "time", "tangyi");
if(strvalue.empty())
{
cout<<"the content is empty"<<endl;
return -1;
}
else
{
cout<<"******************"<<endl
<<"test ReadString()"<<endl
<<" "<<endl;
cout<<"value = "<<strvalue.c_str()<<endl;
}
//-----------------test ReadSection()------------------------
vector<string> key;
int count_key;
count_key = PIni.ReadSection("sect2", key );
if(count_key == 0)
{
cout<<"ReadSection false!"<<endl;
return -1;
}
else
{
cout<<"******************"<<endl
<<"test ReadSection()"<<endl
<<" "<<endl;
for(int i=0; i<count_key; i++)
{
cout<<key[i]<<endl;
}
}
//----------------test ReadSections()----------------------
vector<string> sections;
int count_sect;
count_sect = PIni.ReadSections(sections);
if(count_sect == 0)
{
cout<<"ReadSections false!"<<endl;
return -1;
}
else
{
cout<<"******************"<<endl
<<"test ReadSections()"<<endl
<<" "<<endl;
for(int i=0; i<count_sect; i++)
{
cout<<sections[i]<<endl;
}
}
//--------------test ReadSectionValue()--------------------
vector<string> Values;
PIni.ReadSectionValues("sect2",Values);
if(Values.size() == 0)
{
cout<<"ReadSection false!"<<endl;
return -1;
}
else
{
cout<<"******************"<<endl
<<"test ReadSectionValue()"<<endl
<<" "<<endl;
for(int i=0;i<Values.size();i++)
{
cout<<Values[i]<<endl;
}
}
//---------------test SectionExists()---------------------
cout<<"******************"<<endl
<<"test SectionExists()"<<endl
<<" "<<endl;
bool IsExist = PIni.SectionExists("sect3");
if(IsExist)
{
cout<<"sect3 exsit!"<<endl;
}
else
{
cout<<"sect3 not exsit!"<<endl;
}
//---------------test KeyExists()------------------------
cout<<"******************"<<endl
<<"test KeyExists()"<<endl
<<" "<<endl;
bool hehe = PIni.KeyExists("sect2","day");
if(hehe)
{
cout<<"day exsit!"<<endl;
}
else
{
cout<<"day not exsit!"<<endl;
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -