2121 */
2222
2323
24- #ifndef __STR_FORMAT_H__
25- #define __STR_FORMAT_H__
24+ #pragma once
25+ #ifndef CODA_OSS_str_Format_h_INCLUDED_
26+ #define CODA_OSS_str_Format_h_INCLUDED_
2627
2728#include < stdarg.h>
29+ #include < stdint.h>
30+ #include < stddef.h>
31+
2832#include < string>
2933
3034#include " config/Exports.h"
3135
3236namespace str
3337{
34-
35- /* !
36- * \param format The format
37- * \param ... Any printf like thing
38- */
39- CODA_OSS_API std::string format (const char * format, ...);
40-
4138struct CODA_OSS_API Format final
4239{
4340 Format (const char * format, ...);
@@ -47,14 +44,95 @@ struct CODA_OSS_API Format final
4744 return mString ;
4845 }
4946
50- operator std::string& () noexcept
51- {
52- return mString ;
53- }
54-
55- protected:
47+ private:
5648 std::string mString ;
5749};
5850
51+ /* !
52+ * \param format The format
53+ * \param ... Any printf like thing
54+ */
55+ // CODA_OSS_API std::string format(const char* format, ...);
56+
57+ inline std::string format (const char * format)
58+ {
59+ return Format (format);
60+ }
61+
62+ inline std::string format (const char * format, const char * pStr)
63+ {
64+ return Format (format, pStr);
65+ }
66+ inline std::string format (const char * format, const std::string& s)
67+ {
68+ return Format (format, s.c_str ());
69+ }
70+ inline std::string format (const char * format, int i)
71+ {
72+ return Format (format, i);
73+ }
74+ inline std::string format (const char * format, uint32_t i)
75+ {
76+ return Format (format, i);
77+ }
78+ inline std::string format (const char * format, ptrdiff_t l)
79+ {
80+ return Format (format, l);
81+ }
82+ inline std::string format (const char * format, size_t ul)
83+ {
84+ return Format (format, ul);
85+ }
86+ inline std::string format (const char * format, float f)
87+ {
88+ return Format (format, f);
89+ }
90+
91+ inline std::string format (const char * format, char ch, const char * pStr)
92+ {
93+ return Format (format, ch, pStr);
94+ }
95+ inline std::string format (const char * format, char ch, const std::string& s)
96+ {
97+ return Format (format, ch, s.c_str ());
98+ }
99+ inline std::string format (const char * format, const std::string& s1, const std::string& s2)
100+ {
101+ return Format (format, s1.c_str (), s2.c_str ());
102+ }
103+ inline std::string format (const char * format, const std::string& s, size_t ul)
104+ {
105+ return Format (format, s.c_str (), ul);
106+ }
107+ inline std::string format (const char * format, char ch1, char ch2)
108+ {
109+ return Format (format, ch1, ch2);
110+ }
111+ inline std::string format (const char * format, size_t ul1, size_t ul2)
112+ {
113+ return Format (format, ul1, ul2);
114+ }
115+ inline std::string format (const char * format, int i, const std::string& s)
116+ {
117+ return Format (format, i, s.c_str ());
118+ }
119+ inline std::string format (const char * format, int i, const char * pStr)
120+ {
121+ return Format (format, i, pStr);
122+ }
123+
124+ inline std::string format (const char * format, char ch1, char ch2, const std::string& s)
125+ {
126+ return Format (format, ch1, ch2, s.c_str ());
127+ }
128+ inline std::string format (const char * format, int i1, int i2, unsigned long ul)
129+ {
130+ return Format (format, i1, i2, ul);
131+ }
132+ inline std::string format (const char * format, const std::string& s1, const std::string& s2, uint32_t ui)
133+ {
134+ return Format (format, s1.c_str (), s2.c_str (), ui);
135+ }
136+
59137}
60- #endif
138+ #endif // CODA_OSS_str_Format_h_INCLUDED_
0 commit comments