/* This Source Code Form is subject to the terms of the Mozilla Public *License,v.2.0.IfacopyoftheMPLwasnotdistributedwiththis
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* Printf-like functions, with canned variants that malloc their result. */
/* Fast paths for formatting integers as though by %d, %o, %u, or %x. Sinceoctalandhexformattingalwaystreatnumbersasunsigned,there
are no signed overloads for AppendInt{Oct,Hex}. */ bool MFBT_API appendIntDec(int32_t); bool MFBT_API appendIntDec(uint32_t); bool MFBT_API appendIntOct(uint32_t); bool MFBT_API appendIntHex(uint32_t); bool MFBT_API appendIntDec(int64_t); bool MFBT_API appendIntDec(uint64_t); bool MFBT_API appendIntOct(uint64_t); bool MFBT_API appendIntHex(uint64_t);
/* Subclasses override this. It is called when more output is available.Itmaybecalledwithlen==0.Thisshouldreturn
true on success, or false on failure. */
virtual bool append(constchar* sp, size_t len) = 0;
private: /* Number of bytes emitted so far. */
size_t mEmitted;
/* The implementation calls this to emit bytes and update
mEmitted. */ bool emit(constchar* sp, size_t len) {
mEmitted += len; return append(sp, len);
}
bool fill2(constchar* src, int srclen, int width, int flags); bool fill_n(constchar* src, int srclen, int width, int prec, int type, int flags); bool cvt_l(long num, int width, int prec, int radix, int type, int flags, constchar* hexp); bool cvt_ll(int64_t num, int width, int prec, int radix, int type, int flags, constchar* hexp); bool cvt_f(double d, char c, int width, int prec, int flags); bool cvt_s(constchar* s, int width, int prec, int flags);
};
// The type returned by Smprintf and friends. template <typename AllocPolicy>
using SmprintfPolicyPointer =
mozilla::UniquePtr<char, detail::AllocPolicyBasedFreePolicy<AllocPolicy>>;
// The default type if no alloc policy is specified. typedef SmprintfPolicyPointer<mozilla::MallocAllocPolicy> SmprintfPointer;
// Used in the implementation of Smprintf et al. template <typename AllocPolicy> class MOZ_STACK_CLASS SprintfState final : private mozilla::PrintfTarget, private AllocPolicy {
public: explicit SprintfState(char* base)
: mMaxlen(base ? strlen(base) : 0),
mBase(base),
mCur(base ? base + mMaxlen : 0) {}
~SprintfState() { this->free_(mBase); }
bool vprint(constchar* format, va_list ap_list) MOZ_FORMAT_PRINTF(2, 0) { // The "" here has a single \0 character, which is what we're // trying to append. return mozilla::PrintfTarget::vprint(format, ap_list) && append("", 1);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.