Boost logo

Boost Users :

Subject: [Boost-users] Boilerplate generated code
From: Ryan McConnehey (mccorywork_at_[hidden])
Date: 2010-09-03 20:46:08


I have a class that mostly remains the same except for the variables and
functions to retrieve the variables. I've looked at boost preprocessor
and it seems more designed to create classes that have a fixed number of
variables but different defaults. Could any of the boost libraries turn
the included class into boilerplate code that allows an arbitrary number
of variables? The example below only has three variables but I could
have used any number.

Ryan

//Minimal detail. Not complete class
struct Arguments {
  Arguments(void) {
    xxx = false;
    yyy = 3;
    zzz = 4530;
  }

  bool operator== (Arugments const& rhs) {
    return (
      (xxx == rhs.xxx) &&
      (yyy == rhs.yyy) &&
      (zzz == rhs.zzz));
  }

  bool getXXX(void) const { return xxx; }
  int getYYY(void) const { return yyy; }
  long getZZZ(void) const { return zzz; }

  bool xxx;
  int yyy;
  long zzz;
};

//Would like to be able to call it instead something like this
Create(
  Arguments, //Class name
  ((bool, xxx, getXXX, false),
   (int, yyy, getYYY, 3),
   (long, zzz, getZZZ, 4530)));


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net