Scanframe Modular Application 0.1.0
Loading...
Searching...
No Matches
Formatter.h
Go to the documentation of this file.
1#pragma once
2#include <misc/gen/string.h>
3#include <misc/global.h>
4#include <string>
5#include <vector>
6
7namespace sf
8{
9
19{
20 public:
25 explicit Formatter(const std::string& fmt);
26
31 Formatter(const Formatter& other);
32
36 Formatter(Formatter&& other) noexcept;
37
42
46 Formatter& operator=(Formatter&& other) noexcept;
47
54 Formatter& arg(const std::string& arg, int width = 0);
55
62 Formatter& arg(const char* arg, int width = 0);
63
70 Formatter& arg(int arg, int width = 0);
71
78 Formatter& arg(unsigned int arg, int width = 0);
79
86 Formatter& arg(long arg, int width = 0);
87
94 Formatter& arg(unsigned long arg, int width = 0);
95
102 Formatter& arg(long long arg, int width = 0);
103
110 Formatter& arg(unsigned long long arg, int width = 0);
111
119 Formatter& arg(float arg, int width = 0, int precision = std::numeric_limits<int>::max());
120
128 Formatter& arg(double arg, int width = 0, int precision = std::numeric_limits<int>::max());
129
133 std::string str() const;
134
138 operator std::string() const;
139
140 private:
147 void storeArg(const std::string& arg, int width, bool right_align);
148
152 std::vector<std::pair<std::string, int>> _strings;
156 std::vector<std::string> _args;
157};
158
159}// namespace sf
160
161
162// Include all inlined functions and template implementations.
163#include <misc/gen/Formatter.hpp>
Class implements a formater like QString from Qt.
Definition Formatter.h:19
Formatter & arg(const char *arg, int width=0)
Argument to string formatter.
Formatter & operator=(const Formatter &other)
Assignment operator.
Formatter(const Formatter &other)
Copy constructor.
Formatter & arg(long long arg, int width=0)
Argument to string formatter.
Formatter(Formatter &&other) noexcept
Move constructor.
Formatter & arg(unsigned int arg, int width=0)
Argument to string formatter.
Formatter & arg(long arg, int width=0)
Argument to string formatter.
Formatter & arg(unsigned long long arg, int width=0)
Argument to string formatter.
Formatter & operator=(Formatter &&other) noexcept
Move assignment operator.
Formatter & arg(int arg, int width=0)
Argument to string formatter.
Formatter & arg(double arg, int width=0, int precision=std::numeric_limits< int >::max())
Argument to string formatter.
Formatter & arg(float arg, int width=0, int precision=std::numeric_limits< int >::max())
Argument to string formatter.
Formatter & arg(const std::string &arg, int width=0)
Argument to string formatter.
std::string str() const
Gets the assembled std::string class.
Formatter & arg(unsigned long arg, int width=0)
Argument to string formatter.
Formatter(const std::string &fmt)
Constructor takes a const reference to a std::string.
#define _MISC_CLASS
Definition misc/global.h:40
Definition Application.h:10