// Copyright (c) 2014, Thomas Goyne // // Permission to use, copy, modify, and distribute this software for any // purpose with or without fee is hereby granted, provided that the above // copyright notice and this permission notice appear in all copies. // // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR // ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. // // Aegisub Project http://www.aegisub.org/ #include #include #include namespace agi { template<> struct writer { static void write(std::basic_ostream& out, int max_len, wxString const& value) { writer::write(out, max_len, value.wx_str()); } }; template<> struct writer { static void write(std::basic_ostream& out, int max_len, wxString const& value) { writer::write(out, max_len, value.wx_str()); } }; template std::string format(wxString const& fmt, Args&&... args) { boost::interprocess::basic_vectorstream> out; format(out, (const char *)fmt.utf8_str(), std::forward(args)...); return out.vector(); } template wxString wxformat(wxString const& fmt, Args&&... args) { boost::interprocess::basic_vectorstream> out; format(out, fmt.wx_str(), std::forward(args)...); return out.vector(); } template wxString wxformat(const wxStringCharType *fmt, Args&&... args) { boost::interprocess::basic_vectorstream> out; format(out, fmt, std::forward(args)...); return out.vector(); } } #define fmt_wx(str, ...) agi::wxformat(wxS(str), __VA_ARGS__) #define fmt_tl(str, ...) agi::wxformat(wxGetTranslation(wxS(str)), __VA_ARGS__) #define fmt_plural(n, sing, plural, ...) \ agi::wxformat(wxGetTranslation(wxS(sing), wxS(plural), (n)), __VA_ARGS__)