cprintf.hh (2665:a124942bacb8) | cprintf.hh (3874:964682aaad3d) |
---|---|
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; --- 151 unchanged lines hidden (view full) --- 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, args...) \ 164 cp::__csprintf(format, (*(new cp::ArgList), args)) 165#define csprintf(args...) \ 166 __csprintf__(args, cp::ArgListNull()) 167 | 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; --- 151 unchanged lines hidden (view full) --- 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, args...) \ 164 cp::__csprintf(format, (*(new cp::ArgList), args)) 165#define csprintf(args...) \ 166 __csprintf__(args, cp::ArgListNull()) 167 |
168template<class T> 169inline ArgList & 170operator<<(ArgList &list, const T &data) 171{ 172 list.append(data); 173 return list; | |
174} 175 | 168} 169 |
176inline ArgList & 177operator<<(std::ostream &str, ArgList &list) 178{ 179 list.stream = &str; 180 return list; 181} 182 183class ArgListTemp 184{ 185 private: 186 std::string format; 187 ArgList *args; 188 189 public: 190 ArgListTemp(const std::string &f) : format(f) { args = new ArgList; } 191 ~ArgListTemp() { args->dump(format); delete args; } 192 193 operator ArgList *() { return args; } 194}; 195 196#define cformat(format) \ 197 (*((cp::ArgList *)cp::ArgListTemp(format))) 198} 199 | |
200#endif // __CPRINTF_HH__ | 170#endif // __CPRINTF_HH__ |