67 {
68
69 if ( argc<2 ) return -1;
70
71 std::ifstream
file( argv[1] );
72
73 std::vector<std::vector<std::string> > block(1,std::vector<std::string>() );
74
76
78
79 std::vector<int> position(1, 0);
80
81 int iblock = 0;
82
83 while( getline(
file, line ) && !
file.fail() ) {
84
85 if (
line.find(
"action")!=std::string::npos ) {
86 if (
line.find(
"/action")==std::string::npos ) {
89 size_t pos =
tmp.find(
"\"");
90 std::string
p =
tmp.substr( pos+1,
tmp.size()-pos-1 );
92 if (pos!=std::string::npos)
p.resize( pos );
93
94
95
96
97 if ( iblock==0 ) {
98 iblock++;
99 block.push_back(std::vector<std::string>());
100 position.push_back( 0 );
101 }
102 position[iblock] = std::atoi(
p.c_str() );
103 }
104 }
105
106 block[iblock].push_back(line);
107
108
109 if (
line.find(
"/action")!=std::string::npos ) {
111 iblock++;
112 block.push_back(std::vector<std::string>());
113 position.push_back( 0 );
114 }
115
116 }
117
118
119
120
121 int maxblock = 0;
122
123 for (
size_t i=0 ;
i<block.size() ;
i++ ) {
124 if (
comparitor(block[i]) && position[i]>position[maxblock] ) maxblock =
i;
125 }
126
127 int lastblock = 0;
128
129 for (
size_t i=0 ;
i<block.size() ;
i++ )
if ( position[i]>0 ) lastblock =
i;
130
131
132
133 for (
size_t i=0 ;
i<=lastblock ;
i++ ) {
134 if ( !
comparitor( block[i] ) ) std::cout << block[
i] << std::endl;
135 }
136
137 int nblock = position[maxblock]+1;
138
139
140
141
142
143
144
145 for (
size_t i=lastblock+1 ;
i<block.size() ;
i++ ) std::cout << block[i] << std::endl;
146
147
148 return 0;
149}
bool comparitor(std::vector< std::string > &b)