aboutsummaryrefslogtreecommitdiffstats
path: root/util/string/printf.cpp
blob: a8a2e71c9dea1beed6a7608597efcdf9da9f85bf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include "printf.h"

#include <util/stream/printf.h>
#include <util/stream/str.h> 

int vsprintf(TString& s, const char* c, va_list params) {
    TStringOutput so(s.remove());

    return Printf(so, c, params);
}

int sprintf(TString& s, const char* c, ...) {
    va_list params;
    va_start(params, c);
    const int k = vsprintf(s, c, params);
    va_end(params);
    return k;
}

TString Sprintf(const char* c, ...) {
    TString s;
    va_list params;
    va_start(params, c);
    vsprintf(s, c, params);
    va_end(params);
    return s;
}

int fcat(TString& s, const char* c, ...) {
    TStringOutput so(s);

    va_list params;
    va_start(params, c);
    const size_t ret = Printf(so, c, params);
    va_end(params);

    return ret;
}