32 #ifndef STRING_COMPOSE_H
33 #define STRING_COMPOSE_H
61 std::string str()
const;
64 std::ostringstream
os;
94 default:
return -1000;
119 template <
typename T>
124 std::string rep =
os.str();
127 for (specification_map::const_iterator i =
specs.lower_bound(
arg_no),
129 output_list::iterator pos = i->second;
135 os.str(std::string());
148 for (specification_map::const_iterator i =
specs.lower_bound(
arg_no),
150 output_list::iterator pos = i->second;
166 for (specification_map::const_iterator i =
specs.lower_bound(
arg_no),
168 output_list::iterator pos = i->second;
171 output.insert(pos, std::string (cstr));
182 std::string::size_type b = 0, i = 0;
186 while (i < fmt.length()) {
187 if (fmt[i] ==
'%' && i + 1 < fmt.length()) {
188 if (fmt[i + 1] ==
'%') {
189 fmt.replace(i, 2,
"%");
194 output.push_back(fmt.substr(b, i - b));
203 }
while (i + n < fmt.length() &&
is_number(fmt[i + n]));
206 output_list::iterator pos =
output.end();
209 specs.insert(specification_map::value_type(spec_no, pos));
223 output.push_back(fmt.substr(b, i - b));
232 for (output_list::const_iterator i =
output.begin(), end =
output.end();
245 template <
typename T1>
253 template <
typename T1,
typename T2>
255 const T1 &o1,
const T2 &o2)
262 template <
typename T1,
typename T2,
typename T3>
264 const T1 &o1,
const T2 &o2,
const T3 &o3)
271 template <
typename T1,
typename T2,
typename T3,
typename T4>
273 const T1 &o1,
const T2 &o2,
const T3 &o3,
281 template <
typename T1,
typename T2,
typename T3,
typename T4,
typename T5>
283 const T1 &o1,
const T2 &o2,
const T3 &o3,
284 const T4 &o4,
const T5 &o5)
291 template <
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
294 const T1 &o1,
const T2 &o2,
const T3 &o3,
295 const T4 &o4,
const T5 &o5,
const T6 &o6)
302 template <
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
303 typename T6,
typename T7>
305 const T1 &o1,
const T2 &o2,
const T3 &o3,
306 const T4 &o4,
const T5 &o5,
const T6 &o6,
314 template <
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
315 typename T6,
typename T7,
typename T8>
317 const T1 &o1,
const T2 &o2,
const T3 &o3,
318 const T4 &o4,
const T5 &o5,
const T6 &o6,
319 const T7 &o7,
const T8 &o8)
326 template <
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
327 typename T6,
typename T7,
typename T8,
typename T9>
329 const T1 &o1,
const T2 &o2,
const T3 &o3,
330 const T4 &o4,
const T5 &o5,
const T6 &o6,
331 const T7 &o7,
const T8 &o8,
const T9 &o9)
338 template <
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
339 typename T6,
typename T7,
typename T8,
typename T9,
typename T10>
341 const T1 &o1,
const T2 &o2,
const T3 &o3,
342 const T4 &o4,
const T5 &o5,
const T6 &o6,
343 const T7 &o7,
const T8 &o8,
const T9 &o9,
352 template <
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
353 typename T6,
typename T7,
typename T8,
typename T9,
typename T10,
356 const T1 &o1,
const T2 &o2,
const T3 &o3,
357 const T4 &o4,
const T5 &o5,
const T6 &o6,
358 const T7 &o7,
const T8 &o8,
const T9 &o9,
359 const T10 &o10,
const T11 &o11)
367 template <
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
368 typename T6,
typename T7,
typename T8,
typename T9,
typename T10,
369 typename T11,
typename T12>
371 const T1 &o1,
const T2 &o2,
const T3 &o3,
372 const T4 &o4,
const T5 &o5,
const T6 &o6,
373 const T7 &o7,
const T8 &o8,
const T9 &o9,
374 const T10 &o10,
const T11 &o11,
const T12 &o12)
382 template <
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
383 typename T6,
typename T7,
typename T8,
typename T9,
typename T10,
384 typename T11,
typename T12,
typename T13>
386 const T1 &o1,
const T2 &o2,
const T3 &o3,
387 const T4 &o4,
const T5 &o5,
const T6 &o6,
388 const T7 &o7,
const T8 &o8,
const T9 &o9,
389 const T10 &o10,
const T11 &o11,
const T12 &o12,
398 template <
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
399 typename T6,
typename T7,
typename T8,
typename T9,
typename T10,
400 typename T11,
typename T12,
typename T13,
typename T14>
402 const T1 &o1,
const T2 &o2,
const T3 &o3,
403 const T4 &o4,
const T5 &o5,
const T6 &o6,
404 const T7 &o7,
const T8 &o8,
const T9 &o9,
405 const T10 &o10,
const T11 &o11,
const T12 &o12,
406 const T13 &o13,
const T14 &o14)
414 template <
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
415 typename T6,
typename T7,
typename T8,
typename T9,
typename T10,
416 typename T11,
typename T12,
typename T13,
typename T14,
419 const T1 &o1,
const T2 &o2,
const T3 &o3,
420 const T4 &o4,
const T5 &o5,
const T6 &o6,
421 const T7 &o7,
const T8 &o8,
const T9 &o9,
422 const T10 &o10,
const T11 &o11,
const T12 &o12,
423 const T13 &o13,
const T14 &o14,
const T15 &o15)
std::multimap< int, output_list::iterator > specification_map
Composition & arg(const T &obj)
Composition(std::string fmt)
std::list< std::string > output_list
std::string string_compose(const std::string &fmt, const T1 &o1)