Implement left alignment.

This commit is contained in:
Victor Zverovich
2012-12-22 14:05:56 -08:00
parent c5f4ecb25a
commit be6e54de36
3 changed files with 63 additions and 42 deletions
+8 -1
View File
@@ -123,13 +123,18 @@ class FormatError : public std::runtime_error {
: std::runtime_error(message) {}
};
enum Alignment {
ALIGN_DEFAULT, ALIGN_LEFT, ALIGN_RIGHT, ALIGN_CENTER, ALIGN_NUMERIC
};
struct FormatSpec {
Alignment align;
unsigned flags;
unsigned width;
char type;
char fill;
FormatSpec() : flags(0), width(0), type(0), fill(' ') {}
FormatSpec() : align(ALIGN_DEFAULT), flags(0), width(0), type(0), fill(' ') {}
};
// Formatter provides string formatting functionality similar to Python's
@@ -266,6 +271,8 @@ class Formatter {
void ReportError(const char *s, const std::string &message) const;
char *PrepareFilledBuffer(unsigned size, FormatSpec spec, char sign);
// Formats an integer.
template <typename T>
void FormatInt(T value, FormatSpec spec);