 |
Livox SDK API
V2.0.0
|
Go to the documentation of this file.
22 template <
typename Char>
23 class null_terminating_iterator {
36 template <
typename Range>
47 return ptr_ != end_ ? *ptr_ : Char();
81 return ptr_ - other.ptr_;
85 return ptr_ != other.ptr_;
89 return ptr_ >= other.ptr_;
94 template <
typename CharT>
103 template <
typename T>
106 template <
typename Char>
115 template <
typename Iterator,
typename ErrorHandler>
117 assert(
'0' <= *it && *it <=
'9');
124 unsigned max_int = (std::numeric_limits<int>::max)();
125 unsigned big = max_int / 10;
137 }
while (
'0' <= *it && *it <=
'9');
139 eh.on_error(
"number is too big");
145 template <
bool IsSigned>
147 template <
typename T>
149 unsigned max = std::numeric_limits<int>::max();
157 template <
typename T>
159 return value >= std::numeric_limits<int>::min() &&
167 template <
typename T>
168 typename std::enable_if<std::is_integral<T>::value,
int>
::type
172 return static_cast<int>(
value);
175 template <
typename T>
185 template <
typename T>
186 typename std::enable_if<std::is_integral<T>::value,
bool>
::type
189 template <
typename T>
190 typename std::enable_if<!std::is_integral<T>::value,
bool>
::type
194 template <
typename T>
202 template <
typename T,
typename Context>
216 operator()<
bool>(
value);
219 template <
typename U>
220 typename std::enable_if<std::is_integral<U>::value>
::type
222 bool is_signed = type_ ==
'd' || type_ ==
'i';
223 typedef typename std::conditional<
224 std::is_same<T, void>::value, U, T>
::type TargetType;
225 if (
const_check(
sizeof(TargetType) <=
sizeof(
int))) {
228 arg_ = internal::make_arg<Context>(
229 static_cast<int>(static_cast<TargetType>(
value)));
232 arg_ = internal::make_arg<Context>(
233 static_cast<unsigned>(static_cast<Unsigned>(
value)));
240 arg_ = internal::make_arg<Context>(static_cast<long long>(
value));
242 arg_ = internal::make_arg<Context>(
248 template <
typename U>
258 template <
typename T,
typename Context,
typename Char>
264 template <
typename Context>
272 template <
typename T>
273 typename std::enable_if<std::is_integral<T>::value>
::type
276 arg_ = internal::make_arg<Context>(static_cast<Char>(
value));
279 template <
typename T>
287 template <
typename Char>
297 template <
typename T>
298 typename std::enable_if<std::is_integral<T>::value,
unsigned>
::type
301 UnsignedType width = static_cast<UnsignedType>(
value);
306 unsigned int_max = std::numeric_limits<int>::max();
309 return static_cast<unsigned>(width);
312 template <
typename T>
313 typename std::enable_if<!std::is_integral<T>::value,
unsigned>
::type
320 template <
typename Char,
typename Context>
323 Context(std::back_inserter(buf),
format, args).format();
329 template <
typename Range>
333 typename OutputIt,
typename Char,
334 typename ArgFormatter =
343 template <
typename Range>
346 typename internal::arg_formatter_base<Range>::iterator>,
349 typedef typename Range::value_type
char_type;
350 typedef decltype(internal::declval<Range>().
begin())
iterator;
351 typedef internal::arg_formatter_base<Range>
base;
354 context_type &context_;
356 void write_null_pointer(
char) {
357 this->spec()->type = 0;
358 this->
write(
"(nil)");
361 void write_null_pointer(
wchar_t) {
362 this->spec()->type = 0;
363 this->
write(L
"(nil)");
382 template <
typename T>
383 typename std::enable_if<std::is_integral<T>::value, iterator>
::type
387 if (std::is_same<T, bool>::value) {
389 if (fmt_spec.
type !=
's')
390 return base::operator()(value ? 1 : 0);
392 this->
write(value != 0);
393 }
else if (std::is_same<T, char_type>::value) {
395 if (fmt_spec.
type && fmt_spec.
type !=
'c')
396 return (*
this)(static_cast<int>(value));
399 return base::operator()(value);
401 return base::operator()(value);
406 template <
typename T>
407 typename std::enable_if<std::is_floating_point<T>::value, iterator>
::type
409 return base::operator()(value);
415 base::operator()(value);
416 else if (this->spec()->
type ==
'p')
419 this->
write(
"(null)");
426 base::operator()(value);
427 else if (this->spec()->
type ==
'p')
430 this->
write(L
"(null)");
435 return base::operator()(value);
439 return base::operator()(value);
445 return base::operator()(value);
446 this->spec()->type = 0;
458 template <
typename T>
460 template <
typename ParseContext>
461 auto parse(ParseContext &ctx) -> decltype(ctx.begin()) {
return ctx.begin(); }
463 template <
typename FormatContext>
464 auto format(
const T &value, FormatContext &ctx) -> decltype(ctx.out()) {
471 template <
typename OutputIt,
typename Char,
typename ArgFormatter>
476 OutputIt, basic_printf_context<OutputIt, Char, ArgFormatter>, Char> {
481 template <
typename T>
496 unsigned arg_index = (std::numeric_limits<unsigned>::max)());
511 :
base(out, format_str, args) {}
515 using base::advance_to;
521 template <
typename OutputIt,
typename Char,
typename AF>
548 template <
typename OutputIt,
typename Char,
typename AF>
549 typename basic_printf_context<OutputIt, Char, AF>::format_arg
550 basic_printf_context<OutputIt, Char, AF>::get_arg(
551 iterator it,
unsigned arg_index) {
553 if (arg_index == std::numeric_limits<unsigned>::max())
554 return this->do_get_arg(this->
parse_context().next_arg_id());
555 return base::get_arg(arg_index - 1);
558 template <
typename OutputIt,
typename Char,
typename AF>
559 unsigned basic_printf_context<OutputIt, Char, AF>::parse_header(
561 unsigned arg_index = std::numeric_limits<unsigned>::max();
563 if (c >=
'0' && c <=
'9') {
566 internal::error_handler eh;
582 parse_flags(spec, it);
584 if (*it >=
'0' && *it <=
'9') {
585 internal::error_handler eh;
587 }
else if (*it ==
'*') {
590 internal::printf_width_handler<char_type>(spec), get_arg(it));
595 template <
typename OutputIt,
typename Char,
typename AF>
603 if (c !=
'%')
continue;
615 unsigned arg_index = parse_header(it, spec);
620 if (
'0' <= *it && *it <=
'9') {
623 }
else if (*it ==
'*') {
634 spec.
flags = static_cast<uint_least8_t>(spec.
flags & (~internal::to_unsigned<int>(
HASH_FLAG)));
635 if (spec.
fill_ ==
'0') {
636 if (
arg.is_arithmetic())
647 convert_arg<signed char>(
arg, *++it);
649 convert_arg<short>(
arg, *it);
653 convert_arg<long long>(
arg, *++it);
655 convert_arg<long>(
arg, *it);
658 convert_arg<intmax_t>(
arg, *it);
661 convert_arg<std::size_t>(
arg, *it);
664 convert_arg<std::ptrdiff_t>(
arg, *it);
672 convert_arg<void>(
arg, *it);
678 spec.
type = static_cast<char>(*it++);
679 if (
arg.is_integral()) {
701 template <
typename Buffer>
704 std::back_insert_iterator<Buffer>,
typename Buffer::value_type>
type;
719 template<
typename... Args>
729 template<
typename... Args>
733 template <
typename S,
typename Char = FMT_CHAR(S)>
734 inline std::basic_string<Char>
752 template <
typename S,
typename... Args>
764 template <
typename S,
typename Char = FMT_CHAR(S)>
772 buffer.
data(),
sizeof(Char), size, f) < size ? -1 : static_cast<int>(size);
784 template <
typename S,
typename... Args>
795 template <
typename S,
typename Char = FMT_CHAR(S)>
811 template <
typename S,
typename... Args>
813 printf(const S &format_str, const Args & ... args) {
822 template <
typename S,
typename Char = FMT_CHAR(S)>
842 template <
typename S,
typename... Args>
845 const S &format_str, const Args & ... args) {
855 #endif // FMT_PRINTF_H_
null_terminating_iterator(const Char *ptr, const Char *end)
std::enable_if<!std::is_integral< U >::value >::type operator()(U)
format_arg_store< printf_context, Args... > make_printf_args(const Args &... args)
null_terminating_iterator()
null_terminating_iterator operator--()
basic_printf_context_t< internal::wbuffer >::type wprintf_context
char_converter(basic_format_arg< Context > &arg)
null_terminating_iterator(const Range &r)
std::basic_string< Char > vsprintf(const S &format, basic_format_args< typename basic_printf_context_t< internal::basic_buffer< Char >>::type > args)
basic_printf_context_t< internal::buffer >::type printf_context
internal::result_of< Visitor(int)>::type visit_format_arg(Visitor &&vis, const basic_format_arg< Context > &arg)
difference_type operator-(null_terminating_iterator other) const
int vprintf(const S &format, basic_format_args< typename basic_printf_context_t< internal::basic_buffer< Char >>::type > args)
bool operator>=(null_terminating_iterator other) const
void operator()(bool value)
auto end(const C &c) -> decltype(c.end())
printf_formatter< T > type
std::enable_if<!std::is_integral< T >::value, unsigned >::type operator()(T)
std::enable_if< std::is_integral< T >::value, int >::type operator()(T value)
void append(const U *begin, const U *end)
std::random_access_iterator_tag iterator_category
Container & get_container(std::back_insert_iterator< Container > it)
std::string to_string(const T &value)
format_arg_store< wprintf_context, Args... > make_wprintf_args(const Args &... args)
std::enable_if< internal::is_string< S >::value, int >::type printf(const S &format_str, const Args &... args)
basic_format_args< printf_context > printf_args
bool operator!=(null_terminating_iterator other) const
std::enable_if<!is_compile_string< S >::value >::type check_format_string(const S &)
std::enable_if< internal::is_string< S >::value, int >::type fprintf(std::basic_ostream< typename char_t< S >::type > &os, const S &format_str, const Args &... args)
std::enable_if< std::numeric_limits< T >::is_signed, bool >::type is_negative(T value)
std::enable_if<!std::is_integral< T >::value >::type operator()(T)
const T * pointer_from(const T *p)
string_view_t & to_string_view(spdlog::level::level_enum l) noexcept
#define FMT_END_NAMESPACE
basic_buffer< char > buffer
basic_printf_context< std::back_insert_iterator< Buffer >, typename Buffer::value_type > type
null_terminating_iterator operator++(int)
null_terminating_iterator operator++()
static bool fits_in_int(int)
static bool fits_in_int(bool)
basic_format_args< wprintf_context > wprintf_args
void convert_arg(basic_format_arg< Context > &arg, Char type)
static bool fits_in_int(T value)
std::enable_if< std::is_integral< T >::value, bool >::type operator()(T value)
int vfprintf(std::basic_ostream< Char > &os, const S &format, basic_format_args< typename basic_printf_context_t< internal::basic_buffer< Char >>::type > args)
basic_format_specs< char > format_specs
std::enable_if< std::is_integral< T >::value >::type operator()(T value)
std::enable_if< internal::is_string< S >::value, std::basic_string< typename char_t< S >::type > >::type sprintf(const S &format, const Args &... args)
arg_converter(basic_format_arg< Context > &arg, Char type)
null_terminating_iterator operator-(difference_type n)
unsigned parse_nonnegative_int(Iterator &it, ErrorHandler &&eh)
void format_value(basic_buffer< Char > &buffer, const T &value)
#define FMT_BEGIN_NAMESPACE
internal::named_arg< T, char > arg(string_view name, const T &arg)
std::enable_if< std::is_integral< U >::value >::type operator()(U value)
const typedef Char & reference
auto begin(const C &c) -> decltype(c.begin())
printf_width_handler(format_specs &spec)
std::basic_string< typename char_t< S >::type > format(const S &format_str, const Args &... args)
null_terminating_iterator operator+(difference_type n)
std::enable_if<!std::is_integral< T >::value, int >::type operator()(T)
std::ptrdiff_t difference_type
const typedef Char * pointer
const void * ptr(const T *p)
basic_printf_context(OutputIt out, basic_string_view< char_type > format_str, basic_format_args< basic_printf_context > args)
static bool fits_in_int(T value)
basic_parse_context< char > parse_context
null_terminating_iterator & operator=(const Char *ptr)
void write(std::basic_ostream< Char > &os, basic_buffer< Char > &buf)
null_terminating_iterator operator+=(difference_type n)
#define FMT_CONSTEXPR_DECL
std::enable_if< std::is_integral< T >::value, unsigned >::type operator()(T value)
#define FMT_ENABLE_IF_T(B, T)
std::enable_if<!std::is_integral< T >::value, bool >::type operator()(T)