Jpp 19.3.0-rc.3
the software that should make you happy
Loading...
Searching...
No Matches
JCRC.cc File Reference

Example program to test CRC evaluation (see JCRC.hh). More...

#include <iostream>
#include <string>
#include "JLang/JCRC.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

void fun (const std::string &value)
 User function.
 
int main (int argc, char **argv)
 

Detailed Description

Example program to test CRC evaluation (see JCRC.hh).

Author
mdejong

Definition in file JCRC.cc.

Function Documentation

◆ fun()

void fun ( const std::string & value)
inline

User function.

Parameters
valuevalue

Definition at line 13 of file JCRC.cc.

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}
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).

◆ main()

int main ( int argc,
char ** argv )

Definition at line 45 of file JCRC.cc.

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
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
#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