Defines
Params.h File Reference
#include <boost/lexical_cast.hpp>
#include <map>
#include <string>
#include <bwi_tools/json/json.h>
Include dependency graph for Params.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define PARAM_DECL(type, var, key, val)   type var;
#define PARAM_INIT(type, var, key, val)   var = val;
#define PARAM_MAP(type, var, key, val)   stringMap[#var] = boost::lexical_cast<std::string>(var);
#define PARAM_OUT(type, var, key, val)   os << #var << ": " << p.var << " ";
#define PARAM_SET(type, var, key, val)   setFromJson(opts,#key,var);
#define Params_STRUCT(params)
#define SET_FROM_JSON(type, jsonCmd)
#define SET_FROM_JSON_ENUM(ENUM)

Define Documentation

#define PARAM_DECL (   type,
  var,
  key,
  val 
)    type var;

Definition at line 31 of file Params.h.

#define PARAM_INIT (   type,
  var,
  key,
  val 
)    var = val;

Definition at line 32 of file Params.h.

#define PARAM_MAP (   type,
  var,
  key,
  val 
)    stringMap[#var] = boost::lexical_cast<std::string>(var);

Definition at line 35 of file Params.h.

#define PARAM_OUT (   type,
  var,
  key,
  val 
)    os << #var << ": " << p.var << " ";

Definition at line 34 of file Params.h.

#define PARAM_SET (   type,
  var,
  key,
  val 
)    setFromJson(opts,#key,var);

Definition at line 33 of file Params.h.

#define Params_STRUCT (   params)
Value:
struct Params {\
    params(PARAM_DECL) \
    \
    Params() { \
      params(PARAM_INIT) \
    } \
    \
    void fromJson(const Json::Value &opts) { \
      (void)opts; /* to remove any compiler warnings if params is empty */ \
      params(PARAM_SET) \
    } \
    std::map<std::string, std::string> asMap() { \
      std::map<std::string, std::string> stringMap; \
      params(PARAM_MAP) \
      return stringMap; \
    } \
    friend std::ostream& operator<<(std::ostream &os, const Params &p) { \
      params(PARAM_OUT) \
      return os; \
    } \
  };

Definition at line 37 of file Params.h.

#define SET_FROM_JSON (   type,
  jsonCmd 
)
Value:
inline void setFromJson(const Json::Value &opts, const char *key, type &val) { \
    const Json::Value &opt = opts[key]; \
    if (!opt.isNull()) \
      val = opt.jsonCmd(); \
  }

Definition at line 10 of file Params.h.

#define SET_FROM_JSON_ENUM (   ENUM)
Value:
inline void setFromJson(const Json::Value &opts, const char *key, ENUM::type &val) { \
    const Json::Value &opt = opts[key]; \
    if (!opt.isNull()) \
      val = ENUM::fromName(opt.asCString()); \
  }

Definition at line 17 of file Params.h.



bwi_tools
Author(s): Piyush Khandelwal
autogenerated on Thu Jun 6 2019 17:57:26