string_stream.h - エンジンの C API リファレンス

string_stream.h
  1. #pragma once
  2. #include "allocator.h"
  3. #include "array.h"
  4. #include "platform.h"
  5. namespace stingray_plugin_foundation {
  6. class StringStream
  7. {
  8. public:
  9. StringStream(Allocator &a);
  10. StringStream &operator<<(char c);
  11. StringStream &operator<<(char *s);
  12. StringStream &operator<<(const char *s);
  13. StringStream &operator<<(wchar_t *s);
  14. StringStream &operator<<(const wchar_t *s);
  15. StringStream &operator<<(double d);
  16. StringStream &operator<<(float f);
  17. StringStream &operator<<(int i);
  18. StringStream &operator<<(unsigned u);
  19. StringStream &operator<<(uint64_t u);
  20. template <class T> StringStream &operator<<(T t) {t.other_types_are_not_allowed(); return *this;}
  21. // As regular printf, but prints to string stream.
  22. StringStream &printf(const char *format, ...);
  23. // Push a chunk of non null terminated data to the stream.
  24. StringStream &push(const char *data, unsigned int size);
  25. // Allocates size bytes of data at the end of the stream and returns a pointer for filling it.
  26. char *allocate(unsigned int size);
  27. // Logs a hex dump of the data to the string stream.
  28. StringStream &hex_dump(const char *p, unsigned size, int columns=16);
  29. void set_capacity(unsigned s);
  30. // Pads with spaces to arrive at the specified column.
  31. void indent(unsigned column);
  32. // Adds a multi-line string so each line, padded with spaces, begins at the specified column `column` and returns the number of lines that was added;
  33. unsigned add_indented_lines(unsigned column, const char* lines);
  34. // Adds the specified number of spaces.
  35. void add_spaces(unsigned n);
  36. const char *c_str() const;
  37. unsigned size() const;
  38. void clear() {_buffer.clear();}
  39. private:
  40. mutable Array<char> _buffer;
  41. };
  42. } // namespace stingray_plugin_foundation
  43. #include "string_stream.inl"