-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFormatString.h
More file actions
27 lines (20 loc) · 775 Bytes
/
FormatString.h
File metadata and controls
27 lines (20 loc) · 775 Bytes
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
#ifndef BLANG_FORMAT_STRING_H_
#define BLANG_FORMAT_STRING_H_
#include <string>
#include <vector>
#include <stdexcept>
namespace QLang {
struct FormatPlaceholder {
int argIndex; // 0-based positional index
std::string specifier; // text after ':', empty for plain {}
char type = '\0'; // parsed: 'x','X','o','b','e','f', or '\0' (default)
int precision = -1; // parsed: N from .Nf, or -1
};
struct ParsedFormatString {
std::vector<std::string> literals; // N+1 literal segments
std::vector<FormatPlaceholder> placeholders; // N placeholders
std::string error; // non-empty if parse failed
static ParsedFormatString parse( const std::string &fmt );
};
} // namespace QLang
#endif // BLANG_FORMAT_STRING_H_