1/* 2 * Copyright (c) 2002-2005 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; --- 122 unchanged lines hidden (view full) --- 131 132// 133// cprintf(format, args, ...) prints to cout 134// (analogous to printf()) 135// 136inline void 137__cprintf(const std::string &format, ArgList &args) 138{ args.dump(format); delete &args; } |
139#define __cprintf__(format, ...) \ 140 cp::__cprintf(format, (*(new cp::ArgList), __VA_ARGS__)) 141#define cprintf(...) \ 142 __cprintf__(__VA_ARGS__, cp::ArgListNull()) |
143 144// 145// ccprintf(stream, format, args, ...) prints to the specified stream 146// (analogous to fprintf()) 147// 148inline void 149__ccprintf(std::ostream &stream, const std::string &format, ArgList &args) 150{ args.dump(stream, format); delete &args; } |
151#define __ccprintf__(stream, format, ...) \ 152 cp::__ccprintf(stream, format, (*(new cp::ArgList), __VA_ARGS__)) 153#define ccprintf(stream, ...) \ 154 __ccprintf__(stream, __VA_ARGS__, cp::ArgListNull()) |
155 156// 157// csprintf(format, args, ...) returns a string 158// (roughly analogous to sprintf()) 159// 160inline std::string 161__csprintf(const std::string &format, ArgList &args) 162{ std::string s = args.dumpToString(format); delete &args; return s; } |
163#define __csprintf__(format, ...) \ 164 cp::__csprintf(format, (*(new cp::ArgList), __VA_ARGS__)) 165#define csprintf(...) \ 166 __csprintf__(__VA_ARGS__, cp::ArgListNull()) |
167 168} 169 170#endif // __CPRINTF_HH__ |