summaryrefslogtreecommitdiff
path: root/src/io/cxxstdio.hpp
diff options
context:
space:
mode:
authorBen Longbons <b.r.longbons@gmail.com>2014-03-15 19:34:59 -0700
committerBen Longbons <b.r.longbons@gmail.com>2014-03-16 18:58:48 -0700
commitc812c92d1a1835f0bda783e709481188c8d92225 (patch)
treeb401ede48a088ad1aaed88fe3b997cd26ff7ae08 /src/io/cxxstdio.hpp
parentde9ee1b9754af9d954487121947352f32d7ebb7e (diff)
downloadtmwa-c812c92d1a1835f0bda783e709481188c8d92225.tar.gz
tmwa-c812c92d1a1835f0bda783e709481188c8d92225.tar.bz2
tmwa-c812c92d1a1835f0bda783e709481188c8d92225.tar.xz
tmwa-c812c92d1a1835f0bda783e709481188c8d92225.zip
Clean up header organization
Diffstat (limited to 'src/io/cxxstdio.hpp')
-rw-r--r--src/io/cxxstdio.hpp61
1 files changed, 29 insertions, 32 deletions
diff --git a/src/io/cxxstdio.hpp b/src/io/cxxstdio.hpp
index 753a1fc..0324ebc 100644
--- a/src/io/cxxstdio.hpp
+++ b/src/io/cxxstdio.hpp
@@ -24,9 +24,10 @@
# include <cstdarg>
# include <cstdio>
-// TODO get rid of these header order violations
-# include "../common/const_array.hpp"
-# include "../common/utils2.hpp"
+# include "../compat/cast.hpp"
+
+# include "../generic/const_array.hpp"
+# include "../generic/enum.hpp"
# include "fwd.hpp"
@@ -213,27 +214,25 @@ namespace cxxstdio
}
};
-# define XPRINTF(out, fmt, ...) \
- (/*[&]() -> int*/ \
- { \
- struct format_impl \
- { \
- constexpr static \
- const char *print_format() { return fmt; } \
- }; \
- /*return*/ cxxstdio::PrintFormatter<format_impl>::print(out, ## __VA_ARGS__); \
- }/*()*/)
+# define XPRINTF(out, fmt, ...) \
+ ({ \
+ struct format_impl \
+ { \
+ constexpr static \
+ const char *print_format() { return fmt; } \
+ }; \
+ cxxstdio::PrintFormatter<format_impl>::print(out, ## __VA_ARGS__); \
+ })
-# define XSCANF(out, fmt, ...) \
- (/*[&]() -> int*/ \
- { \
- struct format_impl \
- { \
- constexpr static \
- const char *scan_format() { return fmt; } \
- }; \
- /*return*/ cxxstdio::ScanFormatter<format_impl>::scan(out, ## __VA_ARGS__); \
- }/*()*/)
+# define XSCANF(out, fmt, ...) \
+ ({ \
+ struct format_impl \
+ { \
+ constexpr static \
+ const char *scan_format() { return fmt; } \
+ }; \
+ cxxstdio::ScanFormatter<format_impl>::scan(out, ## __VA_ARGS__); \
+ })
# define FPRINTF(file, fmt, ...) XPRINTF(/*no_cast<FILE *>*/(file), fmt, ## __VA_ARGS__)
# define FSCANF(file, fmt, ...) XSCANF(no_cast<FILE *>(file), fmt, ## __VA_ARGS__)
@@ -241,23 +240,21 @@ namespace cxxstdio
# define SPRINTF(str, fmt, ...) XPRINTF(base_cast<AString&>(str), fmt, ## __VA_ARGS__)
# define SNPRINTF(str, n, fmt, ...) XPRINTF(base_cast<VString<n-1>&>(str), fmt, ## __VA_ARGS__)
# define SCANF(fmt, ...) FSCANF(stdin, fmt, ## __VA_ARGS__)
-# define SSCANF(str, fmt, ...) XSCANF(/*ZString or compatible*/str, fmt, ## __VA_ARGS__)
+# define SSCANF(str, fmt, ...) XSCANF(maybe_cast<ZString>(str), fmt, ## __VA_ARGS__)
# define STRPRINTF(fmt, ...) \
- (/*[&]() -> AString*/ \
- { \
+ ({ \
AString _out_impl; \
SPRINTF(_out_impl, fmt, ## __VA_ARGS__); \
- /*return*/ _out_impl; \
- }/*()*/)
+ _out_impl; \
+ })
# define STRNPRINTF(n, fmt, ...) \
- (/*[&]() -> VString<n - 1>*/ \
- { \
+ ({ \
VString<n - 1> _out_impl; \
SNPRINTF(_out_impl, n, fmt, ## __VA_ARGS__); \
- /*return*/ _out_impl; \
- }/*()*/)
+ _out_impl; \
+ })
} // namespace cxxstdio