55 lines
2.2 KiB
Text
55 lines
2.2 KiB
Text
// <sstream> - cout-replacement wrapper for the W65816 / Apple IIgs target.
|
|
//
|
|
// std::stringstream / std::ostringstream are NOT provided on this target.
|
|
// The full std::iostream surface pulls in a locale-aware num_put/num_get
|
|
// machinery that, with the soft-float libcalls and ctype tables, blows
|
|
// past a single-bank text budget on most demos. Per Phase 5.4 of the
|
|
// gap-closure plan, the cout replacement is:
|
|
//
|
|
// 1. etl::string_stream<> - fixed-capacity ETL string + operator<<
|
|
// overloads for int / hex / bool / span /
|
|
// string_view, plus optional FP if
|
|
// ETL_USING_FORMAT_FLOATING_POINT=1 (off
|
|
// by default on this target).
|
|
// 2. printf("%s", ss.str().c_str())
|
|
// - emit the result through the existing
|
|
// libc printf which already handles GNO
|
|
// / GS/OS / MAME stdout routing.
|
|
//
|
|
// Convenience aliases so existing portable code that #include's
|
|
// <sstream> compiles by pointing at the ETL surface. Note that this
|
|
// is a thin alias header - the underlying type is etl::string_stream
|
|
// (fixed capacity), NOT std::stringstream (heap-grown). Callers
|
|
// preferring the longer form can use etl::string_stream directly.
|
|
//
|
|
// Idiom:
|
|
//
|
|
// #include <sstream>
|
|
// #include <etl/string.h>
|
|
// #include <etl/to_string.h>
|
|
// #include <stdio.h>
|
|
//
|
|
// etl::string<128> buf;
|
|
// std::stringstream ss(buf); // alias of etl::string_stream
|
|
// ss << "hello, " << 42 << " world";
|
|
// printf("%s\n", ss.str().c_str()); // -> "hello, 42 world"
|
|
|
|
#ifndef _W65816_CXX_SSTREAM
|
|
#define _W65816_CXX_SSTREAM
|
|
|
|
#include "etl/string.h"
|
|
#include "etl/string_stream.h"
|
|
#include "etl/to_string.h"
|
|
|
|
namespace std {
|
|
|
|
// Alias the ETL fixed-capacity string-stream into the std:: namespace
|
|
// so generic code that names `std::stringstream` resolves. This is
|
|
// NOT a full std::stringstream - it requires an external string
|
|
// buffer (passed to the constructor) and is fixed-capacity.
|
|
using stringstream = ::etl::string_stream;
|
|
using ostringstream = ::etl::string_stream;
|
|
|
|
} // namespace std
|
|
|
|
#endif // _W65816_CXX_SSTREAM
|