diff --git a/apps/transmitmedia.cpp b/apps/transmitmedia.cpp index 8ec4751dd..30c602587 100644 --- a/apps/transmitmedia.cpp +++ b/apps/transmitmedia.cpp @@ -524,7 +524,7 @@ SrtCommon::~SrtCommon() SrtSource::SrtSource(string host, int port, const map& par) { Init(host, port, par, false); - hostport_copy = srt::ocat(host, ":"_V, port); + hostport_copy = srt::fmtcat(host, ":"_V, port); } int SrtSource::Read(size_t chunk, MediaPacket& pkt, ostream &out_stats) diff --git a/apps/uriparser.cpp b/apps/uriparser.cpp index 91a91bd84..a0c7ce278 100644 --- a/apps/uriparser.cpp +++ b/apps/uriparser.cpp @@ -68,35 +68,35 @@ string UriParser::makeUri() ofmtstream out; - oprint(out, prefix, m_host); + out.print(prefix, m_host); if ((m_port == "" || m_port == "0") && m_expect == EXPECT_FILE) { // Do not add port } else { - oprint(out, ":"_V, m_port); + out.print(":"_V, m_port); } if (m_path != "") { if (m_path[0] != '/') - oprint(out, "/"_V); - oprint(out, m_path); + out.print("/"_V); + out.print(m_path); } if (!m_mapQuery.empty()) { - oprint(out, "?"_V); + out.print("?"_V); query_it i = m_mapQuery.begin(); for (;;) { - oprint(out, i->first, "="_V, i->second); + out.print(i->first, "="_V, i->second); ++i; if (i == m_mapQuery.end()) break; - oprint(out, "&"_V); + out.print("&"_V); } } diff --git a/srtcore/ofmt.h b/srtcore/ofmt.h index e2af8b46b..301c5dd85 100644 --- a/srtcore/ofmt.h +++ b/srtcore/ofmt.h @@ -312,6 +312,36 @@ class ofmtstream { return buffer.str(); } + +// Additionally for C++11 +#if (defined(__cplusplus) && __cplusplus > 199711L) \ + || (defined(_MSVC_LANG) && _MSVC_LANG > 199711L) // Some earlier versions get this wrong + void print_chain() + { + } + + template + void print_chain(const Arg1& arg1, const Args&... args) + { + *this << arg1; + print_chain(args...); + } + + template + ofmtstream& print(const Args&... args) + { + print_chain(args...); + return *this; + } + + template + ofmtstream& puts(const Args&... args) + { + print_chain(args...); + buffer << std::endl; + return *this; + } +#endif }; // Additionally for C++11 @@ -323,24 +353,11 @@ inline internal::fmt_stringview operator""_V(const char* ptr, size_t s) return internal::fmt_stringview(ptr, s); } -template inline -Stream& oprint(Stream& out) -{ - return out; -} - -template inline -Stream& oprint(Stream& out, const Arg1& arg1, const Args&... args) -{ - out << arg1; - return oprint(out, args...); -} - template inline -std::string ocat(const Args&... args) +std::string fmtcat(const Args&... args) { ofmtstream out; - oprint(out, args...); + out.print(args...); return out.str(); } @@ -366,7 +383,7 @@ std::string fmts(const Value& val, const fmtc& fmtspec) } // This prevents the macro from being used with anything else -// than a string literal +// than a string literal. Version of ""_V UDL available for C++03. #define OFMT_RAWSTR(arg) srt::internal::CreateRawString_FWD("" arg) diff --git a/testing/testmedia.cpp b/testing/testmedia.cpp index d50e5fa5c..8414d9c78 100755 --- a/testing/testmedia.cpp +++ b/testing/testmedia.cpp @@ -1606,7 +1606,7 @@ void SrtCommon::UpdateGroupStatus(const SRT_SOCKGROUPDATA* grpdata, size_t grpda SrtSource::SrtSource(string host, int port, std::string path, const map& par) { Init(host, port, path, par, SRT_EPOLL_IN); - hostport_copy = srt::ocat(host, ":"_V, port); + hostport_copy = srt::fmtcat(host, ":"_V, port); } static void PrintSrtStats(SRTSOCKET sock, bool clr, bool bw, bool stats)