From b1836ffb49bd7740dbd7c32bfad04d077e81ecb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Remko=20Tron=C3=A7on?= Date: Sat, 19 Feb 2011 09:48:05 +0100 Subject: Make Swift translatable. diff --git a/3rdParty/Boost/src/boost/format.hpp b/3rdParty/Boost/src/boost/format.hpp new file mode 100644 index 0000000..73464a8 --- /dev/null +++ b/3rdParty/Boost/src/boost/format.hpp @@ -0,0 +1,59 @@ +// ---------------------------------------------------------------------------- +// format.hpp : primary header +// ---------------------------------------------------------------------------- + +// Copyright Samuel Krempp 2003. Use, modification, and distribution are +// subject to the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/libs/format for library home page + + +// ---------------------------------------------------------------------------- + +#ifndef BOOST_FORMAT_HPP +#define BOOST_FORMAT_HPP + +#include +#include +#include +#include + +#ifndef BOOST_NO_STD_LOCALE +#include +#endif + +// *** Compatibility framework +#include + +#ifdef BOOST_NO_LOCALE_ISIDIGIT +#include // we'll use the non-locale 's std::isdigit(int) +#endif + +// **** Forward declarations ---------------------------------- +#include // basic_format, and other frontends +#include // misc forward declarations for internal use + +// **** Auxiliary structs (stream_format_state , and format_item ) +#include + +// **** Format class interface -------------------------------- +#include + +// **** Exceptions ----------------------------------------------- +#include + +// **** Implementation ------------------------------------------- +#include // member functions +#include // class for grouping arguments +#include // argument-feeding functions +#include // format-string parsing (member-)functions + +// **** Implementation of the free functions ---------------------- +#include + + +// *** Undefine 'local' macros : +#include + +#endif // BOOST_FORMAT_HPP diff --git a/3rdParty/Boost/src/boost/format/alt_sstream.hpp b/3rdParty/Boost/src/boost/format/alt_sstream.hpp new file mode 100644 index 0000000..e236be3 --- /dev/null +++ b/3rdParty/Boost/src/boost/format/alt_sstream.hpp @@ -0,0 +1,176 @@ +// ---------------------------------------------------------------------------- +// alt_sstream.hpp : alternative stringstream +// ---------------------------------------------------------------------------- + +// Copyright Samuel Krempp 2003. Use, modification, and distribution are +// subject to the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/libs/format for library home page + +// ---------------------------------------------------------------------------- + + + +#ifndef BOOST_SK_ALT_SSTREAM_HPP +#define BOOST_SK_ALT_SSTREAM_HPP + +#include +#include +#include +#include +#include + +namespace boost { + namespace io { + + template, + class Alloc=::std::allocator > + class basic_altstringbuf; + + template, + class Alloc=::std::allocator > + class basic_oaltstringstream; + + + template + class basic_altstringbuf + : public ::std::basic_streambuf + { + typedef ::std::basic_streambuf streambuf_t; + typedef typename CompatAlloc::compatible_type compat_allocator_type; + typedef typename CompatTraits::compatible_type compat_traits_type; + public: + typedef Ch char_type; + typedef Tr traits_type; + typedef typename compat_traits_type::int_type int_type; + typedef typename compat_traits_type::pos_type pos_type; + typedef typename compat_traits_type::off_type off_type; + typedef Alloc allocator_type; + typedef ::std::basic_string string_type; + typedef typename string_type::size_type size_type; + + typedef ::std::streamsize streamsize; + + + explicit basic_altstringbuf(std::ios_base::openmode mode + = std::ios_base::in | std::ios_base::out) + : putend_(NULL), is_allocated_(false), mode_(mode) + {} + explicit basic_altstringbuf(const string_type& s, + ::std::ios_base::openmode mode + = ::std::ios_base::in | ::std::ios_base::out) + : putend_(NULL), is_allocated_(false), mode_(mode) + { dealloc(); str(s); } + virtual ~basic_altstringbuf() + { dealloc(); } + using streambuf_t::pbase; + using streambuf_t::pptr; + using streambuf_t::epptr; + using streambuf_t::eback; + using streambuf_t::gptr; + using streambuf_t::egptr; + + void clear_buffer(); + void str(const string_type& s); + + // 0-copy access : + Ch * begin() const; + size_type size() const; + size_type cur_size() const; // stop at current pointer + Ch * pend() const // the highest position reached by pptr() since creation + { return ((putend_ < pptr()) ? pptr() : putend_); } + size_type pcount() const + { return static_cast( pptr() - pbase()) ;} + + // copy buffer to string : + string_type str() const + { return string_type(begin(), size()); } + string_type cur_str() const + { return string_type(begin(), cur_size()); } + protected: + explicit basic_altstringbuf (basic_altstringbuf * s, + ::std::ios_base::openmode mode + = ::std::ios_base::in | ::std::ios_base::out) + : putend_(NULL), is_allocated_(false), mode_(mode) + { dealloc(); str(s); } + + virtual pos_type seekoff(off_type off, ::std::ios_base::seekdir way, + ::std::ios_base::openmode which + = ::std::ios_base::in | ::std::ios_base::out); + virtual pos_type seekpos (pos_type pos, + ::std::ios_base::openmode which + = ::std::ios_base::in | ::std::ios_base::out); + virtual int_type underflow(); + virtual int_type pbackfail(int_type meta = compat_traits_type::eof()); + virtual int_type overflow(int_type meta = compat_traits_type::eof()); + void dealloc(); + private: + enum { alloc_min = 256}; // minimum size of allocations + + Ch *putend_; // remembers (over seeks) the highest value of pptr() + bool is_allocated_; + ::std::ios_base::openmode mode_; + compat_allocator_type alloc_; // the allocator object + }; + + +// --- class basic_oaltstringstream ---------------------------------------- + template + class basic_oaltstringstream + : private base_from_member< shared_ptr< basic_altstringbuf< Ch, Tr, Alloc> > >, + public ::std::basic_ostream + { + class No_Op { + // used as no-op deleter for (not-owner) shared_pointers + public: + template + const T & operator()(const T & arg) { return arg; } + }; + typedef ::std::basic_ostream stream_t; + typedef boost::base_from_member > > + pbase_type; + typedef ::std::basic_string string_type; + typedef typename string_type::size_type size_type; + typedef basic_altstringbuf stringbuf_t; + public: + typedef Alloc allocator_type; + basic_oaltstringstream() + : pbase_type(new stringbuf_t), stream_t(rdbuf()) + { } + basic_oaltstringstream(::boost::shared_ptr buf) + : pbase_type(buf), stream_t(rdbuf()) + { } + basic_oaltstringstream(stringbuf_t * buf) + : pbase_type(buf, No_Op() ), stream_t(rdbuf()) + { } + stringbuf_t * rdbuf() const + { return pbase_type::member.get(); } + void clear_buffer() + { rdbuf()->clear_buffer(); } + + // 0-copy access : + Ch * begin() const + { return rdbuf()->begin(); } + size_type size() const + { return rdbuf()->size(); } + size_type cur_size() const // stops at current position + { return rdbuf()->cur_size(); } + + // copy buffer to string : + string_type str() const // [pbase, epptr[ + { return rdbuf()->str(); } + string_type cur_str() const // [pbase, pptr[ + { return rdbuf()->cur_str(); } + void str(const string_type& s) + { rdbuf()->str(s); } + }; + + } // N.S. io +} // N.S. boost + +#include + +#endif // include guard + diff --git a/3rdParty/Boost/src/boost/format/alt_sstream_impl.hpp b/3rdParty/Boost/src/boost/format/alt_sstream_impl.hpp new file mode 100644 index 0000000..9975e4f --- /dev/null +++ b/3rdParty/Boost/src/boost/format/alt_sstream_impl.hpp @@ -0,0 +1,313 @@ +// ---------------------------------------------------------------------------- +// alt_sstream_impl.hpp : alternative stringstream, templates implementation +// ---------------------------------------------------------------------------- + +// Copyright Samuel Krempp 2003. Use, modification, and distribution are +// subject to the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/libs/format for library home page + +// ---------------------------------------------------------------------------- + +#ifndef BOOST_SK_ALT_SSTREAM_IMPL_HPP +#define BOOST_SK_ALT_SSTREAM_IMPL_HPP + +namespace boost { + namespace io { +// --- Implementation ------------------------------------------------------// + + template + void basic_altstringbuf:: + clear_buffer () { + const Ch * p = pptr(); + const Ch * b = pbase(); + if(p != NULL && p != b) { + seekpos(0, ::std::ios_base::out); + } + p = gptr(); + b = eback(); + if(p != NULL && p != b) { + seekpos(0, ::std::ios_base::in); + } + } + + template + void basic_altstringbuf:: + str (const string_type& s) { + size_type sz=s.size(); + if(sz != 0 && mode_ & (::std::ios_base::in | ::std::ios_base::out) ) { +#ifdef _RWSTD_NO_CLASS_PARTIAL_SPEC + void *vd_ptr = alloc_.allocate(sz, is_allocated_? eback() : 0); + Ch *new_ptr = static_cast(vd_ptr); +#else + Ch *new_ptr = alloc_.allocate(sz, is_allocated_? eback() : 0); +#endif + // if this didnt throw, we're safe, update the buffer + dealloc(); + sz = s.copy(new_ptr, sz); + putend_ = new_ptr + sz; + if(mode_ & ::std::ios_base::in) + streambuf_t::setg(new_ptr, new_ptr, new_ptr + sz); + if(mode_ & ::std::ios_base::out) { + streambuf_t::setp(new_ptr, new_ptr + sz); + if(mode_ & (::std::ios_base::app | ::std::ios_base::ate)) + streambuf_t::pbump(static_cast(sz)); + if(gptr() == NULL) + streambuf_t::setg(new_ptr, NULL, new_ptr); + } + is_allocated_ = true; + } + else + dealloc(); + } + template + Ch* basic_altstringbuf:: + begin () const { + if(mode_ & ::std::ios_base::out && pptr() != NULL) + return pbase(); + else if(mode_ & ::std::ios_base::in && gptr() != NULL) + return eback(); + return NULL; + } + + template + typename std::basic_string::size_type + basic_altstringbuf:: + size () const { + if(mode_ & ::std::ios_base::out && pptr()) + return static_cast(pend() - pbase()); + else if(mode_ & ::std::ios_base::in && gptr()) + return static_cast(egptr() - eback()); + else + return 0; + } + + template + typename std::basic_string::size_type + basic_altstringbuf:: + cur_size () const { + if(mode_ & ::std::ios_base::out && pptr()) + return static_cast( pptr() - pbase()); + else if(mode_ & ::std::ios_base::in && gptr()) + return static_cast( gptr() - eback()); + else + return 0; + } + + template + typename basic_altstringbuf::pos_type + basic_altstringbuf:: + seekoff (off_type off, ::std::ios_base::seekdir way, ::std::ios_base::openmode which) { + if(pptr() != NULL && putend_ < pptr()) + putend_ = pptr(); + if(which & ::std::ios_base::in && gptr() != NULL) { + // get area + if(way == ::std::ios_base::end) + off += static_cast(putend_ - gptr()); + else if(way == ::std::ios_base::beg) + off += static_cast(eback() - gptr()); + else if(way != ::std::ios_base::cur || (which & ::std::ios_base::out) ) + // (altering in&out is only supported if way is beg or end, not cur) + return pos_type(off_type(-1)); + if(eback() <= off+gptr() && off+gptr() <= putend_ ) { + // set gptr + streambuf_t::gbump(static_cast(off)); + if(which & ::std::ios_base::out && pptr() != NULL) + // update pptr to match gptr + streambuf_t::pbump(static_cast(gptr()-pptr())); + } + else + off = off_type(-1); + } + else if(which & ::std::ios_base::out && pptr() != NULL) { + // put area + if(way == ::std::ios_base::end) + off += static_cast(putend_ - pptr()); + else if(way == ::std::ios_base::beg) + off += static_cast(pbase() - pptr()); + else if(way != ::std::ios_base::beg) + return pos_type(off_type(-1)); + if(pbase() <= off+pptr() && off+pptr() <= putend_) + // set pptr + streambuf_t::pbump(static_cast(off)); + else + off = off_type(-1); + } + else // neither in nor out + off = off_type(-1); + return (pos_type(off)); + } + //- end seekoff(..) + + + template + typename basic_altstringbuf::pos_type + basic_altstringbuf:: + seekpos (pos_type pos, ::std::ios_base::openmode which) { + off_type off = off_type(pos); // operation guaranteed by 27.4.3.2 table 88 + if(pptr() != NULL && putend_ < pptr()) + putend_ = pptr(); + if(off != off_type(-1)) { + if(which & ::std::ios_base::in && gptr() != NULL) { + // get area + if(0 <= off && off <= putend_ - eback()) { + streambuf_t::gbump(static_cast(eback() - gptr() + off)); + if(which & ::std::ios_base::out && pptr() != NULL) { + // update pptr to match gptr + streambuf_t::pbump(static_cast(gptr()-pptr())); + } + } + else + off = off_type(-1); + } + else if(which & ::std::ios_base::out && pptr() != NULL) { + // put area + if(0 <= off && off <= putend_ - eback()) + streambuf_t::pbump(static_cast(eback() - pptr() + off)); + else + off = off_type(-1); + } + else // neither in nor out + off = off_type(-1); + return (pos_type(off)); + } + else { + BOOST_ASSERT(0); // §27.4.3.2 allows undefined-behaviour here + return pos_type(off_type(-1)); + } + } + // -end seekpos(..) + + + template + typename basic_altstringbuf::int_type + basic_altstringbuf:: + underflow () { + if(gptr() == NULL) // no get area -> nothing to get. + return (compat_traits_type::eof()); + else if(gptr() < egptr()) // ok, in buffer + return (compat_traits_type::to_int_type(*gptr())); + else if(mode_ & ::std::ios_base::in && pptr() != NULL + && (gptr() < pptr() || gptr() < putend_) ) + { // expand get area + if(putend_ < pptr()) + putend_ = pptr(); // remember pptr reached this far + streambuf_t::setg(eback(), gptr(), putend_); + return (compat_traits_type::to_int_type(*gptr())); + } + else // couldnt get anything. EOF. + return (compat_traits_type::eof()); + } + // -end underflow(..) + + + template + typename basic_altstringbuf::int_type + basic_altstringbuf:: + pbackfail (int_type meta) { + if(gptr() != NULL && (eback() < gptr()) + && (mode_ & (::std::ios_base::out) + || compat_traits_type::eq_int_type(compat_traits_type::eof(), meta) + || compat_traits_type::eq(compat_traits_type::to_char_type(meta), gptr()[-1]) ) ) { + streambuf_t::gbump(-1); // back one character + if(!compat_traits_type::eq_int_type(compat_traits_type::eof(), meta)) + // put-back meta into get area + *gptr() = compat_traits_type::to_char_type(meta); + return (compat_traits_type::not_eof(meta)); + } + else + return (compat_traits_type::eof()); // failed putback + } + // -end pbackfail(..) + + + template + typename basic_altstringbuf::int_type + basic_altstringbuf:: + overflow (int_type meta) { +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable:4996) +#endif + if(compat_traits_type::eq_int_type(compat_traits_type::eof(), meta)) + return compat_traits_type::not_eof(meta); // nothing to do + else if(pptr() != NULL && pptr() < epptr()) { + streambuf_t::sputc(compat_traits_type::to_char_type(meta)); + return meta; + } + else if(! (mode_ & ::std::ios_base::out)) + // no write position, and cant make one + return compat_traits_type::eof(); + else { // make a write position available + std::size_t prev_size = pptr() == NULL ? 0 : epptr() - eback(); + std::size_t new_size = prev_size; + // exponential growth : size *= 1.5 + std::size_t add_size = new_size / 2; + if(add_size < alloc_min) + add_size = alloc_min; + Ch * newptr = NULL, *oldptr = eback(); + + // make sure adding add_size wont overflow size_t + while (0 < add_size && ((std::numeric_limits::max)() + - add_size < new_size) ) + add_size /= 2; + if(0 < add_size) { + new_size += add_size; +#ifdef _RWSTD_NO_CLASS_PARTIAL_SPEC + void *vdptr = alloc_.allocate(new_size, is_allocated_? oldptr : 0); + newptr = static_cast(vdptr); +#else + newptr = alloc_.allocate(new_size, is_allocated_? oldptr : 0); +#endif + } + + if(0 < prev_size) + compat_traits_type::copy(newptr, oldptr, prev_size); + if(is_allocated_) + alloc_.deallocate(oldptr, prev_size); + is_allocated_=true; + + if(prev_size == 0) { // first allocation + putend_ = newptr; + streambuf_t::setp(newptr, newptr + new_size); + if(mode_ & ::std::ios_base::in) + streambuf_t::setg(newptr, newptr, newptr + 1); + else + streambuf_t::setg(newptr, 0, newptr); + } + else { // update pointers + putend_ = putend_ - oldptr + newptr; + int pptr_count = static_cast(pptr()-pbase()); + int gptr_count = static_cast(gptr()-eback()); + streambuf_t::setp(pbase() - oldptr + newptr, newptr + new_size); + streambuf_t::pbump(pptr_count); + if(mode_ & ::std::ios_base::in) + streambuf_t::setg(newptr, newptr + gptr_count, pptr() + 1); + else + streambuf_t::setg(newptr, 0, newptr); + } + streambuf_t::sputc(compat_traits_type::to_char_type(meta)); + return meta; + } +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + } + // -end overflow(..) + + template + void basic_altstringbuf:: dealloc() { + if(is_allocated_) + alloc_.deallocate(eback(), (pptr() != NULL ? epptr() : egptr()) - eback()); + is_allocated_ = false; + streambuf_t::setg(0, 0, 0); + streambuf_t::setp(0, 0); + putend_ = NULL; + } + + }// N.S. io +} // N.S. boost + +#endif // include guard + diff --git a/3rdParty/Boost/src/boost/format/detail/compat_workarounds.hpp b/3rdParty/Boost/src/boost/format/detail/compat_workarounds.hpp new file mode 100644 index 0000000..8e51514 --- /dev/null +++ b/3rdParty/Boost/src/boost/format/detail/compat_workarounds.hpp @@ -0,0 +1,86 @@ +// ---------------------------------------------------------------------------- +// compat_workarounds : general framework for non-conformance workarounds +// ---------------------------------------------------------------------------- + +// Copyright Samuel Krempp 2003. Use, modification, and distribution are +// subject to the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// see http://www.boost.org/libs/format for library home page + +// ---------------------------------------------------------------------------- + + +// this file defines wrapper classes to hide non-conforming +// std::char_traits<> and std::allocator<> traits +// and Includes : config_macros.hpp (defines config macros +// and compiler-specific switches) + +// Non-conformant Std-libs fail to supply conformant traits (std::char_traits, +// std::allocator) and/or the std::string doesnt support them. +// We don't want to have hundreds of #ifdef workarounds, so we define +// replacement traits. +// But both char_traits and allocator traits are visible in the interface, +// (inside the final string type), thus we need to keep both +// the replacement type (typedefed to 'compatible_type') for real use, +// and the original stdlib type (typedef to 'type_for_string') for interface +// visibility. This is what Compat* classes do (as well as be transparent +// when good allocator and char traits are present) + +#ifndef BOOST_FORMAT_COMPAT_WORKAROUNDS_HPP +#define BOOST_FORMAT_COMPAT_WORKAROUNDS_HPP + +namespace boost { + namespace io { + + // gcc-2.95 char traits (non-conformantly named string_char_traits) + // lack several functions so we extend them in a replacement class. + template + class CompatTraits; + + // std::allocator in gcc-2.95 is ok, but basic_string only works + // with plain 'std::alloc' still, alt_stringbuf requires a functionnal + // alloc template argument, so we need a replacement allocator + template + class CompatAlloc; + } // N.S. io +}// N.S. boost + + +#include + // sets-up macros and load compiler-specific workarounds headers. + +#if !defined(BOOST_FORMAT_STREAMBUF_DEFINED) +// workarounds-gcc-2.95 might have defined own streambuf +#include +#endif + +#if !defined(BOOST_FORMAT_OSTREAM_DEFINED) +// workarounds-gcc-2.95 might already have included +#include +#endif + + + +namespace boost { + namespace io { + + // **** CompatTraits general definitions : ---------------------------- + template + class CompatTraits + { // general case : be transparent + public: + typedef Tr compatible_type; + }; + + // **** CompatAlloc general definitions : ----------------------------- + template + class CompatAlloc + { // general case : be transparent + public: + typedef Alloc compatible_type; + }; + + } //N.S. io +} // N.S. boost +#endif // include guard diff --git a/3rdParty/Boost/src/boost/format/detail/config_macros.hpp b/3rdParty/Boost/src/boost/format/detail/config_macros.hpp new file mode 100644 index 0000000..1f01b17 --- /dev/null +++ b/3rdParty/Boost/src/boost/format/detail/config_macros.hpp @@ -0,0 +1,97 @@ +// -*- C++ -*- +// ---------------------------------------------------------------------------- +// config_macros.hpp : configuration macros for the format library +// only BOOST_IO_STD is absolutely needed (it should be 'std::' in general) +// others are compiler-specific workaround macros used in #ifdef switches +// ---------------------------------------------------------------------------- + +// Copyright Samuel Krempp 2003. Use, modification, and distribution are +// subject to the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// see http://www.boost.org/libs/format for library home page + + +// ---------------------------------------------------------------------------- + +#ifndef BOOST_FORMAT_CONFIG_MACROS_HPP +#define BOOST_FORMAT_CONFIG_MACROS_HPP + +#include +#include + +// make sure our local macros wont override something : +#if defined(BOOST_NO_LOCALE_ISDIGIT) || defined(BOOST_OVERLOAD_FOR_NON_CONST) \ + || defined(BOOST_IO_STD) || defined( BOOST_IO_NEEDS_USING_DECLARATION ) \ + || defined(BOOST_NO_TEMPLATE_STD_STREAM) \ + || defined(BOOST_FORMAT_STREAMBUF_DEFINED) || defined(BOOST_FORMAT_OSTREAM_DEFINED) +#error "boost::format uses a local macro that is already defined." +#endif + +// specific workarounds. each header can define BOOS_IO_STD if it +// needs. (e.g. because of IO_NEEDS_USING_DECLARATION) +#include +#include + +#ifndef BOOST_IO_STD +# define BOOST_IO_STD ::std:: +#endif + +#if defined(BOOST_NO_STD_LOCALE) || \ + ( BOOST_WORKAROUND(__BORLANDC__, <= 0x564) \ + || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT( 0x570 ) ) ) +// some future __BORLANDC__ >0x564 versions might not need this +// 0x570 is Borland's kylix branch +#define BOOST_NO_LOCALE_ISDIGIT +#endif + +#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x570) ) || BOOST_WORKAROUND( BOOST_MSVC, BOOST_TESTED_AT(1300)) +#define BOOST_NO_OVERLOAD_FOR_NON_CONST +#endif + +// gcc-2.95's native stringstream is not usable +#if BOOST_WORKAROUND(__GNUC__, < 3) && !defined(__SGI_STL_PORT) && !defined(_STLPORT_VERSION) +#define BOOST_FORMAT_IGNORE_STRINGSTREAM +#endif + + +// **** Workaround for io streams, stlport and msvc. +#ifdef BOOST_IO_NEEDS_USING_DECLARATION +namespace boost { + using std::char_traits; + using std::basic_ostream; + namespace io { + using std::basic_ostream; + namespace detail { + using std::basic_ios; + using std::basic_ostream; + } + } +#if ! defined(BOOST_NO_STD_LOCALE) + using std::locale; + namespace io { + using std::locale; + namespace detail { + using std::locale; + } + } +#endif // locale +} + // -end N.S. boost +#endif // needs_using_declaration + + +// *** hide std::locale if it doesnt exist. +// this typedef is either std::locale or int, avoids placing ifdefs everywhere +namespace boost { namespace io { namespace detail { +#if ! defined(BOOST_NO_STD_LOCALE) + typedef BOOST_IO_STD locale locale_t; +#else + typedef int locale_t; +#endif +} } } + + +// ---------------------------------------------------------------------------- + +#endif // BOOST_FORMAT_MACROS_DEFAULT_HPP diff --git a/3rdParty/Boost/src/boost/format/detail/msvc_disambiguater.hpp b/3rdParty/Boost/src/boost/format/detail/msvc_disambiguater.hpp new file mode 100644 index 0000000..f12e5e9 --- /dev/null +++ b/3rdParty/Boost/src/boost/format/detail/msvc_disambiguater.hpp @@ -0,0 +1,56 @@ +// ---------------------------------------------------------------------------- +// msvc_disambiguater.hpp : msvc workarounds. (for put_{head|last} overloads) +// the trick was described in boost's list by Aleksey Gurtovoy +// ---------------------------------------------------------------------------- + +// Copyright Samuel Krempp 2003. Use, modification, and distribution are +// subject to the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// see http://www.boost.org/libs/format for library home page + +// ---------------------------------------------------------------------------- + +#ifndef BOOST_MSVC_DISAMBIGUATER_HPP +#define BOOST_MSVC_DISAMBIGUATER_HPP + +#if BOOST_WORKAROUND( BOOST_MSVC, <= 1300) || \ + BOOST_WORKAROUND(__DECCXX_VER, BOOST_TESTED_AT(60590042)) + // this whole header is specifically for msvc up to 7.0 + +#include +#include + +namespace boost { +namespace io { +namespace detail { + +template< class Ch, class Tr, class T > +struct disambiguater +{ + template< typename U > + static void put_head(BOOST_IO_STD basic_ostream& os, group1 const& x, long) + { + os << group_head(x.a1_); + } + static void put_head(BOOST_IO_STD basic_ostream& os, T const& x, int) + { + } + template< typename U > + static void put_last(BOOST_IO_STD basic_ostream& os, group1 const& x, long) + { + os << group_last(x.a1_); + } + static void put_last(BOOST_IO_STD basic_ostream& os, T const& x, int) + { + os << x; + } +}; + +} // namespace detail +} // namespace io +} // namespace boost + +#endif // -BOOST_MSVC + +#endif // -BOOST_MSVC_DISAMBIGUATER_HPP diff --git a/3rdParty/Boost/src/boost/format/detail/unset_macros.hpp b/3rdParty/Boost/src/boost/format/detail/unset_macros.hpp new file mode 100644 index 0000000..b3ac47b --- /dev/null +++ b/3rdParty/Boost/src/boost/format/detail/unset_macros.hpp @@ -0,0 +1,34 @@ +// ---------------------------------------------------------------------------- +// unset_macros.hpp +// ---------------------------------------------------------------------------- + +// Copyright Samuel Krempp 2003. Use, modification, and distribution are +// subject to the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/libs/format for library home page + +// ---------------------------------------------------------------------------- + +// *** Undefine 'local' macros : +#ifdef BOOST_NO_OVERLOAD_FOR_NON_CONST +#undef BOOST_NO_OVERLOAD_FOR_NON_CONST +#endif +#ifdef BOOST_NO_LOCALE_ISDIGIT +#undef BOOST_NO_LOCALE_ISDIGIT +#endif +#ifdef BOOST_IO_STD +#undef BOOST_IO_STD +#endif +#ifdef BOOST_IO_NEEDS_USING_DECLARATION +#undef BOOST_IO_NEEDS_USING_DECLARATION +#endif +#ifdef BOOST_NO_TEMPLATE_STD_STREAM +#undef BOOST_NO_TEMPLATE_STD_STREAM +#endif +#ifdef BOOST_FORMAT_STREAMBUF_DEFINED +#undef BOOST_FORMAT_STREAMBUF_DEFINED +#endif +#ifdef BOOST_FORMAT_OSTREAM_DEFINED +#undef BOOST_FORMAT_OSTREAM_DEFINED +#endif diff --git a/3rdParty/Boost/src/boost/format/detail/workarounds_gcc-2_95.hpp b/3rdParty/Boost/src/boost/format/detail/workarounds_gcc-2_95.hpp new file mode 100644 index 0000000..8c49d42 --- /dev/null +++ b/3rdParty/Boost/src/boost/format/detail/workarounds_gcc-2_95.hpp @@ -0,0 +1,162 @@ +// ---------------------------------------------------------------------------- +// workarounds for gcc < 3.0. +// ---------------------------------------------------------------------------- + +// Copyright Samuel Krempp 2003. Use, modification, and distribution are +// subject to the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/libs/format for library home page + + +// ---------------------------------------------------------------------------- + +// There's a lot to do, the stdlib shipped with gcc prior to 3.x +// was terribly non-conforming. +// . defines macros switches +// . supplies template classes basic_foo where gcc only supplies foo. +// i.e : +// - basic_ios from ios +// - basic_ostream from ostream +// - basic_srteambuf from streambuf +// these can be used transparently. (it obviously does not work for wchar_t) +// . specialise CompatAlloc and CompatTraits to wrap gcc-2.95's +// string_char_traits and std::alloc + +#if BOOST_WORKAROUND(__GNUC__, < 3) && !defined(__SGI_STL_PORT) && !defined(_STLPORT_VERSION) + // only for gcc-2.95's native stdlib + +#ifndef BOOST_FORMAT_WORKAROUNDS_GCC295_H +#define BOOST_FORMAT_WORKAROUNDS_GCC295_H + +// SGI STL doesnt have and others, so we need iostream. +#include +#define BOOST_FORMAT_OSTREAM_DEFINED + +#include +#define BOOST_FORMAT_STREAMBUF_DEFINED + +#define BOOST_NO_TEMPLATE_STD_STREAM + +#ifndef BOOST_IO_STD +# define BOOST_IO_STD std:: +#endif + + + +// *** +// gcc's simple classes turned into standard-like template classes : + +namespace std { + + + // gcc has string_char_traits, it's incomplete. + // we declare a std::char_traits, and specialize CompatTraits<..> on it + // to do what is required + template + class char_traits; // no definition here, we will just use it as a tag. + + template + class basic_streambuf; + + template + class basic_streambuf : public streambuf { + }; + + template > + class basic_ios; + + template + class basic_ios : public ostream { + public: + basic_ios(streambuf * p) : ostream(p) {}; + char fill() const { return ios::fill(); } // gcc returns wchar.. + char fill(char c) { return ios::fill(c); } // gcc takes wchar.. + char widen(char c) { return c; } + char narrow(char c, char def) { return c; } + basic_ios& copyfmt(const ios& right) { + fill(right.fill()); + flags(right.flags() ); + exceptions(right.exceptions()); + width(right.width()); + precision(right.precision()); + return *this; + } + }; + + + typedef ios ios_base; + + template + class basic_ostream; + + template + class basic_ostream : public basic_ios + { + public: + basic_ostream(streambuf * p) : basic_ios (p) {} + }; + +} // namespace std + + +namespace boost { + namespace io { + + + // ** CompatTraits gcc2.95 specialisations ---------------------------- + template + class CompatTraits< ::std::string_char_traits > + : public ::std::string_char_traits + { + public: + typedef CompatTraits compatible_type; + + typedef Ch char_type; + typedef int int_type; + typedef ::std::streampos pos_type; + typedef ::std::streamoff off_type; + + static char_type + to_char_type(const int_type& meta) { + return static_cast(meta); } + static int_type + to_int_type(const char_type& ch) { + return static_cast(static_cast(ch) );} + static bool + eq_int_type(const int_type& left, const int_type& right) { + return left == right; } + static int_type + eof() { + return static_cast(EOF); + } + static int_type + not_eof(const int_type& meta) { + return (meta == eof()) ? 0 : meta; + } + }; + + template + class CompatTraits< ::std::char_traits > { + public: + typedef CompatTraits< ::std::string_char_traits > compatible_type; + }; + + // ** CompatAlloc gcc-2.95 specialisations --------------------------- + template<> + class CompatAlloc< ::std::alloc> + { + public: + typedef ::std::allocator compatible_type; + }; + + } // N.S. io +} // N.S. boost + + + + + +#endif // include guard + +#endif // if workaround diff --git a/3rdParty/Boost/src/boost/format/detail/workarounds_stlport.hpp b/3rdParty/Boost/src/boost/format/detail/workarounds_stlport.hpp new file mode 100644 index 0000000..eb35dc1 --- /dev/null +++ b/3rdParty/Boost/src/boost/format/detail/workarounds_stlport.hpp @@ -0,0 +1,42 @@ +// ---------------------------------------------------------------------------- +// workarounds_stlport.hpp : workaround STLport issues +// ---------------------------------------------------------------------------- + +// Copyright Samuel Krempp 2003. Use, modification, and distribution are +// subject to the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// see http://www.boost.org/libs/format for library home page + +// ---------------------------------------------------------------------------- + +#ifndef BOOST_MACROS_STLPORT_HPP +#define BOOST_MACROS_STLPORT_HPP + +#if defined(_STLPORT_VERSION) && BOOST_WORKAROUND( BOOST_MSVC, <= 1300) +// msvc-6-stlport fails to find basic_string::append( iterator, iterator) when linking +// might affect other MSwindows compilers +#define BOOST_NO_STRING_APPEND +#endif + +// *** This should go to "boost/config/stdlib/stlport.hpp". + +// If the streams are not native and there are problems with using templates +// accross namespaces, we define some macros to enable a workaround for this. + +// STLport 4.5 +#if !defined(_STLP_OWN_IOSTREAMS) && defined(_STLP_USE_NAMESPACES) && defined(BOOST_NO_USING_TEMPLATE) +# define BOOST_IO_STD +# define BOOST_IO_NEEDS_USING_DECLARATION +#endif + +// STLport 4.0 +#if !defined(__SGI_STL_OWN_IOSTREAMS) && defined(__STL_USE_OWN_NAMESPACE) && defined(BOOST_NO_USING_TEMPLATE) +# define BOOST_IO_STD +# define BOOST_IO_NEEDS_USING_DECLARATION +#endif + + +// ---------------------------------------------------------------------------- + +#endif // BOOST_MACROS_STLPORT_HPP diff --git a/3rdParty/Boost/src/boost/format/exceptions.hpp b/3rdParty/Boost/src/boost/format/exceptions.hpp new file mode 100644 index 0000000..9b2de83 --- /dev/null +++ b/3rdParty/Boost/src/boost/format/exceptions.hpp @@ -0,0 +1,103 @@ +// ---------------------------------------------------------------------------- +// boost/format/exceptions.hpp +// ---------------------------------------------------------------------------- + +// Copyright Samuel Krempp 2003. +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// +// See http://www.boost.org/libs/format/ for library home page + +// ---------------------------------------------------------------------------- + +#ifndef BOOST_FORMAT_EXCEPTIONS_HPP +#define BOOST_FORMAT_EXCEPTIONS_HPP + + +#include + + +namespace boost { + + namespace io { + +// **** exceptions ----------------------------------------------- + + class format_error : public std::exception + { + public: + format_error() {} + virtual const char *what() const throw() { + return "boost::format_error: " + "format generic failure"; + } + }; + + class bad_format_string : public format_error + { + std::size_t pos_, next_; + public: + bad_format_string(std::size_t pos, std::size_t size) + : pos_(pos), next_(size) {} + std::size_t get_pos() const { return pos_; } + std::size_t get_next() const { return next_; } + virtual const char *what() const throw() { + return "boost::bad_format_string: format-string is ill-formed"; + } + }; + + class too_few_args : public format_error + { + std::size_t cur_, expected_; + public: + too_few_args(std::size_t cur, std::size_t expected) + : cur_(cur), expected_(expected) {} + std::size_t get_cur() const { return cur_; } + std::size_t get_expected() const { return expected_; } + virtual const char *what() const throw() { + return "boost::too_few_args: " + "format-string referred to more arguments than were passed"; + } + }; + + class too_many_args : public format_error + { + std::size_t cur_, expected_; + public: + too_many_args(std::size_t cur, std::size_t expected) + : cur_(cur), expected_(expected) {} + std::size_t get_cur() const { return cur_; } + std::size_t get_expected() const { return expected_; } + virtual const char *what() const throw() { + return "boost::too_many_args: " + "format-string referred to less arguments than were passed"; + } + }; + + + class out_of_range : public format_error + { + int index_, beg_, end_; // range is [ beg, end [ + public: + out_of_range(int index, int beg, int end) + : index_(index), beg_(beg), end_(end) {} + int get_index() const { return index_; } + int get_beg() const { return beg_; } + int get_end() const { return end_; } + virtual const char *what() const throw() { + return "boost::out_of_range: " + "tried to refer to an argument (or item) number which" + " is out of range, according to the format string"; + } + }; + + + } // namespace io + +} // namespace boost + + +#endif // BOOST_FORMAT_EXCEPTIONS_HPP diff --git a/3rdParty/Boost/src/boost/format/feed_args.hpp b/3rdParty/Boost/src/boost/format/feed_args.hpp new file mode 100644 index 0000000..53243dc --- /dev/null +++ b/3rdParty/Boost/src/boost/format/feed_args.hpp @@ -0,0 +1,277 @@ +// ---------------------------------------------------------------------------- +// feed_args.hpp : functions for processing each argument +// (feed, feed_manip, and distribute) +// ---------------------------------------------------------------------------- + +// Copyright Samuel Krempp 2003. Use, modification, and distribution are +// subject to the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/libs/format for library home page + +// ---------------------------------------------------------------------------- + +#ifndef BOOST_FORMAT_FEED_ARGS_HPP +#define BOOST_FORMAT_FEED_ARGS_HPP + +#include +#include +#include + +#include +#include +#include + +namespace boost { +namespace io { +namespace detail { + + template + void mk_str( std::basic_string & res, + const Ch * beg, + typename std::basic_string::size_type size, + std::streamsize w, + const Ch fill_char, + std::ios_base::fmtflags f, + const Ch prefix_space, // 0 if no space-padding + bool center) + // applies centered/left/right padding to the string [beg, beg+size[ + // Effects : the result is placed in res. + { + typedef typename std::basic_string::size_type size_type; + res.resize(0); + if(w<=0 || static_cast(w) <=size) { + // no need to pad. + res.reserve(size + !!prefix_space); + if(prefix_space) + res.append(1, prefix_space); + if (size) + res.append(beg, size); + } + else { + std::streamsize n=static_cast(w-size-!!prefix_space); + std::streamsize n_after = 0, n_before = 0; + res.reserve(static_cast(w)); // allocate once for the 2 inserts + if(center) + n_after = n/2, n_before = n - n_after; + else + if(f & std::ios_base::left) + n_after = n; + else + n_before = n; + // now make the res string : + if(n_before) res.append(static_cast(n_before), fill_char); + if(prefix_space) + res.append(1, prefix_space); + if (size) + res.append(beg, size); + if(n_after) res.append(static_cast(n_after), fill_char); + } + } // -mk_str(..) + + +#if BOOST_WORKAROUND( BOOST_MSVC, <= 1300) || \ + BOOST_WORKAROUND(__DECCXX_VER, BOOST_TESTED_AT(60590042)) +// MSVC needs to be tricked to disambiguate this simple overload.. +// the trick is in "boost/format/msvc_disambiguater.hpp" + + template< class Ch, class Tr, class T> inline + void put_head (BOOST_IO_STD basic_ostream & os, const T& x ) { + disambiguater::put_head(os, x, 1L); + } + template< class Ch, class Tr, class T> inline + void put_last (BOOST_IO_STD basic_ostream & os, const T& x ) { + disambiguater::put_last(os, x, 1L); + } + +#else + + template< class Ch, class Tr, class T> inline + void put_head (BOOST_IO_STD basic_ostream &, const T& ) { + } + + template< class Ch, class Tr, class T> inline + void put_head( BOOST_IO_STD basic_ostream & os, const group1& x ) { + os << group_head(x.a1_); // send the first N-1 items, not the last + } + + template< class Ch, class Tr, class T> inline + void put_last( BOOST_IO_STD basic_ostream & os, const T& x ) { + os << x ; + } + + template< class Ch, class Tr, class T> inline + void put_last( BOOST_IO_STD basic_ostream & os, const group1& x ) { + os << group_last(x.a1_); // this selects the last element + } + +#ifndef BOOST_NO_OVERLOAD_FOR_NON_CONST + template< class Ch, class Tr, class T> inline + void put_head( BOOST_IO_STD basic_ostream &, T& ) { + } + + template< class Ch, class Tr, class T> inline + void put_last( BOOST_IO_STD basic_ostream & os, T& x) { + os << x ; + } +#endif +#endif // -msvc workaround + + + template< class Ch, class Tr, class Alloc, class T> + void put( T x, + const format_item& specs, + typename basic_format::string_type& res, + typename basic_format::internal_streambuf_t & buf, + io::detail::locale_t *loc_p = NULL) + { +#ifdef BOOST_MSVC + // If std::min or std::max are already instantiated + // at this point then we get a blizzard of warning messages when we call + // those templates with std::size_t as arguments. Weird and very annoyning... +#pragma warning(push) +#pragma warning(disable:4267) +#endif + // does the actual conversion of x, with given params, into a string + // using the supplied stringbuf. + + typedef typename basic_format::string_type string_type; + typedef typename basic_format::format_item_t format_item_t; + typedef typename string_type::size_type size_type; + + basic_oaltstringstream oss( &buf); + specs.fmtstate_.apply_on(oss, loc_p); + + // the stream format state can be modified by manipulators in the argument : + put_head( oss, x ); + // in case x is a group, apply the manip part of it, + // in order to find width + + const std::ios_base::fmtflags fl=oss.flags(); + const bool internal = (fl & std::ios_base::internal) != 0; + const std::streamsize w = oss.width(); + const bool two_stepped_padding= internal && (w!=0); + + res.resize(0); + if(! two_stepped_padding) { + if(w>0) // handle padding via mk_str, not natively in stream + oss.width(0); + put_last( oss, x); + const Ch * res_beg = buf.pbase(); + Ch prefix_space = 0; + if(specs.pad_scheme_ & format_item_t::spacepad) + if(buf.pcount()== 0 || + (res_beg[0] !=oss.widen('+') && res_beg[0] !=oss.widen('-') )) + prefix_space = oss.widen(' '); + size_type res_size = (std::min)( + static_cast(specs.truncate_ - !!prefix_space), + buf.pcount() ); + mk_str(res, res_beg, res_size, w, oss.fill(), fl, + prefix_space, (specs.pad_scheme_ & format_item_t::centered) !=0 ); + } + else { // 2-stepped padding + // internal can be implied by zeropad, or user-set. + // left, right, and centered alignment overrule internal, + // but spacepad or truncate might be mixed with internal (using manipulator) + put_last( oss, x); // may pad + const Ch * res_beg = buf.pbase(); + size_type res_size = buf.pcount(); + bool prefix_space=false; + if(specs.pad_scheme_ & format_item_t::spacepad) + if(buf.pcount()== 0 || + (res_beg[0] !=oss.widen('+') && res_beg[0] !=oss.widen('-') )) + prefix_space = true; + if(res_size == static_cast(w) && w<=specs.truncate_ && !prefix_space) { + // okay, only one thing was printed and padded, so res is fine + res.assign(res_beg, res_size); + } + else { // length w exceeded + // either it was multi-output with first output padding up all width.. + // either it was one big arg and we are fine. + // Note that res_size oss2( &buf); + specs.fmtstate_.apply_on(oss2, loc_p); + put_head( oss2, x ); + + oss2.width(0); + if(prefix_space) + oss2 << ' '; + put_last(oss2, x ); + if(buf.pcount()==0 && specs.pad_scheme_ & format_item_t::spacepad) { + prefix_space =true; + oss2 << ' '; + } + // we now have the minimal-length output + const Ch * tmp_beg = buf.pbase(); + size_type tmp_size = (std::min)(static_cast(specs.truncate_), + buf.pcount() ); + + + if(static_cast(w) <= tmp_size) { + // minimal length is already >= w, so no padding (cool!) + res.assign(tmp_beg, tmp_size); + } + else { // hum.. we need to pad (multi_output, or spacepad present) + //find where we should pad + size_type sz = (std::min)(res_size + (prefix_space ? 1 : 0), tmp_size); + size_type i = prefix_space; + for(; i=tmp_size) i=prefix_space; + res.assign(tmp_beg, i); + std::streamsize d = w - static_cast(tmp_size); + BOOST_ASSERT(d>0); + res.append(static_cast( d ), oss2.fill()); + res.append(tmp_beg+i, tmp_size-i); + BOOST_ASSERT(i+(tmp_size-i)+(std::max)(d,(std::streamsize)0) + == static_cast(w)); + BOOST_ASSERT(res.size() == static_cast(w)); + } + } + } + buf.clear_buffer(); +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + } // end- put(..) + + + template< class Ch, class Tr, class Alloc, class T> + void distribute (basic_format& self, T x) { + // call put(x, ..) on every occurence of the current argument : + if(self.cur_arg_ >= self.num_args_) { + if( self.exceptions() & too_many_args_bit ) + boost::throw_exception(too_many_args(self.cur_arg_, self.num_args_)); + else return; + } + for(unsigned long i=0; i < self.items_.size(); ++i) { + if(self.items_[i].argN_ == self.cur_arg_) { + put (x, self.items_[i], self.items_[i].res_, + self.buf_, boost::get_pointer(self.loc_) ); + } + } + } + + template + basic_format& + feed (basic_format& self, T x) { + if(self.dumped_) self.clear(); + distribute (self, x); + ++self.cur_arg_; + if(self.bound_.size() != 0) { + while( self.cur_arg_ < self.num_args_ && self.bound_[self.cur_arg_] ) + ++self.cur_arg_; + } + return self; + } + +} // namespace detail +} // namespace io +} // namespace boost + + +#endif // BOOST_FORMAT_FEED_ARGS_HPP diff --git a/3rdParty/Boost/src/boost/format/format_class.hpp b/3rdParty/Boost/src/boost/format/format_class.hpp new file mode 100644 index 0000000..4555e56 --- /dev/null +++ b/3rdParty/Boost/src/boost/format/format_class.hpp @@ -0,0 +1,168 @@ +// ---------------------------------------------------------------------------- +// format_class.hpp : class interface +// ---------------------------------------------------------------------------- + +// Copyright Samuel Krempp 2003. Use, modification, and distribution are +// subject to the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/libs/format for library home page + +// ---------------------------------------------------------------------------- + +#ifndef BOOST_FORMAT_CLASS_HPP +#define BOOST_FORMAT_CLASS_HPP + + +#include +#include + +#include // to store locale when needed + +#include +#include +#include +#include + +namespace boost { + + template + class basic_format + { + typedef typename io::CompatTraits::compatible_type compat_traits; + public: + typedef Ch CharT; // borland fails in operator% if we use Ch and Tr directly + typedef std::basic_string string_type; + typedef typename string_type::size_type size_type; + typedef io::detail::format_item format_item_t; + typedef io::basic_altstringbuf internal_streambuf_t; + + + explicit basic_format(const Ch* str=NULL); + explicit basic_format(const string_type& s); + basic_format(const basic_format& x); + basic_format& operator= (const basic_format& x); + void swap(basic_format& x); + +#if !defined(BOOST_NO_STD_LOCALE) + explicit basic_format(const Ch* str, const std::locale & loc); + explicit basic_format(const string_type& s, const std::locale & loc); +#endif + io::detail::locale_t getloc() const; + + basic_format& clear(); // empty all converted string buffers (except bound items) + basic_format& clear_binds(); // unbind all bound items, and call clear() + basic_format& parse(const string_type&); // resets buffers and parse a new format string + + // ** formatted result ** // + size_type size() const; // sum of the current string pieces sizes + string_type str() const; // final string + + // ** arguments passing ** // + template + basic_format& operator%(const T& x) + { return io::detail::feed(*this,x); } + +#ifndef BOOST_NO_OVERLOAD_FOR_NON_CONST + template basic_format& operator%(T& x) + { return io::detail::feed(*this,x); } +#endif + +#if defined(__GNUC__) + // GCC can't handle anonymous enums without some help + // ** arguments passing ** // + basic_format& operator%(const int& x) + { return io::detail::feed(*this,x); } + +#ifndef BOOST_NO_OVERLOAD_FOR_NON_CONST + basic_format& operator%(int& x) + { return io::detail::feed(*this,x); } +#endif +#endif + + // The total number of arguments expected to be passed to the format objectt + int expected_args() const + { return num_args_; } + // The number of arguments currently bound (see bind_arg(..) ) + int bound_args() const; + // The number of arguments currently fed to the format object + int fed_args() const; + // The index (1-based) of the current argument (i.e. next to be formatted) + int cur_arg() const; + // The number of arguments still required to be fed + int remaining_args() const; // same as expected_args() - bound_args() - fed_args() + + + // ** object modifying **// + template + basic_format& bind_arg(int argN, const T& val) + { return io::detail::bind_arg_body(*this, argN, val); } + basic_format& clear_bind(int argN); + template + basic_format& modify_item(int itemN, T manipulator) + { return io::detail::modify_item_body (*this, itemN, manipulator);} + + // Choosing which errors will throw exceptions : + unsigned char exceptions() const; + unsigned char exceptions(unsigned char newexcept); + +#if !defined( BOOST_NO_MEMBER_TEMPLATE_FRIENDS ) \ + && !BOOST_WORKAROUND(__BORLANDC__, <= 0x570) \ + && !BOOST_WORKAROUND( _CRAYC, != 0) \ + && !BOOST_WORKAROUND(__DECCXX_VER, BOOST_TESTED_AT(60590042)) + // use friend templates and private members only if supported + +#ifndef BOOST_NO_TEMPLATE_STD_STREAM + template + friend std::basic_ostream & + operator<<( std::basic_ostream & , + const basic_format& ); +#else + template + friend std::ostream & + operator<<( std::ostream & , + const basic_format& ); +#endif + + template + friend basic_format& + io::detail::feed (basic_format&, T); + + template friend + void io::detail::distribute (basic_format&, T); + + template friend + basic_format& + io::detail::modify_item_body (basic_format&, int, T); + + template friend + basic_format& + io::detail::bind_arg_body (basic_format&, int, const T&); + + private: +#endif + typedef io::detail::stream_format_state stream_format_state; + // flag bits, used for style_ + enum style_values { ordered = 1, // set only if all directives are positional + special_needs = 4 }; + + void make_or_reuse_data(std::size_t nbitems);// used for (re-)initialisation + + // member data --------------------------------------------// + std::vector items_; // each '%..' directive leads to a format_item + std::vector bound_; // stores which arguments were bound. size() == 0 || num_args + + int style_; // style of format-string : positional or not, etc + int cur_arg_; // keep track of wich argument is current + int num_args_; // number of expected arguments + mutable bool dumped_; // true only after call to str() or << + string_type prefix_; // piece of string to insert before first item + unsigned char exceptions_; + internal_streambuf_t buf_; // the internal stream buffer. + boost::optional loc_; + }; // class basic_format + +} // namespace boost + + +#endif // BOOST_FORMAT_CLASS_HPP diff --git a/3rdParty/Boost/src/boost/format/format_fwd.hpp b/3rdParty/Boost/src/boost/format/format_fwd.hpp new file mode 100644 index 0000000..be3228a --- /dev/null +++ b/3rdParty/Boost/src/boost/format/format_fwd.hpp @@ -0,0 +1,49 @@ +// ---------------------------------------------------------------------------- +// format_fwd.hpp : forward declarations +// ---------------------------------------------------------------------------- + +// Copyright Samuel Krempp 2003. Use, modification, and distribution are +// subject to the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/libs/format for library home page + +// ---------------------------------------------------------------------------- + +#ifndef BOOST_FORMAT_FWD_HPP +#define BOOST_FORMAT_FWD_HPP + +#include +#include + +#include + +namespace boost { + + template , class Alloc = std::allocator > +#else + class Tr = std::string_char_traits, class Alloc = std::alloc > +#endif + class basic_format; + + typedef basic_format format; + +#if !defined(BOOST_NO_STD_WSTRING) && !defined(BOOST_NO_STD_WSTREAMBUF) \ + && !defined(BOOST_FORMAT_IGNORE_STRINGSTREAM) + typedef basic_format wformat; +#endif + + namespace io { + enum format_error_bits { bad_format_string_bit = 1, + too_few_args_bit = 2, too_many_args_bit = 4, + out_of_range_bit = 8, + all_error_bits = 255, no_error_bits=0 }; + + } // namespace io + +} // namespace boost + +#endif // BOOST_FORMAT_FWD_HPP diff --git a/3rdParty/Boost/src/boost/format/format_implementation.hpp b/3rdParty/Boost/src/boost/format/format_implementation.hpp new file mode 100644 index 0000000..2abb5c4 --- /dev/null +++ b/3rdParty/Boost/src/boost/format/format_implementation.hpp @@ -0,0 +1,329 @@ +// ---------------------------------------------------------------------------- +// format_implementation.hpp Implementation of the basic_format class +// ---------------------------------------------------------------------------- + +// Copyright Samuel Krempp 2003. Use, modification, and distribution are +// subject to the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/libs/format for library home page + + +// ---------------------------------------------------------------------------- + +#ifndef BOOST_FORMAT_IMPLEMENTATION_HPP +#define BOOST_FORMAT_IMPLEMENTATION_HPP + +#include +#include +#include +#include +#include // std::swap + +namespace boost { + +// --- basic_format implementation -----------------------------------------// + + template< class Ch, class Tr, class Alloc> + basic_format:: basic_format(const Ch* s) + : style_(0), cur_arg_(0), num_args_(0), dumped_(false), + exceptions_(io::all_error_bits) + { + if( s) + parse( s ); + } + +#if !defined(BOOST_NO_STD_LOCALE) + template< class Ch, class Tr, class Alloc> + basic_format:: basic_format(const Ch* s, const std::locale & loc) + : style_(0), cur_arg_(0), num_args_(0), dumped_(false), + exceptions_(io::all_error_bits), loc_(loc) + { + if(s) parse( s ); + } + + template< class Ch, class Tr, class Alloc> + basic_format:: basic_format(const string_type& s, const std::locale & loc) + : style_(0), cur_arg_(0), num_args_(0), dumped_(false), + exceptions_(io::all_error_bits), loc_(loc) + { + parse(s); + } +#endif // ! BOOST_NO_STD_LOCALE + template< class Ch, class Tr, class Alloc> + io::detail::locale_t basic_format:: + getloc() const { + return loc_ ? loc_.get() : io::detail::locale_t(); + } + + template< class Ch, class Tr, class Alloc> + basic_format:: basic_format(const string_type& s) + : style_(0), cur_arg_(0), num_args_(0), dumped_(false), + exceptions_(io::all_error_bits) + { + parse(s); + } + + template< class Ch, class Tr, class Alloc> // just don't copy the buf_ member + basic_format:: basic_format(const basic_format& x) + : items_(x.items_), bound_(x.bound_), style_(x.style_), + cur_arg_(x.cur_arg_), num_args_(x.num_args_), dumped_(x.dumped_), + prefix_(x.prefix_), exceptions_(x.exceptions_), loc_(x.loc_) + { + } + + template< class Ch, class Tr, class Alloc> // just don't copy the buf_ member + basic_format& basic_format:: + operator= (const basic_format& x) { + if(this == &x) + return *this; + (basic_format(x)).swap(*this); + return *this; + } + template< class Ch, class Tr, class Alloc> + void basic_format:: + swap (basic_format & x) { + std::swap(exceptions_, x.exceptions_); + std::swap(style_, x.style_); + std::swap(cur_arg_, x.cur_arg_); + std::swap(num_args_, x.num_args_); + std::swap(dumped_, x.dumped_); + + items_.swap(x.items_); + prefix_.swap(x.prefix_); + bound_.swap(x.bound_); + } + + template< class Ch, class Tr, class Alloc> + unsigned char basic_format:: exceptions() const { + return exceptions_; + } + + template< class Ch, class Tr, class Alloc> + unsigned char basic_format:: exceptions(unsigned char newexcept) { + unsigned char swp = exceptions_; + exceptions_ = newexcept; + return swp; + } + + template + void basic_format:: + make_or_reuse_data (std::size_t nbitems) { +#if !defined(BOOST_NO_STD_LOCALE) + Ch fill = ( BOOST_USE_FACET(std::ctype, getloc()) ). widen(' '); +#else + Ch fill = ' '; +#endif + if(items_.size() == 0) + items_.assign( nbitems, format_item_t(fill) ); + else { + if(nbitems>items_.size()) + items_.resize(nbitems, format_item_t(fill)); + bound_.resize(0); + for(std::size_t i=0; i < nbitems; ++i) + items_[i].reset(fill); // strings are resized, instead of reallocated + } + prefix_.resize(0); + } + + template< class Ch, class Tr, class Alloc> + basic_format& basic_format:: + clear () { + // empty the string buffers (except bound arguments) + // and make the format object ready for formatting a new set of arguments + + BOOST_ASSERT( bound_.size()==0 || num_args_ == static_cast(bound_.size()) ); + + for(unsigned long i=0; i + basic_format& basic_format:: + clear_binds () { + // remove all binds, then clear() + bound_.resize(0); + clear(); + return *this; + } + + template< class Ch, class Tr, class Alloc> + basic_format& basic_format:: + clear_bind (int argN) { + // remove the bind of ONE argument then clear() + if(argN<1 || argN > num_args_ || bound_.size()==0 || !bound_[argN-1] ) { + if( exceptions() & io::out_of_range_bit) + boost::throw_exception(io::out_of_range(argN, 1, num_args_+1 ) ); + else return *this; + } + bound_[argN-1]=false; + clear(); + return *this; + } + + template< class Ch, class Tr, class Alloc> + int basic_format:: + bound_args() const { + if(bound_.size()==0) + return 0; + int n=0; + for(int i=0; i + int basic_format:: + fed_args() const { + if(bound_.size()==0) + return cur_arg_; + int n=0; + for(int i=0; i + int basic_format:: + cur_arg() const { + return cur_arg_+1; } + + template< class Ch, class Tr, class Alloc> + int basic_format:: + remaining_args() const { + if(bound_.size()==0) + return num_args_-cur_arg_; + int n=0; + for(int i=cur_arg_; i + typename basic_format::string_type + basic_format:: + str () const { + if(items_.size()==0) + return prefix_; + if( cur_arg_ < num_args_) + if( exceptions() & io::too_few_args_bit ) + // not enough variables supplied + boost::throw_exception(io::too_few_args(cur_arg_, num_args_)); + + unsigned long i; + string_type res; + res.reserve(size()); + res += prefix_; + for(i=0; i < items_.size(); ++i) { + const format_item_t& item = items_[i]; + res += item.res_; + if( item.argN_ == format_item_t::argN_tabulation) { + BOOST_ASSERT( item.pad_scheme_ & format_item_t::tabulation); + if( static_cast(item.fmtstate_.width_) > res.size() ) + res.append( static_cast(item.fmtstate_.width_) - res.size(), + item.fmtstate_.fill_ ); + } + res += item.appendix_; + } + dumped_=true; + return res; + } + template< class Ch, class Tr, class Alloc> + typename std::basic_string::size_type basic_format:: + size () const { +#ifdef BOOST_MSVC + // If std::min or std::max are already instantiated + // at this point then we get a blizzard of warning messages when we call + // those templates with std::size_t as arguments. Weird and very annoyning... +#pragma warning(push) +#pragma warning(disable:4267) +#endif + BOOST_USING_STD_MAX(); + size_type sz = prefix_.size(); + unsigned long i; + for(i=0; i < items_.size(); ++i) { + const format_item_t& item = items_[i]; + sz += item.res_.size(); + if( item.argN_ == format_item_t::argN_tabulation) + sz = max BOOST_PREVENT_MACRO_SUBSTITUTION (sz, + static_cast(item.fmtstate_.width_) ); + sz += item.appendix_.size(); + } + return sz; +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + } + +namespace io { +namespace detail { + + template + basic_format& + bind_arg_body (basic_format& self, int argN, const T& val) { + // bind one argument to a fixed value + // this is persistent over clear() calls, thus also over str() and << + if(self.dumped_) + self.clear(); // needed because we will modify cur_arg_ + if(argN<1 || argN > self.num_args_) { + if( self.exceptions() & io::out_of_range_bit ) + boost::throw_exception(io::out_of_range(argN, 1, self.num_args_+1 ) ); + else return self; + } + if(self.bound_.size()==0) + self.bound_.assign(self.num_args_,false); + else + BOOST_ASSERT( self.num_args_ == static_cast(self.bound_.size()) ); + int o_cur_arg = self.cur_arg_; + self.cur_arg_ = argN-1; // arrays begin at 0 + + self.bound_[self.cur_arg_]=false; // if already set, we unset and re-sets.. + self.operator%(val); // put val at the right place, because cur_arg is set + + + // Now re-position cur_arg before leaving : + self.cur_arg_ = o_cur_arg; + self.bound_[argN-1]=true; + if(self.cur_arg_ == argN-1 ) { + // hum, now this arg is bound, so move to next free arg + while(self.cur_arg_ < self.num_args_ && self.bound_[self.cur_arg_]) + ++self.cur_arg_; + } + // In any case, we either have all args, or are on an unbound arg : + BOOST_ASSERT( self.cur_arg_ >= self.num_args_ || ! self.bound_[self.cur_arg_]); + return self; + } + + template basic_format& + modify_item_body (basic_format& self, int itemN, T manipulator) { + // applies a manipulator to the format_item describing a given directive. + // this is a permanent change, clear or reset won't cancel that. + if(itemN<1 || itemN > static_cast(self.items_.size() )) { + if( self.exceptions() & io::out_of_range_bit ) + boost::throw_exception(io::out_of_range(itemN, 1, static_cast(self.items_.size()) )); + else return self; + } + self.items_[itemN-1].fmtstate_. template apply_manip ( manipulator ); + return self; + } + +} // namespace detail +} // namespace io +} // namespace boost + + + +#endif // BOOST_FORMAT_IMPLEMENTATION_HPP diff --git a/3rdParty/Boost/src/boost/format/free_funcs.hpp b/3rdParty/Boost/src/boost/format/free_funcs.hpp new file mode 100644 index 0000000..3a51545 --- /dev/null +++ b/3rdParty/Boost/src/boost/format/free_funcs.hpp @@ -0,0 +1,70 @@ +// ---------------------------------------------------------------------------- +// free_funcs.hpp : implementation of the free functions of boost::format +// ---------------------------------------------------------------------------- + +// Copyright Samuel Krempp 2003. Use, modification, and distribution are +// subject to the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/libs/format for library home page + +// ---------------------------------------------------------------------------- + +#ifndef BOOST_FORMAT_FUNCS_HPP +#define BOOST_FORMAT_FUNCS_HPP + +#include +#include + +namespace boost { + + template inline + std::basic_string str(const basic_format& f) { + // adds up all pieces of strings and converted items, and return the formatted string + return f.str(); + } + namespace io { + using ::boost::str; // keep compatibility with when it was defined in this N.S. + } // - namespace io + +#ifndef BOOST_NO_TEMPLATE_STD_STREAM + template + std::basic_ostream & + operator<<( std::basic_ostream & os, + const basic_format& f) +#else + template + std::ostream & + operator<<( std::ostream & os, + const basic_format& f) +#endif + // effect: "return os << str(f);" but we can do it faster + { + typedef boost::basic_format format_t; + if(f.items_.size()==0) + os << f.prefix_; + else { + if(f.cur_arg_ < f.num_args_) + if( f.exceptions() & io::too_few_args_bit ) + // not enough variables supplied + boost::throw_exception(io::too_few_args(f.cur_arg_, f.num_args_)); + if(f.style_ & format_t::special_needs) + os << f.str(); + else { + // else we dont have to count chars output, so we dump directly to os : + os << f.prefix_; + for(unsigned long i=0; i + + +namespace boost { +namespace io { + + +namespace detail { + + +// empty group, but useful even though. +struct group0 +{ + group0() {} +}; + +template +inline +BOOST_IO_STD basic_ostream& +operator << ( BOOST_IO_STD basic_ostream& os, + const group0& ) +{ + return os; +} + +template +struct group1 +{ + T1 a1_; + group1(T1 a1) + : a1_(a1) + {} +private: + group1& operator=(const group1&); +}; + +template +inline +BOOST_IO_STD basic_ostream& +operator << (BOOST_IO_STD basic_ostream& os, + const group1& x) +{ + os << x.a1_; + return os; +} + + + + +template +struct group2 +{ + T1 a1_; + T2 a2_; + group2(T1 a1,T2 a2) + : a1_(a1),a2_(a2) + {} +private: + group2& operator=(const group2&); +}; + +template +inline +BOOST_IO_STD basic_ostream& +operator << (BOOST_IO_STD basic_ostream& os, + const group2& x) +{ + os << x.a1_<< x.a2_; + return os; +} + +template +struct group3 +{ + T1 a1_; + T2 a2_; + T3 a3_; + group3(T1 a1,T2 a2,T3 a3) + : a1_(a1),a2_(a2),a3_(a3) + {} +private: + group3& operator=(const group3&); +}; + +template +inline +BOOST_IO_STD basic_ostream& +operator << (BOOST_IO_STD basic_ostream& os, + const group3& x) +{ + os << x.a1_<< x.a2_<< x.a3_; + return os; +} + +template +struct group4 +{ + T1 a1_; + T2 a2_; + T3 a3_; + T4 a4_; + group4(T1 a1,T2 a2,T3 a3,T4 a4) + : a1_(a1),a2_(a2),a3_(a3),a4_(a4) + {} +private: + group4& operator=(const group4&); +}; + +template +inline +BOOST_IO_STD basic_ostream& +operator << (BOOST_IO_STD basic_ostream& os, + const group4& x) +{ + os << x.a1_<< x.a2_<< x.a3_<< x.a4_; + return os; +} + +template +struct group5 +{ + T1 a1_; + T2 a2_; + T3 a3_; + T4 a4_; + T5 a5_; + group5(T1 a1,T2 a2,T3 a3,T4 a4,T5 a5) + : a1_(a1),a2_(a2),a3_(a3),a4_(a4),a5_(a5) + {} +}; + +template +inline +BOOST_IO_STD basic_ostream& +operator << (BOOST_IO_STD basic_ostream& os, + const group5& x) +{ + os << x.a1_<< x.a2_<< x.a3_<< x.a4_<< x.a5_; + return os; +} + +template +struct group6 +{ + T1 a1_; + T2 a2_; + T3 a3_; + T4 a4_; + T5 a5_; + T6 a6_; + group6(T1 a1,T2 a2,T3 a3,T4 a4,T5 a5,T6 a6) + : a1_(a1),a2_(a2),a3_(a3),a4_(a4),a5_(a5),a6_(a6) + {} +}; + +template +inline +BOOST_IO_STD basic_ostream& +operator << (BOOST_IO_STD basic_ostream& os, + const group6& x) +{ + os << x.a1_<< x.a2_<< x.a3_<< x.a4_<< x.a5_<< x.a6_; + return os; +} + +template +struct group7 +{ + T1 a1_; + T2 a2_; + T3 a3_; + T4 a4_; + T5 a5_; + T6 a6_; + T7 a7_; + group7(T1 a1,T2 a2,T3 a3,T4 a4,T5 a5,T6 a6,T7 a7) + : a1_(a1),a2_(a2),a3_(a3),a4_(a4),a5_(a5),a6_(a6),a7_(a7) + {} +}; + +template +inline +BOOST_IO_STD basic_ostream& +operator << (BOOST_IO_STD basic_ostream& os, + const group7& x) +{ + os << x.a1_<< x.a2_<< x.a3_<< x.a4_<< x.a5_<< x.a6_<< x.a7_; + return os; +} + +template +struct group8 +{ + T1 a1_; + T2 a2_; + T3 a3_; + T4 a4_; + T5 a5_; + T6 a6_; + T7 a7_; + T8 a8_; + group8(T1 a1,T2 a2,T3 a3,T4 a4,T5 a5,T6 a6,T7 a7,T8 a8) + : a1_(a1),a2_(a2),a3_(a3),a4_(a4),a5_(a5),a6_(a6),a7_(a7),a8_(a8) + {} +}; + +template +inline +BOOST_IO_STD basic_ostream& +operator << (BOOST_IO_STD basic_ostream& os, + const group8& x) +{ + os << x.a1_<< x.a2_<< x.a3_<< x.a4_<< x.a5_<< x.a6_<< x.a7_<< x.a8_; + return os; +} + +template +struct group9 +{ + T1 a1_; + T2 a2_; + T3 a3_; + T4 a4_; + T5 a5_; + T6 a6_; + T7 a7_; + T8 a8_; + T9 a9_; + group9(T1 a1,T2 a2,T3 a3,T4 a4,T5 a5,T6 a6,T7 a7,T8 a8,T9 a9) + : a1_(a1),a2_(a2),a3_(a3),a4_(a4),a5_(a5),a6_(a6),a7_(a7),a8_(a8),a9_(a9) + {} +}; + +template +inline +BOOST_IO_STD basic_ostream& +operator << (BOOST_IO_STD basic_ostream& os, + const group9& x) +{ + os << x.a1_<< x.a2_<< x.a3_<< x.a4_<< x.a5_<< x.a6_<< x.a7_<< x.a8_<< x.a9_; + return os; +} + +template +struct group10 +{ + T1 a1_; + T2 a2_; + T3 a3_; + T4 a4_; + T5 a5_; + T6 a6_; + T7 a7_; + T8 a8_; + T9 a9_; + T10 a10_; + group10(T1 a1,T2 a2,T3 a3,T4 a4,T5 a5,T6 a6,T7 a7,T8 a8,T9 a9,T10 a10) + : a1_(a1),a2_(a2),a3_(a3),a4_(a4),a5_(a5),a6_(a6),a7_(a7),a8_(a8),a9_(a9),a10_(a10) + {} +}; + +template +inline +BOOST_IO_STD basic_ostream& +operator << (BOOST_IO_STD basic_ostream& os, + const group10& x) +{ + os << x.a1_<< x.a2_<< x.a3_<< x.a4_<< x.a5_<< x.a6_<< x.a7_<< x.a8_<< x.a9_<< x.a10_; + return os; +} + + + + +template +inline +group1 +group_head( group2 const& x) +{ + return group1 (x.a1_); +} + +template +inline +group1 +group_last( group2 const& x) +{ + return group1 (x.a2_); +} + + + +template +inline +group2 +group_head( group3 const& x) +{ + return group2 (x.a1_,x.a2_); +} + +template +inline +group1 +group_last( group3 const& x) +{ + return group1 (x.a3_); +} + + + +template +inline +group3 +group_head( group4 const& x) +{ + return group3 (x.a1_,x.a2_,x.a3_); +} + +template +inline +group1 +group_last( group4 const& x) +{ + return group1 (x.a4_); +} + + + +template +inline +group4 +group_head( group5 const& x) +{ + return group4 (x.a1_,x.a2_,x.a3_,x.a4_); +} + +template +inline +group1 +group_last( group5 const& x) +{ + return group1 (x.a5_); +} + + + +template +inline +group5 +group_head( group6 const& x) +{ + return group5 (x.a1_,x.a2_,x.a3_,x.a4_,x.a5_); +} + +template +inline +group1 +group_last( group6 const& x) +{ + return group1 (x.a6_); +} + + + +template +inline +group6 +group_head( group7 const& x) +{ + return group6 (x.a1_,x.a2_,x.a3_,x.a4_,x.a5_,x.a6_); +} + +template +inline +group1 +group_last( group7 const& x) +{ + return group1 (x.a7_); +} + + + +template +inline +group7 +group_head( group8 const& x) +{ + return group7 (x.a1_,x.a2_,x.a3_,x.a4_,x.a5_,x.a6_,x.a7_); +} + +template +inline +group1 +group_last( group8 const& x) +{ + return group1 (x.a8_); +} + + + +template +inline +group8 +group_head( group9 const& x) +{ + return group8 (x.a1_,x.a2_,x.a3_,x.a4_,x.a5_,x.a6_,x.a7_,x.a8_); +} + +template +inline +group1 +group_last( group9 const& x) +{ + return group1 (x.a9_); +} + + + +template +inline +group9 +group_head( group10 const& x) +{ + return group9 (x.a1_,x.a2_,x.a3_,x.a4_,x.a5_,x.a6_,x.a7_,x.a8_,x.a9_); +} + +template +inline +group1 +group_last( group10 const& x) +{ + return group1 (x.a10_); +} + + + + + +} // namespace detail + + + +// helper functions + + +inline detail::group1< detail::group0 > +group() { return detail::group1< detail::group0 > ( detail::group0() ); } + +template +inline +detail::group1< detail::group2 > + group(T1 a1, Var const& var) +{ + return detail::group1< detail::group2 > + ( detail::group2 + (a1, var) + ); +} + +template +inline +detail::group1< detail::group3 > + group(T1 a1,T2 a2, Var const& var) +{ + return detail::group1< detail::group3 > + ( detail::group3 + (a1,a2, var) + ); +} + +template +inline +detail::group1< detail::group4 > + group(T1 a1,T2 a2,T3 a3, Var const& var) +{ + return detail::group1< detail::group4 > + ( detail::group4 + (a1,a2,a3, var) + ); +} + +template +inline +detail::group1< detail::group5 > + group(T1 a1,T2 a2,T3 a3,T4 a4, Var const& var) +{ + return detail::group1< detail::group5 > + ( detail::group5 + (a1,a2,a3,a4, var) + ); +} + +template +inline +detail::group1< detail::group6 > + group(T1 a1,T2 a2,T3 a3,T4 a4,T5 a5, Var const& var) +{ + return detail::group1< detail::group6 > + ( detail::group6 + (a1,a2,a3,a4,a5, var) + ); +} + +template +inline +detail::group1< detail::group7 > + group(T1 a1,T2 a2,T3 a3,T4 a4,T5 a5,T6 a6, Var const& var) +{ + return detail::group1< detail::group7 > + ( detail::group7 + (a1,a2,a3,a4,a5,a6, var) + ); +} + +template +inline +detail::group1< detail::group8 > + group(T1 a1,T2 a2,T3 a3,T4 a4,T5 a5,T6 a6,T7 a7, Var const& var) +{ + return detail::group1< detail::group8 > + ( detail::group8 + (a1,a2,a3,a4,a5,a6,a7, var) + ); +} + +template +inline +detail::group1< detail::group9 > + group(T1 a1,T2 a2,T3 a3,T4 a4,T5 a5,T6 a6,T7 a7,T8 a8, Var const& var) +{ + return detail::group1< detail::group9 > + ( detail::group9 + (a1,a2,a3,a4,a5,a6,a7,a8, var) + ); +} + +template +inline +detail::group1< detail::group10 > + group(T1 a1,T2 a2,T3 a3,T4 a4,T5 a5,T6 a6,T7 a7,T8 a8,T9 a9, Var const& var) +{ + return detail::group1< detail::group10 > + ( detail::group10 + (a1,a2,a3,a4,a5,a6,a7,a8,a9, var) + ); +} + + +#ifndef BOOST_NO_OVERLOAD_FOR_NON_CONST + +template +inline +detail::group1< detail::group2 > + group(T1 a1, Var& var) +{ + return detail::group1< detail::group2 > + ( detail::group2 + (a1, var) + ); +} + +template +inline +detail::group1< detail::group3 > + group(T1 a1,T2 a2, Var& var) +{ + return detail::group1< detail::group3 > + ( detail::group3 + (a1,a2, var) + ); +} + +template +inline +detail::group1< detail::group4 > + group(T1 a1,T2 a2,T3 a3, Var& var) +{ + return detail::group1< detail::group4 > + ( detail::group4 + (a1,a2,a3, var) + ); +} + +template +inline +detail::group1< detail::group5 > + group(T1 a1,T2 a2,T3 a3,T4 a4, Var& var) +{ + return detail::group1< detail::group5 > + ( detail::group5 + (a1,a2,a3,a4, var) + ); +} + +template +inline +detail::group1< detail::group6 > + group(T1 a1,T2 a2,T3 a3,T4 a4,T5 a5, Var& var) +{ + return detail::group1< detail::group6 > + ( detail::group6 + (a1,a2,a3,a4,a5, var) + ); +} + +template +inline +detail::group1< detail::group7 > + group(T1 a1,T2 a2,T3 a3,T4 a4,T5 a5,T6 a6, Var& var) +{ + return detail::group1< detail::group7 > + ( detail::group7 + (a1,a2,a3,a4,a5,a6, var) + ); +} + +template +inline +detail::group1< detail::group8 > + group(T1 a1,T2 a2,T3 a3,T4 a4,T5 a5,T6 a6,T7 a7, Var& var) +{ + return detail::group1< detail::group8 > + ( detail::group8 + (a1,a2,a3,a4,a5,a6,a7, var) + ); +} + +template +inline +detail::group1< detail::group9 > + group(T1 a1,T2 a2,T3 a3,T4 a4,T5 a5,T6 a6,T7 a7,T8 a8, Var& var) +{ + return detail::group1< detail::group9 > + ( detail::group9 + (a1,a2,a3,a4,a5,a6,a7,a8, var) + ); +} + +template +inline +detail::group1< detail::group10 > + group(T1 a1,T2 a2,T3 a3,T4 a4,T5 a5,T6 a6,T7 a7,T8 a8,T9 a9, Var& var) +{ + return detail::group1< detail::group10 > + ( detail::group10 + (a1,a2,a3,a4,a5,a6,a7,a8,a9, var) + ); +} + + +#endif // - BOOST_NO_OVERLOAD_FOR_NON_CONST + + +} // namespace io + +} // namespace boost + + +#endif // BOOST_FORMAT_GROUP_HPP diff --git a/3rdParty/Boost/src/boost/format/internals.hpp b/3rdParty/Boost/src/boost/format/internals.hpp new file mode 100644 index 0000000..b0d874a --- /dev/null +++ b/3rdParty/Boost/src/boost/format/internals.hpp @@ -0,0 +1,201 @@ +// ---------------------------------------------------------------------------- +// internals.hpp : internal structs : stream_format_state, format_item. +// included by format.hpp +// ---------------------------------------------------------------------------- + +// Copyright Samuel Krempp 2003. Use, modification, and distribution are +// subject to the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/libs/format for library home page + +// ---------------------------------------------------------------------------- + +#ifndef BOOST_FORMAT_INTERNALS_HPP +#define BOOST_FORMAT_INTERNALS_HPP + + +#include +#include +#include +#include +#include +#include // used as a dummy stream + +namespace boost { +namespace io { +namespace detail { + + +//---- stream_format_state --------------------------------------------------// + +// set of params that define the format state of a stream + template + struct stream_format_state + { + typedef BOOST_IO_STD basic_ios basic_ios; + + stream_format_state(Ch fill) { reset(fill); } +// stream_format_state(const basic_ios& os) { set_by_stream(os); } + + void reset(Ch fill); //- sets to default state. + void set_by_stream(const basic_ios& os); //- sets to os's state. + void apply_on(basic_ios & os, //- applies format_state to the stream + boost::io::detail::locale_t * loc_default = 0) const; + template + void apply_manip(T manipulator) //- modifies state by applying manipulator + { apply_manip_body( *this, manipulator) ; } + + // --- data --- + std::streamsize width_; + std::streamsize precision_; + Ch fill_; + std::ios_base::fmtflags flags_; + std::ios_base::iostate rdstate_; + std::ios_base::iostate exceptions_; + boost::optional loc_; + }; + + +//---- format_item ---------------------------------------------------------// + +// stores all parameters that can be specified in format strings + template + struct format_item + { + enum pad_values { zeropad = 1, spacepad =2, centered=4, tabulation = 8 }; + // 1. if zeropad is set, all other bits are not, + // 2. if tabulation is set, all others are not. + // centered and spacepad can be mixed freely. + enum arg_values { argN_no_posit = -1, // non-positional directive. will set argN later + argN_tabulation = -2, // tabulation directive. (no argument read) + argN_ignored = -3 // ignored directive. (no argument read) + }; + typedef BOOST_IO_STD basic_ios basic_ios; + typedef detail::stream_format_state stream_format_state; + typedef ::std::basic_string string_type; + + format_item(Ch fill) :argN_(argN_no_posit), fmtstate_(fill), + truncate_(max_streamsize()), pad_scheme_(0) {} + void reset(Ch fill); + void compute_states(); // sets states according to truncate and pad_scheme. + + static std::streamsize max_streamsize() { + return (std::numeric_limits::max)(); + } + + // --- data --- + int argN_; //- argument number (starts at 0, eg : %1 => argN=0) + // negative values for items that don't process an argument + string_type res_; //- result of the formatting of this item + string_type appendix_; //- piece of string between this item and the next + + stream_format_state fmtstate_;// set by parsing, is only affected by modify_item + + std::streamsize truncate_;//- is set for directives like %.5s that ask truncation + unsigned int pad_scheme_;//- several possible padding schemes can mix. see pad_values + }; + + + +//--- Definitions ------------------------------------------------------------ + +// - stream_format_state:: ------------------------------------------------- + template + void stream_format_state:: apply_on (basic_ios & os, + boost::io::detail::locale_t * loc_default) const { + // set the state of this stream according to our params + if(width_ != -1) + os.width(width_); + if(precision_ != -1) + os.precision(precision_); + if(fill_ != 0) + os.fill(fill_); + os.flags(flags_); + os.clear(rdstate_); + os.exceptions(exceptions_); +#if !defined(BOOST_NO_STD_LOCALE) + if(loc_) + os.imbue(loc_.get()); + else if(loc_default) + os.imbue(*loc_default); +#else + (void) loc_default; // keep compiler quiet if we don't support locales +#endif + } + + template + void stream_format_state:: set_by_stream(const basic_ios& os) { + // set our params according to the state of this stream + flags_ = os.flags(); + width_ = os.width(); + precision_ = os.precision(); + fill_ = os.fill(); + rdstate_ = os.rdstate(); + exceptions_ = os.exceptions(); + } + + + template + void apply_manip_body( stream_format_state& self, + T manipulator) { + // modify our params according to the manipulator + basic_oaltstringstream ss; + self.apply_on( ss ); + ss << manipulator; + self.set_by_stream( ss ); + } + + template inline + void stream_format_state:: reset(Ch fill) { + // set our params to standard's default state. cf 27.4.4.1 of the C++ norm + width_=0; precision_=6; + fill_=fill; // default is widen(' '), but we cant compute it without the locale + flags_ = std::ios_base::dec | std::ios_base::skipws; + // the adjust_field part is left equal to 0, which means right. + exceptions_ = std::ios_base::goodbit; + rdstate_ = std::ios_base::goodbit; + } + + +// --- format_item:: -------------------------------------------------------- + + template + void format_item:: + reset (Ch fill) { + argN_=argN_no_posit; truncate_ = max_streamsize(); pad_scheme_ =0; + res_.resize(0); appendix_.resize(0); + fmtstate_.reset(fill); + } + + template + void format_item:: + compute_states() { + // reflect pad_scheme_ on fmt_state_ + // because some pad_schemes has complex consequences on several state params. + if(pad_scheme_ & zeropad) { + // ignore zeropad in left alignment : + if(fmtstate_.flags_ & std::ios_base::left) { + BOOST_ASSERT(!(fmtstate_.flags_ &(std::ios_base::adjustfield ^std::ios_base::left))); + // only left bit might be set. (not right, nor internal) + pad_scheme_ = pad_scheme_ & (~zeropad); + } + else { + pad_scheme_ &= ~spacepad; // printf ignores spacepad when zeropadding + fmtstate_.fill_='0'; + fmtstate_.flags_ = (fmtstate_.flags_ & ~std::ios_base::adjustfield) + | std::ios_base::internal; + // removes all adjustfield bits, and adds internal. + } + } + if(pad_scheme_ & spacepad) { + if(fmtstate_.flags_ & std::ios_base::showpos) + pad_scheme_ &= ~spacepad; + } + } + + +} } } // namespaces boost :: io :: detail + + +#endif // BOOST_FORMAT_INTERNALS_HPP diff --git a/3rdParty/Boost/src/boost/format/internals_fwd.hpp b/3rdParty/Boost/src/boost/format/internals_fwd.hpp new file mode 100644 index 0000000..e44eb3c --- /dev/null +++ b/3rdParty/Boost/src/boost/format/internals_fwd.hpp @@ -0,0 +1,60 @@ +// ---------------------------------------------------------------------------- +// internals_fwd.hpp : forward declarations, for internal headers +// ---------------------------------------------------------------------------- + +// Copyright Samuel Krempp 2003. Use, modification, and distribution are +// subject to the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/libs/format for library home page + +// ---------------------------------------------------------------------------- + +#ifndef BOOST_FORMAT_INTERNAL_FWD_HPP +#define BOOST_FORMAT_INTERNAL_FWD_HPP + +#include +#include + + +namespace boost { +namespace io { + +namespace detail { + template struct stream_format_state; + template struct format_item; + + + // these functions were intended as methods, + // but MSVC have problems with template member functions : + // defined in format_implementation.hpp : + template + basic_format& + modify_item_body (basic_format& self, + int itemN, T manipulator); + + template + basic_format& + bind_arg_body (basic_format& self, + int argN, const T& val); + + // in internals.hpp : + template + void apply_manip_body (stream_format_state& self, + T manipulator); + + // argument feeding (defined in feed_args.hpp ) : + template + void distribute (basic_format& self, T x); + + template + basic_format& + feed (basic_format& self, T x); + +} // namespace detail + +} // namespace io +} // namespace boost + + +#endif // BOOST_FORMAT_INTERNAL_FWD_HPP diff --git a/3rdParty/Boost/src/boost/format/parsing.hpp b/3rdParty/Boost/src/boost/format/parsing.hpp new file mode 100644 index 0000000..b14ca82 --- /dev/null +++ b/3rdParty/Boost/src/boost/format/parsing.hpp @@ -0,0 +1,504 @@ +// ---------------------------------------------------------------------------- +// parsing.hpp : implementation of the parsing member functions +// ( parse, parse_printf_directive) +// ---------------------------------------------------------------------------- + +// Copyright Samuel Krempp 2003. Use, modification, and distribution are +// subject to the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// see http://www.boost.org/libs/format for library home page + +// ---------------------------------------------------------------------------- + +#ifndef BOOST_FORMAT_PARSING_HPP +#define BOOST_FORMAT_PARSING_HPP + + +#include +#include +#include +#include + + +namespace boost { +namespace io { +namespace detail { + +#if defined(BOOST_NO_STD_LOCALE) + // streams will be used for narrow / widen. but these methods are not const + template + T& const_or_not(const T& x) { + return const_cast (x); + } +#else + template + const T& const_or_not(const T& x) { + return x; + } +#endif + + template inline + char wrap_narrow(const Facet& fac, Ch c, char deflt) { + return const_or_not(fac).narrow(c, deflt); + } + + template inline + bool wrap_isdigit(const Facet& fac, Ch c) { +#if ! defined( BOOST_NO_LOCALE_ISDIGIT ) + return fac.is(std::ctype::digit, c); +# else + (void) fac; // remove "unused parameter" warning + using namespace std; + return isdigit(c); +#endif + } + + template + Iter wrap_scan_notdigit(const Facet & fac, Iter beg, Iter end) { + using namespace std; + for( ; beg!=end && wrap_isdigit(fac, *beg); ++beg) ; + return beg; + } + + + // Input : [start, last) iterators range and a + // a Facet to use its widen/narrow member function + // Effects : read sequence and convert digits into integral n, of type Res + // Returns : n + template + Iter str2int (const Iter & start, const Iter & last, Res & res, + const Facet& fac) + { + using namespace std; + Iter it; + res=0; + for(it=start; it != last && wrap_isdigit(fac, *it); ++it ) { + char cur_ch = wrap_narrow(fac, *it, 0); // cant fail. + res *= 10; + res += cur_ch - '0'; // 22.2.1.1.2.13 of the C++ standard + } + return it; + } + + // skip printf's "asterisk-fields" directives in the format-string buf + // Input : char string, with starting index *pos_p + // a Facet merely to use its widen/narrow member function + // Effects : advance *pos_p by skipping printf's asterisk fields. + // Returns : nothing + template + Iter skip_asterisk(Iter start, Iter last, const Facet& fac) + { + using namespace std; + ++ start; + start = wrap_scan_notdigit(fac, start, last); + if(start!=last && *start== const_or_not(fac).widen( '$') ) + ++start; + return start; + } + + + // auxiliary func called by parse_printf_directive + // for centralising error handling + // it either throws if user sets the corresponding flag, or does nothing. + inline void maybe_throw_exception(unsigned char exceptions, + std::size_t pos, std::size_t size) + { + if(exceptions & io::bad_format_string_bit) + boost::throw_exception(io::bad_format_string(pos, size) ); + } + + + // Input: the position of a printf-directive in the format-string + // a basic_ios& merely to use its widen/narrow member function + // a bitset'exceptions' telling whether to throw exceptions on errors. + // Returns: + // true if parse succeeded (ignore some errors if exceptions disabled) + // false if it failed so bad that the directive should be printed verbatim + // Effects: + // start is incremented so that *start is the first char after + // this directive + // *fpar is set with the parameters read in the directive + template + bool parse_printf_directive(Iter & start, const Iter& last, + detail::format_item * fpar, + const Facet& fac, + std::size_t offset, unsigned char exceptions) + { + typedef typename basic_format::format_item_t format_item_t; + + fpar->argN_ = format_item_t::argN_no_posit; // if no positional-directive + bool precision_set = false; + bool in_brackets=false; + Iter start0 = start; + std::size_t fstring_size = last-start0+offset; + + if(start>= last) { // empty directive : this is a trailing % + maybe_throw_exception(exceptions, start-start0 + offset, fstring_size); + return false; + } + + if(*start== const_or_not(fac).widen( '|')) { + in_brackets=true; + if( ++start >= last ) { + maybe_throw_exception(exceptions, start-start0 + offset, fstring_size); + return false; + } + } + + // the flag '0' would be picked as a digit for argument order, but here it's a flag : + if(*start== const_or_not(fac).widen( '0')) + goto parse_flags; + + // handle argument order (%2$d) or possibly width specification: %2d + if(wrap_isdigit(fac, *start)) { + int n; + start = str2int(start, last, n, fac); + if( start >= last ) { + maybe_throw_exception(exceptions, start-start0+offset, fstring_size); + return false; + } + + // %N% case : this is already the end of the directive + if( *start == const_or_not(fac).widen( '%') ) { + fpar->argN_ = n-1; + ++start; + if( in_brackets) + maybe_throw_exception(exceptions, start-start0+offset, fstring_size); + // but don't return. maybe "%" was used in lieu of '$', so we go on. + else + return true; + } + + if ( *start== const_or_not(fac).widen( '$') ) { + fpar->argN_ = n-1; + ++start; + } + else { + // non-positionnal directive + fpar->fmtstate_.width_ = n; + fpar->argN_ = format_item_t::argN_no_posit; + goto parse_precision; + } + } + + parse_flags: + // handle flags + while ( start != last) { // as long as char is one of + - = _ # 0 l h or ' ' + // misc switches + switch ( wrap_narrow(fac, *start, 0)) { + case '\'' : break; // no effect yet. (painful to implement) + case 'l': + case 'h': // short/long modifier : for printf-comaptibility (no action needed) + break; + case '-': + fpar->fmtstate_.flags_ |= std::ios_base::left; + break; + case '=': + fpar->pad_scheme_ |= format_item_t::centered; + break; + case '_': + fpar->fmtstate_.flags_ |= std::ios_base::internal; + break; + case ' ': + fpar->pad_scheme_ |= format_item_t::spacepad; + break; + case '+': + fpar->fmtstate_.flags_ |= std::ios_base::showpos; + break; + case '0': + fpar->pad_scheme_ |= format_item_t::zeropad; + // need to know alignment before really setting flags, + // so just add 'zeropad' flag for now, it will be processed later. + break; + case '#': + fpar->fmtstate_.flags_ |= std::ios_base::showpoint | std::ios_base::showbase; + break; + default: + goto parse_width; + } + ++start; + } // loop on flag. + + if( start>=last) { + maybe_throw_exception(exceptions, start-start0+offset, fstring_size); + return true; + } + parse_width: + // handle width spec + // first skip 'asterisk fields' : *, or *N$ + if(*start == const_or_not(fac).widen( '*') ) + start = skip_asterisk(start, last, fac); + if(start!=last && wrap_isdigit(fac, *start)) + start = str2int(start, last, fpar->fmtstate_.width_, fac); + + parse_precision: + if( start>= last) { + maybe_throw_exception(exceptions, start-start0+offset, fstring_size); + return true; + } + // handle precision spec + if (*start== const_or_not(fac).widen( '.')) { + ++start; + if(start != last && *start == const_or_not(fac).widen( '*') ) + start = skip_asterisk(start, last, fac); + if(start != last && wrap_isdigit(fac, *start)) { + start = str2int(start, last, fpar->fmtstate_.precision_, fac); + precision_set = true; + } + else + fpar->fmtstate_.precision_ =0; + } + + // handle formatting-type flags : + while( start != last && ( *start== const_or_not(fac).widen( 'l') + || *start== const_or_not(fac).widen( 'L') + || *start== const_or_not(fac).widen( 'h')) ) + ++start; + if( start>=last) { + maybe_throw_exception(exceptions, start-start0+offset, fstring_size); + return true; + } + + if( in_brackets && *start== const_or_not(fac).widen( '|') ) { + ++start; + return true; + } + switch ( wrap_narrow(fac, *start, 0) ) { + case 'X': + fpar->fmtstate_.flags_ |= std::ios_base::uppercase; + case 'p': // pointer => set hex. + case 'x': + fpar->fmtstate_.flags_ &= ~std::ios_base::basefield; + fpar->fmtstate_.flags_ |= std::ios_base::hex; + break; + + case 'o': + fpar->fmtstate_.flags_ &= ~std::ios_base::basefield; + fpar->fmtstate_.flags_ |= std::ios_base::oct; + break; + + case 'E': + fpar->fmtstate_.flags_ |= std::ios_base::uppercase; + case 'e': + fpar->fmtstate_.flags_ &= ~std::ios_base::floatfield; + fpar->fmtstate_.flags_ |= std::ios_base::scientific; + + fpar->fmtstate_.flags_ &= ~std::ios_base::basefield; + fpar->fmtstate_.flags_ |= std::ios_base::dec; + break; + + case 'f': + fpar->fmtstate_.flags_ &= ~std::ios_base::floatfield; + fpar->fmtstate_.flags_ |= std::ios_base::fixed; + case 'u': + case 'd': + case 'i': + fpar->fmtstate_.flags_ &= ~std::ios_base::basefield; + fpar->fmtstate_.flags_ |= std::ios_base::dec; + break; + + case 'T': + ++start; + if( start >= last) + maybe_throw_exception(exceptions, start-start0+offset, fstring_size); + else + fpar->fmtstate_.fill_ = *start; + fpar->pad_scheme_ |= format_item_t::tabulation; + fpar->argN_ = format_item_t::argN_tabulation; + break; + case 't': + fpar->fmtstate_.fill_ = const_or_not(fac).widen( ' '); + fpar->pad_scheme_ |= format_item_t::tabulation; + fpar->argN_ = format_item_t::argN_tabulation; + break; + + case 'G': + fpar->fmtstate_.flags_ |= std::ios_base::uppercase; + break; + case 'g': // 'g' conversion is default for floats. + fpar->fmtstate_.flags_ &= ~std::ios_base::basefield; + fpar->fmtstate_.flags_ |= std::ios_base::dec; + + // CLEAR all floatield flags, so stream will CHOOSE + fpar->fmtstate_.flags_ &= ~std::ios_base::floatfield; + break; + + case 'C': + case 'c': + fpar->truncate_ = 1; + break; + case 'S': + case 's': + if(precision_set) // handle truncation manually, with own parameter. + fpar->truncate_ = fpar->fmtstate_.precision_; + fpar->fmtstate_.precision_ = 6; // default stream precision. + break; + case 'n' : + fpar->argN_ = format_item_t::argN_ignored; + break; + default: + maybe_throw_exception(exceptions, start-start0+offset, fstring_size); + } + ++start; + + if( in_brackets ) { + if( start != last && *start== const_or_not(fac).widen( '|') ) { + ++start; + return true; + } + else maybe_throw_exception(exceptions, start-start0+offset, fstring_size); + } + return true; + } + // -end parse_printf_directive() + + template + int upper_bound_from_fstring(const String& buf, + const typename String::value_type arg_mark, + const Facet& fac, + unsigned char exceptions) + { + // quick-parsing of the format-string to count arguments mark (arg_mark, '%') + // returns : upper bound on the number of format items in the format strings + using namespace boost::io; + typename String::size_type i1=0; + int num_items=0; + while( (i1=buf.find(arg_mark,i1)) != String::npos ) { + if( i1+1 >= buf.size() ) { + if(exceptions & bad_format_string_bit) + boost::throw_exception(bad_format_string(i1, buf.size() )); // must not end in ".. %" + else { + ++num_items; + break; + } + } + if(buf[i1+1] == buf[i1] ) {// escaped "%%" + i1+=2; continue; + } + + ++i1; + // in case of %N% directives, dont count it double (wastes allocations..) : + i1 = detail::wrap_scan_notdigit(fac, buf.begin()+i1, buf.end()) - buf.begin(); + if( i1 < buf.size() && buf[i1] == arg_mark ) + ++i1; + ++num_items; + } + return num_items; + } + template inline + void append_string(String& dst, const String& src, + const typename String::size_type beg, + const typename String::size_type end) { +#if !defined(BOOST_NO_STRING_APPEND) + dst.append(src.begin()+beg, src.begin()+end); +#else + dst += src.substr(beg, end-beg); +#endif + } + +} // detail namespace +} // io namespace + + + +// ----------------------------------------------- +// format :: parse(..) + + template + basic_format& basic_format:: + parse (const string_type& buf) { + // parse the format-string + using namespace std; +#if !defined(BOOST_NO_STD_LOCALE) + const std::ctype & fac = BOOST_USE_FACET( std::ctype, getloc()); +#else + io::basic_oaltstringstream fac; + //has widen and narrow even on compilers without locale +#endif + + const Ch arg_mark = io::detail::const_or_not(fac).widen( '%'); + bool ordered_args=true; + int max_argN=-1; + + // A: find upper_bound on num_items and allocates arrays + int num_items = io::detail::upper_bound_from_fstring(buf, arg_mark, fac, exceptions()); + make_or_reuse_data(num_items); + + // B: Now the real parsing of the format string : + num_items=0; + typename string_type::size_type i0=0, i1=0; + typename string_type::const_iterator it; + bool special_things=false; + int cur_item=0; + while( (i1=buf.find(arg_mark,i1)) != string_type::npos ) { + string_type & piece = (cur_item==0) ? prefix_ : items_[cur_item-1].appendix_; + if( buf[i1+1] == buf[i1] ) { // escaped mark, '%%' + io::detail::append_string(piece, buf, i0, i1+1); + i1+=2; i0=i1; + continue; + } + BOOST_ASSERT( static_cast(cur_item) < items_.size() || cur_item==0); + + if(i1!=i0) { + io::detail::append_string(piece, buf, i0, i1); + i0=i1; + } + ++i1; + it = buf.begin()+i1; + bool parse_ok = io::detail::parse_printf_directive( + it, buf.end(), &items_[cur_item], fac, i1, exceptions()); + i1 = it - buf.begin(); + if( ! parse_ok ) // the directive will be printed verbatim + continue; + i0=i1; + items_[cur_item].compute_states(); // process complex options, like zeropad, into params + + int argN=items_[cur_item].argN_; + if(argN == format_item_t::argN_ignored) + continue; + if(argN ==format_item_t::argN_no_posit) + ordered_args=false; + else if(argN == format_item_t::argN_tabulation) special_things=true; + else if(argN > max_argN) max_argN = argN; + ++num_items; + ++cur_item; + } // loop on %'s + BOOST_ASSERT(cur_item == num_items); + + // store the final piece of string + { + string_type & piece = (cur_item==0) ? prefix_ : items_[cur_item-1].appendix_; + io::detail::append_string(piece, buf, i0, buf.size()); + } + + if( !ordered_args) { + if(max_argN >= 0 ) { // dont mix positional with non-positionnal directives + if(exceptions() & io::bad_format_string_bit) + boost::throw_exception(io::bad_format_string(max_argN, 0)); + // else do nothing. => positionnal arguments are processed as non-positionnal + } + // set things like it would have been with positional directives : + int non_ordered_items = 0; + for(int i=0; i< num_items; ++i) + if(items_[i].argN_ == format_item_t::argN_no_posit) { + items_[i].argN_ = non_ordered_items; + ++non_ordered_items; + } + max_argN = non_ordered_items-1; + } + + // C: set some member data : + items_.resize(num_items, format_item_t(io::detail::const_or_not(fac).widen( ' ')) ); + + if(special_things) style_ |= special_needs; + num_args_ = max_argN + 1; + if(ordered_args) style_ |= ordered; + else style_ &= ~ordered; + return *this; + } + +} // namespace boost + + +#endif // BOOST_FORMAT_PARSING_HPP diff --git a/3rdParty/Boost/update.sh b/3rdParty/Boost/update.sh index 4be35df..9af5258 100755 --- a/3rdParty/Boost/update.sh +++ b/3rdParty/Boost/update.sh @@ -32,6 +32,7 @@ fi regex.hpp \ boost/unordered_map.hpp \ boost/algorithm/string.hpp \ + boost/format.hpp \ $TARGET_DIR rm -rf $TARGET_DIR/libs/config diff --git a/BuildTools/SCons/SConstruct b/BuildTools/SCons/SConstruct index 86ec719..69dbe19 100644 --- a/BuildTools/SCons/SConstruct +++ b/BuildTools/SCons/SConstruct @@ -281,6 +281,8 @@ if int(ARGUMENTS.get("V", 0)) == 0: env["QT4_UICCOMSTR"] = colorize("UIC", "$TARGET", "blue") env["QT4_MOCFROMHCOMSTR"] = colorize("MOC", "$TARGET", "blue") env["QT4_MOCFROMCXXCOMSTR"] = colorize("MOC", "$TARGET", "blue") + env["QT4_LRELEASECOMSTR"] = colorize("LRELEASE", "$TARGET", "blue") + env["QT4_LUPDATECOMSTR"] = colorize("LUPDATE", "$TARGET", "blue") env["GENCOMSTR"] = colorize("GEN", "$TARGET", "blue") env["RCCOMSTR"] = colorize("RC", "$TARGET", "blue") env["BUNDLECOMSTR"] = colorize("BUNDLE", "$TARGET", "blue") diff --git a/BuildTools/SCons/Tools/AppBundle.py b/BuildTools/SCons/Tools/AppBundle.py index 92ab814..c271575 100644 --- a/BuildTools/SCons/Tools/AppBundle.py +++ b/BuildTools/SCons/Tools/AppBundle.py @@ -1,4 +1,4 @@ -import SCons.Util +import SCons.Util, os.path def generate(env) : def createAppBundle(env, bundle, version = "1.0", resources = [], frameworks = [], info = {}) : @@ -37,8 +37,8 @@ def generate(env) : """ env.WriteVal(bundleContentsDir + "/Info.plist", env.Value(plist)) - for resource in resources : - env.Install(resourcesDir, resource) + for (target, resource) in resources.items() : + env.Install(os.path.join(resourcesDir, target), resource) for framework in frameworks : env.Install(frameworksDir, framework) diff --git a/BuildTools/SCons/Tools/qt4.py b/BuildTools/SCons/Tools/qt4.py index e735fe9..0f2e976 100644 --- a/BuildTools/SCons/Tools/qt4.py +++ b/BuildTools/SCons/Tools/qt4.py @@ -291,7 +291,7 @@ def generate(env): '$QT4_MOC $QT4_MOCFROMCXXFLAGS $QT4_MOCINCFLAGS -o $TARGET $SOURCE', Action(checkMocIncluded,None)], QT4_LUPDATECOM = '$QT4_LUPDATE $SOURCE -ts $TARGET', - QT4_LRELEASECOM = '$QT4_LRELEASE $SOURCE', + QT4_LRELEASECOM = '$QT4_LRELEASE -silent $SOURCE -qm $TARGET', QT4_RCCCOM = '$QT4_RCC $QT4_QRCFLAGS -name $SOURCE $SOURCE -o $TARGET', ) if len(env["QTDIR"]) > 0 : @@ -304,7 +304,7 @@ def generate(env): ) env.Append( BUILDERS = { 'Ts': tsbuilder } ) qmbuilder = Builder( - action = SCons.Action.Action('$QT4_LRELEASECOM'),# , '$QT4_LRELEASECOMSTR'), + action = SCons.Action.Action('$QT4_LRELEASECOM', cmdstr = '$QT4_LRELEASECOMSTR'), src_suffix = '.ts', suffix = '.qm', single_source = True diff --git a/Slimber/Cocoa/SConscript b/Slimber/Cocoa/SConscript index 01dff1b..e2d8221 100644 --- a/Slimber/Cocoa/SConscript +++ b/Slimber/Cocoa/SConscript @@ -21,7 +21,7 @@ myenv.Program("Slimber", [ myenv.Nib("MainMenu") -myenv.AppBundle("Slimber", resources = [ +myenv.AppBundle("Slimber", resources = { "": [ "MainMenu.nib", "../Resources/Slimber.icns", "../Resources/Credits.html", @@ -29,7 +29,7 @@ myenv.AppBundle("Slimber", resources = [ "../Resources/Offline.png", "../Resources/UsersOnline.png", "../Resources/UsersOffline.png" - ], info = { + ]}, info = { "NSMainNibFile" : "MainMenu", "LSUIElement" : "1", }) diff --git a/Slimber/Qt/SConscript b/Slimber/Qt/SConscript index cd77950..c71d480 100644 --- a/Slimber/Qt/SConscript +++ b/Slimber/Qt/SConscript @@ -44,7 +44,7 @@ else : if env["PLATFORM"] == "win32" : if "dist" in COMMAND_LINE_TARGETS or env.GetOption("clean") : - myenv.WindowsBundle("Slimber", resources = [], qtlibs = ["QtCore4", "QtGui4"]) + myenv.WindowsBundle("Slimber", resources = {}, qtlibs = ["QtCore4", "QtGui4"]) myenv.Append(NSIS_OPTIONS = [ "/DmsvccRedistributableDir=\"" + env["vcredist"] + "\"", "/DbuildDate=" + datetime.date.today().strftime("%Y%m%d") diff --git a/Swift/Controllers/Chat/ChatController.cpp b/Swift/Controllers/Chat/ChatController.cpp index e4ad9c8..6e7825f 100644 --- a/Swift/Controllers/Chat/ChatController.cpp +++ b/Swift/Controllers/Chat/ChatController.cpp @@ -9,6 +9,8 @@ #include #include +#include +#include #include "Swiften/Avatars/AvatarManager.h" #include "Swiften/Chat/ChatStateNotifier.h" #include "Swiften/Chat/ChatStateTracker.h" @@ -18,6 +20,7 @@ #include "Swift/Controllers/UIInterfaces/ChatWindowFactory.h" #include "Swiften/Client/NickResolver.h" #include "Swift/Controllers/XMPPEvents/EventController.h" +#include namespace Swift { @@ -37,16 +40,16 @@ ChatController::ChatController(const JID& self, StanzaChannel* stanzaChannel, IQ nickResolver_->onNickChanged.connect(boost::bind(&ChatController::handleContactNickChanged, this, _1, _2)); std::string nick = nickResolver_->jidToNick(toJID_); chatWindow_->setName(nick); - std::string startMessage("Starting chat with " + nick); + std::string startMessage; Presence::ref theirPresence; if (isInMUC) { - startMessage += " in chatroom " + contact.toBare().toString(); + startMessage = str(format(QT_TRANSLATE_NOOP("", "Starting chat with %1% in chatroom %2%")) % nick % contact.toBare().toString()); theirPresence = presenceOracle->getLastPresence(contact); } else { - startMessage += " - " + contact.toBare().toString(); + startMessage = str(format(QT_TRANSLATE_NOOP("", "Starting chat with %1% - %2%")) % nick % contact.toBare().toString()); theirPresence = contact.isBare() ? presenceOracle->getHighestPriorityPresence(contact.toBare()) : presenceOracle->getLastPresence(contact); } - startMessage += ": " + StatusShow::typeToFriendlyName(theirPresence ? theirPresence->getShow() : StatusShow::None); + startMessage += ": " + statusShowTypeToFriendlyName(theirPresence ? theirPresence->getShow() : StatusShow::None); if (theirPresence && !theirPresence->getStatus().empty()) { startMessage += " (" + theirPresence->getStatus() + ")"; } @@ -109,7 +112,7 @@ void ChatController::preSendMessageRequest(boost::shared_ptr message) { } void ChatController::postSendMessage(const std::string& body, boost::shared_ptr sentStanza) { - std::string id = addMessage(body, "me", true, labelsEnabled_ ? chatWindow_->getSelectedSecurityLabel() : boost::optional(), std::string(avatarManager_->getAvatarPath(selfJID_).string()), boost::posix_time::microsec_clock::universal_time()); + std::string id = addMessage(body, QT_TRANSLATE_NOOP("", "me"), true, labelsEnabled_ ? chatWindow_->getSelectedSecurityLabel() : boost::optional(), std::string(avatarManager_->getAvatarPath(selfJID_).string()), boost::posix_time::microsec_clock::universal_time()); if (stanzaChannel_->getStreamManagementEnabled()) { chatWindow_->setAckState(id, ChatWindow::Pending); unackedStanzas_[sentStanza] = id; @@ -148,19 +151,23 @@ std::string ChatController::senderDisplayNameFromMessage(const JID& from) { std::string ChatController::getStatusChangeString(boost::shared_ptr presence) { std::string nick = senderDisplayNameFromMessage(presence->getFrom()); - std::string response = nick; + std::string response; if (!presence || presence->getType() == Presence::Unavailable || presence->getType() == Presence::Error) { - response += " has gone offline"; + response = QT_TRANSLATE_NOOP("", "%1% has gone offline"); } else if (presence->getType() == Presence::Available) { StatusShow::Type show = presence->getShow(); if (show == StatusShow::Online || show == StatusShow::FFC) { - response += " has become available"; + response = QT_TRANSLATE_NOOP("", "%1% has become available"); } else if (show == StatusShow::Away || show == StatusShow::XA) { - response += " has gone away"; + response = QT_TRANSLATE_NOOP("", "%1% has gone away"); } else if (show == StatusShow::DND) { - response += " is now busy"; + response = QT_TRANSLATE_NOOP("", "%1% is now busy"); } } + if (!response.empty()) { + response = str(format(response) % nick); + } + if (!presence->getStatus().empty()) { response += " (" + presence->getStatus() + ")"; } diff --git a/Swift/Controllers/Chat/ChatControllerBase.cpp b/Swift/Controllers/Chat/ChatControllerBase.cpp index f70ec81..a970d88 100644 --- a/Swift/Controllers/Chat/ChatControllerBase.cpp +++ b/Swift/Controllers/Chat/ChatControllerBase.cpp @@ -13,6 +13,8 @@ #include #include +#include +#include #include "Swiften/Base/String.h" #include "Swiften/Client/StanzaChannel.h" #include "Swiften/Elements/Delay.h" @@ -51,7 +53,7 @@ void ChatControllerBase::createDayChangeTimer() { void ChatControllerBase::handleDayChangeTick() { dateChangeTimer_->stop(); boost::posix_time::ptime now = boost::posix_time::second_clock::local_time(); - chatWindow_->addSystemMessage("The day is now " + std::string(boost::posix_time::to_iso_extended_string(now)).substr(0,10)); + chatWindow_->addSystemMessage(str(format(QT_TRANSLATE_NOOP("", "The day is now %1%")) % std::string(boost::posix_time::to_iso_extended_string(now)).substr(0,10))); dayTicked(); createDayChangeTimer(); } @@ -188,34 +190,34 @@ void ChatControllerBase::handleIncomingMessage(boost::shared_ptr m } std::string ChatControllerBase::getErrorMessage(boost::shared_ptr error) { - std::string defaultMessage = "Error sending message"; + std::string defaultMessage = QT_TRANSLATE_NOOP("", "Error sending message"); if (!error->getText().empty()) { return error->getText(); } else { switch (error->getCondition()) { - case ErrorPayload::BadRequest: return "Bad request"; break; - case ErrorPayload::Conflict: return "Conflict"; break; - case ErrorPayload::FeatureNotImplemented: return "This feature is not implemented"; break; - case ErrorPayload::Forbidden: return "Forbidden"; break; - case ErrorPayload::Gone: return "Recipient can no longer be contacted"; break; - case ErrorPayload::InternalServerError: return "Internal server error"; break; - case ErrorPayload::ItemNotFound: return "Item not found"; break; - case ErrorPayload::JIDMalformed: return "JID Malformed"; break; - case ErrorPayload::NotAcceptable: return "Message was rejected"; break; - case ErrorPayload::NotAllowed: return "Not allowed"; break; - case ErrorPayload::NotAuthorized: return "Not authorized"; break; - case ErrorPayload::PaymentRequired: return "Payment is required"; break; - case ErrorPayload::RecipientUnavailable: return "Recipient is unavailable."; break; - case ErrorPayload::Redirect: return "Redirect"; break; - case ErrorPayload::RegistrationRequired: return "Registration required"; break; - case ErrorPayload::RemoteServerNotFound: return "Recipient's server not found."; break; - case ErrorPayload::RemoteServerTimeout: return "Remote server timeout"; break; - case ErrorPayload::ResourceConstraint: return "The server is low on resources"; break; - case ErrorPayload::ServiceUnavailable: return "The service is unavailable"; break; - case ErrorPayload::SubscriptionRequired: return "A subscription is required"; break; - case ErrorPayload::UndefinedCondition: return "Undefined condition"; break; - case ErrorPayload::UnexpectedRequest: return "Unexpected request"; break; + case ErrorPayload::BadRequest: return QT_TRANSLATE_NOOP("", "Bad request"); break; + case ErrorPayload::Conflict: return QT_TRANSLATE_NOOP("", "Conflict"); break; + case ErrorPayload::FeatureNotImplemented: return QT_TRANSLATE_NOOP("", "This feature is not implemented"); break; + case ErrorPayload::Forbidden: return QT_TRANSLATE_NOOP("", "Forbidden"); break; + case ErrorPayload::Gone: return QT_TRANSLATE_NOOP("", "Recipient can no longer be contacted"); break; + case ErrorPayload::InternalServerError: return QT_TRANSLATE_NOOP("", "Internal server error"); break; + case ErrorPayload::ItemNotFound: return QT_TRANSLATE_NOOP("", "Item not found"); break; + case ErrorPayload::JIDMalformed: return QT_TRANSLATE_NOOP("", "JID Malformed"); break; + case ErrorPayload::NotAcceptable: return QT_TRANSLATE_NOOP("", "Message was rejected"); break; + case ErrorPayload::NotAllowed: return QT_TRANSLATE_NOOP("", "Not allowed"); break; + case ErrorPayload::NotAuthorized: return QT_TRANSLATE_NOOP("", "Not authorized"); break; + case ErrorPayload::PaymentRequired: return QT_TRANSLATE_NOOP("", "Payment is required"); break; + case ErrorPayload::RecipientUnavailable: return QT_TRANSLATE_NOOP("", "Recipient is unavailable"); break; + case ErrorPayload::Redirect: return QT_TRANSLATE_NOOP("", "Redirect"); break; + case ErrorPayload::RegistrationRequired: return QT_TRANSLATE_NOOP("", "Registration required"); break; + case ErrorPayload::RemoteServerNotFound: return QT_TRANSLATE_NOOP("", "Recipient's server not found"); break; + case ErrorPayload::RemoteServerTimeout: return QT_TRANSLATE_NOOP("", "Remote server timeout"); break; + case ErrorPayload::ResourceConstraint: return QT_TRANSLATE_NOOP("", "The server is low on resources"); break; + case ErrorPayload::ServiceUnavailable: return QT_TRANSLATE_NOOP("", "The service is unavailable"); break; + case ErrorPayload::SubscriptionRequired: return QT_TRANSLATE_NOOP("", "A subscription is required"); break; + case ErrorPayload::UndefinedCondition: return QT_TRANSLATE_NOOP("", "Undefined condition"); break; + case ErrorPayload::UnexpectedRequest: return QT_TRANSLATE_NOOP("", "Unexpected request"); break; } } return defaultMessage; diff --git a/Swift/Controllers/Chat/MUCController.cpp b/Swift/Controllers/Chat/MUCController.cpp index 765c49d..ce8c946 100644 --- a/Swift/Controllers/Chat/MUCController.cpp +++ b/Swift/Controllers/Chat/MUCController.cpp @@ -10,6 +10,8 @@ #include #include +#include +#include #include "Swiften/Network/Timer.h" #include "Swiften/Network/TimerFactory.h" #include "Swiften/Base/foreach.h" @@ -109,7 +111,7 @@ void MUCController::rejoin() { void MUCController::handleJoinTimeoutTick() { receivedActivity(); - chatWindow_->addSystemMessage("Room " + toJID_.toString() + " is not responding. This operation may never complete"); + chatWindow_->addSystemMessage(str(format(QT_TRANSLATE_NOOP("", "Room %1% is not responding. This operation may never complete.")) % toJID_.toString())); } void MUCController::receivedActivity() { @@ -120,17 +122,38 @@ void MUCController::receivedActivity() { void MUCController::handleJoinFailed(boost::shared_ptr error) { receivedActivity(); - std::string errorMessage = "Unable to join this room"; + std::string errorMessage = QT_TRANSLATE_NOOP("", "Unable to join this room"); std::string rejoinNick; if (error) { switch (error->getCondition()) { - case ErrorPayload::Conflict: rejoinNick = nick_ + "_"; errorMessage += " as " + nick_ + ", retrying as " + rejoinNick; break; - case ErrorPayload::JIDMalformed: errorMessage += ", no nickname specified";break; - case ErrorPayload::NotAuthorized: errorMessage += ", a password needed";break; - case ErrorPayload::RegistrationRequired: errorMessage += ", only members may join"; break; - case ErrorPayload::Forbidden: errorMessage += ", you are banned from the room"; break; - case ErrorPayload::ServiceUnavailable: errorMessage += ", the room is full";break; - case ErrorPayload::ItemNotFound: errorMessage += ", the room does not exist";break; + case ErrorPayload::Conflict: + rejoinNick = nick_ + "_"; + errorMessage = str(format(QT_TRANSLATE_NOOP("", "Unable to join this room as %1%, retrying as %2%")) % nick_ % rejoinNick); + break; + case ErrorPayload::JIDMalformed: + errorMessage += ": "; + errorMessage += QT_TRANSLATE_NOOP("", "No nickname specified"); + break; + case ErrorPayload::NotAuthorized: + errorMessage += ": "; + errorMessage += QT_TRANSLATE_NOOP("", "A password needed"); + break; + case ErrorPayload::RegistrationRequired: + errorMessage += ": "; + errorMessage += QT_TRANSLATE_NOOP("", "Only members may join"); + break; + case ErrorPayload::Forbidden: + errorMessage += ": "; + errorMessage += QT_TRANSLATE_NOOP("", "You are banned from the room"); + break; + case ErrorPayload::ServiceUnavailable: + errorMessage += ": "; + errorMessage += QT_TRANSLATE_NOOP("", "The room is full"); + break; + case ErrorPayload::ItemNotFound: + errorMessage += ": "; + errorMessage += QT_TRANSLATE_NOOP("", "The room does not exist"); + break; default: break; } @@ -147,7 +170,7 @@ void MUCController::handleJoinFailed(boost::shared_ptr error) { void MUCController::handleJoinComplete(const std::string& nick) { receivedActivity(); joined_ = true; - std::string joinMessage = "You have joined room " + toJID_.toString() + " as " + nick; + std::string joinMessage = str(format(QT_TRANSLATE_NOOP("", "You have joined room %1% as %2%")) % toJID_.toString() % nick); nick_ = nick; chatWindow_->addSystemMessage(joinMessage); clearPresenceQueue(); @@ -185,13 +208,14 @@ void MUCController::handleOccupantJoined(const MUCOccupant& occupant) { appendToJoinParts(joinParts_, event); roster_->addContact(jid, realJID, occupant.getNick(), roleToGroupName(occupant.getRole()), avatarManager_->getAvatarPath(jid).string()); if (joined_) { - std::string joinString = occupant.getNick() + " has joined the room"; + std::string joinString; MUCOccupant::Role role = occupant.getRole(); if (role != MUCOccupant::NoRole && role != MUCOccupant::Participant) { - joinString += " as a " + roleToFriendlyName(role); - + joinString = str(format(QT_TRANSLATE_NOOP("", "%1% has joined the room as a %2%.")) % occupant.getNick() % roleToFriendlyName(role)); + } + else { + joinString = str(format(QT_TRANSLATE_NOOP("", "%1% has joined the room.")) % occupant.getNick()); } - joinString += "."; if (shouldUpdateJoinParts()) { updateJoinParts(); } else { @@ -216,9 +240,9 @@ void MUCController::clearPresenceQueue() { std::string MUCController::roleToFriendlyName(MUCOccupant::Role role) { switch (role) { - case MUCOccupant::Moderator: return "moderator"; - case MUCOccupant::Participant: return "participant"; - case MUCOccupant::Visitor: return "visitor"; + case MUCOccupant::Moderator: return QT_TRANSLATE_NOOP("", "moderator"); + case MUCOccupant::Participant: return QT_TRANSLATE_NOOP("", "participant"); + case MUCOccupant::Visitor: return QT_TRANSLATE_NOOP("", "visitor"); case MUCOccupant::NoRole: return ""; } return ""; @@ -257,7 +281,7 @@ void MUCController::preHandleIncomingMessage(boost::shared_ptr mes joined_ = true; if (!message->getSubject().empty() && message->getBody().empty()) { - chatWindow_->addSystemMessage("The room subject is now: " + message->getSubject()); + chatWindow_->addSystemMessage(str(format(QT_TRANSLATE_NOOP("", "The room subject is now: %1%")) % message->getSubject()));; doneGettingHistory_ = true; } @@ -280,16 +304,16 @@ void MUCController::handleOccupantRoleChanged(const std::string& nick, const MUC realJID = occupant.getRealJID().get(); } roster_->addContact(jid, realJID, nick, roleToGroupName(occupant.getRole()), avatarManager_->getAvatarPath(jid).string()); - chatWindow_->addSystemMessage(nick + " is now a " + roleToFriendlyName(occupant.getRole())); + chatWindow_->addSystemMessage(str(format(QT_TRANSLATE_NOOP("", "%1% is now a %2%")) % nick % roleToFriendlyName(occupant.getRole()))); } std::string MUCController::roleToGroupName(MUCOccupant::Role role) { std::string result; switch (role) { - case MUCOccupant::Moderator: result = "Moderators"; break; - case MUCOccupant::Participant: result = "Participants"; break; - case MUCOccupant::Visitor: result = "Visitors"; break; - case MUCOccupant::NoRole: result = "Occupants"; break; + case MUCOccupant::Moderator: result = QT_TRANSLATE_NOOP("", "Moderators"); break; + case MUCOccupant::Participant: result = QT_TRANSLATE_NOOP("", "Participants"); break; + case MUCOccupant::Visitor: result = QT_TRANSLATE_NOOP("", "Visitors"); break; + case MUCOccupant::NoRole: result = QT_TRANSLATE_NOOP("", "Occupants"); break; default: assert(false); } return result; @@ -303,7 +327,7 @@ void MUCController::setOnline(bool online) { processUserPart(); } else { if (shouldJoinOnReconnect_) { - chatWindow_->addSystemMessage("Trying to join room " + toJID_.toString()); + chatWindow_->addSystemMessage(str(format(QT_TRANSLATE_NOOP("", "Trying to join room %1%")) % toJID_.toString())); if (loginCheckTimer_) { loginCheckTimer_->start(); } @@ -332,7 +356,7 @@ void MUCController::handleOccupantLeft(const MUCOccupant& occupant, MUC::Leaving appendToJoinParts(joinParts_, event); currentOccupants_.erase(occupant.getNick()); completer_->removeWord(occupant.getNick()); - std::string partMessage = (occupant.getNick() != nick_) ? occupant.getNick() + " has left the room" : "You have left the room"; + std::string partMessage = (occupant.getNick() != nick_) ? str(format(QT_TRANSLATE_NOOP("", "%1% has left the room")) % occupant.getNick()) : QT_TRANSLATE_NOOP("", "You have left the room"); if (!reason.empty()) { partMessage += " (" + reason + ")"; } @@ -406,7 +430,7 @@ std::string MUCController::concatenateListOfNames(const std::vector populatedEvents; for (size_t i = 0; i < 4; i++) { - std::string eventString = concatenateListOfNames(sorted[i]); - if (!eventString.empty()) { - std::string haveHas = sorted[i].size() > 1 ? " have" : " has"; + std::string names = concatenateListOfNames(sorted[i]); + if (!names.empty()) { + std::string eventString; switch (i) { - case Join: eventString += haveHas + " joined";break; - case Part: eventString += haveHas + " left";break; - case JoinThenPart: eventString += " joined then left";break; - case PartThenJoin: eventString += " left then rejoined";break; + case Join: + if (sorted[i].size() > 1) { + eventString = QT_TRANSLATE_NOOP("", "%1% have joined the room"); + } + else { + eventString = QT_TRANSLATE_NOOP("", "%1% has joined the room"); + } + break; + case Part: + if (sorted[i].size() > 1) { + eventString = QT_TRANSLATE_NOOP("", "%1% have left the room"); + } + else { + eventString = QT_TRANSLATE_NOOP("", "%1% has left the room"); + } + break; + case JoinThenPart: + if (sorted[i].size() > 1) { + eventString = QT_TRANSLATE_NOOP("", "%1% have joined then left the room"); + } + else { + eventString = QT_TRANSLATE_NOOP("", "%1% has joined then left the room"); + } + break; + case PartThenJoin: + if (sorted[i].size() > 1) { + eventString = QT_TRANSLATE_NOOP("", "%1% have left then rejoined the room"); + } + else { + eventString = QT_TRANSLATE_NOOP("", "%1% has left then rejoined the room"); + } + break; } populatedEvents.push_back(static_cast(i)); - eventStrings[i] = eventString; + eventStrings[i] = str(boost::format(eventString) % names); } } for (size_t i = 0; i < populatedEvents.size(); i++) { @@ -442,12 +494,11 @@ std::string MUCController::generateJoinPartString(const std::vector list; list.push_back(NickJoinPart("Kev", Join)); - CPPUNIT_ASSERT_EQUAL(std::string("Kev has joined the room."), MUCController::generateJoinPartString(list)); + CPPUNIT_ASSERT_EQUAL(std::string("Kev has joined the room"), MUCController::generateJoinPartString(list)); list.push_back(NickJoinPart("Remko", Part)); - CPPUNIT_ASSERT_EQUAL(std::string("Kev has joined and Remko has left the room."), MUCController::generateJoinPartString(list)); + CPPUNIT_ASSERT_EQUAL(std::string("Kev has joined the room and Remko has left the room"), MUCController::generateJoinPartString(list)); list.push_back(NickJoinPart("Bert", Join)); - CPPUNIT_ASSERT_EQUAL(std::string("Kev and Bert have joined and Remko has left the room."), MUCController::generateJoinPartString(list)); + CPPUNIT_ASSERT_EQUAL(std::string("Kev and Bert have joined the room and Remko has left the room"), MUCController::generateJoinPartString(list)); list.push_back(NickJoinPart("Ernie", Join)); - CPPUNIT_ASSERT_EQUAL(std::string("Kev, Bert and Ernie have joined and Remko has left the room."), MUCController::generateJoinPartString(list)); + CPPUNIT_ASSERT_EQUAL(std::string("Kev, Bert and Ernie have joined the room and Remko has left the room"), MUCController::generateJoinPartString(list)); } void testJoinPartStringContructionMixed() { std::vector list; list.push_back(NickJoinPart("Kev", JoinThenPart)); - CPPUNIT_ASSERT_EQUAL(std::string("Kev joined then left the room."), MUCController::generateJoinPartString(list)); + CPPUNIT_ASSERT_EQUAL(std::string("Kev has joined then left the room"), MUCController::generateJoinPartString(list)); list.push_back(NickJoinPart("Remko", Part)); - CPPUNIT_ASSERT_EQUAL(std::string("Remko has left and Kev joined then left the room."), MUCController::generateJoinPartString(list)); + CPPUNIT_ASSERT_EQUAL(std::string("Remko has left the room and Kev has joined then left the room"), MUCController::generateJoinPartString(list)); list.push_back(NickJoinPart("Bert", PartThenJoin)); - CPPUNIT_ASSERT_EQUAL(std::string("Remko has left, Kev joined then left and Bert left then rejoined the room."), MUCController::generateJoinPartString(list)); + CPPUNIT_ASSERT_EQUAL(std::string("Remko has left the room, Kev has joined then left the room and Bert has left then rejoined the room"), MUCController::generateJoinPartString(list)); list.push_back(NickJoinPart("Ernie", JoinThenPart)); - CPPUNIT_ASSERT_EQUAL(std::string("Remko has left, Kev and Ernie joined then left and Bert left then rejoined the room."), MUCController::generateJoinPartString(list)); + CPPUNIT_ASSERT_EQUAL(std::string("Remko has left the room, Kev and Ernie have joined then left the room and Bert has left then rejoined the room"), MUCController::generateJoinPartString(list)); } private: diff --git a/Swift/Controllers/Intl.h b/Swift/Controllers/Intl.h new file mode 100644 index 0000000..3ed664d --- /dev/null +++ b/Swift/Controllers/Intl.h @@ -0,0 +1,12 @@ +/* + * Copyright (c) 2011 Remko Tronçon + * Licensed under the GNU General Public License v3. + * See Documentation/Licenses/GPLv3.txt for more information. + */ + +#pragma once + +#include + +#define QT_TRANSLATE_NOOP(context, text) \ + Swift::Translator::getInstance()->translate(text, context) diff --git a/Swift/Controllers/MainController.cpp b/Swift/Controllers/MainController.cpp index 1257845..6263636 100644 --- a/Swift/Controllers/MainController.cpp +++ b/Swift/Controllers/MainController.cpp @@ -10,8 +10,11 @@ #include #include #include +#include #include +#include +#include #include #include "Swiften/Network/TimerFactory.h" #include "Swift/Controllers/BuildVersion.h" @@ -41,7 +44,6 @@ #include "SwifTools/Dock/Dock.h" #include "SwifTools/Notifier/TogglableNotifier.h" #include "Swiften/Base/foreach.h" -#include #include "Swiften/Client/Client.h" #include "Swiften/Presence/PresenceSender.h" #include "Swiften/Elements/ChatState.h" @@ -432,36 +434,35 @@ void MainController::handleDisconnected(const boost::optional& erro std::string message; std::string certificateErrorMessage; switch(error->getType()) { - case ClientError::UnknownError: message = "Unknown Error"; break; - case ClientError::DomainNameResolveError: message = "Unable to find server"; break; - case ClientError::ConnectionError: message = "Error connecting to server"; break; - case ClientError::ConnectionReadError: message = "Error while receiving server data"; break; - case ClientError::ConnectionWriteError: message = "Error while sending data to the server"; break; - case ClientError::XMLError: message = "Error parsing server data"; break; - case ClientError::AuthenticationFailedError: message = "Login/password invalid"; break; - case ClientError::CompressionFailedError: message = "Error while compressing stream"; break; - case ClientError::ServerVerificationFailedError: message = "Server verification failed"; break; - case ClientError::NoSupportedAuthMechanismsError: message = "Authentication mechanisms not supported"; break; - case ClientError::UnexpectedElementError: message = "Unexpected response"; break; - case ClientError::ResourceBindError: message = "Error binding resource"; break; - case ClientError::SessionStartError: message = "Error starting session"; break; - case ClientError::StreamError: message = "Stream error"; break; - case ClientError::TLSError: message = "Encryption error"; break; - case ClientError::ClientCertificateLoadError: message = "Error loading certificate (Invalid password?)"; break; - case ClientError::ClientCertificateError: message = "Certificate not authorized"; break; - - case ClientError::UnknownCertificateError: certificateErrorMessage = "Unknown certificate"; break; - case ClientError::CertificateExpiredError: certificateErrorMessage = "Certificate has expired"; break; - case ClientError::CertificateNotYetValidError: certificateErrorMessage = "Certificate is not yet valid"; break; - case ClientError::CertificateSelfSignedError: certificateErrorMessage = "Certificate is self-signed"; break; - case ClientError::CertificateRejectedError: certificateErrorMessage = "Certificate has been rejected"; break; - case ClientError::CertificateUntrustedError: certificateErrorMessage = "Certificate is not trusted"; break; - case ClientError::InvalidCertificatePurposeError: certificateErrorMessage = "Certificate cannot be used for encryptig your connection"; break; - case ClientError::CertificatePathLengthExceededError: certificateErrorMessage = "Certificate path length constraint exceeded"; break; - case ClientError::InvalidCertificateSignatureError: certificateErrorMessage = "Invalid certificate signature"; break; - case ClientError::InvalidCAError: certificateErrorMessage = "Invalid Certificate Authority"; break; - case ClientError::InvalidServerIdentityError: certificateErrorMessage = "Certificate does not match the host identity"; break; - + case ClientError::UnknownError: message = QT_TRANSLATE_NOOP("", "Unknown Error"); break; + case ClientError::DomainNameResolveError: message = QT_TRANSLATE_NOOP("", "Unable to find server"); break; + case ClientError::ConnectionError: message = QT_TRANSLATE_NOOP("", "Error connecting to server"); break; + case ClientError::ConnectionReadError: message = QT_TRANSLATE_NOOP("", "Error while receiving server data"); break; + case ClientError::ConnectionWriteError: message = QT_TRANSLATE_NOOP("", "Error while sending data to the server"); break; + case ClientError::XMLError: message = QT_TRANSLATE_NOOP("", "Error parsing server data"); break; + case ClientError::AuthenticationFailedError: message = QT_TRANSLATE_NOOP("", "Login/password invalid"); break; + case ClientError::CompressionFailedError: message = QT_TRANSLATE_NOOP("", "Error while compressing stream"); break; + case ClientError::ServerVerificationFailedError: message = QT_TRANSLATE_NOOP("", "Server verification failed"); break; + case ClientError::NoSupportedAuthMechanismsError: message = QT_TRANSLATE_NOOP("", "Authentication mechanisms not supported"); break; + case ClientError::UnexpectedElementError: message = QT_TRANSLATE_NOOP("", "Unexpected response"); break; + case ClientError::ResourceBindError: message = QT_TRANSLATE_NOOP("", "Error binding resource"); break; + case ClientError::SessionStartError: message = QT_TRANSLATE_NOOP("", "Error starting session"); break; + case ClientError::StreamError: message = QT_TRANSLATE_NOOP("", "Stream error"); break; + case ClientError::TLSError: message = QT_TRANSLATE_NOOP("", "Encryption error"); break; + case ClientError::ClientCertificateLoadError: message = QT_TRANSLATE_NOOP("", "Error loading certificate (Invalid password?)"); break; + case ClientError::ClientCertificateError: message = QT_TRANSLATE_NOOP("", "Certificate not authorized"); break; + + case ClientError::UnknownCertificateError: certificateErrorMessage = QT_TRANSLATE_NOOP("", "Unknown certificate"); break; + case ClientError::CertificateExpiredError: certificateErrorMessage = QT_TRANSLATE_NOOP("", "Certificate has expired"); break; + case ClientError::CertificateNotYetValidError: certificateErrorMessage = QT_TRANSLATE_NOOP("", "Certificate is not yet valid"); break; + case ClientError::CertificateSelfSignedError: certificateErrorMessage = QT_TRANSLATE_NOOP("", "Certificate is self-signed"); break; + case ClientError::CertificateRejectedError: certificateErrorMessage = QT_TRANSLATE_NOOP("", "Certificate has been rejected"); break; + case ClientError::CertificateUntrustedError: certificateErrorMessage = QT_TRANSLATE_NOOP("", "Certificate is not trusted"); break; + case ClientError::InvalidCertificatePurposeError: certificateErrorMessage = QT_TRANSLATE_NOOP("", "Certificate cannot be used for encryptig your connection"); break; + case ClientError::CertificatePathLengthExceededError: certificateErrorMessage = QT_TRANSLATE_NOOP("", "Certificate path length constraint exceeded"); break; + case ClientError::InvalidCertificateSignatureError: certificateErrorMessage = QT_TRANSLATE_NOOP("", "Invalid certificate signature"); break; + case ClientError::InvalidCAError: certificateErrorMessage = QT_TRANSLATE_NOOP("", "Invalid Certificate Authority"); break; + case ClientError::InvalidServerIdentityError: certificateErrorMessage = QT_TRANSLATE_NOOP("", "Certificate does not match the host identity"); break; } bool forceReconnectAfterCertificateTrust = false; if (!certificateErrorMessage.empty()) { @@ -471,7 +472,7 @@ void MainController::handleDisconnected(const boost::optional& erro forceReconnectAfterCertificateTrust = true; } else { - message = "Certificate error"; + message = QT_TRANSLATE_NOOP("", "Certificate error"); } } @@ -485,10 +486,10 @@ void MainController::handleDisconnected(const boost::optional& erro logout(); setReconnectTimer(); if (lastDisconnectError_) { - message = "Reconnect to " + jid_.getDomain() + " failed: " + message + ". Will retry in " + boost::lexical_cast(timeBeforeNextReconnect_) + " seconds."; + message = str(format(QT_TRANSLATE_NOOP("", "Reconnect to %1% failed: %2%. Will retry in %3% seconds.")) % jid_.getDomain() % message % boost::lexical_cast(timeBeforeNextReconnect_)); lastDisconnectError_->conclude(); } else { - message = "Disconnected from " + jid_.getDomain() + ": " + message; + message = str(format(QT_TRANSLATE_NOOP("", "Disconnected from %1%: %2%.")) % jid_.getDomain() % message); } lastDisconnectError_ = boost::shared_ptr(new ErrorEvent(JID(jid_.getDomain()), message)); eventController_->handleIncomingEvent(lastDisconnectError_); diff --git a/Swift/Controllers/PresenceNotifier.cpp b/Swift/Controllers/PresenceNotifier.cpp index 3d5d71e..e7b25bf 100644 --- a/Swift/Controllers/PresenceNotifier.cpp +++ b/Swift/Controllers/PresenceNotifier.cpp @@ -15,6 +15,7 @@ #include "Swiften/Presence/PresenceOracle.h" #include "Swiften/Network/TimerFactory.h" #include "Swiften/Client/NickResolver.h" +#include namespace Swift { @@ -98,7 +99,7 @@ void PresenceNotifier::handleNotificationActivated(JID jid) { std::string PresenceNotifier::getStatusType(const JID& jid) const { Presence::ref presence = presenceOracle->getLastPresence(jid); if (presence) { - return StatusShow::typeToFriendlyName(presence->getShow()); + return statusShowTypeToFriendlyName(presence->getShow()); } else { return "Unavailable"; diff --git a/Swift/Controllers/Roster/RosterController.cpp b/Swift/Controllers/Roster/RosterController.cpp index e03a8d4..8a0fd53 100644 --- a/Swift/Controllers/Roster/RosterController.cpp +++ b/Swift/Controllers/Roster/RosterController.cpp @@ -37,6 +37,8 @@ #include "Swift/Controllers/UIEvents/RenameGroupUIEvent.h" #include "Swift/Controllers/UIEvents/ToggleShowOfflineUIEvent.h" #include +#include +#include namespace Swift { @@ -121,7 +123,7 @@ void RosterController::handleOnJIDAdded(const JID& jid) { } } else { - roster_->addContact(jid, jid, name, "Contacts", avatarManager_->getAvatarPath(jid).string()); + roster_->addContact(jid, jid, name, QT_TRANSLATE_NOOP("", "Contacts"), avatarManager_->getAvatarPath(jid).string()); } applyAllPresenceTo(jid); } @@ -147,7 +149,7 @@ void RosterController::handleOnJIDUpdated(const JID& jid, const std::string& old std::vector groups = xmppRoster_->getGroupsForJID(jid); std::vector oldGroups = passedOldGroups; std::string name = nickResolver_->jidToNick(jid); - std::string contactsGroup = "Contacts"; + std::string contactsGroup = QT_TRANSLATE_NOOP("", "Contacts"); if (oldGroups.empty()) { oldGroups.push_back(contactsGroup); } @@ -208,7 +210,7 @@ void RosterController::handleUIEvent(boost::shared_ptr event) { std::vector items = xmppRoster_->getItems(); std::string group = renameGroupEvent->getGroup(); // FIXME: We should handle contacts groups specially to avoid clashes - if (group == "Contacts") { + if (group == QT_TRANSLATE_NOOP("", "Contacts")) { group = ""; } foreach(XMPPRosterItem& item, items) { @@ -245,7 +247,7 @@ void RosterController::handleRosterSetError(ErrorPayload::ref error, boost::shar if (!error) { return; } - std::string text = "Server " + myJID_.getDomain() + " rejected roster change to item '" + rosterPayload->getItems()[0].getJID().toString() + "'"; + std::string text = str(format(QT_TRANSLATE_NOOP("", "Server %1% rejected roster change to item '%2%'")) % myJID_.getDomain() % rosterPayload->getItems()[0].getJID().toString()); if (!error->getText().empty()) { text += ": " + error->getText(); } diff --git a/Swift/Controllers/SConscript b/Swift/Controllers/SConscript index c563c7b..61da9fb 100644 --- a/Swift/Controllers/SConscript +++ b/Swift/Controllers/SConscript @@ -52,6 +52,8 @@ if env["SCONS_STAGE"] == "build" : "CertificateStorageFactory.cpp", "CertificateStorage.cpp", "CertificateFileStorage.cpp", + "StatusUtil.cpp", + "Translator.cpp", ]) env.Append(UNITTEST_SOURCES = [ diff --git a/Swift/Controllers/StatusUtil.cpp b/Swift/Controllers/StatusUtil.cpp new file mode 100644 index 0000000..fd1fea3 --- /dev/null +++ b/Swift/Controllers/StatusUtil.cpp @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2011 Remko Tronçon + * Licensed under the GNU General Public License v3. + * See Documentation/Licenses/GPLv3.txt for more information. + */ + +#include + +#include + +namespace Swift { + +std::string statusShowTypeToFriendlyName(StatusShow::Type type) { + switch (type) { + case StatusShow::Online: return QT_TRANSLATE_NOOP("", "Available"); + case StatusShow::FFC: return QT_TRANSLATE_NOOP("", "Available"); + case StatusShow::Away: return QT_TRANSLATE_NOOP("", "Away"); + case StatusShow::XA: return QT_TRANSLATE_NOOP("", "Away"); + case StatusShow::DND: return QT_TRANSLATE_NOOP("", "Busy"); + case StatusShow::None: return QT_TRANSLATE_NOOP("", "Offline"); + } + return ""; +} + +} diff --git a/Swift/Controllers/StatusUtil.h b/Swift/Controllers/StatusUtil.h new file mode 100644 index 0000000..dddee92 --- /dev/null +++ b/Swift/Controllers/StatusUtil.h @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2011 Remko Tronçon + * Licensed under the GNU General Public License v3. + * See Documentation/Licenses/GPLv3.txt for more information. + */ + +#pragma once + +#include + +#include + +namespace Swift { + std::string statusShowTypeToFriendlyName(StatusShow::Type type); +} + diff --git a/Swift/Controllers/Translator.cpp b/Swift/Controllers/Translator.cpp new file mode 100644 index 0000000..82fc46e --- /dev/null +++ b/Swift/Controllers/Translator.cpp @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2011 Remko Tronçon + * Licensed under the GNU General Public License v3. + * See Documentation/Licenses/GPLv3.txt for more information. + */ + +#include + +#include + +namespace Swift { + +struct DefaultTranslator : public Translator { + virtual std::string translate(const std::string& text, const std::string&) { + return text; + } +} defaultTranslator; + +Translator* Translator::translator = &defaultTranslator; + +Translator::~Translator() { +} + +void Translator::setInstance(Translator* t) { + translator = t; +} + +} diff --git a/Swift/Controllers/Translator.h b/Swift/Controllers/Translator.h new file mode 100644 index 0000000..ac4407d --- /dev/null +++ b/Swift/Controllers/Translator.h @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2011 Remko Tronçon + * Licensed under the GNU General Public License v3. + * See Documentation/Licenses/GPLv3.txt for more information. + */ + +#pragma once + +#include + +namespace Swift { + class Translator { + public: + virtual ~Translator(); + + virtual std::string translate(const std::string& text, const std::string& context) = 0; + + static void setInstance(Translator* translator); + + static Translator* getInstance() { + return translator; + } + + private: + static Translator* translator; + }; +} diff --git a/Swift/QtUI/ChatList/ChatListModel.cpp b/Swift/QtUI/ChatList/ChatListModel.cpp index 39b6a3c..ba7b766 100644 --- a/Swift/QtUI/ChatList/ChatListModel.cpp +++ b/Swift/QtUI/ChatList/ChatListModel.cpp @@ -12,7 +12,7 @@ namespace Swift { ChatListModel::ChatListModel() { root_ = new ChatListGroupItem("", NULL); - mucBookmarks_ = new ChatListGroupItem("Bookmarked Rooms", root_); + mucBookmarks_ = new ChatListGroupItem(tr("Bookmarked Rooms"), root_); root_->addItem(mucBookmarks_); } diff --git a/Swift/QtUI/ChatList/QtChatListWindow.cpp b/Swift/QtUI/ChatList/QtChatListWindow.cpp index 48ccf7f..b532cdb 100644 --- a/Swift/QtUI/ChatList/QtChatListWindow.cpp +++ b/Swift/QtUI/ChatList/QtChatListWindow.cpp @@ -59,11 +59,11 @@ void QtChatListWindow::handleClicked(const QModelIndex& index) { void QtChatListWindow::setupContextMenus() { mucMenu_ = new QMenu(); - mucMenu_->addAction("Add New Bookmark", this, SLOT(handleAddBookmark())); - mucMenu_->addAction("Edit Bookmark", this, SLOT(handleEditBookmark())); - mucMenu_->addAction("Remove Bookmark", this, SLOT(handleRemoveBookmark())); + mucMenu_->addAction(tr("Add New Bookmark"), this, SLOT(handleAddBookmark())); + mucMenu_->addAction(tr("Edit Bookmark"), this, SLOT(handleEditBookmark())); + mucMenu_->addAction(tr("Remove Bookmark"), this, SLOT(handleRemoveBookmark())); emptyMenu_ = new QMenu(); - emptyMenu_->addAction("Add New Bookmark", this, SLOT(handleAddBookmark())); + emptyMenu_->addAction(tr("Add New Bookmark"), this, SLOT(handleAddBookmark())); } diff --git a/Swift/QtUI/EventViewer/QtEvent.cpp b/Swift/QtUI/EventViewer/QtEvent.cpp index f0bc276..05080d8 100644 --- a/Swift/QtUI/EventViewer/QtEvent.cpp +++ b/Swift/QtUI/EventViewer/QtEvent.cpp @@ -58,8 +58,14 @@ QString QtEvent::text() { boost::shared_ptr subscriptionRequestEvent = boost::dynamic_pointer_cast(event_); if (subscriptionRequestEvent) { std::string reason = subscriptionRequestEvent->getReason(); - std::string message = subscriptionRequestEvent->getJID().toBare().toString() + " would like to add you to their roster" + (reason.empty() ? "." : ", saying '" + reason + "'."); - return P2QSTRING(message); + QString message; + if (reason.empty()) { + message = QString("%1 would like to add you to their roster.").arg(subscriptionRequestEvent->getJID().toBare().toString().c_str()); + } + else { + message = QString("%1 would like to add you to their roster, saying '%2'").arg(subscriptionRequestEvent->getJID().toBare().toString().c_str()).arg(reason.c_str()); + } + return message; } boost::shared_ptr errorEvent = boost::dynamic_pointer_cast(event_); if (errorEvent) { diff --git a/Swift/QtUI/MUCSearch/MUCSearchEmptyItem.cpp b/Swift/QtUI/MUCSearch/MUCSearchEmptyItem.cpp index b1b4175..f392859 100644 --- a/Swift/QtUI/MUCSearch/MUCSearchEmptyItem.cpp +++ b/Swift/QtUI/MUCSearch/MUCSearchEmptyItem.cpp @@ -22,7 +22,7 @@ MUCSearchServiceItem* MUCSearchEmptyItem::getParent() { QVariant MUCSearchEmptyItem::data(int role) { switch (role) { case Qt::DisplayRole: - return QVariant("No rooms found"); + return QVariant(QObject::tr("No rooms found")); case Qt::FontRole: { QFont font; font.setItalic(true); diff --git a/Swift/QtUI/MUCSearch/QtMUCSearchWindow.cpp b/Swift/QtUI/MUCSearch/QtMUCSearchWindow.cpp index 1e624b3..618ed65 100644 --- a/Swift/QtUI/MUCSearch/QtMUCSearchWindow.cpp +++ b/Swift/QtUI/MUCSearch/QtMUCSearchWindow.cpp @@ -27,7 +27,7 @@ QtMUCSearchWindow::QtMUCSearchWindow() { setWindowIcon(QIcon(":/logo-icon-16.png")); #endif setModal(true); - setWindowTitle("Search Room"); + setWindowTitle(tr("Search Room")); ui_.filter_->hide(); model_ = new MUCSearchModel(); delegate_ = new MUCSearchDelegate(); @@ -47,9 +47,9 @@ QtMUCSearchWindow::QtMUCSearchWindow() { ui_.okButton->setEnabled(false); connect(ui_.cancelButton, SIGNAL(clicked()), this, SLOT(reject())); - throbber_ = new QLabel("Searching", ui_.results_); + throbber_ = new QLabel(tr("Searching"), ui_.results_); throbber_->setMovie(new QMovie(":/icons/throbber.gif", QByteArray(), throbber_)); - throbber_->setToolTip("Searching"); + throbber_->setToolTip(tr("Searching")); hasHadScrollBars_ = false; updateThrobberPosition(); diff --git a/Swift/QtUI/QtAboutWidget.cpp b/Swift/QtUI/QtAboutWidget.cpp index 38a4a8c..2f68769 100644 --- a/Swift/QtUI/QtAboutWidget.cpp +++ b/Swift/QtUI/QtAboutWidget.cpp @@ -20,7 +20,7 @@ namespace Swift { QtAboutWidget::QtAboutWidget() : QDialog() { #ifndef Q_WS_MAC - setWindowTitle("About Swift"); + setWindowTitle(QString(tr("About %1")).arg("Swift")); #endif setWindowIcon(QIcon(":/logo-icon-16.png")); @@ -39,13 +39,13 @@ QtAboutWidget::QtAboutWidget() : QDialog() { QLabel* versionLabel = new QLabel(QString("
Version ") + QCoreApplication::applicationVersion() + "
", this); mainLayout->addWidget(versionLabel); - QString buildString = QString("
Built with: Qt version ") + QT_VERSION_STR; - buildString += QString("
Running with Qt version ") + qVersion(); + QString buildString = QString("
") + QString(tr("Built with: Qt version %1")).arg(QT_VERSION_STR); + buildString += QString("
") + QString(tr("Running with Qt version ")).arg(qVersion()); buildString += "
"; QLabel* buildLabel = new QLabel(buildString, this); mainLayout->addWidget(buildLabel); - QPushButton* licenseButton = new QPushButton("View License", this); + QPushButton* licenseButton = new QPushButton(tr("View License"), this); mainLayout->addWidget(licenseButton); connect(licenseButton, SIGNAL(clicked()), this, SLOT(handleLicenseClicked())); diff --git a/Swift/QtUI/QtAvatarWidget.cpp b/Swift/QtUI/QtAvatarWidget.cpp index 0879d46..ebdf1a6 100644 --- a/Swift/QtUI/QtAvatarWidget.cpp +++ b/Swift/QtUI/QtAvatarWidget.cpp @@ -70,10 +70,10 @@ void QtAvatarWidget::setAvatar(const ByteArray& data, const std::string& type) { void QtAvatarWidget::mousePressEvent(QMouseEvent* event) { QMenu menu; - QAction* selectPicture = new QAction("Select picture ...", this); + QAction* selectPicture = new QAction(tr("Select picture ..."), this); menu.addAction(selectPicture); - QAction* clearPicture = new QAction("Clear picture", this); + QAction* clearPicture = new QAction(tr("Clear picture"), this); menu.addAction(clearPicture); QAction* result = menu.exec(event->globalPos()); @@ -92,7 +92,7 @@ void QtAvatarWidget::mousePressEvent(QMouseEvent* event) { setAvatar(data, Q2PSTRING(type)); } else { - QMessageBox::critical(this, "Error", "The selected picture is in an unrecognized format"); + QMessageBox::critical(this, tr("Error"), tr("The selected picture is in an unrecognized format")); } } } diff --git a/Swift/QtUI/QtBookmarkDetailWindow.cpp b/Swift/QtUI/QtBookmarkDetailWindow.cpp index c0f04e2..fb04e03 100644 --- a/Swift/QtUI/QtBookmarkDetailWindow.cpp +++ b/Swift/QtUI/QtBookmarkDetailWindow.cpp @@ -28,7 +28,7 @@ boost::optional QtBookmarkDetailWindow::createBookmarkFromForm() { //check bookmarkName JID room(Q2PSTRING(room_->text())); if (!room.isValid() || room.getNode().empty() || !room.getResource().empty()) { - QMessageBox::warning(this, "Bookmark not valid", "You must specify a valid room address (e.g. myroom@chats.example.com)."); + QMessageBox::warning(this, tr("Bookmark not valid"), tr("You must specify a valid room address (e.g. myroom@chats.example.com).")); return boost::optional(); } std::string name(Q2PSTRING(name_->text())); diff --git a/Swift/QtUI/QtChatView.cpp b/Swift/QtUI/QtChatView.cpp index 0f25d76..521b072 100644 --- a/Swift/QtUI/QtChatView.cpp +++ b/Swift/QtUI/QtChatView.cpp @@ -58,9 +58,9 @@ QtChatView::QtChatView(QtChatTheme* theme, QWidget* parent) : QWidget(parent) { void QtChatView::handleClearRequested() { QMessageBox messageBox(this); - messageBox.setWindowTitle("Clear log"); - messageBox.setText("You are about to clear the contents of your chat log."); - messageBox.setInformativeText("Are you sure?"); + messageBox.setWindowTitle(tr("Clear log")); + messageBox.setText(tr("You are about to clear the contents of your chat log.")); + messageBox.setInformativeText(tr("Are you sure?")); messageBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); messageBox.setDefaultButton(QMessageBox::Yes); int button = messageBox.exec(); diff --git a/Swift/QtUI/QtChatWindow.cpp b/Swift/QtUI/QtChatWindow.cpp index dac9e93..4b67ef0 100644 --- a/Swift/QtUI/QtChatWindow.cpp +++ b/Swift/QtUI/QtChatWindow.cpp @@ -287,9 +287,9 @@ void QtChatWindow::flash() { void QtChatWindow::setAckState(std::string const& id, ChatWindow::AckState state) { QString xml; switch (state) { - case ChatWindow::Pending: xml = "This message has not been received by your server yet."; break; + case ChatWindow::Pending: xml = "" + tr("This message has not been received by your server yet.") + ""; break; case ChatWindow::Received: xml = ""; break; - case ChatWindow::Failed: xml = "This message may not have been transmitted."; break; + case ChatWindow::Failed: xml = "" + tr("This message may not have been transmitted."; break; } messageLog_->setAckXML(P2QSTRING(id), xml); } @@ -309,7 +309,7 @@ void QtChatWindow::addErrorMessage(const std::string& errorMessage) { QString errorMessageHTML(Qt::escape(P2QSTRING(errorMessage))); errorMessageHTML.replace("\n","
"); - messageLog_->addMessage(boost::shared_ptr(new SystemMessageSnippet(QString("Couldn't send message: %1").arg(errorMessageHTML), QDateTime::currentDateTime(), false, theme_))); + messageLog_->addMessage(boost::shared_ptr(new SystemMessageSnippet(QString("" + tr("Couldn't send message: %1") + "").arg(errorMessageHTML), QDateTime::currentDateTime(), false, theme_))); previousMessageWasSelf_ = false; previousMessageWasSystem_ = true; diff --git a/Swift/QtUI/QtContactEditWidget.cpp b/Swift/QtUI/QtContactEditWidget.cpp index e8fe24a..fbc9685 100644 --- a/Swift/QtUI/QtContactEditWidget.cpp +++ b/Swift/QtUI/QtContactEditWidget.cpp @@ -25,13 +25,13 @@ QtContactEditWidget::QtContactEditWidget(const std::set& allGroups, QHBoxLayout* nameLayout = new QHBoxLayout(); - QLabel* label = new QLabel("Name:", this); + QLabel* label = new QLabel(tr("Name:"), this); nameLayout->addWidget(label); name_ = new QLineEdit(this); nameLayout->addWidget(name_); layout->addLayout(nameLayout); - layout->addWidget(new QLabel("Groups:", this)); + layout->addWidget(new QLabel(tr("Groups:"), this)); QScrollArea* groupsArea = new QScrollArea(this); layout->addWidget(groupsArea); @@ -53,7 +53,7 @@ QtContactEditWidget::QtContactEditWidget(const std::set& allGroups, QHBoxLayout* newGroupLayout = new QHBoxLayout(); newGroup_ = new QCheckBox(groups); - newGroup_->setText("New Group:"); + newGroup_->setText(tr("New Group:")); newGroup_->setCheckState(Qt::Unchecked); newGroupLayout->addWidget(newGroup_); newGroupName_ = new QLineEdit(groups); diff --git a/Swift/QtUI/QtContactEditWindow.cpp b/Swift/QtUI/QtContactEditWindow.cpp index 97b8f95..543d39a 100644 --- a/Swift/QtUI/QtContactEditWindow.cpp +++ b/Swift/QtUI/QtContactEditWindow.cpp @@ -23,7 +23,7 @@ namespace Swift { QtContactEditWindow::QtContactEditWindow() : contactEditWidget_(NULL) { resize(300,300); - setWindowTitle("Edit contact"); + setWindowTitle(tr("Edit contact")); setContentsMargins(0,0,0,0); QBoxLayout* layout = new QVBoxLayout(this); @@ -38,10 +38,10 @@ QtContactEditWindow::QtContactEditWindow() : contactEditWidget_(NULL) { QHBoxLayout* buttonLayout = new QHBoxLayout(); layout->addLayout(buttonLayout); - QPushButton* removeButton = new QPushButton("Remove contact", this); + QPushButton* removeButton = new QPushButton(tr("Remove contact"), this); connect(removeButton, SIGNAL(clicked()), this, SLOT(handleRemoveContact())); buttonLayout->addWidget(removeButton); - QPushButton* okButton = new QPushButton("Ok", this); + QPushButton* okButton = new QPushButton(tr("Ok"), this); connect(okButton, SIGNAL(clicked()), this, SLOT(handleUpdateContact())); buttonLayout->addStretch(); buttonLayout->addWidget(okButton); @@ -73,9 +73,9 @@ void QtContactEditWindow::hide() { void QtContactEditWindow::handleRemoveContact() { QMessageBox msgBox; - msgBox.setWindowTitle("Confirm contact deletion"); - msgBox.setText("Are you sure you want to delete this contact?"); - msgBox.setInformativeText(QString("This will remove the contact '%1' from all groups they may be in.").arg(P2QSTRING(jid_.toString()))); + msgBox.setWindowTitle(tr("Confirm contact deletion")); + msgBox.setText(tr("Are you sure you want to delete this contact?")); + msgBox.setInformativeText(QString(tr("This will remove the contact '%1' from all groups they may be in.")).arg(P2QSTRING(jid_.toString()))); msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); msgBox.setDefaultButton(QMessageBox::Yes); int ret = msgBox.exec(); diff --git a/Swift/QtUI/QtLoginWindow.cpp b/Swift/QtUI/QtLoginWindow.cpp index aae11d1..24e6d76 100644 --- a/Swift/QtUI/QtLoginWindow.cpp +++ b/Swift/QtUI/QtLoginWindow.cpp @@ -78,23 +78,23 @@ QtLoginWindow::QtLoginWindow(UIEventStream* uiEventStream) : QMainWindow() { layout->addStretch(2); QLabel* jidLabel = new QLabel(this); - jidLabel->setText("User address:"); + jidLabel->setText("" + tr("User address:") + ""); layout->addWidget(jidLabel); username_ = new QComboBox(this); username_->setEditable(true); - username_->setWhatsThis("User address - looks like someuser@someserver.com"); - username_->setToolTip("User address - looks like someuser@someserver.com"); + username_->setWhatsThis(tr("User address - looks like someuser@someserver.com")); + username_->setToolTip(tr("User address - looks like someuser@someserver.com")); username_->view()->installEventFilter(this); layout->addWidget(username_); QLabel* jidHintLabel = new QLabel(this); - jidHintLabel->setText("Example: alice@wonderland.lit"); + jidHintLabel->setText("" + tr("Example: alice@wonderland.lit") + ""); jidHintLabel->setAlignment(Qt::AlignRight); layout->addWidget(jidHintLabel); QLabel* passwordLabel = new QLabel(); - passwordLabel->setText("Password:"); + passwordLabel->setText("" + tr("Password:") + ""); layout->addWidget(passwordLabel); @@ -115,8 +115,8 @@ QtLoginWindow::QtLoginWindow(UIEventStream* uiEventStream) : QMainWindow() { certificateButton_ = new QToolButton(this); certificateButton_->setCheckable(true); certificateButton_->setIcon(QIcon(":/icons/certificate.png")); - certificateButton_->setToolTip("Click if you have a personal certificate used for login to the service."); - certificateButton_->setWhatsThis("Click if you have a personal certificate used for login to the service."); + certificateButton_->setToolTip(tr("Click if you have a personal certificate used for login to the service.")); + certificateButton_->setWhatsThis(tr("Click if you have a personal certificate used for login to the service.")); credentialsLayout->addWidget(certificateButton_); connect(certificateButton_, SIGNAL(clicked(bool)), SLOT(handleCertficateChecked(bool))); @@ -154,7 +154,7 @@ QtLoginWindow::QtLoginWindow(UIEventStream* uiEventStream) : QMainWindow() { generalMenu_ = swiftMenu_; #endif - QAction* aboutAction = new QAction("&About Swift", this); + QAction* aboutAction = new QAction(QString(tr("&About %1")).arg("Swift"), this); connect(aboutAction, SIGNAL(triggered()), SLOT(handleAbout())); swiftMenu_->addAction(aboutAction); @@ -180,7 +180,7 @@ QtLoginWindow::QtLoginWindow(UIEventStream* uiEventStream) : QMainWindow() { swiftMenu_->addSeparator(); #endif - QAction* quitAction = new QAction("&Quit", this); + QAction* quitAction = new QAction(tr("&Quit"), this); connect(quitAction, SIGNAL(triggered()), SLOT(handleQuit())); swiftMenu_->addAction(quitAction); @@ -194,7 +194,7 @@ bool QtLoginWindow::eventFilter(QObject *obj, QEvent *event) { QKeyEvent *keyEvent = static_cast(event); if (keyEvent->key() == Qt::Key_Delete || keyEvent->key() == Qt::Key_Backspace) { QString jid(username_->view()->currentIndex().data().toString()); - int result = QMessageBox::question(this, "Remove profile", "Remove the profile '" + jid + "'?", QMessageBox::Yes | QMessageBox::No); + int result = QMessageBox::question(this, tr("Remove profile"), tr("Remove the profile '%1'?").arg(jid), QMessageBox::Yes | QMessageBox::No); if (result == QMessageBox::Yes) { onPurgeSavedLoginRequest(Q2PSTRING(jid)); } @@ -288,7 +288,7 @@ void QtLoginWindow::loggedOut() { void QtLoginWindow::setIsLoggingIn(bool loggingIn) { /* Change the for loop as well if you add to this.*/ QWidget* widgets[5] = {username_, password_, remember_, loginAutomatically_, certificateButton_}; - loginButton_->setText(loggingIn ? "Cancel" : "Connect"); + loginButton_->setText(loggingIn ? tr("Cancel") : tr("Connect")); for (int i = 0; i < 5; i++) { widgets[i]->setEnabled(!loggingIn); } @@ -309,7 +309,7 @@ void QtLoginWindow::setLoginAutomatically(bool loginAutomatically) { void QtLoginWindow::handleCertficateChecked(bool checked) { if (checked) { - certificateFile_ = QFileDialog::getOpenFileName(this, "Select an authentication certificate", QString(), QString("*.cert")); + certificateFile_ = QFileDialog::getOpenFileName(this, tr("Select an authentication certificate"), QString(), QString("*.cert")); if (certificateFile_.isEmpty()) { certificateButton_->setChecked(false); } @@ -409,11 +409,11 @@ void QtLoginWindow::moveEvent(QMoveEvent*) { bool QtLoginWindow::askUserToTrustCertificatePermanently(const std::string& message, Certificate::ref certificate) { QMessageBox dialog(this); - dialog.setText("The certificate presented by the server is not valid."); - dialog.setInformativeText(P2QSTRING(message) + "\n\nWould you like to permanently trust this certificate? This must only be done if you know it is correct."); + dialog.setText(tr("The certificate presented by the server is not valid.")); + dialog.setInformativeText(P2QSTRING(message) + "\n\n" + tr("Would you like to permanently trust this certificate? This must only be done if you know it is correct.")); - QString detailedText = "Subject: " + P2QSTRING(certificate->getSubjectName()) + "\n"; - detailedText += "SHA-1 Fingerprint: " + P2QSTRING(certificate->getSHA1Fingerprint()); + QString detailedText = tr("Subject: %1").arg(P2QSTRING(certificate->getSubjectName())) + "\n"; + detailedText += tr("SHA-1 Fingerprint: %1").arg(P2QSTRING(certificate->getSHA1Fingerprint())); dialog.setDetailedText(detailedText); dialog.setStandardButtons(QMessageBox::Yes | QMessageBox::No); diff --git a/Swift/QtUI/QtMainWindow.cpp b/Swift/QtUI/QtMainWindow.cpp index 6ebd8aa..0f43f7e 100644 --- a/Swift/QtUI/QtMainWindow.cpp +++ b/Swift/QtUI/QtMainWindow.cpp @@ -60,21 +60,21 @@ QtMainWindow::QtMainWindow(QtSettingsProvider* settings, UIEventStream* uiEventS treeWidget_ = new QtTreeWidget(uiEventStream_); contactTabLayout->addWidget(treeWidget_); - tabs_->addTab(contactsTabWidget_, "&Contacts"); + tabs_->addTab(contactsTabWidget_, tr("&Contacts")); eventWindow_ = new QtEventWindow(uiEventStream_); connect(eventWindow_, SIGNAL(onNewEventCountUpdated(int)), this, SLOT(handleEventCountUpdated(int))); chatListWindow_ = new QtChatListWindow(uiEventStream_); - tabs_->addTab(eventWindow_, "&Notices"); - tabs_->addTab(chatListWindow_, "C&hats"); + tabs_->addTab(eventWindow_, tr("&Notices")); + tabs_->addTab(chatListWindow_, tr("C&hats")); this->setLayout(mainLayout); QMenu* viewMenu = new QMenu(tr("&View"), this); menus_.push_back(viewMenu); - showOfflineAction_ = new QAction("Show offline contacts", this); + showOfflineAction_ = new QAction(tr("Show offline contacts"), this); showOfflineAction_->setCheckable(true); showOfflineAction_->setChecked(false); connect(showOfflineAction_, SIGNAL(toggled(bool)), SLOT(handleShowOfflineToggled(bool))); @@ -82,20 +82,20 @@ QtMainWindow::QtMainWindow(QtSettingsProvider* settings, UIEventStream* uiEventS QMenu* actionsMenu = new QMenu(tr("&Actions"), this); menus_.push_back(actionsMenu); - QAction* editProfileAction = new QAction("Edit Profile", this); + QAction* editProfileAction = new QAction(tr("Edit Profile"), this); connect(editProfileAction, SIGNAL(triggered()), SLOT(handleEditProfileAction())); actionsMenu->addAction(editProfileAction); - QAction* joinMUCAction = new QAction("&Join Room", this); + QAction* joinMUCAction = new QAction(tr("&Join Room"), this); connect(joinMUCAction, SIGNAL(triggered()), SLOT(handleJoinMUCAction())); actionsMenu->addAction(joinMUCAction); - addUserAction_ = new QAction("&Add Contact", this); + addUserAction_ = new QAction(tr("&Add Contact"), this); connect(addUserAction_, SIGNAL(triggered(bool)), this, SLOT(handleAddUserActionTriggered(bool))); actionsMenu->addAction(addUserAction_); - chatUserAction_ = new QAction("Start &Chat", this); + chatUserAction_ = new QAction(tr("Start &Chat"), this); connect(chatUserAction_, SIGNAL(triggered(bool)), this, SLOT(handleChatUserActionTriggered(bool))); actionsMenu->addAction(chatUserAction_); actionsMenu->addSeparator(); - QAction* signOutAction = new QAction("&Sign Out", this); + QAction* signOutAction = new QAction(tr("&Sign Out"), this); connect(signOutAction, SIGNAL(triggered()), SLOT(handleSignOutAction())); actionsMenu->addAction(signOutAction); @@ -127,7 +127,7 @@ void QtMainWindow::handleEventCountUpdated(int count) { QColor eventTabColor = (count == 0) ? QColor() : QColor(255, 0, 0); // invalid resets to default int eventIndex = 1; tabs_->tabBar()->setTabTextColor(eventIndex, eventTabColor); - QString text = "Notices"; + QString text = tr("Notices"); if (count > 0) { text += QString(" (%1)").arg(count); } diff --git a/Swift/QtUI/QtNameWidget.cpp b/Swift/QtUI/QtNameWidget.cpp index 412665d..6124c65 100644 --- a/Swift/QtUI/QtNameWidget.cpp +++ b/Swift/QtUI/QtNameWidget.cpp @@ -44,7 +44,7 @@ void QtNameWidget::mousePressEvent(QMouseEvent* event) { QMenu menu; bool hasNick = !nick.isEmpty(); - QAction* showAsNick = new QAction(hasNick ? "Show nickname" : "(No Nickname Set)", this); + QAction* showAsNick = new QAction(hasNick ? tr("Show nickname") : tr("(No Nickname Set)"), this); showAsNick->setCheckable(true); showAsNick->setEnabled(hasNick); if (mode == ShowNick && hasNick) { @@ -52,14 +52,14 @@ void QtNameWidget::mousePressEvent(QMouseEvent* event) { } menu.addAction(showAsNick); - QAction* showAsJID = new QAction("Show ID", this); + QAction* showAsJID = new QAction(tr("Show ID"), this); showAsJID->setCheckable(true); if (mode == ShowJID || !hasNick) { showAsJID->setChecked(true); } menu.addAction(showAsJID); - QAction* editProfile = new QAction("Edit Profile", this); + QAction* editProfile = new QAction(tr("Edit Profile"), this); menu.addAction(editProfile); QAction* result = menu.exec(event->globalPos()); diff --git a/Swift/QtUI/QtProfileWindow.cpp b/Swift/QtUI/QtProfileWindow.cpp index c4fe400..2b723be 100644 --- a/Swift/QtUI/QtProfileWindow.cpp +++ b/Swift/QtUI/QtProfileWindow.cpp @@ -21,7 +21,7 @@ namespace Swift { QtProfileWindow::QtProfileWindow() { - setWindowTitle("Edit Profile"); + setWindowTitle(tr("Edit Profile")); QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum); sizePolicy.setHorizontalStretch(0); @@ -40,7 +40,7 @@ QtProfileWindow::QtProfileWindow() { QVBoxLayout* fieldsLayout = new QVBoxLayout(); QHBoxLayout* horizontalLayout_2 = new QHBoxLayout(); - nicknameLabel = new QLabel("Nickname: ", this); + nicknameLabel = new QLabel(tr("Nickname:"), this); horizontalLayout_2->addWidget(nicknameLabel); nickname = new QLineEdit(this); horizontalLayout_2->addWidget(nickname); @@ -64,7 +64,7 @@ QtProfileWindow::QtProfileWindow() { throbberLabel->setMovie(new QMovie(":/icons/throbber.gif", QByteArray(), this)); horizontalLayout->addWidget(throbberLabel); - saveButton = new QPushButton("Save", this); + saveButton = new QPushButton(tr("Save"), this); connect(saveButton, SIGNAL(clicked()), SLOT(handleSave())); horizontalLayout->addWidget(saveButton); diff --git a/Swift/QtUI/QtStatusWidget.cpp b/Swift/QtUI/QtStatusWidget.cpp index db6d6c5..78bbb03 100644 --- a/Swift/QtUI/QtStatusWidget.cpp +++ b/Swift/QtUI/QtStatusWidget.cpp @@ -22,11 +22,12 @@ #include "Swift/QtUI/QtElidingLabel.h" #include "Swift/QtUI/QtLineEdit.h" #include "Swift/QtUI/QtSwiftUtil.h" - -const QString NO_MESSAGE = QString("(No message)"); +#include namespace Swift { +const QString QtStatusWidget::NO_MESSAGE = QString(QT_TRANSLATE_NOOP("QtStatusWidget", "(No message)")); + QtStatusWidget::QtStatusWidget(QWidget *parent) : QWidget(parent), editCursor_(Qt::IBeamCursor), viewCursor_(Qt::PointingHandCursor) { isClicking_ = false; connecting_ = false; @@ -131,12 +132,12 @@ void QtStatusWidget::generateList() { foreach (StatusShow::Type type, icons_.keys()) { QListWidgetItem* item = new QListWidgetItem(text == "" ? NO_MESSAGE : text, menu_); item->setIcon(icons_[type]); - item->setToolTip(P2QSTRING(StatusShow::typeToFriendlyName(type)) + ": " + item->text()); + item->setToolTip(P2QSTRING(statusShowTypeToFriendlyName(type)) + ": " + item->text()); item->setStatusTip(item->toolTip()); item->setData(Qt::UserRole, QVariant(type)); } foreach (StatusShow::Type type, icons_.keys()) { - QListWidgetItem* item = new QListWidgetItem(P2QSTRING(StatusShow::typeToFriendlyName(type)), menu_); + QListWidgetItem* item = new QListWidgetItem(P2QSTRING(statusShowTypeToFriendlyName(type)), menu_); item->setIcon(icons_[type]); item->setToolTip(item->text()); item->setStatusTip(item->toolTip()); @@ -168,7 +169,7 @@ void QtStatusWidget::handleClicked() { types.push_back(StatusShow::DND); types.push_back(StatusShow::None); foreach (StatusShow::Type type, types) { - if (statusEdit_->text() == P2QSTRING(StatusShow::typeToFriendlyName(type))) { + if (statusEdit_->text() == P2QSTRING(statusShowTypeToFriendlyName(type))) { statusEdit_->setText(""); } } @@ -229,9 +230,9 @@ void QtStatusWidget::handleItemClicked(QListWidgetItem* item) { void QtStatusWidget::setNewToolTip() { if (connecting_) { - statusTextLabel_->setToolTip("Connecting"); + statusTextLabel_->setToolTip(tr("Connecting")); } else { - statusTextLabel_->setToolTip(P2QSTRING(StatusShow::typeToFriendlyName(selectedStatusType_)) + ": " + statusTextLabel_->text()); + statusTextLabel_->setToolTip(P2QSTRING(statusShowTypeToFriendlyName(selectedStatusType_)) + ": " + statusTextLabel_->text()); } } diff --git a/Swift/QtUI/QtStatusWidget.h b/Swift/QtUI/QtStatusWidget.h index dcff433..f302c64 100644 --- a/Swift/QtUI/QtStatusWidget.h +++ b/Swift/QtUI/QtStatusWidget.h @@ -62,6 +62,7 @@ namespace Swift { bool editing_; QMovie* connectingMovie_; bool connecting_; + static const QString NO_MESSAGE; }; } diff --git a/Swift/QtUI/QtSubscriptionRequestWindow.cpp b/Swift/QtUI/QtSubscriptionRequestWindow.cpp index e201808..c38f421 100644 --- a/Swift/QtUI/QtSubscriptionRequestWindow.cpp +++ b/Swift/QtUI/QtSubscriptionRequestWindow.cpp @@ -15,23 +15,23 @@ namespace Swift { QtSubscriptionRequestWindow::QtSubscriptionRequestWindow(boost::shared_ptr event, QWidget* parent) : QDialog(parent), event_(event) { - QString text = P2QSTRING(event->getJID().toString()) + " would like to add you to their roster.\n Would you like to add them to your roster and share your status when you're online? \n\nIf you choose to defer this choice, you'll be asked again when you next login."; + QString text = QString("%1 would like to add you to their roster.\n Would you like to add them to your roster and share your status when you're online? \n\nIf you choose to defer this choice, you'll be asked again when you next login.").arg(event->getJID().toString().c_str()); QVBoxLayout* layout = new QVBoxLayout(); QLabel* label = new QLabel(text, this); layout->addWidget(label); if (event_->getConcluded()) { - QLabel* doneLabel = new QLabel("You have already replied to this request"); - QPushButton* okButton = new QPushButton("OK", this); + QLabel* doneLabel = new QLabel(tr("You have already replied to this request")); + QPushButton* okButton = new QPushButton(tr("Ok"), this); connect(okButton, SIGNAL(clicked()), this, SLOT(handleDefer())); layout->addWidget(doneLabel); layout->addWidget(okButton); } else { - QPushButton* yesButton = new QPushButton("Yes", this); + QPushButton* yesButton = new QPushButton(tr("Yes"), this); connect(yesButton, SIGNAL(clicked()), this, SLOT(handleYes())); - QPushButton* noButton = new QPushButton("No", this); + QPushButton* noButton = new QPushButton(tr("No"), this); connect(noButton, SIGNAL(clicked()), this, SLOT(handleNo())); - QPushButton* deferButton = new QPushButton("Defer", this); + QPushButton* deferButton = new QPushButton(tr("Defer"), this); connect(deferButton, SIGNAL(clicked()), this, SLOT(handleDefer())); QHBoxLayout* buttonLayout = new QHBoxLayout(); diff --git a/Swift/QtUI/QtSwift.cpp b/Swift/QtUI/QtSwift.cpp index bb40da8..d4c306f 100644 --- a/Swift/QtUI/QtSwift.cpp +++ b/Swift/QtUI/QtSwift.cpp @@ -8,7 +8,6 @@ #include #include -#include #include #include "QtLoginWindow.h" @@ -72,8 +71,6 @@ po::options_description QtSwift::getOptionsDescription() { QtSwift::QtSwift(const po::variables_map& options) : networkFactories_(&clientMainThreadCaller_), autoUpdater_(NULL) { - QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8")); - if (options.count("netbook-mode")) { splitter_ = new QSplitter(); } else { diff --git a/Swift/QtUI/QtTranslator.h b/Swift/QtUI/QtTranslator.h new file mode 100644 index 0000000..fdafaf0 --- /dev/null +++ b/Swift/QtUI/QtTranslator.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2011 Remko Tronçon + * Licensed under the GNU General Public License v3. + * See Documentation/Licenses/GPLv3.txt for more information. + */ + +#pragma once + +#include + +#include + +class QtTranslator : public Swift::Translator { + public: + QtTranslator() { + } + + virtual std::string translate(const std::string& text, const std::string& context) { + return std::string(QCoreApplication::translate(context.c_str(), text.c_str(), 0, QCoreApplication::UnicodeUTF8).toUtf8()); + } +}; diff --git a/Swift/QtUI/QtWebView.cpp b/Swift/QtUI/QtWebView.cpp index 3aab88b..9d12010 100644 --- a/Swift/QtUI/QtWebView.cpp +++ b/Swift/QtUI/QtWebView.cpp @@ -5,7 +5,7 @@ */ -#include "Swift/QtUI/QtWebView.h" +#include "QtWebView.h" #include #include @@ -58,7 +58,7 @@ void QtWebView::contextMenuEvent(QContextMenuEvent* ev) { } // Add our own custom actions - menu->addAction("Clear", this, SIGNAL(clearRequested())); + menu->addAction(tr("Clear"), this, SIGNAL(clearRequested())); menu->exec(ev->globalPos()); delete menu; diff --git a/Swift/QtUI/QtXMLConsoleWidget.cpp b/Swift/QtUI/QtXMLConsoleWidget.cpp index 42c8a8f..c1b1d0d 100644 --- a/Swift/QtUI/QtXMLConsoleWidget.cpp +++ b/Swift/QtUI/QtXMLConsoleWidget.cpp @@ -19,7 +19,7 @@ namespace Swift { QtXMLConsoleWidget::QtXMLConsoleWidget() { - setWindowTitle("Console"); + setWindowTitle(tr("Console")); QVBoxLayout* layout = new QVBoxLayout(this); layout->setSpacing(0); @@ -37,17 +37,17 @@ QtXMLConsoleWidget::QtXMLConsoleWidget() { buttonLayout->setContentsMargins(10,0,20,0); buttonLayout->setSpacing(0); - enabled = new QCheckBox("Trace input/output", bottom); + enabled = new QCheckBox(tr("Trace input/output"), bottom); enabled->setChecked(true); buttonLayout->addWidget(enabled); buttonLayout->addStretch(); - QPushButton* clearButton = new QPushButton("Clear", bottom); + QPushButton* clearButton = new QPushButton(tr("Clear"), bottom); connect(clearButton, SIGNAL(clicked()), textEdit, SLOT(clear())); buttonLayout->addWidget(clearButton); - setWindowTitle("Debug Console"); + setWindowTitle(tr("Debug Console")); emit titleUpdated(); } @@ -72,11 +72,11 @@ void QtXMLConsoleWidget::closeEvent(QCloseEvent* event) { } void QtXMLConsoleWidget::handleDataRead(const std::string& data) { - appendTextIfEnabled("\n" + data + "\n", QColor(33,98,33)); + appendTextIfEnabled(std::string(tr("").toUtf8()) + "\n" + data + "\n", QColor(33,98,33)); } void QtXMLConsoleWidget::handleDataWritten(const std::string& data) { - appendTextIfEnabled("\n" + data + "\n", QColor(155,1,0)); + appendTextIfEnabled(std::string(tr("").toUtf8()) + "\n" + data + "\n", QColor(155,1,0)); } void QtXMLConsoleWidget::appendTextIfEnabled(const std::string& data, const QColor& color) { diff --git a/Swift/QtUI/Roster/QtTreeWidget.cpp b/Swift/QtUI/Roster/QtTreeWidget.cpp index 90084c4..963ce72 100644 --- a/Swift/QtUI/Roster/QtTreeWidget.cpp +++ b/Swift/QtUI/Roster/QtTreeWidget.cpp @@ -83,18 +83,18 @@ void QtTreeWidget::contextMenuEvent(QContextMenuEvent* event) { RosterItem* item = static_cast(index.internalPointer()); QMenu contextMenu; if (ContactRosterItem* contact = dynamic_cast(item)) { - QAction* editContact = contextMenu.addAction("Edit"); + QAction* editContact = contextMenu.addAction(tr("Edit")); QAction* result = contextMenu.exec(event->globalPos()); if (result == editContact) { eventStream_->send(boost::make_shared(contact->getJID())); } } else if (GroupRosterItem* group = dynamic_cast(item)) { - QAction* renameGroup = contextMenu.addAction("Rename"); + QAction* renameGroup = contextMenu.addAction(tr("Rename")); QAction* result = contextMenu.exec(event->globalPos()); if (result == renameGroup) { bool ok; - QString newName = QInputDialog::getText(NULL, "Rename group", "New name for " + P2QSTRING(group->getDisplayName()), QLineEdit::Normal, P2QSTRING(group->getDisplayName()), &ok); + QString newName = QInputDialog::getText(NULL, tr("Rename group"), tr("New name for %1").arg(P2QSTRING(group->getDisplayName())), QLineEdit::Normal, P2QSTRING(group->getDisplayName()), &ok); if (ok) { eventStream_->send(boost::make_shared(group->getDisplayName(), Q2PSTRING(newName))); } diff --git a/Swift/QtUI/Roster/QtTreeWidget.h b/Swift/QtUI/Roster/QtTreeWidget.h index ff11567..3430f7e 100644 --- a/Swift/QtUI/Roster/QtTreeWidget.h +++ b/Swift/QtUI/Roster/QtTreeWidget.h @@ -4,12 +4,10 @@ * See Documentation/Licenses/GPLv3.txt for more information. */ -#ifndef SWIFT_QtTreeWidget_H -#define SWIFT_QtTreeWidget_H +#pragma once #include #include -#include "Swift/QtUI/Roster/QtTreeWidget.h" #include "Swift/QtUI/Roster/RosterModel.h" #include "Swift/QtUI/Roster/RosterDelegate.h" @@ -44,5 +42,3 @@ class QtTreeWidget : public QTreeView{ }; } -#endif - diff --git a/Swift/QtUI/Roster/QtTreeWidgetItem.h b/Swift/QtUI/Roster/QtTreeWidgetItem.h index a2d0cdd..6855989 100644 --- a/Swift/QtUI/Roster/QtTreeWidgetItem.h +++ b/Swift/QtUI/Roster/QtTreeWidgetItem.h @@ -4,22 +4,17 @@ * See Documentation/Licenses/GPLv3.txt for more information. */ -#ifndef SWIFT_QtTreeWidgetItem_H -#define SWIFT_QtTreeWidgetItem_H +#pragma once #include #include - #include + #include "Swiften/Roster/TreeWidgetFactory.h" #include "Swiften/Roster/TreeWidget.h" #include "Swiften/Roster/TreeWidgetItem.h" -#include "Swift/QtUI/Roster/QtTreeWidgetItem.h" - - #include "Swift/QtUI/QtSwiftUtil.h" - namespace Swift { enum RosterRoles { StatusTextRole = Qt::UserRole, @@ -89,5 +84,3 @@ class QtTreeWidgetItem : public QObject, public TreeWidgetItem { bool itemLessThan(QtTreeWidgetItem* left, QtTreeWidgetItem* right); } -#endif - diff --git a/Swift/QtUI/Roster/RosterModel.cpp b/Swift/QtUI/Roster/RosterModel.cpp index 306b76f..2399a21 100644 --- a/Swift/QtUI/Roster/RosterModel.cpp +++ b/Swift/QtUI/Roster/RosterModel.cpp @@ -15,6 +15,7 @@ #include "Swiften/Elements/StatusShow.h" #include "Swift/Controllers/Roster/ContactRosterItem.h" #include "Swift/Controllers/Roster/GroupRosterItem.h" +#include #include "QtSwiftUtil.h" #include "Swift/QtUI/Roster/QtTreeWidget.h" @@ -126,7 +127,7 @@ QString RosterModel::getToolTip(RosterItem* item) const { if (contact->getDisplayJID().isValid()) { tip += "\n" + P2QSTRING(contact->getDisplayJID().toBare().toString()); } - tip += "\n " + P2QSTRING(StatusShow::typeToFriendlyName(contact->getStatusShow())); + tip += "\n " + P2QSTRING(statusShowTypeToFriendlyName(contact->getStatusShow())); if (!getStatusText(item).isEmpty()) { tip += ": " + getStatusText(item); } diff --git a/Swift/QtUI/SConscript b/Swift/QtUI/SConscript index 6238693..e52d76a 100644 --- a/Swift/QtUI/SConscript +++ b/Swift/QtUI/SConscript @@ -155,7 +155,24 @@ myenv.Uic4("QtJoinMUCWindow.ui") myenv.Qrc("DefaultTheme.qrc") myenv.Qrc("Swift.qrc") -commonResources = ["../resources/sounds"] +# Resources +commonResources = { + "": ["../resources/sounds"] +} + +# Translation +translation_sources = [env.File("../Translations/Swift.ts").abspath] +for file in os.listdir(Dir("../Translations").abspath) : + if file.startswith("Swift_") and file.endswith(".ts") : + lang = file[6:-3] + translation_resource = "../resources/translations/Swift_" + lang + ".qm" + translation_source = "../Translations/Swift_" + lang + ".ts" + translation_sources.append(env.File(translation_source).abspath) + myenv.Qm(translation_resource, translation_source) + commonResources["translations"] = commonResources.get("translations", []) + [translation_resource] +if ARGUMENTS.get("update_translations", False) : + t = myenv.Command(translation_sources, [], [myenv.Action("$QT4_LUPDATE -I " + env.Dir("#").abspath + " -silent -codecfortr utf-8 -recursive Swift -ts " + " ".join(translation_sources), cmdstr = "$QT4_LUPDATECOMSTR")]) + myenv.AlwaysBuild(t) if env["PLATFORM"] == "darwin" : frameworks = [] @@ -163,7 +180,8 @@ if env["PLATFORM"] == "darwin" : frameworks.append(env["SPARKLE_FRAMEWORK"]) if env["HAVE_GROWL"] : frameworks.append(env["GROWL_FRAMEWORK"]) - app = myenv.AppBundle("Swift", version = myenv["SWIFT_VERSION"], resources = ["../resources/MacOSX/Swift.icns"] + commonResources, frameworks = frameworks) + commonResources[""] = commonResources.get("", []) + ["../resources/MacOSX/Swift.icns"] + app = myenv.AppBundle("Swift", version = myenv["SWIFT_VERSION"], resources = commonResources, frameworks = frameworks) if env["DIST"] : myenv.Command(["Swift-${SWIFT_VERSION}.dmg"], [app], ["Swift/Packaging/MacOSX/package.sh " + app.path + " Swift/Packaging/MacOSX/Swift.dmg.gz $TARGET $QTDIR"]) @@ -171,15 +189,18 @@ if env.get("SWIFT_INSTALLDIR", "") : env.Install(os.path.join(env["SWIFT_INSTALLDIR"], "bin"), swiftProgram) env.InstallAs(os.path.join(env["SWIFT_INSTALLDIR"], "share", "pixmaps", "swift.xpm"), "../resources/logo/logo-icon-32.xpm") env.Install(os.path.join(env["SWIFT_INSTALLDIR"], "share", "applications"), "../resources/swift.desktop") - for resource in commonResources : - env.Install(os.path.join(env["SWIFT_INSTALLDIR"], "share", "swift"), resource) + for dir, resource in commonResources.items() : + env.Install(os.path.join(env["SWIFT_INSTALLDIR"], "share", "swift", dir), resource) if env["PLATFORM"] == "win32" : if env["DIST"] : - myenv.WindowsBundle("Swift", resources = [ + commonResources[""] = commonResources.get("", []) + [ os.path.join(env["OPENSSL_DIR"], "bin", "ssleay32.dll"), os.path.join(env["OPENSSL_DIR"], "bin", "libeay32.dll"), - ] + commonResources + ["../resources/images"], + "../resources/images", + ] + myenv.WindowsBundle("Swift", + resources = commonResources, qtimageformats = ["gif", "ico", "jpeg", "mng", "svg", "tiff"], qtlibs = ["QtCore4", "QtGui4", "QtNetwork4", "QtWebKit4", "QtXMLPatterns4", "phonon4"]) diff --git a/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp b/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp index c6fb004..a384f5d 100644 --- a/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp +++ b/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp @@ -23,7 +23,7 @@ namespace Swift { QtUserSearchFirstPage::QtUserSearchFirstPage(UserSearchWindow::Type type, const QString& title) { setupUi(this); setTitle(title); - setSubTitle(QString("%1. If you know their JID you can enter it directly, or you can search for them.").arg(type == UserSearchWindow::AddContact ? "Add another user to your roster" : "Chat to another user")); + setSubTitle(QString(tr("%1. If you know their JID you can enter it directly, or you can search for them.")).arg(type == UserSearchWindow::AddContact ? tr("Add another user to your roster") : tr("Chat to another user"))); connect(jid_, SIGNAL(textChanged(const QString&)), this, SLOT(emitCompletenessCheck())); connect(service_->lineEdit(), SIGNAL(textChanged(const QString&)), this, SLOT(emitCompletenessCheck())); } @@ -82,7 +82,7 @@ QtUserSearchWindow::QtUserSearchWindow(UIEventStream* eventStream, UserSearchWin setupUi(this); model_ = new UserSearchModel(); delegate_ = new UserSearchDelegate(); - QString title(type == UserSearchWindow::AddContact ? "Add Contact" : "Chat to User"); + QString title(type == UserSearchWindow::AddContact ? tr("Add Contact") : tr("Chat to User")); setWindowTitle(title); firstPage_ = new QtUserSearchFirstPage(type, title); connect(firstPage_->byJID_, SIGNAL(toggled(bool)), this, SLOT(handleFirstPageRadioChange())); @@ -289,7 +289,14 @@ void QtUserSearchWindow::clearForm() { void QtUserSearchWindow::clear() { firstPage_->errorLabel_->setVisible(false); - firstPage_->howLabel_->setText(QString("How would you like to find the user to %1?").arg(type_ == AddContact ? "add" : "chat to")); + QString howText; + if (type_ == AddContact) { + howText = QString("How would you like to find the user to add?"); + } + else { + howText = QString("How would you like to find the user to chat to?"); + } + firstPage_->howLabel_->setText(howText); firstPage_->byJID_->setChecked(true); clearForm(); model_->clear(); @@ -311,13 +318,13 @@ void QtUserSearchWindow::setError(const QString& error) { void QtUserSearchWindow::setSearchError(bool error) { if (error) { - setError("Error while searching"); + setError(tr("Error while searching")); } } void QtUserSearchWindow::setServerSupportsSearch(bool support) { if (!support) { - setError("This server doesn't support searching for users."); + setError(tr("This server doesn't support searching for users.")); } } diff --git a/Swift/QtUI/main.cpp b/Swift/QtUI/main.cpp index c5f744a..3cbb170 100644 --- a/Swift/QtUI/main.cpp +++ b/Swift/QtUI/main.cpp @@ -8,14 +8,37 @@ #include #include #include - #include - #include +#include +#include +#include + +#include +#include +#include #include "QtSwift.h" +#include "QtTranslator.h" int main(int argc, char* argv[]) { + QApplication app(argc, argv); + + QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8")); + + // Translation + QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8")); + boost::filesystem::path someTranslationPath = Swift::PlatformApplicationPathProvider(SWIFT_APPLICATION_NAME).getResourcePath("/translations/Swift_nl.qm"); + QTranslator qtTranslator; + if (!someTranslationPath.empty()) { + //std::cout << "Loading " << std::string(QLocale::system().name().toUtf8()) << std::endl; + qtTranslator.load("Swift_" + QLocale::system().name(), someTranslationPath.parent_path().string().c_str()); + } + app.installTranslator(&qtTranslator); + QtTranslator swiftTranslator; + Swift::Translator::setInstance(&swiftTranslator); + + // Parse program options boost::program_options::options_description desc = Swift::QtSwift::getOptionsDescription(); boost::program_options::variables_map vm; try { @@ -32,7 +55,11 @@ int main(int argc, char* argv[]) { std::cout << desc << "\n"; return 1; } - QApplication app(argc, argv); + Swift::QtSwift swift(vm); - return app.exec(); + int result = app.exec(); + + Swift::Translator::setInstance(NULL); + + return result; } diff --git a/Swift/QtUI/tmp/QtContextMenu.cpp b/Swift/QtUI/tmp/QtContextMenu.cpp deleted file mode 100644 index c74fb31..0000000 --- a/Swift/QtUI/tmp/QtContextMenu.cpp +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright (c) 2010 Kevin Smith - * Licensed under the GNU General Public License v3. - * See Documentation/Licenses/GPLv3.txt for more information. - */ - -#include "ContextMenus/QtContextMenu.h" - -namespace Swift { - -QtContextMenu::~QtContextMenu() { -} - -} diff --git a/Swift/QtUI/tmp/QtContextMenu.h b/Swift/QtUI/tmp/QtContextMenu.h deleted file mode 100644 index 9e73ef9..0000000 --- a/Swift/QtUI/tmp/QtContextMenu.h +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright (c) 2010 Kevin Smith - * Licensed under the GNU General Public License v3. - * See Documentation/Licenses/GPLv3.txt for more information. - */ - -#pragma once - -namespace Swift { - class RosterItem; - class QtContextMenu { - public: - virtual ~QtContextMenu(); - - virtual void show(RosterItem* item) = 0; - }; -} diff --git a/Swift/QtUI/tmp/QtRosterContextMenu.cpp b/Swift/QtUI/tmp/QtRosterContextMenu.cpp deleted file mode 100644 index c8375ba..0000000 --- a/Swift/QtUI/tmp/QtRosterContextMenu.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (c) 2010 Kevin Smith - * Licensed under the GNU General Public License v3. - * See Documentation/Licenses/GPLv3.txt for more information. - */ - -#include "Swift/QtUI/ContextMenus/QtRosterContextMenu.h" - -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "Swiften/Roster/ContactRosterItem.h" -#include "Swiften/Roster/GroupRosterItem.h" -#include -#include "Swiften/Roster/Roster.h" -#include "Swift/Controllers/UIEvents/UIEvent.h" -#include "Swift/Controllers/UIEvents/RemoveRosterItemUIEvent.h" -#include "Swift/Controllers/UIEvents/RenameRosterItemUIEvent.h" -#include "Swift/QtUI/QtSwiftUtil.h" -#include "Swift/QtUI/QtEditContactDialog.h" - - -namespace Swift { - -QtRosterContextMenu::QtRosterContextMenu(UIEventStream* eventStream, QtTreeWidget* treeWidget) : eventStream_(eventStream), treeWidget_(treeWidget), item_(NULL) { -} - -void QtRosterContextMenu::show(RosterItem* item) { - ContactRosterItem* contact = dynamic_cast(item); - item_ = item; - QMenu contextMenu; - if (contact) { - contextMenu.addAction("Edit", this, SLOT(handleEditContact())); - } - GroupRosterItem* group = dynamic_cast(item); - if (group) { - contextMenu.addAction("Rename", this, SLOT(handleRenameGroup())); - } - contextMenu.exec(QCursor::pos()); -} - -void QtRosterContextMenu::handleEditContact() { - ContactRosterItem* contact = dynamic_cast(item_); - assert(contact); - - // Figure out all the groups the contact is in - QList allGroups; - foreach (RosterItem* item, treeWidget_->getRoster()->getRoot()->getChildren()) { - GroupRosterItem* group = dynamic_cast(item); - if (group) { - allGroups.push_back(P2QSTRING(group->getDisplayName())); - } - } - - QtEditContactDialog editDialog(contact, allGroups, eventStream_); - - if (groupDialog.exec() == QDialog::Accepted) { - eventStream_->send(groupDialog.getRegroupEvent()); - } - - /* ContactRosterItem* contact = dynamic_cast(item_); - QMessageBox msgBox; - msgBox.setWindowTitle("Confirm contact deletion"); - msgBox.setText("Are you sure you want to delete this contact?"); - msgBox.setInformativeText(QString("This will remove the contact '%1' from all groups they may be in.").arg(P2QSTRING(contact->getJID().toString()))); - msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); - msgBox.setDefaultButton(QMessageBox::Yes); - int ret = msgBox.exec(); - if (ret == QMessageBox::Yes) { - eventStream_->send(boost::shared_ptr(new RemoveRosterItemUIEvent(contact->getJID()))); - }*/ - - -/* bool ok; - QString newName = QInputDialog::getText(NULL, "Rename contact", "New name for " + P2QSTRING(item_->getDisplayName()), QLineEdit::Normal, P2QSTRING(item_->getDisplayName()), &ok); - if (ok) { - eventStream_->send(boost::shared_ptr(new RenameRosterItemUIEvent(contact->getJID(), Q2PSTRING(newName)))); - }*/ -} - -void QtRosterContextMenu::handleRenameGroup() { - /* - GroupRosterItem* group = dynamic_cast(item_); - assert(group); - bool ok; - QString newName = QInputDialog::getText(NULL, "Rename group", "New name for " + P2QSTRING(item_->getDisplayName()), QLineEdit::Normal, P2QSTRING(item_->getDisplayName()), &ok); - if (ok) { - std::vector addedGroups; - std::vector removedGroups; - addedGroups.push_back(Q2PSTRING(newName)); - removedGroups.push_back(group->getDisplayName()); - foreach (RosterItem* child, group->getChildren()) { - ContactRosterItem* contact = dynamic_cast(child); - assert(contact); - eventStream_->send(boost::make_shared(contact->getJID(), addedGroups, removedGroups)); - } - } - */ -} - -} diff --git a/Swift/QtUI/tmp/QtRosterContextMenu.h b/Swift/QtUI/tmp/QtRosterContextMenu.h deleted file mode 100644 index 2357735..0000000 --- a/Swift/QtUI/tmp/QtRosterContextMenu.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2010 Kevin Smith - * Licensed under the GNU General Public License v3. - * See Documentation/Licenses/GPLv3.txt for more information. - */ - -#pragma once - -#include - -#include "Swift/QtUI/ContextMenus/QtContextMenu.h" -#include "Swift/QtUI/Roster/QtTreeWidget.h" -#include "Swift/Controllers/UIEvents/UIEventStream.h" - -namespace Swift { - class RosterItem; - class QtRosterContextMenu : public QObject, public QtContextMenu { - Q_OBJECT - public: - QtRosterContextMenu(UIEventStream* eventStream, QtTreeWidget* treeWidget); - void show(RosterItem* item); - - private slots: - void handleRenameGroup(); - void handleEditContact(); - - private: - UIEventStream* eventStream_; - QtTreeWidget* treeWidget_; - RosterItem* item_; - }; -} diff --git a/Swift/Translations/Swift.ts b/Swift/Translations/Swift.ts new file mode 100644 index 0000000..959687e --- /dev/null +++ b/Swift/Translations/Swift.ts @@ -0,0 +1,1387 @@ + + + +UTF-8 + + + + + Starting chat with %1% in chatroom %2% + + + + + Starting chat with %1% - %2% + + + + + me + + + + + %1% has gone offline + + + + + %1% has become available + + + + + %1% has gone away + + + + + %1% is now busy + + + + + The day is now %1% + + + + + Error sending message + + + + + Bad request + + + + + Conflict + + + + + This feature is not implemented + + + + + Forbidden + + + + + Recipient can no longer be contacted + + + + + Internal server error + + + + + Item not found + + + + + JID Malformed + + + + + Message was rejected + + + + + Not allowed + + + + + Not authorized + + + + + Payment is required + + + + + Recipient is unavailable + + + + + Redirect + + + + + Registration required + + + + + Recipient's server not found + + + + + Remote server timeout + + + + + The server is low on resources + + + + + The service is unavailable + + + + + A subscription is required + + + + + Undefined condition + + + + + Unexpected request + + + + + Room %1% is not responding. This operation may never complete. + + + + + Unable to join this room + + + + + Unable to join this room as %1%, retrying as %2% + + + + + No nickname specified + + + + + A password needed + + + + + Only members may join + + + + + You are banned from the room + + + + + The room is full + + + + + The room does not exist + + + + + You have joined room %1% as %2% + + + + + %1% has joined the room as a %2%. + + + + + %1% has joined the room. + + + + + moderator + + + + + participant + + + + + visitor + + + + + The room subject is now: %1% + + + + + %1% is now a %2% + + + + + Moderators + + + + + Participants + + + + + Visitors + + + + + Occupants + + + + + Trying to join room %1% + + + + + + %1% has left the room + + + + + You have left the room + + + + + + and + + + + + %1% have joined the room + + + + + %1% has joined the room + + + + + %1% have left the room + + + + + %1% have joined then left the room + + + + + %1% has joined then left the room + + + + + %1% have left then rejoined the room + + + + + %1% has left then rejoined the room + + + + + Unknown Error + + + + + Unable to find server + + + + + Error connecting to server + + + + + Error while receiving server data + + + + + Error while sending data to the server + + + + + Error parsing server data + + + + + Login/password invalid + + + + + Error while compressing stream + + + + + Server verification failed + + + + + Authentication mechanisms not supported + + + + + Unexpected response + + + + + Error binding resource + + + + + Error starting session + + + + + Stream error + + + + + Encryption error + + + + + Error loading certificate (Invalid password?) + + + + + Certificate not authorized + + + + + Unknown certificate + + + + + Certificate has expired + + + + + Certificate is not yet valid + + + + + Certificate is self-signed + + + + + Certificate has been rejected + + + + + Certificate is not trusted + + + + + Certificate cannot be used for encryptig your connection + + + + + Certificate path length constraint exceeded + + + + + Invalid certificate signature + + + + + Invalid Certificate Authority + + + + + Certificate does not match the host identity + + + + + Certificate error + + + + + Reconnect to %1% failed: %2%. Will retry in %3% seconds. + + + + + Disconnected from %1%: %2%. + + + + + + + Contacts + + + + + Server %1% rejected roster change to item '%2%' + + + + + + Available + + + + + + Away + + + + + Busy + + + + + Offline + + + + + QObject + + + No rooms found + + + + + QtBookmarkDetailWindow + + + + Edit Bookmark Details + + + + + + Bookmark Name: + + + + + + Room JID: + + + + + + Your Nickname: + + + + + + Room password: + + + + + + Join automatically + + + + + QtJoinMUCWindow + + + + + + Join Room + + + + + + Room: + + + + + + Search ... + + + + + + Nickname: + + + + + + Join automatically in future + + + + + QtMUCSearchWindow + + + + Dialog + + + + + + Service: + + + + + + Cancel + + + + + + Ok + + + + + + List rooms + + + + + QtStatusWidget + + + (No message) + + + + + QtUserSearchFieldsPage + + + + WizardPage + + + + + + Nickname: + + + + + + First name: + + + + + + Last name: + + + + + + E-Mail: + + + + + + TextLabel + + + + + + Fetching search fields + + + + + QtUserSearchFirstPage + + + + WizardPage + + + + + + Add a user + + + + + + Add another user to your roster. If you know their JID you can add them directly, or you can search for them. + + + + + + howLabel_ + + + + + + I know their JID: + + + + + + I'd like to search my server + + + + + + I'd like to search another server: + + + + + + <font color='red'>errorLabel_</font> + + + + + QtUserSearchResultsPage + + + + WizardPage + + + + + QtUserSearchWindow + + + Find other users + + + + + Service to search: + + + + + Get Search Form + + + + + TextLabel + + + + + Enter search terms + + + + + Nickname: + + + + + First name: + + + + + Last name: + + + + + E-Mail: + + + + + Search + + + + + Results: + + + + + Address: + + + + + Add to Roster. Nickname: + + + + + Start Chat With Contact + + + + + QtUserSearchWizard + + + + Find User + + + + + Swift::ChatListModel + + + Bookmarked Rooms + + + + + Swift::QtAboutWidget + + + About %1 + + + + + Built with: Qt version %1 + + + + + Running with Qt version + + + + + View License + + + + + Swift::QtAvatarWidget + + + Select picture ... + + + + + Clear picture + + + + + Select picture + + + + + Image Files (*.png *.jpg *.gif) + + + + + Error + + + + + The selected picture is in an unrecognized format + + + + + Swift::QtBookmarkDetailWindow + + + Bookmark not valid + + + + + You must specify a valid room address (e.g. myroom@chats.example.com). + + + + + Swift::QtChatListWindow + + + + Add New Bookmark + + + + + Edit Bookmark + + + + + Remove Bookmark + + + + + Swift::QtChatView + + + Clear log + + + + + You are about to clear the contents of your chat log. + + + + + Are you sure? + + + + + Swift::QtChatWindow + + + This message has not been received by your server yet. + + + + + This message may not have been transmitted.' + + + + + Couldn't send message: %1 + + + + + Swift::QtContactEditWidget + + + Name: + + + + + Groups: + + + + + New Group: + + + + + Swift::QtContactEditWindow + + + Edit contact + + + + + Remove contact + + + + + Ok + + + + + Confirm contact deletion + + + + + Are you sure you want to delete this contact? + + + + + This will remove the contact '%1' from all groups they may be in. + + + + + Swift::QtLoginWindow + + + User address: + + + + + + User address - looks like someuser@someserver.com + + + + + Example: alice@wonderland.lit + + + + + Password: + + + + + + Click if you have a personal certificate used for login to the service. + + + + + + Connect + + + + + Remember Password? + + + + + Login Automatically? + + + + + &Swift + + + + + &General + + + + + &About %1 + + + + + &Show Debug Console + + + + + &Play Sounds + + + + + Show &Notifications + + + + + &Quit + + + + + Remove profile + + + + + Remove the profile '%1'? + + + + + Cancel + + + + + Select an authentication certificate + + + + + The certificate presented by the server is not valid. + + + + + Would you like to permanently trust this certificate? This must only be done if you know it is correct. + + + + + Subject: %1 + + + + + SHA-1 Fingerprint: %1 + + + + + Swift::QtMUCSearchWindow + + + Search Room + + + + + + Searching + + + + + Swift::QtMainWindow + + + &Contacts + + + + + &Notices + + + + + C&hats + + + + + &View + + + + + Show offline contacts + + + + + &Actions + + + + + Edit Profile + + + + + &Join Room + + + + + &Add Contact + + + + + Start &Chat + + + + + &Sign Out + + + + + Notices + + + + + Swift::QtNameWidget + + + Show nickname + + + + + (No Nickname Set) + + + + + Show ID + + + + + Edit Profile + + + + + Swift::QtProfileWindow + + + Edit Profile + + + + + Nickname: + + + + + Save + + + + + Swift::QtStatusWidget + + + Connecting + + + + + Swift::QtSubscriptionRequestWindow + + + You have already replied to this request + + + + + Ok + + + + + Yes + + + + + No + + + + + Defer + + + + + Swift::QtTreeWidget + + + Edit + + + + + Rename + + + + + Rename group + + + + + New name for %1 + + + + + Swift::QtUserSearchFirstPage + + + %1. If you know their JID you can enter it directly, or you can search for them. + + + + + Add another user to your roster + + + + + Chat to another user + + + + + Swift::QtUserSearchWindow + + + Add Contact + + + + + Chat to User + + + + + Error while searching + + + + + This server doesn't support searching for users. + + + + + Swift::QtWebView + + + Clear + + + + + Swift::QtXMLConsoleWidget + + + Console + + + + + Trace input/output + + + + + Clear + + + + + Debug Console + + + + + <!-- IN --> + + + + + <!-- OUT --> + + + + diff --git a/Swift/Translations/Swift_nl.ts b/Swift/Translations/Swift_nl.ts new file mode 100644 index 0000000..d967c57 --- /dev/null +++ b/Swift/Translations/Swift_nl.ts @@ -0,0 +1,1387 @@ + + + +UTF-8 + + + + + Starting chat with %1% in chatroom %2% + + + + + Starting chat with %1% - %2% + + + + + me + + + + + %1% has gone offline + + + + + %1% has become available + + + + + %1% has gone away + + + + + %1% is now busy + + + + + The day is now %1% + + + + + Error sending message + + + + + Bad request + + + + + Conflict + + + + + This feature is not implemented + + + + + Forbidden + + + + + Recipient can no longer be contacted + + + + + Internal server error + + + + + Item not found + + + + + JID Malformed + + + + + Message was rejected + + + + + Not allowed + + + + + Not authorized + + + + + Payment is required + + + + + Recipient is unavailable + + + + + Redirect + + + + + Registration required + + + + + Recipient's server not found + + + + + Remote server timeout + + + + + The server is low on resources + + + + + The service is unavailable + + + + + A subscription is required + + + + + Undefined condition + + + + + Unexpected request + + + + + Room %1% is not responding. This operation may never complete. + + + + + Unable to join this room + + + + + Unable to join this room as %1%, retrying as %2% + + + + + No nickname specified + + + + + A password needed + + + + + Only members may join + + + + + You are banned from the room + + + + + The room is full + + + + + The room does not exist + + + + + You have joined room %1% as %2% + + + + + %1% has joined the room as a %2%. + + + + + %1% has joined the room. + + + + + moderator + + + + + participant + + + + + visitor + + + + + The room subject is now: %1% + + + + + %1% is now a %2% + + + + + Moderators + + + + + Participants + + + + + Visitors + + + + + Occupants + + + + + Trying to join room %1% + + + + + + %1% has left the room + + + + + You have left the room + + + + + + and + + + + + %1% have joined the room + + + + + %1% has joined the room + + + + + %1% have left the room + + + + + %1% have joined then left the room + + + + + %1% has joined then left the room + + + + + %1% have left then rejoined the room + + + + + %1% has left then rejoined the room + + + + + Unknown Error + + + + + Unable to find server + + + + + Error connecting to server + + + + + Error while receiving server data + + + + + Error while sending data to the server + + + + + Error parsing server data + + + + + Login/password invalid + + + + + Error while compressing stream + + + + + Server verification failed + + + + + Authentication mechanisms not supported + + + + + Unexpected response + + + + + Error binding resource + + + + + Error starting session + + + + + Stream error + + + + + Encryption error + + + + + Error loading certificate (Invalid password?) + + + + + Certificate not authorized + + + + + Unknown certificate + + + + + Certificate has expired + + + + + Certificate is not yet valid + + + + + Certificate is self-signed + + + + + Certificate has been rejected + + + + + Certificate is not trusted + + + + + Certificate cannot be used for encryptig your connection + + + + + Certificate path length constraint exceeded + + + + + Invalid certificate signature + + + + + Invalid Certificate Authority + + + + + Certificate does not match the host identity + + + + + Certificate error + + + + + Reconnect to %1% failed: %2%. Will retry in %3% seconds. + + + + + Disconnected from %1%: %2%. + + + + + + + Contacts + + + + + Server %1% rejected roster change to item '%2%' + + + + + + Available + + + + + + Away + + + + + Busy + + + + + Offline + + + + + QObject + + + No rooms found + + + + + QtBookmarkDetailWindow + + + + Edit Bookmark Details + + + + + + Bookmark Name: + + + + + + Room JID: + + + + + + Your Nickname: + + + + + + Room password: + + + + + + Join automatically + + + + + QtJoinMUCWindow + + + + + + Join Room + + + + + + Room: + + + + + + Search ... + + + + + + Nickname: + + + + + + Join automatically in future + + + + + QtMUCSearchWindow + + + + Dialog + + + + + + Service: + + + + + + Cancel + + + + + + Ok + + + + + + List rooms + + + + + QtStatusWidget + + + (No message) + + + + + QtUserSearchFieldsPage + + + + WizardPage + + + + + + Nickname: + + + + + + First name: + + + + + + Last name: + + + + + + E-Mail: + + + + + + TextLabel + + + + + + Fetching search fields + + + + + QtUserSearchFirstPage + + + + WizardPage + + + + + + Add a user + + + + + + Add another user to your roster. If you know their JID you can add them directly, or you can search for them. + + + + + + howLabel_ + + + + + + I know their JID: + + + + + + I'd like to search my server + + + + + + I'd like to search another server: + + + + + + <font color='red'>errorLabel_</font> + + + + + QtUserSearchResultsPage + + + + WizardPage + + + + + QtUserSearchWindow + + + Find other users + + + + + Service to search: + + + + + Get Search Form + + + + + TextLabel + + + + + Enter search terms + + + + + Nickname: + + + + + First name: + + + + + Last name: + + + + + E-Mail: + + + + + Search + + + + + Results: + + + + + Address: + + + + + Add to Roster. Nickname: + + + + + Start Chat With Contact + + + + + QtUserSearchWizard + + + + Find User + + + + + Swift::ChatListModel + + + Bookmarked Rooms + + + + + Swift::QtAboutWidget + + + About %1 + + + + + Built with: Qt version %1 + + + + + Running with Qt version + + + + + View License + + + + + Swift::QtAvatarWidget + + + Select picture ... + + + + + Clear picture + + + + + Select picture + + + + + Image Files (*.png *.jpg *.gif) + + + + + Error + + + + + The selected picture is in an unrecognized format + + + + + Swift::QtBookmarkDetailWindow + + + Bookmark not valid + + + + + You must specify a valid room address (e.g. myroom@chats.example.com). + + + + + Swift::QtChatListWindow + + + + Add New Bookmark + + + + + Edit Bookmark + + + + + Remove Bookmark + + + + + Swift::QtChatView + + + Clear log + + + + + You are about to clear the contents of your chat log. + + + + + Are you sure? + + + + + Swift::QtChatWindow + + + This message has not been received by your server yet. + + + + + This message may not have been transmitted.' + + + + + Couldn't send message: %1 + + + + + Swift::QtContactEditWidget + + + Name: + + + + + Groups: + + + + + New Group: + + + + + Swift::QtContactEditWindow + + + Edit contact + + + + + Remove contact + + + + + Ok + + + + + Confirm contact deletion + + + + + Are you sure you want to delete this contact? + + + + + This will remove the contact '%1' from all groups they may be in. + + + + + Swift::QtLoginWindow + + + User address: + + + + + + User address - looks like someuser@someserver.com + + + + + Example: alice@wonderland.lit + + + + + Password: + + + + + + Click if you have a personal certificate used for login to the service. + + + + + + Connect + + + + + Remember Password? + + + + + Login Automatically? + + + + + &Swift + + + + + &General + + + + + &About %1 + + + + + &Show Debug Console + + + + + &Play Sounds + + + + + Show &Notifications + + + + + &Quit + + + + + Remove profile + + + + + Remove the profile '%1'? + + + + + Cancel + + + + + Select an authentication certificate + + + + + The certificate presented by the server is not valid. + + + + + Would you like to permanently trust this certificate? This must only be done if you know it is correct. + + + + + Subject: %1 + + + + + SHA-1 Fingerprint: %1 + + + + + Swift::QtMUCSearchWindow + + + Search Room + + + + + + Searching + + + + + Swift::QtMainWindow + + + &Contacts + + + + + &Notices + + + + + C&hats + + + + + &View + + + + + Show offline contacts + + + + + &Actions + + + + + Edit Profile + + + + + &Join Room + + + + + &Add Contact + + + + + Start &Chat + + + + + &Sign Out + + + + + Notices + + + + + Swift::QtNameWidget + + + Show nickname + + + + + (No Nickname Set) + + + + + Show ID + + + + + Edit Profile + + + + + Swift::QtProfileWindow + + + Edit Profile + + + + + Nickname: + + + + + Save + + + + + Swift::QtStatusWidget + + + Connecting + + + + + Swift::QtSubscriptionRequestWindow + + + You have already replied to this request + + + + + Ok + + + + + Yes + + + + + No + + + + + Defer + + + + + Swift::QtTreeWidget + + + Edit + + + + + Rename + + + + + Rename group + + + + + New name for %1 + + + + + Swift::QtUserSearchFirstPage + + + %1. If you know their JID you can enter it directly, or you can search for them. + + + + + Add another user to your roster + + + + + Chat to another user + + + + + Swift::QtUserSearchWindow + + + Add Contact + + + + + Chat to User + + + + + Error while searching + + + + + This server doesn't support searching for users. + + + + + Swift::QtWebView + + + Clear + + + + + Swift::QtXMLConsoleWidget + + + Console + + + + + Trace input/output + + + + + Clear + + + + + Debug Console + + + + + <!-- IN --> + + + + + <!-- OUT --> + + + + diff --git a/Swift/resources/.gitignore b/Swift/resources/.gitignore new file mode 100644 index 0000000..f8590a0 --- /dev/null +++ b/Swift/resources/.gitignore @@ -0,0 +1 @@ +translations diff --git a/Swiften/Base/format.h b/Swiften/Base/format.h new file mode 100644 index 0000000..9e242ff --- /dev/null +++ b/Swiften/Base/format.h @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2010 Remko Tronçon + * Licensed under the GNU General Public License v3. + * See Documentation/Licenses/GPLv3.txt for more information. + */ + +#pragma once + +#include + +namespace Swift { + inline boost::format format(const std::string& s) { + using namespace boost::io; + boost::format fmter(s); + fmter.exceptions( all_error_bits ^ ( too_many_args_bit | too_few_args_bit ) ); + return fmter; + } +} diff --git a/Swiften/Elements/StatusShow.h b/Swiften/Elements/StatusShow.h index f579ace..a158239 100644 --- a/Swiften/Elements/StatusShow.h +++ b/Swiften/Elements/StatusShow.h @@ -26,18 +26,6 @@ namespace Swift { return type_; } - static std::string typeToFriendlyName(Type type) { - switch (type) { - case Online: return "Available"; - case FFC: return "Available"; - case Away: return "Away"; - case XA: return "Away"; - case DND: return "Busy"; - case None: return "Offline"; - } - return "Unknown"; - } - /** * Can be used for rough ordering of Types. * Greater magnitude = more available. -- cgit v0.10.2-6-g49f6