File: parser_test.ref

package info (click to toggle)
libitpp 4.0.4-2
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 7,520 kB
  • ctags: 6,341
  • sloc: cpp: 51,608; sh: 9,248; makefile: 636; fortran: 8
file content (86 lines) | stat: -rw-r--r-- 2,218 bytes parent folder | download | duplicates (8)
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
Use the Parser class on a parameter file:
a  = 4
Parsing double: b = 2.35
Parsing double: b = 2.36
Parsing double: b = 2.37
c  = Hello World
d  = [1 2 3 4 3 2 -1]
e  = [1.2 2 3.33 4.01 3.2 2 -1.2]
f  = [1 2 3 4 3 2 -1]
g  = [0 1 0 0 1]
h  = [[1 2 3]
 [4 5 6]]
i  = [[1 2]
 [-3 4.2]]
j  = [[1 -2 -3]
 [4 -5 6]]
k  = [[0 1 0 1]
 [1 0 1 0]
 [0 0 0 0]
 [1 1 1 1]]
l  = false
m  = true
n  = Hello World
------------------------------------------------------------
Use the Parser class on the command line input:
Example: > ./parser_test.run "a=3; b=-1.2; d=[0 1 2 45];"

Use the following code:
    p.init(argc,argv);
    a = p.get_int("a");    cout << "a = " << a << endl;
    b = p.get_double("b"); cout << "b = " << b << endl;
    d = p.get_ivec("d");   cout << "d = " << d << endl;
------------------------------------------------------------
Use the Parser class on a char pointer (usually the command line input):
Parsing int   : a = 345
Parsing double: b = 1.001
Parsing string: c = Hello Bird
Parsing ivec  : d = [1 2 3 -1 -2 -3]
------------------------------------------------------------
Use the Parser class on a parameter file and a char pointer:
a = 4
Parsing double: b = 2.35
b = 2.35
c = Hello World
d = [1 2 3 4 3 2 -1]
------------------------------------------------------------
Use the Parser class on an Array of strings:
Parsing int   : a = -11
Parsing double: b = 3.14
Parsing string: c = Hello Nerd
Parsing ivec  : d = [0 1 2 0 3 4 7]
------------------------------------------------------------
Use the Parser::get() method on a parameter file:
a = 4;
b = 2.35
b = 2.36
b = 2.37
c = 'Hello World';
d = [1 2 3 4 3 2 -1];
e = [1.2 2 3.33 4.01 3.2 2 -1.2];
f = [1 2 3 4 3 2 -1];
g = [0 1 0 0 1];
h = [[1 2 3]
 [4 5 6]];
i = [[1 2]
 [-3 4.2]];
j = [[1 -2 -3]
 [4 -5 6]];
k = [[0 1 0 1]
 [1 0 1 0]
 [0 0 0 0]
 [1 1 1 1]];
l = false;
m = true;
n = 'Hello World';
o = {{[1+2i 3+4i] [5+6i]} {[7+0i 8+0i 9+0i]}}
q = {{[1+0i] [2+0i 3+0i] [4+0i 5+0i 6+0i]}};
r = true;
s = 7;
t = 3.14;
u = 'test string';
------------------------------------------------------------
Check if variables exist in the Parser:
p.exist("a") = true
p.exist("aa") = false
------------------------------------------------------------