Jpp  master_rocky
the software that should make you happy
Functions
JProperties-setValue.cc File Reference

Example program to test JPROPERTIES::JProperties class. More...

#include <iostream>
#include <iomanip>
#include "JLang/JCategory.hh"
#include "Jeep/JProperties.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 JPROPERTIES::JProperties class.

Author
mdejong

Definition in file JProperties-setValue.cc.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 67 of file JProperties-setValue.cc.

68 {
69  using namespace std;
70 
71  int debug;
72 
73  try {
74 
75  JParser<> zap;
76 
77  zap['d'] = make_field(debug) = 3;
78 
79  zap(argc, argv);
80  }
81  catch(const exception &error) {
82  FATAL(error.what() << endl);
83  }
84 
85  double a = 1.0;
86  double b = 2.0;
87  double c = 3.0;
88 
89  JABC test(a, b, c);
90 
91  getProperties(test).getValue<double>("a") *= a;
92  getProperties(test).setValue<double>("b", 111.0);
93  getProperties(test).getValue<double>("c") += c;
94 
95  ASSERT(test.a == a*a);
96  ASSERT(test.b == 111.0);
97  ASSERT(test.c == 2*c);
98 
99  return 0;
100 }
#define ASSERT(A,...)
Assert macro.
Definition: JMessage.hh:90
#define FATAL(A)
Definition: JMessage.hh:67
int debug
debug level
Definition: JSirene.cc:69
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:2142
void setValue(const std::string &key, const T &value)
Set value.
const T & getValue(const std::string &key) const
Get value.
Definition: JProperties.hh:976
Utility class to parse command line options.
Definition: JParser.hh:1698
const double a
Definition: JQuadrature.cc:42
JProperties & getProperties(T &object, const JEquationParameters &parameters=JEquationParameters(), const int debug=1)
Get properties of a given object.
Definition: JSTDTypes.hh:14