Jpp  master_rocky-43-ge265d140c
the software that should make you happy
JCRC.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <string>
3 
4 #include "JLang/JCRC.hh"
5 #include "Jeep/JParser.hh"
6 #include "Jeep/JMessage.hh"
7 
8 /**
9  * User function.
10  *
11  * \param value value
12  */
13 inline void fun(const std::string& value)
14 {
15  using namespace std;
16  using namespace JPP;
17 
18  switch (crc(value)) {
19 
20  case crc("aap"):
21  cout << "aap";
22  break;
23 
24  case crc("noot"):
25  cout << "noot";
26  break;
27 
28  case crc("mies"):
29  cout << "mies";
30  break;
31 
32  default:
33  cout << "default";
34  break;
35  }
36 }
37 
38 
39 /**
40  * \file
41  *
42  * Example program to test CRC evaluation (see JCRC.hh).
43  * \author mdejong
44  */
45 int main(int argc, char **argv)
46 {
47  using namespace std;
48  using namespace JPP;
49 
50  int debug;
51 
52  try {
53 
54  JParser<> zap("Example program to test CRC evaluation.");
55 
56  zap['d'] = make_field(debug) = 0;
57 
58  zap(argc, argv);
59  }
60  catch(const exception &error) {
61  FATAL(error.what() << endl);
62  }
63 
64  for (string str : { "aap", "noot", "mies", "hello" }) {
65 
66  cout << "test \"" << str << "\" -> ";
67 
68  fun(str);
69 
70  cout << endl;
71  }
72 }
void fun(const std::string &value)
User function.
Definition: JCRC.cc:13
int main(int argc, char **argv)
Definition: JCRC.cc:45
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
int debug
debug level
Definition: JSirene.cc:69
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:2142
Utility class to parse command line options.
Definition: JParser.hh:1698
constexpr size_t crc(const char(&buffer)[N])
Get CRC value at compile time.
Definition: JCRC.hh:97
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JSTDTypes.hh:14