Garfield++ v2r0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
definp.cpp
Go to the documentation of this file.
1#include <cstdio>
4
5namespace Heed {
6
7int definp_int(const std::string& str) {
8 mfunnamep("int definp_int(const std::string& str)");
9 int i = 0;
10 mcout << "definp_int: starting, read int " << str << "\n";
11 if (str != std::string()) {
12 // search for mark
13 int i_ret = findmark(std::cin, str.c_str());
14 check_econd11(i_ret, != 1, mcerr);
15 }
16 std::cin >> i;
17 Iprintn(mcout, i);
18 check_econd11(std::cin.good(), != 1, mcerr);
19 mcout << "int is read\n";
20 return i;
21}
22
23long set_position(const std::string& word, std::istream& istrm, int s_rewind,
24 int s_req_sep) {
26 "int set_position(const std::string& word, std::istream& istrm, int "
27 "s_rewind, int s_req_sep)");
28 check_econd11a(istrm.good(), != 1,
29 "before seekg, call for variable named " << word << '\n',
30 mcerr);
31 long nbeg, nnext;
32 char prev;
33 if (s_rewind == 1) istrm.seekg(0);
34 if (s_req_sep == 0) {
35 // int iret = findmark(istrm, word.c_str());
36 int iret = findmark_b(istrm, word, word.length(), nbeg, nnext, prev);
37
38 check_econd11a(iret, != 1,
39 "The keyword \"" << word.c_str() << "\" is not found\n",
40 mcerr);
41 check_econd11a(istrm.good(), != 1,
42 "after the call of findmark for variable named " << word
43 << '\n',
44 mcerr);
45 } else {
46 do {
47 int iret = findmark_b(istrm, word, word.length(), nbeg, nnext, prev);
48 check_econd11a(iret, != 1,
49 "The keyword \"" << word.c_str() << "\" is not found\n",
50 mcerr);
51 check_econd11a(istrm.good(), != 1,
52 "after the call of findmark for variable named " << word
53 << '\n',
54 mcerr);
55 if (nbeg == 0) return nbeg; // no need to search for separator
56 if (prev == '\n' || prev == ' ') return nbeg; // good separator
57 } while (1); // infinite loop
58 }
59 check_econd11a(istrm.good(), != 1,
60 "after findmark_b, call for variable named " << word << '\n',
61 mcerr);
62 return nbeg;
63}
64
65}
#define check_econd11(a, signb, stream)
Definition: FunNameStack.h:155
#define check_econd11a(a, signb, add, stream)
Definition: FunNameStack.h:172
#define mfunnamep(string)
Definition: FunNameStack.h:49
Definition: BGMesh.cpp:5
int findmark_b(std::istream &file, T ws, long qws, long &nbeg, long &nnext, char &prev)
Definition: findmark.h:91
int definp_int(const std::string &str)
Definition: definp.cpp:7
int findmark(std::istream &file, const char *s)
Definition: findmark.cpp:19
long set_position(const std::string &word, std::istream &istrm, int s_rewind, int s_req_sep)
Definition: definp.cpp:23
#define mcout
Definition: prstream.h:126
#define mcerr
Definition: prstream.h:128
#define Iprintn(file, name)
Definition: prstream.h:205