int FileIndent::printf(const char* fmt, ...){
va_list args;
char* s = 0;
int ret;
va_start(args, fmt);
ret = vasprintf(&s, fmt, args);
va_end(args);
if(ret >= 0){
ret = writeLine(s);
free(s);
}
return ret;
}
StringIndent::StringIndent(){
oindent = 0;
}
void StringIndent::indentMore(){
oindent++;
}
void StringIndent::indentLess(){
if(--oindent < 0)
oindent = 0;
}
void StringIndent::writeLine(BString line){
int i = oindent;
while(i--)
append("\t");
append(line);
}
void StringIndent::printf(const char* fmt, ...){
va_list args;
char* s = 0;
int ret;
va_start(args, fmt);
ret = vasprintf(&s, fmt, args);
va_end(args);
if(ret >= 0){
writeLine(s);
free(s);
}
}