Jpp  17.3.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JTemplate.cc File Reference

Example program to test JLANG::JTemplate class. More...

#include <iostream>
#include <string>
#include <istream>
#include <ostream>
#include "JLang/JTemplate.hh"
#include "JLang/JTypeList.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Example program to test JLANG::JTemplate class.

Author
mdejong

Definition in file JTemplate.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 44 of file JTemplate.cc.

45 {
46  using namespace std;
47 
48  int debug;
49 
50  try {
51 
52  JParser<> zap("Example program to test object referencing.");
53 
54  zap['d'] = make_field(debug) = 3;
55 
56  zap(argc, argv);
57  }
58  catch(const exception &error) {
59  FATAL(error.what() << endl);
60  }
61 
62  using namespace JPP;
63 
64 
65  {
66  JTemplate<string> object;
67 
68  object = string("aap");
69 
70  object.set(string("noot")); // exact match
71  object.set("mies"); // implicit cast through std::string
72 
73  object.get<string>() += " says "; // exact match
74  //object.get<int>(); // gives compiler error
75 
76  object->append("\"hello world\""); // smart pointer
77 
78  cout << object << endl;
79  }
80 
81  {
82  class JTemplate_t :
83  public JTemplate<JTYPELIST<std::string, float, int>::typelist>
84  {};
85 
86  JTemplate_t object;
87 
88  object.get<string>() = "abc"; // exact match
89  object.get<int>() = -1; // exact match
90  object.get<float>() = -0.99; // exact match
91 
92  //object.set("hello world"); // gives compiler error
93  object.set(string("aap noot mies")); // exact match
94  object.set<true>("hello world"); // allow cast
95  object.set(777); // exact match
96  object.set(123.456f); // exact match
97  //object.set(123.456); // gives compiler error (argument is double)
98 
99  cout << object << endl;
100  }
101 
102  {
103  JTemplate<JTYPELIST<__C__, __B__, __A__>::typelist> object;
104 
105  object.get<__A__>() = "a"; // exact match
106  object.get<__B__>() = "b"; // exact match
107  object.get<__C__>() = "c"; // exact match
108 
109  cout << object.get<__C__>() // exact match
110  << " == "
111  << object.get<__A__, true>() // first match
112  << endl;
113  }
114 }
Utility class to parse command line options.
Definition: JParser.hh:1517
o $QUALITY_ROOT d $DEBUG!CHECK_EXIT_CODE JPlot1D f
Definition: JDataQuality.sh:76
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1993
then awk string
#define FATAL(A)
Definition: JMessage.hh:67
int debug
debug level