forked from OctaForge/libostd
move format impl into namespace detail
parent
47a98592f0
commit
c17de276e3
|
@ -544,11 +544,11 @@ namespace detail {
|
||||||
if (idx) return get_arg_param(idx - 1, param, args...);
|
if (idx) return get_arg_param(idx - 1, param, args...);
|
||||||
return convert_arg_param(val, param);
|
return convert_arg_param(val, param);
|
||||||
}
|
}
|
||||||
} /* namespace detail */
|
|
||||||
|
|
||||||
template<typename R, typename ...A>
|
template<typename R, typename ...A>
|
||||||
static inline octa::Ptrdiff format(R writer, octa::Size &fmtn,
|
static inline octa::Ptrdiff format_impl(R &writer, octa::Size &fmtn,
|
||||||
const char *fmt, const A &...args) {
|
const char *fmt,
|
||||||
|
const A &...args) {
|
||||||
octa::Size argidx = 1, retn = 0, twr = 0;
|
octa::Size argidx = 1, retn = 0, twr = 0;
|
||||||
octa::Ptrdiff written = 0;
|
octa::Ptrdiff written = 0;
|
||||||
octa::detail::WriteSpec spec(fmt);
|
octa::detail::WriteSpec spec(fmt);
|
||||||
|
@ -559,13 +559,13 @@ static inline octa::Ptrdiff format(R writer, octa::Size &fmtn,
|
||||||
argpos = argidx++;
|
argpos = argidx++;
|
||||||
if (spec.arg_width) {
|
if (spec.arg_width) {
|
||||||
spec.arg_width = false;
|
spec.arg_width = false;
|
||||||
if (!octa::detail::get_arg_param(argpos - 1, spec.width, args...))
|
if (!get_arg_param(argpos - 1, spec.width, args...))
|
||||||
return -1;
|
return -1;
|
||||||
argpos = argidx++;
|
argpos = argidx++;
|
||||||
}
|
}
|
||||||
if (spec.arg_precision) {
|
if (spec.arg_precision) {
|
||||||
spec.arg_precision = false;
|
spec.arg_precision = false;
|
||||||
if (!octa::detail::get_arg_param(argpos - 1, spec.precision, args...))
|
if (!get_arg_param(argpos - 1, spec.precision, args...))
|
||||||
return -1;
|
return -1;
|
||||||
argpos = argidx++;
|
argpos = argidx++;
|
||||||
}
|
}
|
||||||
|
@ -577,7 +577,7 @@ static inline octa::Ptrdiff format(R writer, octa::Size &fmtn,
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
spec.arg_precision = false;
|
spec.arg_precision = false;
|
||||||
if (!octa::detail::get_arg_param(argpos - 2, spec.precision, args...))
|
if (!get_arg_param(argpos - 2, spec.precision, args...))
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (spec.arg_width) {
|
if (spec.arg_width) {
|
||||||
|
@ -586,7 +586,7 @@ static inline octa::Ptrdiff format(R writer, octa::Size &fmtn,
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
spec.arg_width = false;
|
spec.arg_width = false;
|
||||||
if (!octa::detail::get_arg_param(argpos - 2 - argprec, spec.width, args...))
|
if (!get_arg_param(argpos - 2 - argprec, spec.width, args...))
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -597,16 +597,23 @@ static inline octa::Ptrdiff format(R writer, octa::Size &fmtn,
|
||||||
written += twr;
|
written += twr;
|
||||||
fmtn = retn;
|
fmtn = retn;
|
||||||
return written;
|
return written;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename R, typename ...A>
|
template<typename R, typename ...A>
|
||||||
static inline octa::Ptrdiff format(R writer, octa::Size &fmtn,
|
static inline octa::Ptrdiff format(R &writer, octa::Size &fmtn,
|
||||||
const char *fmt) {
|
const char *fmt) {
|
||||||
octa::Size written = 0;
|
octa::Size written = 0;
|
||||||
octa::detail::WriteSpec spec(fmt);
|
octa::detail::WriteSpec spec(fmt);
|
||||||
if (spec.read_until_spec(writer, &written)) return -1;
|
if (spec.read_until_spec(writer, &written)) return -1;
|
||||||
fmtn = 0;
|
fmtn = 0;
|
||||||
return written;
|
return written;
|
||||||
|
}
|
||||||
|
} /* namespace detail */
|
||||||
|
|
||||||
|
template<typename R, typename ...A>
|
||||||
|
static inline octa::Ptrdiff format(R writer, octa::Size &fmtn,
|
||||||
|
const char *fmt, const A &...args) {
|
||||||
|
return octa::detail::format_impl(writer, fmtn, fmt, args...);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename R, typename AL, typename ...A>
|
template<typename R, typename AL, typename ...A>
|
||||||
|
|
Loading…
Reference in New Issue