SkSLOutputStream.cpp 699 B

123456789101112131415161718192021222324252627282930
  1. /*
  2. * Copyright 2019 Google Inc.
  3. *
  4. * Use of this source code is governed by a BSD-style license that can be
  5. * found in the LICENSE file.
  6. */
  7. #include "src/sksl/SkSLOutputStream.h"
  8. namespace SkSL {
  9. void OutputStream::writeString(String s) {
  10. this->write(s.c_str(), s.size());
  11. }
  12. void OutputStream::printf(const char format[], ...) {
  13. va_list args;
  14. va_start(args, format);
  15. this->appendVAList(format, args);
  16. va_end(args);
  17. }
  18. void OutputStream::appendVAList(const char format[], va_list args) {
  19. char buffer[kBufferSize];
  20. int length = vsnprintf(buffer, kBufferSize, format, args);
  21. SkASSERT(length >= 0 && length < (int) kBufferSize);
  22. this->write(buffer, length);
  23. }
  24. }