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

Example program to test JLANG::make_array method. More...

#include <iostream>
#include <iomanip>
#include <vector>
#include "JLang/JVectorize.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::make_array method.

Author
mdejong

Definition in file JVectorize.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 62 of file JVectorize.cc.

63 {
64  using namespace std;
65 
66  int debug;
67 
68  try {
69 
70  JParser<> zap("Example program to test converions of array of objects to array of data members.");
71 
72  zap['d'] = make_field(debug) = 3;
73 
74  zap(argc, argv);
75  }
76  catch(const exception &error) {
77  FATAL(error.what() << endl);
78  }
79 
80 
81  using namespace JPP;
82 
83  vector<__A__> buffer;
84 
85  int numberOfElements = 5;
86 
87  for (int i = 0; i != numberOfElements; ++i) {
88  buffer.push_back(__A__(i));
89  }
90 
91  if (debug >= debug_t) {
92  print(cout, numberOfElements, buffer.data());
93  print(cout, numberOfElements, make_array(buffer.begin(), buffer.end(), &__A__::get).data());
94  print(cout, numberOfElements, make_array(buffer.begin(), buffer.end(), &__A__::i) .data());
95  }
96 
97  {
98  const int* p = make_array(buffer.begin(), buffer.end(), &__A__::get).data();
99 
100  for (int i = 0; i != numberOfElements; ++i, ++p) {
101  ASSERT(buffer[i].get() == *p);
102  }
103  }
104 
105  {
106  const int* p = make_array(buffer.begin(), buffer.end(), &__A__::i).data();
107 
108  for (int i = 0; i != numberOfElements; ++i, ++p) {
109  ASSERT(buffer[i].i == *p);
110  }
111  }
112 
113  return 0;
114 }
Utility class to parse command line options.
Definition: JParser.hh:1500
debug
Definition: JMessage.hh:29
T get(const JHead &header)
Get object from header.
#define ASSERT(A,...)
Assert macro.
Definition: JMessage.hh:90
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
const array_type< JValue_t > & make_array(const JValue_t(&array)[N])
Method to create array of values.
Definition: JVectorize.hh:54
int debug
debug level
Definition: JSirene.cc:68
print
Definition: JConvertDusj.sh:44
#define FATAL(A)
Definition: JMessage.hh:67