#include <iostream>
#include <opencv2/opencv.hpp>
#include <time.h>
using namespace std;
using namespace cv;
int main()
{
FileStorage fs("test.yml", FileStorage::APPEND);
if(!fs.isOpened())
{
cout << "The file is not properly opened" << endl;
return 1;
}
time_t rawtime;
time(&rawtime);
fs << "logotime" << asctime(localtime(&rawtime));
fs << "class" << "class three";
fs << "chengji" << "[";
for(int i = 0; i < 5; i++)
{
int english;
int math;
int chinise;
cout << "english:";
cin >> english;
cout << "math:";
cin >> math;
cout << "chinise:";
cout << chinise;
fs << "{:" << "english" << english
<< "math" << math
<< "chinise" << chinise
<< "}";
}
fs << "]";
//fs.release();
cout << fs.releaseAndGetString() << endl;
fs.open("test.yml",FileStorage::READ);
FileNode top= fs.root(2);
switch(top.type())
{
case FileNode::NONE:
cout << "None" << endl;
break;
case FileNode::INT:
cout << "int" << endl;
break;
case FileNode::FLOAT:
cout << "float" << endl;
break;
case FileNode::STR:
cout << "str" << endl;
break;
case FileNode::REF:
cout << "ref" << endl;
break;
case FileNode::SEQ:
cout << "seq" << endl;
break;
case FileNode::MAP:
cout << "map" << endl;
break;
case FileNode::FLOW:
cout << "flow" << endl;
break;
case FileNode::USER:
cout << "user" << endl;
break;
case FileNode::EMPTY:
cout << "empty" << endl;
break;
case FileNode::NAMED:
cout << "named" << endl;
break;
default:
cout << "default" << endl;
break;
}
cout << (string)top["logotime"] << endl;
fs.release();
cout << "Hello Wolrd" << endl;
system("pause");
return 0;
}
#include <opencv2/opencv.hpp>
#include <time.h>
using namespace std;
using namespace cv;
int main()
{
FileStorage fs("test.yml", FileStorage::APPEND);
if(!fs.isOpened())
{
cout << "The file is not properly opened" << endl;
return 1;
}
time_t rawtime;
time(&rawtime);
fs << "logotime" << asctime(localtime(&rawtime));
fs << "class" << "class three";
fs << "chengji" << "[";
for(int i = 0; i < 5; i++)
{
int english;
int math;
int chinise;
cout << "english:";
cin >> english;
cout << "math:";
cin >> math;
cout << "chinise:";
cout << chinise;
fs << "{:" << "english" << english
<< "math" << math
<< "chinise" << chinise
<< "}";
}
fs << "]";
//fs.release();
cout << fs.releaseAndGetString() << endl;
fs.open("test.yml",FileStorage::READ);
FileNode top= fs.root(2);
switch(top.type())
{
case FileNode::NONE:
cout << "None" << endl;
break;
case FileNode::INT:
cout << "int" << endl;
break;
case FileNode::FLOAT:
cout << "float" << endl;
break;
case FileNode::STR:
cout << "str" << endl;
break;
case FileNode::REF:
cout << "ref" << endl;
break;
case FileNode::SEQ:
cout << "seq" << endl;
break;
case FileNode::MAP:
cout << "map" << endl;
break;
case FileNode::FLOW:
cout << "flow" << endl;
break;
case FileNode::USER:
cout << "user" << endl;
break;
case FileNode::EMPTY:
cout << "empty" << endl;
break;
case FileNode::NAMED:
cout << "named" << endl;
break;
default:
cout << "default" << endl;
break;
}
cout << (string)top["logotime"] << endl;
fs.release();
cout << "Hello Wolrd" << endl;
system("pause");
return 0;
}