summaryrefslogblamecommitdiff
path: root/zap/source/any/str/fmtlen.cc
blob: b5e508ce29d9121e0ec5e70623b22264e40d3ab4 (plain) (tree)
1
2
3
4
5
6
7
8





                                                                                                                     

                      




                        
                                                                                                                                 






















                                                                                                                              
/*
	Copyright 2022-2023 Gabriel Jensen.
	This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
	If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
*/

#include <zap/math.hh>
#include <zap/str.hh>

#include "numdig.hh"

namespace zap {
	namespace impl {
		template<typename typ> zap_attr_iln inline static auto fmtlen(typ val,::zap::i8 const bs) noexcept -> ::zap::i8 {
			::zap::i8 len = 0x0u;
			if (val < 0x0) {
				val = static_cast<typ>(::zap::abs(val));
				len = 0x1u;
			}
			len += ::zap::impl::numdig(val,bs);
			return len;
		}
	}
}

extern "C" {
	auto zap_fmtleni(  int                const val,::zap::i8 const bs) -> ::zap::i8 {return ::zap::impl::fmtlen(val,bs);}
	auto zap_fmtlenl(  long               const val,::zap::i8 const bs) -> ::zap::i8 {return ::zap::impl::fmtlen(val,bs);}
	auto zap_fmtlenll( long long          const val,::zap::i8 const bs) -> ::zap::i8 {return ::zap::impl::fmtlen(val,bs);}
	auto zap_fmtlens(  short              const val,::zap::i8 const bs) -> ::zap::i8 {return ::zap::impl::fmtlen(val,bs);}
	auto zap_fmtlensc( signed char        const val,::zap::i8 const bs) -> ::zap::i8 {return ::zap::impl::fmtlen(val,bs);}
	auto zap_fmtlenuc( unsigned char      const val,::zap::i8 const bs) -> ::zap::i8 {return ::zap::impl::fmtlen(val,bs);}
	auto zap_fmtlenui( unsigned int       const val,::zap::i8 const bs) -> ::zap::i8 {return ::zap::impl::fmtlen(val,bs);}
	auto zap_fmtlenul( unsigned long      const val,::zap::i8 const bs) -> ::zap::i8 {return ::zap::impl::fmtlen(val,bs);}
	auto zap_fmtlenull(unsigned long long const val,::zap::i8 const bs) -> ::zap::i8 {return ::zap::impl::fmtlen(val,bs);}
	auto zap_fmtlenus( unsigned short     const val,::zap::i8 const bs) -> ::zap::i8 {return ::zap::impl::fmtlen(val,bs);}
}