#include "src/stdio/printf_core/converter.h"
#include "src/stdio/printf_core/core_structs.h"
#include "src/stdio/printf_core/writer.h"
#ifndef LLVM_LIBC_PRINTF_CONV_ATLAS
#include "src/stdio/printf_core/converter_atlas.h"
#else
#include LLVM_LIBC_PRINTF_CONV_ATLAS
#endif
#include <stddef.h>
namespace __llvm_libc {
namespace printf_core {
int convert(Writer *writer, const FormatSection &to_conv) {
if (!to_conv.has_conv)
return writer->write(to_conv.raw_string, to_conv.raw_len);
switch (to_conv.conv_name) {
case '%':
return writer->write("%", 1);
case 'c':
return convert_char(writer, to_conv);
case 's':
return convert_string(writer, to_conv);
case 'd':
case 'i':
case 'u':
return convert_int(writer, to_conv);
case 'o':
return convert_oct(writer, to_conv);
case 'x':
case 'X':
return convert_hex(writer, to_conv);
#ifndef LLVM_LIBC_PRINTF_DISABLE_FLOAT
case 'a':
case 'A':
return convert_float_hex_exp(writer, to_conv);
#endif
#ifndef LLVM_LIBC_PRINTF_DISABLE_WRITE_INT
case 'n':
return convert_write_int(writer, to_conv);
#endif
case 'p':
return convert_pointer(writer, to_conv);
default:
return writer->write(to_conv.raw_string, to_conv.raw_len);
}
return -1;
}
}
}