-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.cpp
More file actions
143 lines (137 loc) · 3.85 KB
/
test.cpp
File metadata and controls
143 lines (137 loc) · 3.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
/*
double* getModelParam(string line, string val);
double getData(string aline, double *d);
int* getNum(string pline, string val);
*/
int main(int argc, char *argv[])
{
double w = 5.0;
double *x = NULL;
double *y = x;
double *z = new double(2342.0230235);
delete z; z = NULL;
bool tw = &w == NULL;
bool ty = y == NULL;
bool tx = x == NULL;
bool tz = z == NULL;
bool c = z == x;
cout << w << " " << x << " " << y << " " << z << endl;
cout << &w << " " << &x << " " << &y << " " << &z << " " << endl;
cout << tw << " " << tx << " " << ty << " " << tz << " " << c << endl;
cout << endl;
y = new double(42.0);
ty = y == NULL;
tx = x == NULL;
tz = z == NULL;
c = z == x;
cout << w << " " << x << " " << y << " " << z << endl;
cout << &w << " " << &x << " " << &y << " " << &z << " " << endl;
cout << tw << " " << tx << " " << ty << " " << tz << " " << c << endl;
cout << endl;
*y = NULL;
x = new double(NULL);
z = y;
ty = y == NULL;
tx = x == NULL;
tz = z == NULL;
c = z == x;
cout << w << " " << x << " " << y << " " << z << endl;
cout << w << " " << *x << " " << *y << " " << *z << endl;
cout << &w << " " << &x << " " << &y << " " << &z << " " << endl;
cout << tw << " " << tx << " " << ty << " " << tz << " " << c << endl;
cout << endl << endl << endl;
}
/*
string s = "A 23.255 AL 42.2135 AU NULL";
int pos1 = s.find("A ")+2;
int pos2 = s.find(" ",pos1);
int pos3 = s.find("AL ")+3;
int pos4 = s.find(" ",pos3);
int pos5 = s.find("AU ");
//cout << pos1 << " " << pos2 << " " << pos3 << " " << pos4 << " " << pos5 << endl;
//cout << s << endl;
//cout << "a " << s.substr(pos1, pos2-pos1) << " al " << s.substr(pos3, pos4-pos3) <<
// " au " << s.substr(pos5+3) << endl;
//cout << getModelParam(s, "AU ") << endl;
double *d;
d = new double[3];
string aline = "0.251235214241 231.215234124 743.2342346134";
getData(aline, d);
//cout << aline << endl;
//cout << d[0] << " " << d[1] << " " << d[2] << endl;
string pline = "NUMCURVES NULL NUMPARAMS 36";
cout << "hel1" << endl;
int *x = getNum(pline, "NUMCURVES ");
cout << "hel2" << endl;
int *y = getNum(pline, "NUMPARAMS ");
cout << "done extracting" << endl;
cout.flush();
cout << "x = " ;
cout << x << endl;
cout << "y = " ;
cout << y << endl;
return 0;
}
int* getNum(string line, string val)
{
int p1, p2;
stringstream tmp;
int *i;
p1 = line.find(val) + val.size();
p2 = line.find(" ", p1);
cout << "substr " << line.substr(p1, p2-p1) << endl;
tmp << line.substr(p1, p2-p1);
cout << "substr " << line.substr(p1, p2-p1) << endl;
if(tmp.str().compare("NULL") == 0)
{
cout << "substr " << line.substr(p1, p2-p1) << endl;
i = NULL;
cout << "substr " << i << endl;
}
else
{
cout << "substr " << line.substr(p1, p2-p1) << endl;
tmp >> *i;
cout << "substr " << line.substr(p1, p2-p1) << endl;
}
return i;
}
double* getModelParam(string line, string val)
{
int p1, p2;
stringstream tmp;
double *d;
p1 = line.find(val) + val.size();
p2 = line.find(" ", p1);
tmp << line.substr(p1, p2-p1);
if(tmp.str().compare("NULL") == 0)
d = NULL;
else
tmp >> *d;
return d;
}
double getData(string line, double *d)
{
int p1, p2;
stringstream tmp;
p1 = line.find(" ");
p2 = line.find(" ", p1+1);
tmp << line.substr(0, p1);
tmp >> d[0];
tmp.str(std::string());
tmp.clear();
tmp << line.substr(p1+1, p2-p1);
tmp >> d[1];
tmp.str(std::string());
tmp.clear();
tmp << line.substr(p2+1);
tmp >> d[2];
return *d;
}
*/