#ifndef NEWPRINT_H #define NEWPRINT_H #include <vector> class MudObject; class TeleObject; class NewWorld; class OfflinePlayer; #include "World.h" class defbool { bool b; public: defbool() : b(0) { } defbool(bool b) : b(b) { } operator bool() const { return b; } }; class printarg { public: defbool isstr; const char *str; defbool isnum; long long num; defbool isreal; double real; defbool isdefault; defbool isobj; const MudObject *obj; defbool istele; const TeleObject *tele; defbool isworld;const World<MudObject> *world; printarg() : isdefault(1) { } printarg(const char *str) : isstr(1), str(str) { } printarg(const string &str) : isstr(1), str(str.c_str()) { } printarg(long long i) : isnum(1), num(i) { } printarg(int i) : isnum(1), num(i) { } printarg(unsigned i) : isnum(1), num(i) { } printarg(long i) : isnum(1), num(i) { } printarg(short i) : isnum(1), num(i) { } printarg(char i) : isnum(1), num(i) { } printarg(double r) : isreal(1), real(r) { } printarg(const MudObject *o) : isobj(1), obj(o) { } printarg(const TeleObject *t) : istele(1), tele(t) { } printarg(const TeleObject &t) : istele(1), tele(&t) { } printarg(const OfflinePlayer &p); printarg(const World<MudObject> &nw) : isworld(1), world(&nw) { } printarg(const World<MudObject> *nw) : isworld(1), world(nw) { } friend string printarg_format(const printarg &a, int flags, MudObject *who); }; #define PRINT_ARG(name) const printarg &name=printarg() #define PRINT_ARGS PRINT_ARG(a1), PRINT_ARG(a2), PRINT_ARG(a3), PRINT_ARG(a4), PRINT_ARG(a5), \ PRINT_ARG(a6), PRINT_ARG(a7), PRINT_ARG(a8), PRINT_ARG(a9), PRINT_ARG(a10) #define PRINT_PARM(name) const printarg &name #define PRINT_PARMS PRINT_PARM(a1), PRINT_PARM(a2), PRINT_PARM(a3), PRINT_PARM(a4), PRINT_PARM(a5), \ PRINT_PARM(a6), PRINT_PARM(a7), PRINT_PARM(a8), PRINT_PARM(a9), PRINT_PARM(a10) #define PRINT_PASS_PARMS a1, a2, a3, a4, a5, a6, a7, a8, a9, a10 typedef std::vector<printarg> PARMS; inline PARMS getparms(PRINT_PARMS) { std::vector<printarg> q; q.push_back(a1); q.push_back(a2); q.push_back(a3); q.push_back(a4); q.push_back(a5); q.push_back(a6); q.push_back(a7); q.push_back(a8); q.push_back(a9); q.push_back(a10); return q; } #define GET_PARMS() getparms(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) string formatprint(const char *fmt, const PARMS &); string formatprint(MudObject *who, const char *fmt, const PARMS &); #endif