summaryrefslogtreecommitdiff
path: root/src/io/cxxstdio.hpp
diff options
context:
space:
mode:
authorBen Longbons <b.r.longbons@gmail.com>2014-06-26 18:18:01 -0700
committerBen Longbons <b.r.longbons@gmail.com>2014-06-26 20:45:30 -0700
commitec21450522e3c2124f3510eef5cfd88420483248 (patch)
tree2d3dbd342dccd34bc3545ae3ab7902042abe6815 /src/io/cxxstdio.hpp
parent296629e067563e82b4a08b2a785d1c2f13b5a285 (diff)
downloadtmwa-ec21450522e3c2124f3510eef5cfd88420483248.tar.gz
tmwa-ec21450522e3c2124f3510eef5cfd88420483248.tar.bz2
tmwa-ec21450522e3c2124f3510eef5cfd88420483248.tar.xz
tmwa-ec21450522e3c2124f3510eef5cfd88420483248.zip
Low hanging fruit
Diffstat (limited to 'src/io/cxxstdio.hpp')
-rw-r--r--src/io/cxxstdio.hpp82
1 files changed, 2 insertions, 80 deletions
diff --git a/src/io/cxxstdio.hpp b/src/io/cxxstdio.hpp
index c040d90..fc5829f 100644
--- a/src/io/cxxstdio.hpp
+++ b/src/io/cxxstdio.hpp
@@ -1,6 +1,6 @@
#ifndef TMWA_IO_CXXSTDIO_HPP
#define TMWA_IO_CXXSTDIO_HPP
-// cxxstdio.hpp - pass C++ types through scanf/printf
+// cxxstdio.hpp - pass C++ types through printf
//
// Copyright © 2011-2013 Ben Longbons <b.r.longbons@gmail.com>
//
@@ -31,30 +31,13 @@
namespace cxxstdio
{
- // other implementations of do_vprint or do_vscan are injected by ADL.
+ // other implementations of do_vprint are injected by ADL.
inline __attribute__((format(printf, 2, 0)))
int do_vprint(FILE *out, const char *fmt, va_list ap)
{
return vfprintf(out, fmt, ap);
}
- inline __attribute__((format(scanf, 2, 0)))
- int do_vscan(FILE *in, const char *fmt, va_list ap)
- {
- return vfscanf(in, fmt, ap);
- }
-
-# if 0
- inline __attribute__((format(scanf, 2, 0)))
- int do_vscan(const char *in, const char *fmt, va_list ap)
- {
- return vsscanf(in, fmt, ap);
- }
-# else
- inline
- int do_vscan(const char *, const char *, va_list) = delete;
-# endif
-
template<class T>
inline __attribute__((format(printf, 2, 3)))
int do_print(T&& t, const char *fmt, ...)
@@ -67,19 +50,6 @@ namespace cxxstdio
return rv;
}
- template<class T>
- inline __attribute__((format(scanf, 2, 3)))
- int do_scan(T&& t, const char *fmt, ...)
- {
- int rv;
- va_list ap;
- va_start(ap, fmt);
- rv = do_vscan(std::forward<T>(t), fmt, ap);
- va_end(ap);
- return rv;
- }
-
-
template<class T, typename=typename std::enable_if<!std::is_class<T>::value>::type>
typename remove_enum<T>::type decay_for_printf(T v)
{
@@ -93,16 +63,8 @@ namespace cxxstdio
return std::forward<T>(v);
}
- template<class T, typename = typename std::enable_if<!std::is_enum<T>::value>::type>
- T& convert_for_scanf(T& v)
- {
- return v;
- }
-
inline
const char *convert_for_printf(const char *) = delete;
- inline
- char *convert_for_scanf(char *) = delete;
# if 0
template<class E>
@@ -180,12 +142,6 @@ namespace cxxstdio
}
};
- template<class T, typename = typename std::enable_if<std::is_enum<T>::value>::type>
- EnumConverter<T> convert_for_scanf(T& v)
- {
- return v;
- }
-
template<class Format>
class PrintFormatter
{
@@ -201,21 +157,6 @@ namespace cxxstdio
}
};
- template<class Format>
- class ScanFormatter
- {
- public:
- template<class T, class... A>
- static
- int scan(T&& t, A&&... a)
- {
- constexpr static
- const char *scan_format = Format::scan_format().format_string();
- return do_scan(std::forward<T>(t), scan_format,
- &convert_for_scanf(*a)...);
- }
- };
-
# define XPRINTF(out, fmt, ...) \
({ \
struct format_impl \
@@ -226,29 +167,10 @@ namespace cxxstdio
cxxstdio::PrintFormatter<format_impl>::print(out, ## __VA_ARGS__); \
})
-# if 0
-# define XSCANF(out, fmt, ...) \
- ({ \
- struct format_impl \
- { \
- constexpr static \
- FormatString scan_format() { return fmt; } \
- }; \
- cxxstdio::ScanFormatter<format_impl>::scan(out, ## __VA_ARGS__); \
- })
-# endif
-
# define FPRINTF(file, fmt, ...) XPRINTF(/*no_cast<FILE *>*/(file), fmt, ## __VA_ARGS__)
-# if 0
-# define FSCANF(file, fmt, ...) XSCANF(no_cast<FILE *>(file), fmt, ## __VA_ARGS__)
-# endif
# define PRINTF(fmt, ...) FPRINTF(stdout, fmt, ## __VA_ARGS__)
# 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__)
-# if 0
-# define SCANF(fmt, ...) FSCANF(stdin, fmt, ## __VA_ARGS__)
-# define SSCANF(str, fmt, ...) XSCANF(maybe_cast<ZString>(str), fmt, ## __VA_ARGS__)
-# endif
# define STRPRINTF(fmt, ...) \
({ \