diff options
author | 2016-08-27 16:45:53 +1000 | |
---|---|---|
committer | 2016-08-27 16:45:53 +1000 | |
commit | 75be4dff5f28a3dbca9fdfe1781adbc147d57411 (patch) | |
tree | 2ee4baecdfbd330b0e64c81910a5cf864a433a02 | |
parent | eff28a88cd200be94564dc2fc950d901224de62a (diff) |
While I'm causing full recompiles all the time, reduce necessary number of instantiations of parts of string formatting engine
-rw-r--r-- | scripts/src/lib.lua | 2 | ||||
-rw-r--r-- | src/lib/util/strformat.cpp | 93 | ||||
-rw-r--r-- | src/lib/util/strformat.h | 88 | ||||
-rw-r--r-- | src/lib/util/vecstream.cpp | 22 | ||||
-rw-r--r-- | src/lib/util/vecstream.h | 10 |
5 files changed, 213 insertions, 2 deletions
diff --git a/scripts/src/lib.lua b/scripts/src/lib.lua index be96214139e..51b92d098d2 100644 --- a/scripts/src/lib.lua +++ b/scripts/src/lib.lua @@ -79,6 +79,7 @@ project "utils" MAME_DIR .. "src/lib/util/pool.h", MAME_DIR .. "src/lib/util/sha1.cpp", MAME_DIR .. "src/lib/util/sha1.h", + MAME_DIR .. "src/lib/util/strformat.cpp", MAME_DIR .. "src/lib/util/strformat.h", MAME_DIR .. "src/lib/util/timeconv.cpp", MAME_DIR .. "src/lib/util/timeconv.h", @@ -90,6 +91,7 @@ project "utils" MAME_DIR .. "src/lib/util/un7z.h", MAME_DIR .. "src/lib/util/vbiparse.cpp", MAME_DIR .. "src/lib/util/vbiparse.h", + MAME_DIR .. "src/lib/util/vecstream.cpp", MAME_DIR .. "src/lib/util/vecstream.h", MAME_DIR .. "src/lib/util/wavwrite.cpp", MAME_DIR .. "src/lib/util/wavwrite.h", diff --git a/src/lib/util/strformat.cpp b/src/lib/util/strformat.cpp new file mode 100644 index 00000000000..b1ae7ff8875 --- /dev/null +++ b/src/lib/util/strformat.cpp @@ -0,0 +1,93 @@ +// license:BSD-3-Clause +// copyright-holders:Vas Crabb +/*************************************************************************** + + strformat.h + + type-safe printf substitutes + +***************************************************************************/ + +#include "strformat.h" +#include "vecstream.h" + +#include <iostream> +#include <sstream> + + +namespace util { + +namespace detail { + +template class format_chars<char>; +template class format_chars<wchar_t>; + +template void format_flags::apply(std::ostream &) const; +template void format_flags::apply(std::wostream &) const; +template void format_flags::apply(std::iostream &) const; +template void format_flags::apply(std::wiostream &) const; +template void format_flags::apply(std::ostringstream &) const; +template void format_flags::apply(std::wostringstream &) const; +template void format_flags::apply(std::stringstream &) const; +template void format_flags::apply(std::wstringstream &) const; +template void format_flags::apply(ovectorstream &) const; +template void format_flags::apply(wovectorstream &) const; +template void format_flags::apply(vectorstream &) const; +template void format_flags::apply(wvectorstream &) const; + +template class format_argument<std::ostream>; +template class format_argument<std::wostream.; +template class format_argument<std::iostream>; +template class format_argument<std::wiostream>; +template class format_argument<std::ostringstream>; +template class format_argument<std::wostringstream>; +template class format_argument<std::stringstream>; +template class format_argument<std::wstringstream>; +template class format_argument<ovectorstream>; +template class format_argument<wovectorstream>; +template class format_argument<vectorstream>; +template class format_argument<wvectorstream>; + +template class format_argument_pack<std::ostream>; +template class format_argument_pack<std::wostream>; +template class format_argument_pack<std::iostream>; +template class format_argument_pack<std::wiostream>; +template class format_argument_pack<std::ostringstream>; +template class format_argument_pack<std::wostringstream>; +template class format_argument_pack<std::stringstream>; +template class format_argument_pack<std::wstringstream>; +template class format_argument_pack<ovectorstream>; +template class format_argument_pack<wovectorstream>; +template class format_argument_pack<vectorstream>; +template class format_argument_pack<wvectorstream>; + +template std::ostream::off_type stream_format(std::ostream &, format_argument_pack<std::ostream> const &); +template std::wostream::off_type stream_format(std::wostream &, format_argument_pack<std::wostream> const &); +template std::iostream::off_type stream_format(std::iostream &, format_argument_pack<std::ostream> const &); +template std::iostream::off_type stream_format(std::iostream &, format_argument_pack<std::iostream> const &); +template std::wiostream::off_type stream_format(std::wiostream &, format_argument_pack<std::wostream> const &); +template std::wiostream::off_type stream_format(std::wiostream &, format_argument_pack<std::wiostream> const &); +template std::ostringstream::off_type stream_format(std::ostringstream &, format_argument_pack<std::ostream> const &); +template std::ostringstream::off_type stream_format(std::ostringstream &, format_argument_pack<std::ostringstream> const &); +template std::wostringstream::off_type stream_format(std::wostringstream &, format_argument_pack<std::wostream> const &); +template std::wostringstream::off_type stream_format(std::wostringstream &, format_argument_pack<std::wostringstream> const &); +template std::stringstream::off_type stream_format(std::stringstream &, format_argument_pack<std::ostream> const &); +template std::stringstream::off_type stream_format(std::stringstream &, format_argument_pack<std::iostream> const &); +template std::stringstream::off_type stream_format(std::stringstream &, format_argument_pack<std::stringstream> const &); +template std::wstringstream::off_type stream_format(std::wstringstream &, format_argument_pack<std::wostream> const &); +template std::wstringstream::off_type stream_format(std::wstringstream &, format_argument_pack<std::wiostream> const &); +template std::wstringstream::off_type stream_format(std::wstringstream &, format_argument_pack<std::wstringstream> const &); +template ovectorstream::off_type stream_format(ovectorstream &, format_argument_pack<std::ostream> const &); +template ovectorstream::off_type stream_format(ovectorstream &, format_argument_pack<ovectorstream> const &); +template wovectorstream::off_type stream_format(wovectorstream &, format_argument_pack<std::wostream> const &); +template wovectorstream::off_type stream_format(wovectorstream &, format_argument_pack<wovectorstream> const &); +template vectorstream::off_type stream_format(vectorstream &, format_argument_pack<std::ostream> const &); +template vectorstream::off_type stream_format(vectorstream &, format_argument_pack<std::iostream> const &); +template vectorstream::off_type stream_format(vectorstream &, format_argument_pack<vectorstream> const &); +template wvectorstream::off_type stream_format(wvectorstream &, format_argument_pack<std::wostream> const &); +template wvectorstream::off_type stream_format(wvectorstream &, format_argument_pack<std::wiostream> const &); +template wvectorstream::off_type stream_format(wvectorstream &, format_argument_pack<wvectorstream> const &); + +} // namespace detail + +} // namespace util diff --git a/src/lib/util/strformat.h b/src/lib/util/strformat.h index 7fb41c1d52b..abb34e80d3f 100644 --- a/src/lib/util/strformat.h +++ b/src/lib/util/strformat.h @@ -166,11 +166,13 @@ ***************************************************************************/ -#pragma once - #ifndef MAME_UTIL_STRFORMAT_H #define MAME_UTIL_STRFORMAT_H +#pragma once + +#include "vecstream.h" + #include <algorithm> #include <array> #include <cassert> @@ -1746,4 +1748,86 @@ using detail::make_format_argument_pack; using util::string_format; + +//************************************************************************** +// EXTERNAL TEMPLATE INSTANTIATIONS +//************************************************************************** + +namespace util { + +namespace detail { + +extern template class format_chars<char>; +extern template class format_chars<wchar_t>; + +extern template void format_flags::apply(std::ostream &) const; +extern template void format_flags::apply(std::wostream &) const; +extern template void format_flags::apply(std::iostream &) const; +extern template void format_flags::apply(std::wiostream &) const; +extern template void format_flags::apply(std::ostringstream &) const; +extern template void format_flags::apply(std::wostringstream &) const; +extern template void format_flags::apply(std::stringstream &) const; +extern template void format_flags::apply(std::wstringstream &) const; +extern template void format_flags::apply(ovectorstream &) const; +extern template void format_flags::apply(wovectorstream &) const; +extern template void format_flags::apply(vectorstream &) const; +extern template void format_flags::apply(wvectorstream &) const; + +extern template class format_argument<std::ostream>; +extern template class format_argument<std::wostream>; +extern template class format_argument<std::iostream>; +extern template class format_argument<std::wiostream>; +extern template class format_argument<std::ostringstream>; +extern template class format_argument<std::wostringstream>; +extern template class format_argument<std::stringstream>; +extern template class format_argument<std::wstringstream>; +extern template class format_argument<ovectorstream>; +extern template class format_argument<wovectorstream>; +extern template class format_argument<vectorstream>; +extern template class format_argument<wvectorstream>; + +extern template class format_argument_pack<std::ostream>; +extern template class format_argument_pack<std::wostream>; +extern template class format_argument_pack<std::iostream>; +extern template class format_argument_pack<std::wiostream>; +extern template class format_argument_pack<std::ostringstream>; +extern template class format_argument_pack<std::wostringstream>; +extern template class format_argument_pack<std::stringstream>; +extern template class format_argument_pack<std::wstringstream>; +extern template class format_argument_pack<ovectorstream>; +extern template class format_argument_pack<wovectorstream>; +extern template class format_argument_pack<vectorstream>; +extern template class format_argument_pack<wvectorstream>; + +extern template std::ostream::off_type stream_format(std::ostream &, format_argument_pack<std::ostream> const &); +extern template std::wostream::off_type stream_format(std::wostream &, format_argument_pack<std::wostream> const &); +extern template std::iostream::off_type stream_format(std::iostream &, format_argument_pack<std::ostream> const &); +extern template std::iostream::off_type stream_format(std::iostream &, format_argument_pack<std::iostream> const &); +extern template std::wiostream::off_type stream_format(std::wiostream &, format_argument_pack<std::wostream> const &); +extern template std::wiostream::off_type stream_format(std::wiostream &, format_argument_pack<std::wiostream> const &); +extern template std::ostringstream::off_type stream_format(std::ostringstream &, format_argument_pack<std::ostream> const &); +extern template std::ostringstream::off_type stream_format(std::ostringstream &, format_argument_pack<std::ostringstream> const &); +extern template std::wostringstream::off_type stream_format(std::wostringstream &, format_argument_pack<std::wostream> const &); +extern template std::wostringstream::off_type stream_format(std::wostringstream &, format_argument_pack<std::wostringstream> const &); +extern template std::stringstream::off_type stream_format(std::stringstream &, format_argument_pack<std::ostream> const &); +extern template std::stringstream::off_type stream_format(std::stringstream &, format_argument_pack<std::iostream> const &); +extern template std::stringstream::off_type stream_format(std::stringstream &, format_argument_pack<std::stringstream> const &); +extern template std::wstringstream::off_type stream_format(std::wstringstream &, format_argument_pack<std::wostream> const &); +extern template std::wstringstream::off_type stream_format(std::wstringstream &, format_argument_pack<std::wiostream> const &); +extern template std::wstringstream::off_type stream_format(std::wstringstream &, format_argument_pack<std::wstringstream> const &); +extern template ovectorstream::off_type stream_format(ovectorstream &, format_argument_pack<std::ostream> const &); +extern template ovectorstream::off_type stream_format(ovectorstream &, format_argument_pack<ovectorstream> const &); +extern template wovectorstream::off_type stream_format(wovectorstream &, format_argument_pack<std::wostream> const &); +extern template wovectorstream::off_type stream_format(wovectorstream &, format_argument_pack<wovectorstream> const &); +extern template vectorstream::off_type stream_format(vectorstream &, format_argument_pack<std::ostream> const &); +extern template vectorstream::off_type stream_format(vectorstream &, format_argument_pack<std::iostream> const &); +extern template vectorstream::off_type stream_format(vectorstream &, format_argument_pack<vectorstream> const &); +extern template wvectorstream::off_type stream_format(wvectorstream &, format_argument_pack<std::wostream> const &); +extern template wvectorstream::off_type stream_format(wvectorstream &, format_argument_pack<std::wiostream> const &); +extern template wvectorstream::off_type stream_format(wvectorstream &, format_argument_pack<wvectorstream> const &); + +} // namespace detail + +} // namespace util + #endif // MAME_UTIL_STRFORMAT_H diff --git a/src/lib/util/vecstream.cpp b/src/lib/util/vecstream.cpp new file mode 100644 index 00000000000..0d584167c62 --- /dev/null +++ b/src/lib/util/vecstream.cpp @@ -0,0 +1,22 @@ +// license:BSD-3-Clause +// copyright-holders:Vas Crabb +/*************************************************************************** + + vecstream.cpp + + streams with vector storage + +***************************************************************************/ + +#include "vecstream.h" + +namespace util { + +template class basic_ivectorstream<char>; +template class basic_ivectorstream<wchar_t>; +template class basic_ovectorstream<char>; +template class basic_ovectorstream<wchar_t>; +template class basic_vectorstream<char>; +template class basic_vectorstream<wchar_t>; + +} // namespace util diff --git a/src/lib/util/vecstream.h b/src/lib/util/vecstream.h index e4e8ddb5481..1af7dd0cd86 100644 --- a/src/lib/util/vecstream.h +++ b/src/lib/util/vecstream.h @@ -17,6 +17,8 @@ #ifndef MAME_UTIL_VECSTREAM_H #define MAME_UTIL_VECSTREAM_H +#pragma once + #include <algorithm> #include <cassert> #include <ios> @@ -31,6 +33,7 @@ #include <vector> namespace util { + template <typename CharT, typename Traits = std::char_traits<CharT>, typename Allocator = std::allocator<CharT> > class basic_vectorbuf : public std::basic_streambuf<CharT, Traits> { @@ -393,6 +396,13 @@ void swap(basic_ovectorstream<CharT, Traits, Allocator> &a, basic_ovectorstream< template <typename CharT, typename Traits, typename Allocator> void swap(basic_vectorstream<CharT, Traits, Allocator> &a, basic_vectorstream<CharT, Traits, Allocator> &b) { a.swap(b); } +extern template class basic_ivectorstream<char>; +extern template class basic_ivectorstream<wchar_t>; +extern template class basic_ovectorstream<char>; +extern template class basic_ovectorstream<wchar_t>; +extern template class basic_vectorstream<char>; +extern template class basic_vectorstream<wchar_t>; + } // namespace util #endif // MAME_UTIL_VECSTREAM_H |