#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
Go to the source code of this file.
|
| template<typename T> |
| std::ostream & | operator<< (std::ostream &s, std::vector< T > &v) |
| void | replace (std::vector< std::string > b, int position, const std::string ®ex, const std::string &pattern) |
| bool | comparitor (std::vector< std::string > &b) |
| int | main (int argc, char **argv) |
◆ comparitor()
| bool comparitor |
( |
std::vector< std::string > & | b | ) |
|
Definition at line 60 of file selectblock.cxx.
60 {
61
62 for (
size_t i=0 ;
i<
b.size() ;
i++ )
if ( b[i].
find(
"TIDArun")!=std::string::npos )
return true;
63 return false;
64}
std::string find(const std::string &s)
return a remapped string
◆ main()
| int main |
( |
int | argc, |
|
|
char ** | argv ) |
Definition at line 67 of file selectblock.cxx.
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
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>());
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>());
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
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}
const Amg::Vector3D & position() const
Method to retrieve the position of the Intersection.
bool comparitor(std::vector< std::string > &b)
◆ operator<<()
template<typename T>
| std::ostream & operator<< |
( |
std::ostream & | s, |
|
|
std::vector< T > & | v ) |
Definition at line 15 of file selectblock.cxx.
15 {
16 for (
size_t i=0 ;
i<
v.size() ;
i++ ) s << v[i] << std::endl;
18}
◆ replace()
| void replace |
( |
std::vector< std::string > | b, |
|
|
int | position, |
|
|
const std::string & | regex, |
|
|
const std::string & | pattern ) |
Definition at line 21 of file selectblock.cxx.
21 {
22 for (
int i=0 ;
i<
b.size() ;
i++ ) {
23
24 size_t p0 =
b[
i].find(
"position=" );
25
27
28 if ( p0!=std::string::npos ) {
29 char nl[128];
30
31 sprintf( nl, b[i].substr( 0, p0 ).c_str() );
32
34 ns+=
"position=\"%02d\">";
35
36 sprintf( nl,
ns.c_str(), position );
37
38
40 }
41 else {
42
43 size_t p =
b[
i].find( regex );
44
45 if ( p!=std::string::npos ) {
47 }
49 }
50
51 if (
newline.find(
"-plots")!=std::string::npos ) {
53 }
54
55 std::cout <<
newline << std::endl;
56 }
57}