/* * Copyright 2006 The Android Open Source Project * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file.
*/
/* * The SkStrAppend... methods will write into the provided buffer, assuming it is large enough. * Each method has an associated const (e.g. kSkStrAppendU32_MaxSize) which will be the largest * value needed for that method's buffer. * * char storage[kSkStrAppendU32_MaxSize]; * SkStrAppendU32(storage, value); * * Note : none of the SkStrAppend... methods write a terminating 0 to their buffers. Instead, * the methods return the ptr to the end of the written part of the buffer. This can be used * to compute the length, and/or know where to write a 0 if that is desired. * * char storage[kSkStrAppendU32_MaxSize + 1]; * char* stop = SkStrAppendU32(storage, value); * size_t len = stop - storage; * *stop = 0; // valid, since storage was 1 byte larger than the max.
*/
static constexpr int kSkStrAppendU32_MaxSize = 10; char* SkStrAppendU32(char buffer[], uint32_t); static constexpr int kSkStrAppendU64_MaxSize = 20; char* SkStrAppendU64(char buffer[], uint64_t, int minDigits);
static constexpr int kSkStrAppendS32_MaxSize = kSkStrAppendU32_MaxSize + 1; char* SkStrAppendS32(char buffer[], int32_t); static constexpr int kSkStrAppendS64_MaxSize = kSkStrAppendU64_MaxSize + 1; char* SkStrAppendS64(char buffer[], int64_t, int minDigits);
/** * Floats have at most 8 significant digits, so we limit our %g to that. * However, the total string could be 15 characters: -1.2345678e-005 * * In theory we should only expect up to 2 digits for the exponent, but on * some platforms we have seen 3 (as in the example above).
*/ static constexpr int kSkStrAppendScalar_MaxSize = 15;
/** * Write the scalar in decimal format into buffer, and return a pointer to * the next char after the last one written. Note: a terminating 0 is not * written into buffer, which must be at least kSkStrAppendScalar_MaxSize. * Thus if the caller wants to add a 0 at the end, buffer must be at least * kSkStrAppendScalar_MaxSize + 1 bytes large.
*/ char* SkStrAppendScalar(char buffer[], SkScalar);
/** \class SkString
Light weight class for managing strings. Uses reference counting to make string assignments and copies very fast with no extra RAM cost. Assumes UTF8 encoding.
*/ class SK_API SkString { public:
SkString(); explicit SkString(size_t len); explicit SkString(constchar text[]);
SkString(constchar text[], size_t len);
SkString(const SkString&);
SkString(SkString&&); explicit SkString(const std::string&); explicit SkString(std::string_view);
~SkString();
friendbooloperator==(const SkString& a, const SkString& b) { return a.equals(b);
} friendbooloperator!=(const SkString& a, const SkString& b) { return !a.equals(b);
}
/// Creates a new string and writes into it using a printf()-style format.
SK_API SkString SkStringPrintf(constchar* format, ...) SK_PRINTF_LIKE(1, 2); /// This makes it easier to write a caller as a VAR_ARGS function where the format string is /// optional. staticinline SkString SkStringPrintf() { return SkString(); }
staticinlinevoid swap(SkString& a, SkString& b) {
a.swap(b);
}
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.